For Ubuntu’s default keybinding settings (i.e Emacs keybindings)
In Linux you can repeat commands to go back in history
Last command is:
mv foo bar
mv
foo
mv foo
(relative to cursor’s position)
bind -lp
bindkey -L
only works in zsh, and probably only Linux
Insert any argument of a previous command by iterating one by one until selection
run this:
autoload -Uz copy-earlier-word
zle -N copy-earlier-word
bindkey "^[:" copy-earlier-word
(to make this permanent, add it to your ~/.zshrc
and restart shell)
Now use Alt+. to go as back as you want, then use Alt+: to iterate through the arguments
Last command is
echo 1 2 3 4 5
5
4
3
2
1
echo
source: https://stackoverflow.com/a/34861762/3163120
Let’s consider the last command to be:
mv foo bar
up , Ctrl+w: last command without the last word = mv foo
Alt+0+.: first argument of last command = mv
“words” only includes a-zA-Z
characters, so any symbol character will stop word-shortcuts.
So if last argument was a url and you want to erase it with Ctrl+w it will be a pain.
E.g: curl -I --header "Connection: Keep-Alive" https://stackoverflow.com/questions/38176514/re-run-previous-command-with-different-arguments
To erase that url using Ctrl+w, you’d have to repeat it 12 times.
It would be great to have similar shortcuts that only stops at the space character