Last active
October 22, 2023 11:58
-
-
Save dogwong/07d1a149db774bfb3c281125e6791cd9 to your computer and use it in GitHub Desktop.
Ubuntu install zsh with p9k and basic vimrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# tested on DigitalOcean Ubuntu 22.04 LTS | |
# Ubuntu 22.04, prevent "Daemons using outdated libraries" popup | |
sed -i -e "/#\$nrconf{restart} = 'i';/s/.*/\$nrconf{restart} = 'a';/" /etc/needrestart/needrestart.conf | |
apt-get update | |
apt-get install -y git curl vim # basic stuffs | |
apt-get install -y language-pack-en # in case of "command not found: print_icon" | |
apt-get install -y zsh | |
# https://github.com/ohmyzsh/ohmyzsh | |
# for manual | |
# sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" | |
# --unattended. This will have the effect of not trying to change the default shell, and also won't run zsh when the installation has finished. | |
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended | |
chsh -s $(which zsh) | |
# https://github.com/Powerlevel9k/powerlevel9k/wiki/Install-Instructions#step-1-install-powerlevel9k | |
git clone https://github.com/bhilburn/powerlevel9k.git ~/.oh-my-zsh/custom/themes/powerlevel9k | |
sed -i '/^\# Path to your oh-my-zsh installation./i export TERM="xterm-256color"' ~/.zshrc | |
sed -i -e 's/^\(ZSH_THEME="robbyrussell"\)/\# \1\nZSH_THEME="powerlevel9k\/powerlevel9k"/' ~/.zshrc | |
sed -i -e 's/^plugins=(git)/plugins=(git docker npm history)/' ~/.zshrc | |
# sed -i -e 's/^\# \(export LANG=en_US\.UTF-8\)/\1/' ~/.zshrc | |
sed -i '/^source $ZSH\/oh-my-zsh.sh/i POWERLEVEL9K_MODE="nerdfont-complete"' ~/.zshrc | |
echo "" >> ~/.zshrc | |
echo "" >> ~/.zshrc | |
echo "# https://github.com/Powerlevel9k/powerlevel9k/wiki/stylizing-your-prompt#special-segment-colors" >> ~/.zshrc | |
echo "POWERLEVEL9K_DIR_HOME_BACKGROUND='123'" >> ~/.zshrc | |
echo "POWERLEVEL9K_DIR_HOME_SUBFOLDER_BACKGROUND='123'" >> ~/.zshrc | |
echo "POWERLEVEL9K_DIR_ETC_BACKGROUND='123'" >> ~/.zshrc | |
echo "POWERLEVEL9K_DIR_DEFAULT_BACKGROUND='123'" >> ~/.zshrc | |
echo "POWERLEVEL9K_PROMPT_ON_NEWLINE='true'" >> ~/.zshrc | |
echo "POWERLEVEL9K_CONTEXT_DEFAULT_FOREGROUND='77'" >> ~/.zshrc | |
echo "" >> ~/.zshrc | |
echo "" >> ~/.zshrc | |
# Number pad fix | |
# https://github.com/ohmyzsh/ohmyzsh/issues/4916 | |
echo '# Keypad' >> ~/.zshrc | |
echo '# 0 . Enter' >> ~/.zshrc | |
echo 'bindkey -s "^[Op" "0"' >> ~/.zshrc | |
echo 'bindkey -s "^[On" "."' >> ~/.zshrc | |
echo 'bindkey -s "^[OM" "^M"' >> ~/.zshrc | |
echo '# 1 2 3' >> ~/.zshrc | |
echo 'bindkey -s "^[Oq" "1"' >> ~/.zshrc | |
echo 'bindkey -s "^[Or" "2"' >> ~/.zshrc | |
echo 'bindkey -s "^[Os" "3"' >> ~/.zshrc | |
echo '# 4 5 6' >> ~/.zshrc | |
echo 'bindkey -s "^[Ot" "4"' >> ~/.zshrc | |
echo 'bindkey -s "^[Ou" "5"' >> ~/.zshrc | |
echo 'bindkey -s "^[Ov" "6"' >> ~/.zshrc | |
echo '# 7 8 9' >> ~/.zshrc | |
echo 'bindkey -s "^[Ow" "7"' >> ~/.zshrc | |
echo 'bindkey -s "^[Ox" "8"' >> ~/.zshrc | |
echo 'bindkey -s "^[Oy" "9"' >> ~/.zshrc | |
echo '# + - * /' >> ~/.zshrc | |
echo 'bindkey -s "^[Ok" "+"' >> ~/.zshrc | |
echo 'bindkey -s "^[Om" "-"' >> ~/.zshrc | |
echo 'bindkey -s "^[Oj" "*"' >> ~/.zshrc | |
echo 'bindkey -s "^[Oo" "/"' >> ~/.zshrc | |
echo '# Home End' >> ~/.zshrc | |
echo 'bindkey "^[[1~" beginning-of-line' >> ~/.zshrc | |
echo 'bindkey "^[[4~" end-of-line' >> ~/.zshrc | |
echo '# Alt+Left Alt+Right' >> ~/.zshrc | |
# TODO: seems this value differs with different terminal / OS | |
#echo 'bindkey "^[^[[D" forward-word' >> ~/.zshrc | |
#echo 'bindkey "^[^[[C" backward-word' >> ~/.zshrc | |
echo 'bindkey "^[[1;5C" forward-word' >> ~/.zshrc | |
echo 'bindkey "^[[1;5D" backward-word' >> ~/.zshrc | |
echo "" >> ~/.zshrc | |
echo "" >> ~/.zshrc | |
# share history | |
echo "# unsetopt share_history" >> ~/.zshrc | |
curl https://raw.githubusercontent.com/amix/vimrc/master/vimrcs/basic.vim > ~/.vimrc | |
sed -i -e 's/^\( colorscheme desert\)/\# \1/' ~/.vimrc | |
# set git default editor | |
git config --global core.editor "vim" | |
# reload config, for manual and using zsh | |
# . ~/.zshrc | |
zsh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment