2 ms·
'cd !$' is another recent discovery for me, as in: mv somefile -t /somedir cd !$ # now you are in /somedir
by 2mur 16y ago
'cd !$' is another recent discovery for me, as in:
mv somefile -t /somedir
cd !$ # now you are in /somedir
- kjetil 16y agoA more general way to do this is with M-. (Esc-.). This fetches the last argument from the previously entered command. Very handy when you need to apply multiple commands to a file or directory. Repeat this key combo to fetch the last argument from further back in your command history. I use this all the time (almost as much as tab completion).
- nwomack 16y agoeven better (if you are using bash, not sure about other shells) and use shopt -s histverify then if you type !$<enter> will replace !$ with /somedir but not hit return, so you could then modify it. Then you could do... mv somefile -t /somedir vim !$<enter>/somefile
- steve___ 16y agoTry adding this to your .inputrc file $if Bash Space: magic-space $endif Now the history expansion will be done when 'space' is pressed.