Try   HackMD
tags: terminal

自定義 terminal style (Ubuntu)

開啟 ~/bash.bashrc 檔,你可以使用 vi 或者 nano 來進行文字上的編輯,或者你也可以使用內建的文字編輯器,如下:

gedit ~/.bashrc

然後在最下方新增此語法:

# kali style PS1='\n\[\e[38;5;37m\]┌──(\[\e[38;5;33;1m\]\u\[\e[38;5;208;1m\]@\[\e[38;5;99;1m\]\H\[\e[0m\]\[\e[38;5;37m\])─[\[\e[0m\w\e[38;5;37m\]]\n└─\[\e[38;5;33;1m\]\$\[\e[0m\] '

之後輸入下方命令即可完成變更

source ~/.bashrc

root 提示符則:

sudo gedit /root/.bashrc

一樣在最下面新增:

# kali style PS1='\n\[\e[38;5;37m\]┌──(\[\e[38;5;9;1m\]\u\[\e[38;5;208;1m\]@\[\e[38;5;99;1m\]\H\[\e[0m\]\[\e[38;5;37m\])─[\[\e[0m\w\e[38;5;37m\]]\n└─\[\e[38;5;9;1m\]#\[\e[0m\] '

輸入 sudo su 後就可以馬上看到效果了。

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

小老鼠號也可以換回它原本的特殊字符『㉿』,其他更詳細的設定可參照這裡

個人愛用

# user PS1='\n\[\e[38;5;37m\]┌──(\[\e[38;5;33;1m\]\u ㉿ \H\[\e[0m\]\e[38;5;37m\])─[\[\e[0m\w\e[38;5;37m\]]\n└─\[\e[38;5;33;1m\]\$\[\e[0m\] ' # root PS1='\n\[\e[38;5;37m\]┌──(\[\e[38;5;9;1m\]\u\[\e[38;5;33;1m\] ㉿ \H\[\e[0m\]\[\e[38;5;37m\])─[\[\e[0m\w\e[38;5;37m\]]\n└─\[\e[38;5;9;1m\]#\[\e[0m\] '

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

Parrot

PS1='\[\033[0;31m\]\342\224\214\342\224\200$([[ $? != 0 ]] && echo "[\[\033[0;31m\]\342\234\227\[\033[0;37m\]]\342\224\200")[\[\033[0;39m\]\u\[\033[01;33m\]@\[\033[01;96m\]\h\[\033[0;31m\]]\342\224\200[\[\033[0;32m\]\w\[\033[0;31m\]]\n\[\033[0;31m\]\342\224\224\342\224\200\342\224\200\342\225\274 \[\033[0m\]\[\e[01;33m\]\$ \[\e[0m\]'

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

oh my zsh 自定義 style

安裝 Zsh

sudo apt install zsh -y

安裝 Oh My Zsh (安裝完畢後,按下 Enter 同意把預設 Shell 換成 Zsh。)

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

如果你不小心沒有預設到,可輸入以下指令設定

chsh -s $(which zsh)

安裝好之後輸入 zsh ,以切換當前的 shell 環境

安裝語法檢查插件(個人愛用)

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

編輯 ~/.zshrc 新增語法在最底下

source ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh PS1=$'\n\[\e[38;5;37m]┌──(\[\e[38;5;33;1m\]%n\[\e[38;5;166m\]@%m\[\e[0m\[\e[38;5;37m\])─[\[\e[0m\]%~\[\e[38;5;37m\]]\n└─\[\e[38;5;33;1m\]$\[\e[0m\] '

一樣重載入即可

source ~/.zshrc

之後如果要有 style,開啟 terminal 的時候輸入 zsh 即可切換了,如果你想要一開 terminal 就是 zsh 模式,只需要新增下面程式碼在 ~/.bashrc 最後一行即可

zsh