Home > Software design >  Linux: Declare a shorthand for any command with fish
Linux: Declare a shorthand for any command with fish

Time:04-14

I'm using the fish shell and i would add custom shorthand for path i frequently use in my commands.

E.g: i would add something like @ corresponding to my dev folder, very similar to how ~ works:

cd @ => cd /home/sigma/dev

some_command @/foo @/bar => some_command /home/sigma/dev/foo /home/sigma/dev/bar

CodePudding user response:

Define a variable:

set -g dev /home/sigma/dev
cd $dev
some_command $dev/foo $dev/bar

CodePudding user response:

I'd normally advice writing a wrapper function around the cd command, but fish already provides cd as a wrapper function.

I do something like this:

function cddev
  cd /home/sigma/dev
end

Save that as ~/.config/fish/functions/cddev.fish

  • Related