Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create a function that performs cd then ls in fish? [closed]

Tags:

fish

I have posted the solution as an answer.

like image 716
PuffySparrow Avatar asked Sep 18 '14 13:09

PuffySparrow


People also ask

How do you make a function in a fish shell?

By using one of the event handler switches, a function can be made to run automatically at specific events. The user may generate new events using the emit builtin. Fish generates the following named events: fish_prompt , which is emitted whenever a new fish prompt is about to be displayed.

How do you set a variable in a fish shell?

Unlike other shells, fish has no dedicated VARIABLE=VALUE syntax for setting variables. Instead it has an ordinary command: set , which takes a variable name, and then its value.

Where do you put a fish function?

For the first issue, all functions live in your home directory under ~/. config/fish/functions . They're automatically loaded to the list of functions you can access from the fish shell, so there's no need to add the directory to the path yourself.

Where is fish config stored?

The configuration file runs at every login and is located at ~/. config/fish/config. fish . Adding commands or functions to the file will execute/define them when opening a terminal, similar to .


1 Answers

Simply add this to your config.fish file:

function cs
   cd $argv
   ls -ahl
end
like image 98
PuffySparrow Avatar answered Nov 15 '22 04:11

PuffySparrow