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


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

項目地址

安裝

Linux

  1. 安裝 Zsh

    sudo apt install zsh
    
  2. 安裝 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)"
  3. 安裝 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

    ZSH_THEME="powerlevel10k/powerlevel10k"
    
  4. 重啟命令行

  5. 設置 P10k

    p10k configure
    

    configure

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

Windows

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

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

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

  2. 和 Linux 一毛一樣

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

字體問題

字體爆炸

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

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

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

  1. Gnome-terminal

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

    Gnome-terminal

  2. 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