Aliases for command line
These are mine aliases for command line that I use regularly. I use fish shell by the way. For bash or zsh the syntax may differ slightly.
1# File operations
2alias cp='cp -v'
3alias rm='rm -I'
4
5# Navigation
6alias ..='cd ..'
7alias ...='cd ../..'
8alias dl='cd ~/Downloads'
9alias dv='cd ~/Developer'
10alias dw='cd ~/Developer/workspace'
11alias home='cd ~/'
12
13# Git alias
14alias g='git'
15alias gs='git status'
16alias gc='git commit'
17alias gp='git pull'
18
19# Node package managers
20alias yi='yarn install'
21alias pi='pnpm install'
22alias yd='yarn dev'
23alias pd='pnpm dev'
24alias yb='yarn build'
25alias pb='pnpm build'
26
27# Fancy ls using eza (https://github.com/eza-community/eza)
28alias ls='eza -la --git --icons'
29alias ll='eza -la --git --icons'
30alias lsd='ls -lF'
31
32# grep with color
33alias grep='grep --color=auto'
34alias fgrep='fgrep --color=auto'
35alias egrep='egrep --color=auto'
36
37# Cat with syntax highlighting (https://github.com/sharkdp/bat)
38alias cat='bat'
39
40# fzf
41
42# fuzzy find file and open it with nvim
43alias fzp='nvim $(fzf --preview="bat --color=always {}")'
44
45# List all process
46alias lsp='lsof -n -i | fzf'
47
48# fuzzy search directory in workspace folder
49# https://github.com/sharkdp/fd
50alias fsd="fd -t d . ~/Developer/workspace/ --no-hidden | fzf --height 50% --border --preview 'ls -la {}'"
51
52# Git with fzf
53# Switch branch with interactive selection
54alias gco="git checkout (git branch -a | fzf | tr -d ' *')"
55
56# Interactive git log
57alias gl="git log --oneline --decorate --color=always | fzf --ansi --preview 'git show {1}' | awk '{print \$1}' | xargs git show"
58
59# interactive stash
60alias gstash='git stash list | fzf --preview="git stash show -p (string split ':' {} | head -n1)" | string split ':' | head -n1 | xargs -r git stash show -p'
61
62# History
63alias fh="eval (history | fzf)"
64
65# Search and install brew packages
66alias fbrew="brew search '' | fzf | xargs brew install"
67
68# Uninstall brew packages
69alias funbrew="brew list | fzf | xargs brew uninstall"
70
71# List installed brew packages
72alias lbrew="brew list | fzf --preview='brew info {}'"
73
74# env
75alias fenv="env | fzf"
The fish documentation on aliases can be found here.