Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8763607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:49:04+00:00 2026-06-13T15:49:04+00:00

zsh has a feature (auto_cd) where just typing the directory name will automatically go

  • 0

zsh has a feature (auto_cd) where just typing the directory name will automatically go to (cd) that directory. I’m curious if there would be a way to configure zsh to do something similar with file names, automatically open files with vim if I type only a file name?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T15:49:05+00:00Added an answer on June 13, 2026 at 3:49 pm

    There are three possibilities I can think of. First is suffix aliases which may automatically translate

    % *.ps
    

    to

    % screen -d -m okular *.ps
    

    after you do

    alias -s ps='screen -d -m okular'
    

    . But you need to define this alias for every file suffix. It is also processed before most expansions so if

    % *.p?
    

    matches same files as *.ps it won’t open anything.

    Second is command_not_found handler:

    function command_not_found_handler()
    {
        emulate -L zsh
        for file in $@ ; do test -e $file && xdg-open $file:A ; done
    }
    

    . But this does not work for absolute or relative paths, only for something that does not contain forward slashes.

    Third is a hack overriding accept-line widget:

    function xdg-open()
    {
        emulate -L zsh
        for arg in $@ ; do
            command xdg-open $arg
        endfor
    }
    function _-accept-line()
    {
        emulate -L zsh
        FILE="${(z)BUFFER[1]}"
        whence $FILE &>/dev/null || BUFFER="xdg-open $BUFFER"
        zle .accept-line
    }
    zle -N accept-line _-accept-line
    

    . The above alters the history (I can show how to avoid this) and is rather hackish. Good it does not disable suffix aliases (whence '*.ps' returns the value of the alias), I used to think it does. It does disable autocd though. I can avoid this (just || test -d $FILE after whence test), but who knows how many other things are getting corrupt as well. If you are fine with the first and second solutions better to use them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Zsh has the following keyboard shortcut for Man Esc + h I would like
I have a script that has a string in a file name like so:
Zsh has a nice feature of expanding globs. For example, hitting Tab turns ls
Using zsh, i would like to add a shortcut to go in parent directory.
I want to adjust zsh so that I can tab complete: myprog <tab> using
http://min.us/muKpIB16z Is that zsh? Could somebody share the PS1 code to everyone :P? Thank
I've just started using ZSH with Cygwin/rxvt today (along with a default install of
In zsh , how can I set up the line editor such that backward-kill-word
By using zsh for some time along with oh-my-zsh framework, I noticed that which
I've just discovered oh-my-zsh, but I can't get it to work. While themes work

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.