Skip to content

Latest commit

 

History

History
61 lines (40 loc) · 1.53 KB

README.md

File metadata and controls

61 lines (40 loc) · 1.53 KB

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