Skip to content

Easily prefix your current or previous commands with `./` by pressing esc once

License

Notifications You must be signed in to change notification settings

tmiland/zsh-script-prefix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

zsh-script-prefix

Easily prefix your current or previous commands with ./ by pressing esc once.

Modified version of ohmyzsh plugins/sudo

Install

git clone https://github.com/tmiland/zsh-script-prefix.git "$ZSH_CUSTOM"/plugins/zsh-script-prefix

To use it, add zsh-script-prefix to the plugins array in your zshrc file:

plugins=(... zsh-script-prefix)

Usage

Current typed commands

Say you have typed a script name and forgot to add ./ in front:

$ somescript.sh

By pressing the esc key once, you will have the same command with ./ prefixed without typing:

$ ./somescript.sh

Previous executed commands

By pressing the esc key once, you will have the same command with ./ prefixed without typing:

$ somescript.sh
zsh: command not found: somescript.sh
$ ./somescript.sh

Key binding

By default, the zsh-script-prefix plugin uses Esc as the trigger. If you want to change it, you can use the bindkey command to bind it to a different key:

bindkey -M emacs '<seq>' script-prefix-command-line
bindkey -M vicmd '<seq>' script-prefix-command-line
bindkey -M viins '<seq>' script-prefix-command-line

where <seq> is the sequence you want to use. You can find the keyboard sequence by running cat and pressing the keyboard combination you want to use.

Credits

ohmyzsh plugins/sudo

About

Easily prefix your current or previous commands with `./` by pressing esc once

Topics

Resources

License

Stars

Watchers

Forks

Languages