最近在搗鼓 linux終端,使自己開發高效也更加舒適,這里記錄一下:
一、將默認的shell從bash改成更強大的zsh
echo $SHELL #默認返回 bin/bash
二、安裝 zsh
sudo yum install -y zsh
三、設置用戶默認 shell
方法1:
chsh -s /bin/zsh # 修改當前用戶,root用戶請先 su root
方法2:修改 passwd 對應用戶的默認登錄 shell 環境 保存退出
sudo vim /etc/passwd
四、安裝 git, wget, curl
sudo yum install -y git wget curl
五、安裝 oh-my-zsh
方法1:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
方法2:
1 git clone https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh 2 cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
六、修改主題
vim ~/.zshrc #找到文件中 ZSH_THEME="主題名稱"
# 可選主題名稱
# ys
# random
# agnoster
七、安裝oh-my-zsh必備插件
1、autojump(快速跳轉文件夾,效率神器)
git clone git://github.com/joelthelion/autojump.git
# 進入目錄,執行安裝腳本
cd autojump && ./install.py
# .zshrc 加入以下 內容
[[ -s ~/.autojump/etc/profile.d/autojump.sh ]] && . ~/.autojump/etc/profile.d/autojump.sh
2、zsh-syntax-highlighting(命令高亮 正確路徑自帶下划線)
作用 平常用的ls
、cd
等命令輸入正確會綠色高亮顯示,輸入錯誤會顯示其他的顏色。
# 克隆項目
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
# 在~/.zshrc
中配置
plugins=(其他的插件 zsh-syntax-highlighting)
3、zsh-autosuggestions(自動補全可能的路徑)
# 克隆項目
git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
# 在~/.zshrc
中配置
plugins=(其他的插件 zsh-autosuggestions)
4、git-open
官網:
在終端里打開當前項目的遠程倉庫地址
不要小看這個插件歐,每次改完本地代碼,當你想用瀏覽器訪問遠程倉庫的時候,就知道這個插件多方便了 😘
支持打開的遠程倉庫
- github.com
- gist.github.com
- gitlab.com
- 自定義域名的 GitLab
- bitbucket.org
- Atlassian Bitbucket Server (formerly Atlassian Stash)
- Visual Studio Team Services
- Team Foundation Server (on-premises)
# 克隆項目 git clone https://github.com/paulirish/git-open.git $ZSH_CUSTOM/plugins/git-open # 在 ~/.zshrc 中配置 plugins=(其他的插件 git-open) # 使配置生效 source ~/.zshrc
其他設置:
# history 命令查看歷史輸入命令的時間展示格式
alias history="history -t'%F %T'"
最后 source ~/.zshrc