user15476132
user15476132

Reputation:

Linux: Declare a shorthand for any command with fish

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

Upvotes: 1

Views: 98

Answers (2)

glenn jackman
glenn jackman

Reputation: 247062

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

Upvotes: 0

faho
faho

Reputation: 15974

Define a variable:

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

Upvotes: 1

Related Questions