樹莓派提高shell逼格oh-my-zsh
20170904 初成文,未完...
20171012 更新外掛及alias方案
技術可以菜,但寫程式碼的方式一定要帥!
檢視當前系統可用的shell
cat /etc/shells
“Shell是Linux/Unix的一個外殼,你理解成衣服也行。它負責外界與Linux核心的互動,接收使用者或其他應用程式的命令,然後把這些命令轉化成核心能理解的語言,傳給核心,核心是真正幹活的,幹完之後再把結果返回使用者或應用程式。
Linux/Unix提供了很多種Shell,為毛要這麼多Shell?難道用來炒著吃麼?那我問你,你同型別的衣服怎麼有那麼多件?花色,質地還不一樣。寫程式比買衣服複雜多了,而且程式設計師往往負責把複雜的事情搞簡單,簡單的事情搞複雜。牛程式設計師看到不爽的Shell,就會自己重新寫一套,慢慢形成了一些標準,常用的Shell有這麼幾種,sh、bash、csh等” --摘自網上
zsh強大之處在於命令補全,可以補齊路徑,補齊命令,補齊引數等,只需按TAB鍵;另外還有跳轉目錄、萬用字元搜尋、別名、歷史記錄等等...還有幾百種外掛擴充
一、安裝前需要先安裝zsh
sudo apt install zsh
二、兩種下載方式,擇其一
1、通過wget下載安裝指令碼
sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
2、通過curl下載安裝指令碼
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
三、更換主題及部分引數說明
sudo nano ~/.zshrc
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
export TERM=xterm-256color //使終端支援256色,tput colors或echo $TERM顯示是否正確開啟
ZSH_THEME="agnoster" //改為random會在每次開啟終端或執行zsh隨機選擇一種主題風格
plugins=(git autojump zsh-syntax-highlighting) //使用的外掛
DISABLE_AUTO_UPDATE="true" //關閉自動更新
ENABLE_CORRECTION="true" //開啟智慧更正選項
CASE_SENSITIVE="true" //對大小寫敏感
alias g='git' //別名設定
四、使用agnoster主題時依賴powerline字型,安裝缺失字型
wget https://raw.githubusercontent.com/powerline/powerline/develop/font/10-powerline-symbols.conf
wget https://raw.githubusercontent.com/powerline/powerline/develop/font/PowerlineSymbols.otf
sudo mkdir /usr/share/fonts/OTF
sudo cp 10-powerline-symbols.conf /usr/share/fonts/OTF/
sudo mv 10-powerline-symbols.conf /etc/fonts/conf.d/
sudo mv PowerlineSymbols.otf /usr/share/fonts/OTF/
五、切換預設shell
chsh -s /bin/zsh
六、外掛
ls ~/.oh-my-zsh/plugins //列出內建可用外掛
直接在~/.zshrc裡新增即可,部分需要安裝,比如指令高亮外掛:
git clone git://github.com/jimmijj/zsh-syntax-highlighting ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting
plugins=(zsh-syntax-highlighting) //終端命令提示,正確為綠色,錯誤為紅色
我自己使用的外掛(僅供參考):
plugins=(git sudo colored-man-pages last-working-dir command-not-found zsh-syntax-highlighting zsh-autosuggestions autojump command-time alias-tips you-should-use debian dirhistory)
sudo //忘了加sudo只需按兩下Esc鍵
colored-man-pages //man手冊頁面,高亮版,更容易閱讀
last-working-dir //返回上次開啟終端的目錄
command-time //顯示某命令執行完成所用的時間
zsh-autosuggestions //根據使用習慣自動顯示建議,按→補充
alias-tips //提示可用的alias
zsh-you-should-use //與上面類似,提示可用的alias,可配置
dirhistory //使用alt+左右方向鍵來切換歷史上級或下級目錄
上面需自行安裝的外掛:
git clone git://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions
git clone https://github.com/popstas/zsh-command-time.git ~/.oh-my-zsh/custom/plugins/command-time
git clone https://github.com/MichaelAquilina/zsh-you-should-use.git ~/.oh-my-zsh/custom/plugins/you-should-use
git clone https://github.com/djui/alias-tips.git ~/.oh-my-zsh/custom/plugins/alias-tips
七、別名方案(參考,可按個人使用習慣自行修改)
alias wget="wget -c"
alias du="du -h"
alias df="df -Th"
alias cp="cp -iv"
alias mv="mv -iv"
alias rm="rm -iv"
alias ls="ls -F --color=auto"
alias ll="ls -alF"
alias la="ls -aF"
#下面這個是按大小排序,僅顯示大小和檔名,不顯示其他資訊
alias lll="ls -AlhF --sort=size . | tr -s " " | cut -d " " -f 5,9"
alias grep="grep --color=auto'
#輸出當前目錄size最大的10個資料夾
alias dumax="du -hsx * | sort -rh | head -10"
alias fm="free -m"
alias ua="uname -a"
alias acs="apt-cache search"
alias ats="sudo aptitude show"
alias ati="sudo aptitude install"
alias aud="sudo aptitude update && sudo aptitude upgrade"
參考文章:
相關文章
- 樹莓派使用入門:如何更新樹莓派樹莓派
- 樹莓派是什麼 樹莓派能做什麼 樹莓派的功能用途樹莓派
- 樹莓派使用樹莓派
- 樹莓派使用入門:用樹莓派學 Linux樹莓派Linux
- 樹莓派使用入門:如何用樹莓派來娛樂樹莓派
- 樹莓派使用入門:如何購買一個樹莓派樹莓派
- 樹莓派使用入門:慶祝樹莓派的 14 天樹莓派
- 樹莓派筆記樹莓派筆記
- 樹莓派與FileZilla樹莓派
- 折騰樹莓派樹莓派
- 樹莓派裝opencv樹莓派OpenCV
- 新樹莓派入手樹莓派
- 樹莓派電臺樹莓派
- 樹莓派使用入門:如何為樹莓派社群做出貢獻樹莓派
- 「玩轉樹莓派」樹莓派 3B+ 配置無線WiFi樹莓派WiFi
- 樹莓派搭建git伺服器 | 樹莓派小無相系列樹莓派Git伺服器
- 樹莓派使用入門:如何啟動一個新的樹莓派樹莓派
- 5、樹莓派3 Model B ——— 樹莓派PWM控制直流電機速度樹莓派
- 樹莓派 | 修改樹莓派3熱點的名稱和密碼樹莓派密碼
- 樹莓派 -入門篇樹莓派
- 樹莓派-進階篇樹莓派
- 樹莓派 4 開箱記樹莓派
- 樹莓派 4 來襲!樹莓派
- 樹莓派桌面體驗樹莓派
- (二)樹莓派配置MySQL樹莓派MySql
- 樹莓派:開機使用樹莓派
- 樹莓派配置watchdog樹莓派
- 樹莓派:最好的安排樹莓派
- 樹莓派的連線樹莓派
- 樹莓派的啟動樹莓派
- 樹莓派自建 NAS 雲盤之——樹莓派搭建網路儲存盤樹莓派
- 樹莓派-感測器篇樹莓派
- 將樹莓派配置成路由樹莓派路由
- PiShrink:使樹莓派映象更小樹莓派
- 樹莓派搭建下載機樹莓派
- 樹莓派安裝nodejs樹莓派NodeJS
- 樹莓派GUI程式設計樹莓派GUI程式設計
- 樹莓派 3 新手指南樹莓派