shell, zsh

List files without stopping to type in zsh

This zsh widget allows you to list files in the current directory without interrupting the command you are typing.

Usage
  1. Hit <tab>  in the middle of any command. It will list all files below the command line.
  2. Hit  <space><tab>  on an empty command line. It will list directories.
  3. Hit  <space><space><tab>  on an empty command line. It will list executables.

Regular completion is unaffected.

Installation

Get the code from github, and append it to your .bashrc or .zshrc.

To do it in one step, paste the following in your zsh terminal

It will be available next time you open a zsh session.

Configuration

You can configure cases 2 and 3 above to include a cd  and ./ as a prefix for a nice and handy shortcut. Include in your .zshrc

Extras

I recommend complementing this with the push-line-or-edit  zsh builtin. Include the following in your .zshrc

After this, you can cancel any ongoing command that you might be typing by hitting <CTRL>q , perform another command and then come back just to where you left off.

Code

github

References

http://zsh.sourceforge.net/Guide/zshguide04.html

http://sgeb.io/posts/2016/11/til-bash-zsh-half-typed-commands

Author: nachoparker

Humbly sharing things that I find useful [ github ]

2 Comments on “List files without stopping to type in zsh

    1. Unfortunately bash is way less flexible. You can do the following with by default emacs-based shortcuts

      ^A^K (whatever) ^Y

      ^A – place cursor at the beginning of the line
      ^K – delete the whole line from the cursor
      ^Y – “yank”, or paste last thing you deleted

      You can save the ^A bit if you include to your .inputrc
      “\C-k”: kill-whole-line

      Then, ^K would delete the whole line regardless of the position of the cursor

      … or you can just switch to zsh 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *