Extending a native terminal command with the Fish shell
Published on 2024-09-07 • Modified on 2024-09-07
This snippet shows how to extend a native terminal command with the Fish shell. This snippet is extracted from the official documentation and adds behaviour to the mkdir
command to jump into the new directory after its successful creation. The trick is to use command
with the native one to avoid an infinite loop.
function mkdir -d "Create a directory and set CWD"
command mkdir $argv
if test $status = 0
switch $argv[(count $argv)]
case '-*'
case '*'
cd $argv[(count $argv)]
return
end
end
end
More on Stackoverflow Read the doc Random snippet
Call to action
Did you like this post? You can help me back in several ways: (use the "reply" link on the right to comment or to contact me )
- Report any error/typo.
- Report something that could be improved.
- Like and repost!
- Follow me on Bluesky 🦋
- Subscribe to the RSS feed.
- Click on the More on Stackoverflow buttons to make me win "Announcer" badges 🏅.
Thank you for reading! And see you soon on Strangebuzz! 😉