Skip to content

achinhchin/Fish-Shell-setup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

My Fish Shell setup

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.

Image Preview

  • Example command fish

Go to

Credits

OS support

  • Windows 10, 11 (WSL)
  • macOS
  • linux

Packages requirement

Contents

  1. Install WSL
  2. Install Nerd Font
  3. Set your font in terminal to Nerd Font
  1. Install Fish
  2. Install useful package
  1. Tab to get command, directory or option suggestion to your command line
  2. Right arrow to get command suggestion to your command line
  3. Z command to jump around
  4. Search files
  5. Search command from history
  6. Useful shortcut command

0. Update apt (For Debain only, if you use other you should update your Linux before start)

Run these commands on your terminal

sudo apt update && sudo apt upgrade

1. Prepare to use fish shell

1.1 Install WSL (For Windows only)

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.

1.2 Install Nerd Font

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.

1.3 Set your font in terminal to Nerd Font

2. Install Fish and useful package

2.1 Install Fish

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.

Fish Shell face

2.2 Install useful package

  1. Install Fisher - Fish plugin manager
curl -sL https://raw.githubusercontent.com/jorgebucaran/fisher/main/functions/fisher.fish | source && fisher install jorgebucaran/fisher
  1. Install and setup Tide - Beutiful shell theme.
fisher install IlanCosman/tide@v5

Then, customize tide to your style.

This's mine. my tide

If you want to customize tide again type this in fish shell

tide configure
  1. Install Z - Directory jumper
fisher install jethrokuan/z
  1. Install Exa - Colorful and icons when list directory.
brew install exa
  1. Install Ghq - Local Git repository organizer
brew install ghq
ghq get chinhchin/Fish-Shell-setup
  1. Install Peco - Interactive filtering
brew install peco

3. config.fish

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

4. Features

4.1 Tab to get command, directory or option suggestion to your command line

  1. Type some command.
  2. Press "Tab" then press "(Down)".
  3. Use "(Arrow Key)" to control position.
  4. Press "Enter/Return" to select directory.

Image Image

4.2 Right arrow to get command suggestion to your command line

  1. Type some command.
  2. If it show suggestion of command at right of cursor, press "Right" if you want to choose.

Image

4.3 Z command to jump around

Type z then followed by directory name or some part of directory name.

You can also jump over directory.

Image

4.4 Search files

You can search file by type "Ctrl-f".

Search files

Note

You can add more directory for search in file "~/.config/fish/config.fish" after line 59.

4.5 Search command from history

You can search command from history by type "Ctrl-r".

Search command from history

4.6 Useful shortcut command

  • 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>

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published