A handful of conveniences for anyone using Fish extensively, with some vim-like syntax.
<Leader>-<register>-<action>vim-like mnemonics.- Register sets for common bits like working directories and commandline snippets,
- Statusline toggles, clipboard registers, assorted features.
- Extensible - define your own registers and bindings.
Vish is available as a package in oh-my-fish. Once you have oh-my-fish set up, just run:
omf install vish
- Set the following variables in your config.fish, before omf hooks:
_VISH_ESCAPEto the terminal sequence you want to be your "leader" key. By default it's set to\e'.VISH_FEATURES(array) to the set of features you want. Default isdirs prefices prompt misc, addtmuxif you use it.- If you use tmux, set
_VISH_PROMPT_MAGIC_CHARto a character that only appears in your prompt. This helps some keybindings identify your prompt in tmux panes.
Vish uses modal key sequences, kind of like vim does. All sequences start with the leader key <L>, then use some sequence of register names and commands, usually <register><command>. For example, <L><L>h calls history --merge, while <L>am saves current directory to register a. Here's a few sequences I commonly use:
<L>amsaves current directory to register a.<L>aggoes to directory under register a.<L>=mlists all saved directories.<L>*psaves current commandline contents to selection buffer.<L>*aappends selection buffer to commandline.- With tmux,
<L>-1laappends last line of command output to commandline.
To list all configured bindings with brief descriptions, run vish_help.
Vish defines registers from a to z, plus some special registers. Unlike vim, there can be multiple sets of registers a-z, e.g. one for directories, one for commands etc, with each keybinding implicitly using one of them. Registers are UNIVERSAL and are shared between all shells. Special registers are shared by all keybindings, and by default are as follows:
0is the "implicit" register.*and+are equivalents of vim clipboard registers. For convenience they're also mapped under,and., respectively.- Additionally,
<L>a*and<L>a+bindings copy register 'a' to the clipboard register.
Each register set is bound to a letter. For a set bound to a letter <x>, <L>a<x> sets register a, <L>a-<x> clears it and <L>=<x> lists all letters in a set.
Enabled by dirs in VISH_FEATURES. Defines a "dirs" register set under letter m.
<L>amsaves current directory to register a.<L>aggoes to directory under register a. Try<L>*gfor going to directory saved to clipboard.
Enabled by prefices in VISH_FEATURES. Defines a "prefices" register set under letter p.
<L>apto save current commandline to register a.<L>aato append contents of register a to commandline.<L>axto execute contents of register a.<L>azto prepend contents of register a at every prompt,<L>azagain to turn it off.
Enabled by misc in VISH_FEATURES.
<L><L>hcallshistory --merge.
Enabled by prompt in VISH_FEATURES.
For fish_prompt:
_vish_prompt_pathprints current directory in short or long format.<L><L>stoggles the format.
For fish_right_prompt:
_vish_right_prompt_git_branchprints current git branch.<L><L>gtoogles it on or off._vish_right_prompt_statusprints return code of last command._vish_right_prompt_statesprints useful status info. At the moments it printsjif there are background jobs andIif ping mode is enabled.
Each right prompt function can be toggled by calling _vish_prompt_toggle GIT_BRANCH/PING/SHORT_PATH, e.g. in your config.fish.
<L><L>i toogles ping mode on and off.
- When ping mode is on, fish will run a
_vish_pingfunction, if defined, after long-running commands. It's up to you to define_vish_ping. - Any command that matches a regex in
$VISH_INTERACTIVE_CMDSarray will be considered interactive and_vish_pingwon't be called. - By default any command that runs 10 seconds or longer is long-running. You can change that nubmer by defining
$VISH_COMMAND_PING_MIN_TIME.
Enabled by tmux in VISH_FEATURES.
<L>t<x>for various tmux shortcuts, seevish_help. In particular<L>ttautocompletes word under cursor, searching in current window's panes.<L><N>lto copy lines from last command's output to register 0, then wait for another keybinding. For example:<L>-1lato copy first line from the bottom to prompt.<L>3l+to copy third line from the top to clipboard.
<L><N>gto copy current directory from pane N to register 0, then wait for another keybinding. For pane 0, use -1.
vish_help- list all bindings.
It's possible to define your own registers and bindings and do some limited scripting. For details, see custom.md.
