···11function __fish_bind_bang
22 switch (commandline --current-token)[-1]
33 case "!"
44- # Without the `--`, the functionality can break when completing
55- # flags used in the history (since, in certain edge cases
66- # `commandline` will assume that *it* should try to interpret
77- # the flag)
84 commandline --current-token -- $history[1]
95 commandline --function repaint
106 case "*"
+7-38
.config/fish/functions/__fish_bind_dollar.fish
···11function __fish_bind_dollar
22 switch (commandline --current-token)[-1]
33- # This case lets us still type a literal `!$` if we need to (by
44- # typing `!\$`). Probably overkill.
53 case "*!\\"
66- # Without the `--`, the functionality can break when completing
77- # flags used in the history (since, in certain edge cases
88- # `commandline` will assume that *it* should try to interpret
99- # the flag)
1010- commandline --current-token -- (echo -ns (commandline --current-token)[-1] | head -c '-1')
44+ # This case lets us still type a literal `!$` if we need to (by
55+ # typing `!\$`). Probably overkill.
116 commandline --insert '$'
1212- case "!"
1313- commandline --current-token ""
1414- commandline --function history-token-search-backward
1515-1616-1717- # Main difference from referenced version is this `*!` case
1818- # =========================================================
1919- #
2020- # If the `!$` is preceded by any text, search backward for tokens
2121- # that contain that text as a substring. E.g., if we'd previously
2222- # run
2323- #
2424- # git checkout -b a_feature_branch
2525- # git checkout master
2626- #
2727- # then the `fea!$` in the following would be replaced with
2828- # `a_feature_branch`
2929- #
3030- # git branch -d fea!$
3131- #
3232- # and our command line would look like
3333- #
3434- # git branch -d a_feature_branch
3535- #
3636- case "*!"
3737- # Without the `--`, the functionality can break when completing
3838- # flags used in the history (since, in certain edge cases
3939- # `commandline` will assume that *it* should try to interpret
4040- # the flag)
4141- commandline --current-token -- (echo -ns (commandline --current-token)[-1] | head -c '-1')
4242- commandline --function history-token-search-backward
77+ case "!" "*!"
88+ set -l last_cmd $history[1]
99+ set -l tokenized (string split ' ' -- $last_cmd)
1010+ commandline --current-token -- $tokenized[-1]
1111+ commandline --function repaint
4312 case "*"
4413 commandline --insert '$'
4514 end
+15
.config/fish/functions/__fish_bind_star.fish
···11+function __fish_bind_star
22+ switch (commandline --current-token)[-1]
33+ case "*!\\"
44+ # This case lets us still type a literal `!*` if we need to (by
55+ # typing `!\*`). Probably overkill.
66+ commandline --insert '*'
77+ case "*!" "!"
88+ set -l last_cmd $history[1]
99+ set -l tokenized (string split ' ' -- $last_cmd)
1010+ commandline --current-token -- (string join ' ' $tokenized[2..])
1111+ commandline --function repaint
1212+ case "*"
1313+ commandline --insert '*'
1414+ end
1515+end