Skip to content

Instantly share code, notes, and snippets.

@hjst
Created April 18, 2015 06:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hjst/fd3edc1482e312d112d3 to your computer and use it in GitHub Desktop.
Save hjst/fd3edc1482e312d112d3 to your computer and use it in GitHub Desktop.
This adds bash-history-esque !! and !$ bindings to fish shell (and the substitution is immediate, which is neat)
# put these in ~/.config/fish/functions/fish_user_key_bindings.fish
function bind_bang
switch (commandline -t)
case "!"
commandline -t $history[1]
commandline -f repaint
case "*"
commandline -i !
end
end
function bind_dollar
switch (commandline -t)
case "!"
commandline -t ""
commandline -f history-token-search-backward
case "*"
commandline -i '$'
end
end
function fish_user_key_bindings
bind ! bind_bang
bind '$' bind_dollar
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment