This is my Fish Shell setup, and I use it for create more speed and productivity such as create shortcut for many frequently used command, jump to many location by use shortcut path, show repository of git in line and also make it beutiful.
- Inspiration, list of modules and solution from craftzdog/dotfiles-public.
- Windows 10, 11 (WSL)
- macOS
- linux
0. Update apt
3. config.fish
4. Features
- Tab to get command, directory or option suggestion to your command line
- Right arrow to get command suggestion to your command line
- Z command to jump around
- Search files
- Search command from history
- Useful shortcut command
Run these commands on your terminal
sudo apt update && sudo apt upgrade
If you want to use Fish Shell on Windows, you have to install WSL (Windows Subsystem for Linux) for running Linux on Windows.
Note
In every command next from this, type every command into WSL.
First, I have to install Nerd Fonts so that I can display the icons and markers used in programming nicely.
So I use Caskaydia Cove Nerd Font.
And you can see more fonts to get the one that is right for you here.
Important
You have to install brew before use this command, see install solution in packages requirement
brew install fish
fish
Note
All next command you have to type in Fish Shell so make it sure that you're in fish shell. If you are not, type
fish
. In fish shell it will look like this.
- Install Fisher - Fish plugin manager
curl -sL https://raw.githubusercontent.com/jorgebucaran/fisher/main/functions/fisher.fish | source && fisher install jorgebucaran/fisher
- Install and setup Tide - Beutiful shell theme.
fisher install IlanCosman/tide@v5
Then, customize tide to your style.
If you want to customize tide again type this in fish shell
tide configure
- Install Z - Directory jumper
fisher install jethrokuan/z
- Install Exa - Colorful and icons when list directory.
brew install exa
- Install Ghq - Local Git repository organizer
brew install ghq
ghq get chinhchin/Fish-Shell-setup
- Install Peco - Interactive filtering
brew install peco
Copy below data and paste it in ~/.config/fish/config.fish.
# Alias
alias ll "exa -ga --icons"
alias llt "exa -gTa --icons --level 3"
alias md mkdir
# app
alias g git
alias tm tmux
alias tmks "tmux kill-session -t"
alias tmat "tmux attach-session -t"
alias tmls "tm ls"
# workspace
alias cls clear
alias clr clear
command -qv nvim && alias vim nvim
# NVM
function __check_rvm --on-variable PWD --description 'Do nvm stuff'
status --is-command-substitution; and return
if test -f .nvmrc; and test -r .nvmrc;
nvm use
else
end
end
# Key Bindings
function fish_user_key_bindings
# peco
bind \cr peco_select_history # Bind for peco select history to Ctrl+R
bind \cf peco_change_directory # Bind for peco change directory to Ctrl+F
# vim-like
bind \cl forward-char
# prevent iterm2 from closing when typing Ctrl-D (EOF)
bind \cd delete-char
end
#peco change directory
function _peco_change_directory
if [ (count $argv) ]
peco --layout=bottom-up --query "$argv " | read foo
else
peco --layout=bottom-up | read foo
end
if [ $foo ]
cd $foo
commandline -r ''
commandline -f repaint
else
commandline ''
end
end
function peco_change_directory
begin
ls -ad */|perl -pe "s#^#$PWD/#"|grep -v \.git
echo $HOME
echo $HOME/.config
ls -ad $HOME/.config/*
# Add your workflow folder path here.
end | sed -e 's/\/$//' | awk '!a[$0]++' | _peco_change_directory $argv
end
#peco select history
function peco_select_history
if test (count $argv) = 0
set peco_flags --layout=bottom-up
else
set peco_flags --layout=bottom-up --query "$argv"
end
history|peco $peco_flags|read foo
if [ $foo ]
commandline $foo
else
commandline ''
end
end
- Type some command.
- Press "Tab" then press "(Down)".
- Use "(Arrow Key)" to control position.
- Press "Enter/Return" to select directory.
- Type some command.
- If it show suggestion of command at right of cursor, press "Right" if you want to choose.
Type z
then followed by directory name or some part of directory name.
You can also jump over directory.
You can search file by type "Ctrl-f".
Note
You can add more directory for search in file "~/.config/fish/config.fish" after line 59.
You can search command from history by type "Ctrl-r".
-
ll - get list of all file in current directory
-
llt - get list of all file in current directory with tree
-
g - call git
-
cls and clr - clear screen
-
md - create folder (alias from mkdir)
Note
You can edit or add more shortcut in file "~/.config/fish/config.fish" by type
alias <shortcut command> <full command>