What is a fish shell equivalent of mkdir -p foo/bar/baz/quux && cd $_
?
I know about $history[1]
, but here I need only last argument of the previous command.
fish doesn't support a last argument variable unfortunately.
An efficient interactive way to do this is to make the directory:
> mkdir -p foo/bar/baz/quux
Then type cd and the first character of the path.
> cd f
At this point fish will probably autosuggest the whole path. If not you can press alt-up to do a history token search and it will certainly find it.
A scripting way to do it would be:
set path foo/bar/baz/quux && mkdir -p $path && cd $path
As suggested in another thread Alt+. cycles arguments from previous commands at cursor input:
mkdir -p ~/fish/previous/arg/demo
cd
# ^ hit Alt + .
cd ~/fish/previous/arg/demo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With