Easily prefix your current or previous commands with ./
by pressing esc once.
Modified version of ohmyzsh plugins/sudo
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)
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
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
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.
ohmyzsh plugins/sudo