安裝 zsh
# 安裝
sudo apt install zsh -y
# 預設改成使用 zsh
chsh -s $(which zsh)
安裝 oh-my-zsh
# 安裝
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# 環境可以看到已成功安裝 oh-my-zsh
env
安裝 fonts-powerline
# 安裝
sudo apt install fonts-powerline -y
指令顯示執行時間
# 可查看有哪些佈景可以用
ls ~/.oh-my-zsh/themes/
# 查看使用哪一個 theme
cat ~/.zshrc
# 改該 theme 的參數
nano ~/.oh-my-zsh/themes/robbyrussell.zsh-theme
# 加入以下指令
function preexec() {
timer=${timer:-$SECONDS}
}
function precmd() {
if [ $timer ]; then
timer_show=$(($SECONDS - $timer))
if [[ $timer_show -ge $min_show_time ]]; then
RPROMPT='%{$fg_bold[red]%}(${timer_show}s)%f%{$fg_bold[white]%}[%*]%f'
else
RPROMPT='%{$fg_bold[white]%}[%*]%f'
fi
unset timer
fi
}
autoload -Uz add-zsh-hook
add-zsh-hook preexec preexec
add-zsh-hook precmd precmd
# Done
自動建議指令
Option 1:
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.zsh/zsh-autosuggestions
# 加進 ~/.zshrc
nano ~/.zshrc
# 加入這一行
source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh
# 重開 terminal
# DONE
Option 2 測試部份:
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions
啟用插件: 在 ~/.zshrc 中找到 plugins,加入以下
plugins=(git zsh-autosuggestions)
Apply changes
source ~/.zshrc
留言
張貼留言