Skip to main content

Improved Commandlines


source code helper:


search and find:


files manager:

bat

A better syntax coloring code reader, the improved product for `less`
Install by Package Manger:
sudo pacman -S --noconfirm bat
On Debian, bat is already registered by other. To remap bat to batcat:
sudo update-alternatives --install /usr/local/bin/bat bat `which batcat` 1

delta

Text Comparison Tool, the improved product for `diff`
Install by Package Manger:
sudo pacman -S --noconfirm git-delta
Git integration:
git config --global pager.show delta
git config --global pager.log delta
git config --global pager.reflog delta
git config --global interactive.difffilter "delta --color-only"

# (optional) will influence `git diff` output format:
# git config --global pager.diff delta

tig

Better git log viewer
The command is already bundled with Git For Windows
Install by Package Manger:
sudo pacman -S --noconfirm tig

recommend config:

# press `C` key switch HEAD pointer to current selected commit
echo 'bind main C ?git checkout %(commit)' >> ~/.tigrc

fzf

Interactive menu selector
Install by Package Manger:
sudo pacman -S --noconfirm fzf

To enable the following shortcut keys within Shell:

  • Ctrl + R to search history (fuzzy search supported)
  • Alt + C to change the current working directory
  • Ctrl + T to search for a file, copy its path
Package Manager:
printf "source /usr/share/fzf/shell/key-bindings.bash\n" >> ~/.bashrc
printf "source /usr/share/fzf/shell/key-bindings.zsh\n" >> ~/.zshrc
exec $SHELL

fd

File Finder, the improved product for `find`
Install by Package Manger:
sudo pacman -S --noconfirm fd
install by APT:
sudo apt install -y fd-find
sudo update-alternatives --install /usr/local/bin/fd fd `which fdfind` 1

ripgrep

Text String Finder
Install by Package Manger:
sudo pacman -S --noconfirm ripgrep

ncdu

Analyze folder size
Install by Package Manger:
sudo pacman -S --noconfirm ncdu

zoxide

Working directory record and jump, the improved product for `cd`
Install by Package Manger:
sudo pacman -S --noconfirm zoxide
Integrate:

bash/zsh:

printf 'eval "$(zoxide init bash)"\n' >> ~/.bashrc
printf 'eval "$(zoxide init zsh)"\n' >> ~/.zshrc

PowerShell $profile:

## For zoxide v0.8.0+
Invoke-Expression (& {
$hook = if ($PSVersionTable.PSVersion.Major -lt 6) { 'prompt' } else { 'pwd' }
(zoxide init --hook $hook powershell | Out-String)
})

## For older versions of zoxide
Invoke-Expression (& {
$hook = if ($PSVersionTable.PSVersion.Major -lt 6) { 'prompt' } else { 'pwd' }
(zoxide init --hook $hook powershell) -join "`n"
})

fzf

type `zi` to search history

moreutils

More useful commands
Install by Package Manger:
sudo pacman -S --noconfirm moreutils

tmux

Terminal Splitting & Multiplexing
printf '# 256 color mode enchance (Y/n)? '; read r
[[ "$r" =~ ^(Y|y|)$ ]] &&
echo 'set -g default-terminal "screen-256color"' >>~/.tmux.conf

printf 'press `Prefix + M` switch mouse mode (Y/n)? '; read r
[[ "$r" =~ ^(Y|y|)$ ]] &&
echo 'bind-key m set-option -g mouse \; display "Mouse: #{?mouse,ON,OFF}"' >>~/.tmux.conf

printf 'replace `Ctrl + S` with `Ctrl + B` as prefix key (y/N)? '; read r
[[ "$r" =~ ^(Y|y)$ ]] &&
echo 'set-option -g prefix C-s' >>~/.tmux.conf

pidof tmux >/dev/null && tmux source-file ~/.tmux.conf

tldr

Commandline Usage Guide, the lite product for `man`
Install by Package Manger:
sudo pacman -S --noconfirm tldr
git clone --depth=1 https://gitclone.com/github.com/tldr-pages/tldr ~/.cache/tldr
Node.js version:
Install:
yarn global add tldr

# make it as a ohmyzsh plugin
ln -s $(yarn global dir)/node_modules/tldr/bin/completion/zsh/_tldr $ZSH_CUSTOM/plugins/tldr/_tldr
echo tldr >> .zshrc.plug.list # add to .zshrc plugins array
Colorize output:
[ -f ~/.tldrrc ] || echo '{"theme":"base16"}' > ~/.tldrrc

pipx

Environment isolation installer, the improved product for `pip`
required Python >= 3.7
Install by Package Manger:
sudo pacman -S --noconfirm python-pipx
install by PIP:
python3 -m pip install --user pipx
python3 -m pipx ensurepath

how to enable auto completion:
echo 'eval "$(register-python-argcomplete pipx)"' >> ~/.zshrc

# other UNIX:
# pipx completions | less

赞助作者 (Sponse me):