From adb444cee08d4f7ffe8723560e5062d94d71e3e3 Mon Sep 17 00:00:00 2001 From: Eduard Tolosa Date: Fri, 28 Feb 2025 19:48:24 +0000 Subject: [PATCH] (post-update): From Bash to Fish: fishing after 15 years Add alias files in conf.d, add completions section --- ...rom-bash-to-fish-fishing-after-15-years.md | 36 +++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/_posts/2025-02-28-from-bash-to-fish-fishing-after-15-years.md b/_posts/2025-02-28-from-bash-to-fish-fishing-after-15-years.md index ebf8963..f419363 100644 --- a/_posts/2025-02-28-from-bash-to-fish-fishing-after-15-years.md +++ b/_posts/2025-02-28-from-bash-to-fish-fishing-after-15-years.md @@ -52,7 +52,7 @@ paru -S oh-my-posh-bin ## Configuration -The Fish configuration is stored in `~/.config/fish/`. The main configuration file is `~/.config/fish/config.fish`. You can also have a `~/.config/fish/functions/` directory to store your functions, and a `~/.config/fish/completions/` directory to store your completions. There's also a `~/.config/fish/conf.d/` directory to store your drop-in configuration files. +The Fish configuration is stored in `~/.config/fish/`. The main configuration file is `~/.config/fish/config.fish`. You can also have a `~/.config/fish/functions/` directory to store your functions, and a `~/.config/fish/completions/` directory to store your completions. There's also a `~/.config/fish/conf.d/` directory to store your drop-in configuration files which gets sourced when Fish starts. ### Main configuration file @@ -73,15 +73,6 @@ set -x DOTNET_CLI_TELEMETRY_OPTOUT 1 set -x PATH $PATH \ $HOME/.local/bin -# Source aliases (if files exist) -if test -f ~/.config/fish/aliases/aliases.fish - source ~/.config/fish/aliases/aliases.fish -end - -if test -f ~/.config/fish/aliases/private-aliases.fish - source ~/.config/fish/aliases/private-aliases.fish -end - # Run only in interactive sessions if status is-interactive # Initialize Oh My Posh @@ -146,6 +137,31 @@ end ``` {% endraw %} +### Aliases + +Aliases use a slightly different syntax in Fish. Here's an example of a few aliases that I use: + +{% raw %} +```sh +# Use `eza` instead of `ls` +alias ls "eza" + +# Upload Gists +alias gist "gh gist create" + +# Some ls aliases +alias ll 'eza -l' +alias la 'eza -la' +alias l 'eza -hF' +``` +{% endraw %} + +So, just migrate your aliases and put the resulting file(s) in `~/.config/fish/conf.d/`. + +### Completions + +Fish automatically searches through any directories in the list variable `$fish_complete_path`, and any completions defined are automatically loaded when needed. Most software already have Fish completions, but if you need to create your own, see the [official documentation](https://fishshell.com/docs/current/completions.html). + ### Plugins Fish has a nice plugin system, you can use [Fisher](https://github.com/jorgebucaran/fisher) to manage your plugins. It's very easy to use, and you can install plugins with a single command. Here's a list of some plugins that I use: