# 【學習筆記】zsh setting change your terminal theme [TOC] ## Ubuntu Setting 1. Install `zsh`, and `git` package >$sudo apt-get install zsh >$sudo apt-get install git 2. Check your current client support shell >$cat /etc/shells > Note: It will list down all the shell it support 3. Check default shell `$echo $SHELLS ` or `$echo $0` default is /bin/bash 4. Install oh-my-zsh You can use either `wget` or `curl` to **download**. Default `wget` is installed, so I will used it instead of `curl`. >via curl $sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" or > via wget $sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)" 5. Change your default shell to zsh `$chsh -s /bin/zsh` 6. Download your theme 7. cd to home directory and copy the download theme to zsh folder ```bash= $cd $sudo mv Downloads/bullet-train.zsh-theme .oh-my-zsh/themes/ ``` 8. edit .zshrc to change your theme >#change ZSH_THEME to bullet-train >nano ZSH_THEME = “bullet-train” 9. restart your terminal or logout 10. install poweline else font will be strange, especially logo >$sudo apt-get install powerline >$sudo apt-get install fonts-powerline ### Script automatic ZSH write file ```batch= #!/bin/bash #creating zsh terminal echo "installing zsh" apt-get install zsh -y echo "installing git" apt-get install git -y echo "check support shell :" cat /etc/shells echo "check current shell:" echo $SHELL echo "install oh-my-zsh" #curl: #sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" #wget sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)" echo "change shell to zsh" chsh -s /bin/zsh #setting theme cd #sudo mv Downloads/bullet-train.zsh-theme .oh-my-zsh/themes/ sudo cp -av bullet-train.zsh-theme .oh-my-zsh/themes/ sed -i -e 's/ZSH_THEME="robbyrussell"/#ZSH_THEME="robbyrussell"\nZSH_THEME="bullet-train"/g' .zshrc #echo 'read -p "please enter your option' #echo '1. setup pxe setting dhcp tftp ' #echo '========================' #read -p "Your Options: " option ``` --- ## Mac Setting 1. 安裝 Homebrew Homebrew 是 Mac OSX 上的的套件管理工具,是方便安裝管理 OSX 裡需要用到但預設沒安裝的套件。 > $/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh )" 2. install iterm2 > brew install --cask iterm2 >> - **背景:** command + i or iterms>preferences 選colors 或是下面plugin >>iterm color plugin [download](https://github.com/mbadolato/iTerm2-Color-Schemes) >>color 選import plugin 上面下載 。選schemes裡面的 >>- **spit terminal:** >> split vertical: ⌘ + D >> horizontal: ⌘ + ⇧+D >> switch terminal: ⌘ + Option+ right left >> max/min terminal:⌘+ shift+ ⏎ >>- **Word Jumps:** >>perference> keys>natural text editing >>add word ex: one two three >>switch word: options right or left move word >>- delete word: delete + backspace >>- command history hint: ⌘ ; 3. 安裝 ZSH - check what shell are are using: >`echo $SHELL` - install zsh > brew install zsh - set default iterm2 shell to zsh > csh -s /bin/zsh #method1 > sudo sh -c "echo $(which zsh) >> /etc/shells" #method2 > chsh -s $(which zsh) #method3 restart itern after setting it 4. 安裝 oh-my-zsh (iterm plugin) - Oh-my-sh [download git page](https://github.com/ohmyzsh/ohmyzsh) - Method1: ``` bash= #via curl sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" # or # via wget sh -c "$(wget -O-https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" ``` - Method 2 >git clone git://github.com/robbyrussell/oh-my-zsh.git >cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc >source ~/.zshrc 5. download zsh theme - makesure you are in home directory `cd ~` - All theme [theme description](https://github.com/ohmyzsh/ohmyzsh/wiki/Themes) - agnoster theme [link](https://github.com/agnoster/agnoster-zsh-theme) - For Mac users, I highly recommend iTerm 2 + Solarized Dark - Powerlevel9k theme - download and install > git clone https://github.com/bhilburn/powerlevel9k.git ~/.oh-my-zsh/custom/themes/powerlevel9k - [Powerlevel10k](https://github.com/romkatv/powerlevel10k) theme - download and install ``` bash= git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k ``` - after set theme `.zshrc` it will ask you question, press > n > n > y > which style you want? > 1unicode or 2ascii? 1 > show time > flat or blurred at end? > same line as heading? > compact or space > instant prompt mode? 1 > apply? 6. open and edit .zshrc to change theme - edit .zshrc >ZSH_THEME="agnoster" >ZSH_THEME="random" #randome theme >ZSH_THEME="powerlevel9k/powerlevel9k" >ZSH_THEME="powerlevel10k/powerlevel10k" 7. update change > source ~/.zshrc 8. install Powerline fonts else not looking rigt - Method 1 - download [Powerline/SourceCodePro](https://github.com/powerline/fonts/blob/master/SourceCodePro/Source%20Code%20Pro%20for%20Powerline.otf) - open it and install it - Method 2 : clone github and install - got to [powerline github](https://github.com/powerline/fonts) and clone - install using the script: > cd fonts >./install.sh - set iterns perference and change fonts perferences>Profile> change font> and select the font you install just now "**source code pro for powerline**" ### 其他ohmyzsh外掛或建議 more plugin - edit .zshrc for plugin same as theme - [All ohmyzsh plugin ](https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins) - copy the plugin name and paste into plugins() > plugins= (osx #type tab will new terminal tab > websearch > vscode #vscode > ) - Auto Suggestions Plugin - download > git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions - add plugin to ~/.zshrc: > plugins=( > git zsh-autosuggestions >) - source ~.zshrc - Syntax Highlighting - download and install > brew install zsh-syntax-highlighting - open and edit ~/.zshrc: - Skip to the end of ~/.zshrc and add below: > source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh - source ~.zshrc - press cd will list all directory - Change the username@hostname - edit .zshrc - add below bottom of ZSH_THEME or any place > DEFAULT_USER = \`whoami` - alias - vscode plugin - add code in plugin > plugins= (vscode) - open vscode > \>shell #install code command in PATH - use `code .` will open vscode - terminal with vscode - go to setting or CMD + - go to edit setting json - for Source Code Pro + Font Awesome: "terminal.integrated.fontFamily": "'SourceCodePro+Powerline+Awesome Regular'". The single quotes are important! Restart VS Code after the config change. - for Source Code Pro: "terminal.integrated.fontFamily": "Source Code Pro for Powerline" - for Meslo: "terminal.integrated.fontFamily": "Meslo LG M for Powerline" - for other fonts you'll need to check the font name in Font Book. You can right click on them on select "Show in Finder" to get the exact name. - neofetch (fancy ) - [github offical](https://github.com/dylanaraps/neofetch) - [installation guide](https://github.com/dylanaraps/neofetch/wiki/Installation#latest-git-master-bleeding-edge) > git clone https://github.com/dylanaraps/neofetc > cd neofetch > make install #install > - fzf (history command) - [fzf github](https://github.com/junegunn/fzf) - Homebrew to install: > brew install fzf > #To install useful key bindings and fuzzy completion: > $(brew --prefix)/opt/fzf/install - github install > git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf > ~/.fzf/install > ask you question: press y - key - fuzzy find command history: ctrl + R - fuzzy find current direcoty: ctrl + T - `rm` with tab - `ls` with tab - .css$ : start with css file - cd ** or ssh ** ## reference: - https://pjchender.dev/app/iterm2/ - https://www.youtube.com/watch?v=xy9OIJWtarc - https://github.com/pugengineer/iTerm2-ohmyzsh-powerlevel9k - https://www.onejar99.com/terminal-iterm2-zsh-powerlevel10k/ - https://www.youtube.com/watch?v=eh7lM3Yvf94 - https://github.com/ohmyzsh/ohmyzsh/wiki/Installing-ZSH - https://www.onejar99.com/terminal-iterm2-zsh-powerlevel10k/ ## ref temp 2025 - ohmyzsh itern +p10k [done] - https://www.youtube.com/watch?v=eh7lM3Yvf94 - https://www.youtube.com/watch?v=SVh4osULjP4&t=200s&pp=ygURenNoIHBvd2VybGV2ZWwxMGs%3D - https://www.youtube.com/watch?v=0FZSshb1qTQ - https://www.youtube.com/watch?v=D2PSsnqgBiw&pp=ygURenNoIHBvd2VybGV2ZWwxMGs%3D - https://www.youtube.com/watch?v=WaU1SP4Dtxo&pp=ygURenNoIHBvd2VybGV2ZWwxMGs%3D - https://www.youtube.com/watch?v=eh7lM3Yvf94&pp=ygURenNoIHBvd2VybGV2ZWwxMGs%3D - wrap - https://www.youtube.com/watch?v=d4bTkiftBOk&t=55s - https://www.youtube.com/watch?v=dIV9Cso4Mi8&pp=ygURenNoIHBvd2VybGV2ZWwxMGs%3D - wrap+Starship - https://www.youtube.com/watch?v=ZDV4edcaXSY&t=257s - https://www.youtube.com/watch?v=WXiNkZVmkD4 - https://www.youtube.com/watch?v=Xyr_EOmEB_g&pp=ygURenNoIHBvd2VybGV2ZWwxMGs%3D - https://www.youtube.com/watch?v=wNQpDWLs4To&t=128s&pp=ygURenNoIHBvd2VybGV2ZWwxMGs%3D - startship - https://www.youtube.com/watch?v=v2S18Xf2PRo&pp=ygURenNoIHBvd2VybGV2ZWwxMGs%3D\ - https://www.youtube.com/watch?v=Wh8yjTWeWQU&t=753s&pp=ygURenNoIHBvd2VybGV2ZWwxMGs%3D - https://www.youtube.com/watch?v=BCqBRvsLlTo&t=389s - other mac - https://www.youtube.com/watch?v=oR_B2gQDVf4&t=882s - https://www.youtube.com/watch?v=GK7zLYAXdDs&t=2141s&pp=ygURenNoIHBvd2VybGV2ZWwxMGs%3D - https://www.youtube.com/watch?v=Bf7bO9VeePA&t=109s ###### tags: `Linux` `Mac` `Zsh` `terminal` `Tool`