powerlevel10k: 最好看,方便,實用的命令行主題


Zsh-Powerlevel10k: 最好看,方便,實用的命令行主題

項目地址

sudo yum remove zsh -y
sudo yum install git gcc perl-ExtUtils-MakeMaker ncurses-devel -y

git clone git@gitee.com:luoxian1011/zsh_home.git
sh zsh_home/install_omz.sh

sudo chmod -R 700 ~/.oh-my-zsh/custom/plugins/
sed -i 's/ZSH_THEME.*/ZSH_THEME="powerlevel10k\/powerlevel10k"/g' .zshrc
sed -i 's/plugins.*/plugins=(git zsh-autosuggestions zsh-syntax-highlighting pip)/g' .zshrc
source .zshrc

安裝

Linux

1、查看系統當前使用的shell
echo $SHELL

2、設置默認zsh
chsh -s /bin/zsh
  1. 安裝 Zsh
# sudo yum install zsh git -y
sudo apt install zsh -y
  1. 安裝 Oh-My-Zsh
方法 命令
curl sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
wget sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# 國內鏡像
sh -c "$(wget -O- https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh)"
  1. 安裝 P10k
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k

Gitee 鏡像

git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k

在 ~/.zshrc 中設置 ZSH_THEME

# sed -i 's/ZSH_THEME.*/ZSH_THEME="powerlevel10k\/powerlevel10k"/g' .zshrc
ZSH_THEME="powerlevel10k/powerlevel10k"
  1. 重啟命令行
source .zshrc
  1. 設置 P10k
p10k configure

-  Character Set : Unicode [多圖]
# 我的p10k配置
https://gitee.com/luoxian1011/files/raw/master/.p10k.zsh

configure

然后... 完成! 是不是很簡單?

Windows

什么? 你居然在用 Windows? 洗洗睡吧。

什么? 你居然在用 Win10, 好像有希望!

  1. 打開你的 WSL (我死了)

  2. 和 Linux 一毛一樣

    既然都用 WSL 了,怎么不裝個 Linux 呢?

安裝 zsh 插件

# git clone加速
    git clone https://github.com/...
==> git clone https://gitclone.com/github.com/...

# 補全提示
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
# 高亮
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

在 ~/.zshrc 中添加:

plugins=(git zsh-autosuggestions zsh-syntax-highlighting pip)

再使用 source ~/.zshrc 應用修改。

更新源

  1. 備份原有軟件源文件
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak_yyyymmdd
  1. 修改sources.list文件
# 修改為如下地址:
sudo vi /etc/apt/sources.list
#163源
deb http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
  1. 更新系統軟件源
# 執行命令,更新系統軟件源地址:
sudo apt-get update
sudo apt-get upgrade
# 安裝lrzsz tree
sudo apt-get -y install lrzsz tree
# 安裝 build-essential 軟件包集合 (其中就包括 gcc、G ++ 和 make 等)
sudo apt install build-essential

設置使用 sudo 時免輸密碼

每次使用 sudo 時都需要輸入密碼確實煩人, 畢竟是私人電腦, 安全性有鎖屏密碼保護就可以了, 為了使用方便, 不仿取消使用 sudo 時需要輸入 root 用戶密碼的設定:

同時按下 ctrl + alt + t 打開終端, 輸入 sudo vi /etc/sudoers , 在打開的文件中, 將

%sudo ALL=(ALL:ALL) ALL

改為:

%sudo ALL=(ALL:ALL) NOPASSWD:ALL

即可。

重置root密碼

  1. 以管理員身份打開 PowerShell

img

  1. 輸入命令 wsl.exe --user root

img

  1. 輸入命令 passwd root 修改 root 密碼

字體問題

字體爆炸

⇡⇡⇡ 誒, 你怎么說裝好了呢, 明明就不行, 太菜了! ⇡⇡⇡

這個嘛,因為里面有這個
尖頭
, 所以需要安裝專門的控制台字體。

個人推薦 Fira CodeMesloLGS NF 或可以使用這個倉庫 https://github.com/powerline/fonts 中的任意字體。

  1. 安裝 Hack Nerd Font

    字體官網鏈接:https://nerdfonts.com/
    下載字體 然后安裝(Ubuntu Nerd Font Complete.ttf)
    Hack.zip

    image

  2. Gnome-terminal

    在 Gnome-terminal(Ubuntu 默認終端) 中在 Preference(首選項)中可以修改。⇣ 如下圖所示。⇣

    Gnome-terminal

  3. VScode

    在 VScode 中可以按下 Ctrl + , 直接在 Settings(設置)中修改。⇣ 如下圖所示。⇣

    VScode-terminal

這個有人不會嗎?

配置

配置文件存在 ~/.p10k.zsh 中,打開可以更改內部設置。具體方式這里不過多敘述,需要了解可以查看 原倉庫 Readme

這是左邊區域的配置

32 |  # The list of segments shown on the left. Fill it with the most important segments.
33 |  typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(
34 |    # =========================[ Line #1 ]=========================
35 |    # os_icon               # os identifier
36 |    dir                     # current directory
37 |    vcs                     # git status
38 |    # =========================[ Line #2 ]=========================
39 |    newline                 # \n
40 |    # prompt_char           # prompt symbol
41 |  )

這是右邊區域的配置

47  |  typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(
48  |    # =========================[ Line #1 ]=========================
49  |    status                  # exit code of the last command
50  |    command_execution_time  # duration of the last command
51  |    background_jobs         # presence of background jobs
52  |    direnv                  # direnv status (https://direnv.net/)
53  |    asdf                    # asdf version manager (https://github.com/asdf-vm/asdf)
54  |    virtualenv              # python virtual environment (https://docs.python.org/3/library/venv.html)
55  |    anaconda                # conda environment (https://conda.io/)
.   |   .
.   |   .
.   |   .
101 |    todo                    # todo items (https://github.com/todotxt/todo.txt-cli)
102 |    # swap                  # used swap
103 |    time                    # current time
104 |    # =========================[ Line #2 ]=========================
105 |    newline
106 |    # ip                    # ip address and bandwidth usage for a specified network interface
107 |    # public_ip             # public IP address
108 |    # proxy                 # system-wide http/https/ftp proxy
109 |    # battery               # internal battery
110 |    # wifi                  # wifi speed
111 |    # example               # example user-defined segment (see prompt_example function below)
112 |  )

取消主矢或添加注釋可以增添顯示的功能方塊

各個功能的作用

所有功能都打開的沙雕樣子

這些功能中比較有用的,比如:

英文名 作用
status 上次運行的指令的運行返回值
command_execution_time 上次指令運行經歷的時間
time 顯示時間
load CPU 負載
ram 顯示剩余內存

通過修改

typeset -g POWERLEVEL9K_***_VISUAL_IDENTIFIER_EXPANSION='⭐'
                                                         ^~~ 這里

可以改變某功能的圖標


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM