I have posted the solution as an answer.
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.
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.
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.
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 .
Simply add this to your config.fish file:
function cs
cd $argv
ls -ahl
end
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