iT邦幫忙

2022 iThome 鐵人賽

DAY 3
0
自我挑戰組

Linux in my LIFE系列 第 3

我的Linux生活日記 03-建立一個友善的終端機人機介面

  • 分享至 

  • xImage
  •  

既然都安裝Lunx而且畢生都得跟Linux 為伍,必須得跟文字介面為伍。但是我記性偏偏不好,大腦記憶體只有256KB少的可憐,所以安裝完Linux第一件事情是優化文字介面。

安裝必要套件

sudo apt install curl wget git

下載字型

下載 Meslo Nerd Font 讓 terminal 可以正常顯示icon

sudo mkdir -p /usr/share/fonts/custom
sudo wget -P /usr/share/fonts/custom https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Regular.ttf
sudo wget -P /usr/share/fonts/custom https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold.ttf
sudo wget -P /usr/share/fonts/custom https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Italic.ttf
sudo fc-cache -v -f

安裝 Tabby terminal

curl -sL -o ~/Downloads/tabby.deb https://github.com/Eugeny/tabby/releases/download/v1.0.183/tabby-1.0.183-linux-x64.deb  && sudo dpkg -i ~/Downloads/tabby.deb

設定字型為 MesloLGS NF

https://ithelp.ithome.com.tw/upload/images/20220916/20128528YOPUN3owII.png

安裝 zsh

  • 安裝指令
sudo apt install zsh
  • 預設 zsh 為殼層
chsh -s $(/usr/bin/zsh)
sudo  chsh -s /usr/bin/zsh

安裝 Oh-my-zsh

下載並安裝 Oh-my-zsh

重新登入後生效

  • 安裝指令
sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

下載plugin

tab 自動完成: zsh-completions

  • 安裝指令
git clone https://github.com/zsh-users/zsh-completions ${ZSH_CUSTOM:=~/.oh-my-zsh/custom}/plugins/zsh-completions
  • 更新指令
git -C ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/zsh-completions pull

自動補全: zsh-autosuggestions

會依據歷史紀錄預覽顯示,效果如圖

https://ithelp.ithome.com.tw/upload/images/20220916/20128528SSqYq0OajM.png

  • 安裝指令
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
  • 更新指令
git -C ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/zsh-autosuggestions pull

高亮度語法: zsh-syntax-highlighting

可以輕易識別一行指令中的組成成份,上面是原始,下面是套用過的效果。

https://ithelp.ithome.com.tw/upload/images/20220916/20128528yEb0ZYLmOv.png

https://ithelp.ithome.com.tw/upload/images/20220916/20128528p6SeTDvwYF.png

  • 安裝指令
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
  • 更新指令
git -C ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/zsh-syntax-highlighting pull

powerlevel10k

可以漂亮顯示當前目錄的狀態。

https://ithelp.ithome.com.tw/upload/images/20220916/20128528cHagoDenaM.png

  • 安裝指令
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
  • 更新指令
git -C ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k pull

設定 oh-my-zsh

下載完成之後,接下來就是配置設定啦。首先我們先編輯 .zshrc 文件。

  • ~/.zshrc

... 部份省略

# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
# ZSH_THEME="robbyrussell"
# 異動內容
ZSH_THEME="powerlevel10k/powerlevel10k"

... 部份省略

# Which plugins would you like to load?
# Standard plugins can be found in $ZSH/plugins/
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
# 異動內容
plugins=(
        git
        zsh-syntax-highlighting
        zsh-autosuggestions
        zsh-completions
)

... 部份省略

  • 套用設定

配置完 .zshrc 文件之後就是跑 powerlevel10k 設定啦!

source ~/.zshrc

接下來就會自動引導設定

https://ithelp.ithome.com.tw/upload/images/20220916/20128528Zown4LXSt1.png

經過一系列喜好設定這就是我自己喜歡的樣式

https://ithelp.ithome.com.tw/upload/images/20220916/20128528HAtWEax6uw.png

如果之後想改樣powerlevel10k樣式設定執行下列命令就可以了。

p10k configure

上一篇
我的Linux生活日記 02-安裝Debian
下一篇
我的Linux生活日記 04-一些電腦基本設定
系列文
Linux in my LIFE32
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言