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-prefixTo 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.shBy pressing the esc key once, you will have the same command with ./ prefixed without typing:
$ ./somescript.shBy pressing the esc key once, you will have the same command with ./ prefixed without typing:
$ somescript.sh
zsh: command not found: somescript.sh
$ ./somescript.shBy 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-linewhere <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