Skip to content

Instantly share code, notes, and snippets.

@mzaidannas
Last active September 18, 2023 07:17
Show Gist options
  • Save mzaidannas/058412818aa0f1d28d927678dd0864f5 to your computer and use it in GitHub Desktop.
Save mzaidannas/058412818aa0f1d28d927678dd0864f5 to your computer and use it in GitHub Desktop.
Better Command Line tools
#!/usr/bin/env bash
# Install common tools and utilities
sudo apt install -y unace unrar zip unzip p7zip-full p7zip-rar sharutils rar uudeview mpack arj cabextract
# Install build tools and programming languages
sudo apt install -y build-essential git git-lfs gitk openssl python3 python3-setuptools python3-pip python3-gi libssl-dev resolvconf default-jre default-jdk llvm clang clang-tools lldb lld cmake gradle nodejs ruby ruby-build rust-all golang
# Configure some system specifications
sudo usermod -G input -a $USER
# Max number of files (Required by services like docker/jvm)
sudo sysctl -w fs.inotify.max_user_watches=524288
sudo sysctl -w vm.max_map_count=262144
# Better swap if system have a lot of unused memory
sudo sysctl -w vm.swappiness=10
sudo sysctl -w vm.vfs_cache_pressure=100
# Better USB transfer speed/progress
sudo sysctl -w vm.dirty_bytes=50331648
sudo sysctl -w vm.dirty_background_bytes=16777216
# Make these changes permanent
echo "fs.inotify.max_user_watches=524288\nvm.max_map_count=262144" | sudo tee /etc/sysctl.d/20-max-files.conf
echo "vm.swappiness=10\nvm.vfs_cache_pressure=100" | sudo tee /etc/sysctl.d/40-swap.conf
echo "vm.dirty_bytes=50331648\nvm.dirty_background_bytes=16777216" | sudo tee /etc/sysctl.d/50-usb-transfer.conf
sudo apt update && sudo apt upgrade -y
# Install asdf and configure ruby, nodejs, python and java plugins
git clone https://github.com/asdf-vm/asdf.git ~/.asdf
tee -a ~/.bashrc << ASDF
# asdf
. "\$HOME/.asdf/asdf.sh"
. "$HOME/.asdf/completions/asdf.bash"
ASDF
. "\$HOME/.asdf/asdf.sh"
. "$HOME/.asdf/completions/asdf.bash"
asdf plugin add nodejs https://github.com/asdf-vm/asdf-nodejs.git
asdf plugin add ruby https://github.com/asdf-vm/asdf-ruby.git
asdf plugin-add python https://github.com/asdf-community/asdf-python.git
asdf plugin-add java https://github.com/halcyon/asdf-java.git
# Use vscode as default editor
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo install -o root -g root -m 644 microsoft.gpg /etc/apt/trusted.gpg.d/
rm microsoft.gpg
echo "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" | sudo tee /etc/apt/sources.list.d/vscode.list
sudo apt update && sudo apt install -y code
# Alias commands (Better commandline tools)
# Zioxide (smart cd replacement)
sudo apt install -y zoxide
tee -a ~/.bashrc << ZOXIDE
# Zoxide (smart cd replacement)
eval "$(zoxide init bash)"
ZOXIDE
# Bat (cat and less alternative for printing to terminal)
sudo apt install -y bat
# NeoVim vim commandline text editor with plugin system
sudo apt install -y neovim
# Prettyping (ping alternative with colors and progress bar)
sudo apt install -y prettyping
# fd (faster find alternative)
sudo apt install -y fd-find
# ripgrep (faster grep and file content search)
sudo apt install -y ripgrep
# diff-so-fancy (git diff with colors and highlighting)
sudo npm install -g diff-so-fancy
# duf (df alternative)
sudo apt install -y duf
# ncdu (du alternative)
sudo apt install -y ncdu
# htop (top alternative)
sudo apt install -y htop
# exa (ls alternative with colors)
sudo apt install -y exa
# lsd (ls alternative with colors and icons)
curl -fsSLO https://github.com/lsd-rs/lsd/releases/download/v1.0.0/lsd_1.0.0_amd64.deb
sudo dpkg -i lsd_1.0.0_amd64.deb
rm lsd_1.0.0_amd64.deb
# tldr (Better help and man pages)
sudo apt install -y tldr
# jq and yq commandline JSON and Yaml parsers
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys CC86BB64
sudo add-apt-repository ppa:rmescandon/yq -y
sudo apt install -y jq yq
# FZF (Fuzzy search everything)
sudo apt install -y fzf
tee -a ~/.bashrc << FZF
# FZF (Fuzzy substring searching)
[ -f /usr/share/doc/fzf/examples/key-bindings.bash ] && source /usr/share/doc/fzf/examples/key-bindings.bash
FZF
# wl-clipboard for wayland cli clipboard managment
sudo apt install -y wl-clipboard
tee -a ~/.bashrc << ALIASES
# Shell alias commands
alias sudo="sudo "
alias cd="z"
alias vim="nvim"
alias less="batcat --pager='less -RF'"
alias cat="batcat --paging never"
alias ping="prettyping --nolegend"
alias preview="fzf --preview 'batcat --color \"always\" {}'"
# add support for ctrl+o to open selected file in Helix text editor
export FZF_DEFAULT_OPTS="--bind='ctrl-o:execute(hx {})+abort'"
export FZF_DEFAULT_COMMAND="fdfind --type file --color=never --hidden --no-ignore"
export FZF_ALT_C_COMMAND='fdfind --type directory . --color=never --hidden --no-ignore'
alias top="htop"
alias find="fdfind"
alias du="ncdu -rr -x --exclude .git --exclude node_modules"
alias ls="lsd"
alias df="duf"
alias grep="rg"
alias help="tldr"
alias yq="yq -CP"
alias pbcopy='wl-copy'
alias pbpaste='wl-paste'
ALIASES
# To enable clipboard sharing between server/client using aliases pbcopy/pbpaste
echo 'ForwardX11 yes' >> ~/.ssh/config
# setup diff-so-fancy
git config --global pager.diff 'diff-so-fancy | less --tabs=1,5 -RF'
git config --global pager.show 'diff-so-fancy | less --tabs=1,5 -RF'
git config --global color.ui true
git config --global color.diff-highlight.oldNormal "red bold"
git config --global color.diff-highlight.oldHighlight "red bold 52"
git config --global color.diff-highlight.newNormal "green bold"
git config --global color.diff-highlight.newHighlight "green bold 22"
git config --global color.diff.meta "11"
git config --global color.diff.frag "magenta bold"
git config --global color.diff.commit "yellow bold"
git config --global color.diff.old "red bold"
git config --global color.diff.new "green bold"
git config --global color.diff.whitespace "red reverse"
# Optional (git default editor as vscode)
git config --global core.editor 'code --wait'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment