Skip to content

Instantly share code, notes, and snippets.

@kiyoon
Last active November 30, 2022 17:38
Show Gist options
  • Save kiyoon/fc1573ed3edf61c142d925e1712940e9 to your computer and use it in GitHub Desktop.
Save kiyoon/fc1573ed3edf61c142d925e1712940e9 to your computer and use it in GitHub Desktop.
Awesome bash defaults for modern users. Locally install most of the programs.

Configure most of the things without root permission.

Neovim, tmux, Starship, zoxide, fzf, exa, bash vi mode, ...

Shows git stats, command runtime etc. in a nice way.

You can change directory with partial keyword you remember. It will remember the most frequent cd and find it.

z exper            # it will find "/disk/scratch1/experiments"
z exper datas      # It will find "/disk/scratch1/experiments/datasets"

zi foo             # cd with interactive selection (using fzf)
z foo<SPACE><TAB>  # show interactive completions

Fuzzy file finder.

  • fzf: find file and print the result
  • fzf-tmux: run fzf on a new tmux pane.
  • anycommand directory/**<TAB>: run fzf and paste to command line
  • Alt+c: change directory
  • Ctrl+t: find file and paste to command line
  • Ctrl+r: reverse search

In VIM,

  • :Files
  • :FZF

and hit Ctrl+x to open in horizontal split, Ctrl+v for vertical split.

ls with more colours.

# Requirements: git, pip3, curl
##### bash vi mode, auto cd
# You can enter command mode by hitting `ESC`.
# You can even type `ESC` then `v` to edit the command line with vim!
echo "set -o vi" >> ~/.bashrc
echo 'shopt -s autocd' >> ~/.bashrc
. ~/.bashrc
##### tmux latest version
source <(curl -sS https://raw.githubusercontent.com/kiyoon/tmux-local-install/master/install.sh)
##### Node.js (for Coc, Github Copilot)
curl -sL install-node.vercel.app/17 | bash -s -- --prefix="$HOME/.local" -y
##### Neovim latest version
source <(curl -sS https://raw.githubusercontent.com/kiyoon/neovim-local-install/master/install.sh)
source <(curl -sS https://raw.githubusercontent.com/kiyoon/neovim-local-install/master/bash.sh)
pip3 install --user pynvim # add python support
##### vimrc, tmux.conf
mkdir ~/bin
cd ~/bin
git clone https://github.com/kiyoon/vimrc4ubuntu
git clone https://github.com/kiyoon/tmux-conf
cd
ln -s bin/vimrc4ubuntu/.vimrc
ln -s bin/tmux-conf/.tmux.conf
# neovim init.vim
mkdir ~/.config/nvim -p
cd ~/.config/nvim
ln -s ~/bin/vimrc4ubuntu/init.vim .
# tmux plugins
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
# start a server but don't attach to it
tmux start-server
# create a new session but don't attach to it either
tmux new-session -d
# install the plugins
~/.tmux/plugins/tpm/scripts/install_plugins.sh
# killing the server is not required, I guess
tmux kill-server
##### Starship
sh -c "$(curl -fsSL https://starship.rs/install.sh)" sh -b "$HOME/.local/bin" -y
echo 'eval "$($HOME/.local/bin/starship init bash)"' >> ~/.bashrc
wget https://gist.githubusercontent.com/kiyoon/53dae21ecd6c35c24c88bcce88b89d27/raw/21e8e98917a08a9cb6d1ab85c0fb6fe39b4c28b5/starship.toml -P ~/.config
. ~/.bashrc
##### zoxide
curl -sS https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | bash
echo 'eval "$($HOME/.local/bin/zoxide init bash)"' >> ~/.bashrc
. ~/.bashrc
##### fzf
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
~/.fzf/install --all
. ~/.bashrc
##### MiniConda
cd
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
CONDADIR="$HOME/bin/miniconda3"
bash Miniconda3-latest-Linux-x86_64.sh -b -p "$CONDADIR"
$CONDADIR/bin/conda init
. ~/.bashrc
# Some may require sudo!
##### Vim Isort
pip3 install --user isort
##### Conda config
conda config --set auto_activate_base false
##### aliases
# `ca` -> `conda activate`
# `ns` -> `nvidia-smi`
# `rb` -> `gio trash`
echo "alias ca='conda activate'" >> ~/.bash_aliases
echo "alias ns='nvidia-smi'" >> ~/.bash_aliases
echo "alias rb='gio trash'" >> ~/.bash_aliases
. ~/.bashrc
##### Config git
git config --global user.email "[email protected]"
git config --global user.name "Kiyoon Kim"
git config --global core.editor nvim
git config --global pull.rebase false
git config --global url.ssh://[email protected]/.insteadOf https://github.com/
##### Neovim and tmux clipboard support
sudo apt update -y
sudo apt install xclip -y
##### exa
sudo apt update -y
sudo apt install exa -y
echo "alias ls='exa'" >> ~/.bash_aliases
echo "alias ll='exa -alF'" >> ~/.bash_aliases
echo "alias la='exa -a'" >> ~/.bash_aliases
echo "alias l='exa -F'" >> ~/.bash_aliases
. ~/.bash_aliases
##### Neovim Github Copilot
nvim +PlugInstall +qall
nvim '+Copilot setup' +q
nvim '+Copilot enable' +q
##### GitHub Cli
type -p curl >/dev/null || sudo apt install curl -y
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
&& sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& sudo apt update \
&& sudo apt install gh -y
gh auth login
gh alias set r repo
##### bashrc
# https://askubuntu.com/questions/5809/bash-does-not-remember-commands
shopt -s histappend
export HISTSIZE='10000'
export HISTFILE="$HOME/.bash_history"
export HISTIGNORE=cd:ls:bg:fg:exit
export HISTCONTROL=ignoredups
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment