LoginSignup
0
0

zshのプロンプトのカスタマイズは簡単にできる!

Last updated at Posted at 2024-05-10

image.png

きっっっっったないdotfile をリファクタリングしてたら素晴らしいものを見つけてしまったのでこっそりと紹介しちゃうよ〜ん

Powerlevel10k とは

柔軟性が高くてスグに使えるzsh のテーマだよ!
...って言ってるけど, カスタマイズをしようと思わなければスグに使えるzsh のテーマだよ!
でも柔軟性はとても高くて理解できるようになればとっても簡単!

なんでかって?

それはREADMEを見ると分かるけどバカみたいになっがい...
なっがいけどすごい親切に書いてある!
だからプロンプトをいい感じにしたいけどzsh 頑張りたくないな...って人でも, オレオレのプロンプトにしてやるぜって人も満足できると思う

ってことで実際にカスタマイズしていこう!

フォントをインストール

Powerlevel10k を触る前にfont をインストールしておこう
フォントについて
色んな人がゴニョゴニョやってMeslo Nerd Font ができてパッチが当てられてるらしいから無難に使っておこう

手動でフォントのインストール方法を詳しく知りたい方はArchwikiを参考に
font を~/.local/share/fontsにダウンロードするよ〜

curl -o ~/.local/share/fonts/'MelsoLGS NF Regular.ttf' https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Regular.ttf \
     -o ~/.local/share/fonts/'MesloLGS NF Bold.ttf' https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold.ttf \
     -o ~/.local/share/fonts/'MesloLGS NF Italic.ttf' https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Italic.ttf \
     -o ~/.local/share/fonts/'MesloLGS NF Bold Italic.ttf' https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold%20Italic.ttf

そしてキャッシュをアップデートしよう

fc-cache

Powerlevel10k をインストール

フォントが終わったらPowerlevel10k の出番だ!
Powerlevel10k の説明でも言った通り親切に書いてあるからどんな人でもインストールできると思う
僕はzinit を使ってるのでzinit でインストールしていくよ! (zinit の導入は省略)
他の人はInstallation を見てやってみよう!

echo 'zinit ice depth=1; zinit light romkatv/powerlevel10k' >> ~/.zshrc

って言っても~/.zshrcに追記するだけなんだけどね
そして追記したら~/.zshrcを読み込もう!

source ~/.zshrc

よしオッケ〜
インストールができたら設定していこう〜

Powerlevel10k の設定

無事にインストールができたら設定していくよ
時間はかかるけどコマンド一つと質問に答えるだけでいい感じのを作ってくれる

これを実行すると

p10k configure

こんな感じで赤丸の部分がダイアモンドに見えるか聞いてくるから自分の環境で見えたらy見えなければnを押す
こんな感じでなっがーい質問タイムが始まる

image.png

ここからはサクッといくよ〜
次は鍵に見えるかy

image.png

上矢印にみえるかy

image.png

アイコンが十字の間に収まってるか
ちょっとよくわからないけどy

image.png

ここからちょっと変わってどのスタイルが好みか3

image.png

ユニコードを使うかどうか1

image.png

右側の表示をどうするか2

image.png

区切りはどんな感じにするか3

image.png

中心はどれにするか5

image.png

端はどれにするか5

image.png

入力部を改行するか2

image.png

中心の繋ぎはどうするか2

image.png

両端のフレームはどうするか4

image.png

フレームの色はどうするか1

image.png

改行はどうするか2

image.png

アイコンマシマシにするか2

image.png

文字もマシマシにするか1

image.png

コマンド実行後にマシマシプロンプトを消すかy

image.png

起動に時間がかかっても入力できるようにするか1

image.png

この設定で大丈夫?y

image.png

~/.zshrcに書き込む?

image.png

無事終了するといい感じになってる!

image.png

これで満足したなら終了!
お疲れ様でした〜
...とはさせないよ

image.png

どっかで見たけど, これはREADMEで紹介されてる超マシマシカスタマイズ
ずるい!!
僕もマシマシにする!!!!

更なる深みへ...

自動生成では満足できないそこの君...
一緒に沼ろうではないか

プロンプトをマシマシにするにはこれで大丈夫?の質問で生成 or 上書きされたファイルをいじる
基本的には~/.p10k.zshになると
僕の場合は~/.config/zsh/rc/.p10k.zsh
(色々と酷いことになってるけどリファクタリング中に書いてるから...)

image.png

好きなエディターでファイルを開いたられっつご〜

左側をイジってみる

左側をイジるには33行目からのPOWERLEVEL9K_LEFT_PROMPT_ELEMENTSをゴニョゴニョやるとイジれる

.p10k.zsh
  typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(
    # =========================[ Line #1 ]=========================
    os_icon                 # os identifier
    dir                     # current directory
    vcs                     # git status
    # =========================[ Line #2 ]=========================
    newline                 # \n
    # prompt_char           # prompt symbol
  )

一応説明すると一行目にos アイコン カレントディレクトリ git status を表示する
そしてnewlineで改行して終わり

ふむ...
これでもいいけどディレクトリの階層が深くなるとみづらくなるからこうじゃ!

.p10k.zsh
  typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(
    # =========================[ Line #1 ]=========================
    dir                     # current directory
    # =========================[ Line #2 ]=========================
    newline                 # \n
    os_icon                 # os identifier
    vi_mode                 # vi mode (you don't need this if you've enabled prompt_char)
    vcs                     # git status
    # prompt_char           # prompt symbol
    # =========================[ Line #3 ]=========================
    newline                 # \n
  )

image.png

vi_mode が動いてないけど設定の問題なので一旦
image.png

右側をイジってみる

右側は50行目あたりのPOWERLEVEL9K_RIGHT_PROMPT_ELEMENTSをイジる
すっごーーーい長くて色々と機能がある...
ざっくりカット

.p10k.zsh
  typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(
    # =========================[ Line #1 ]=========================
    # =========================[ Line #2 ]=========================
    newline
    ip                    # ip address and bandwidth usage for a specified network interface
    public_ip             # public IP address
    # proxy                 # system-wide http/https/ftp proxy
    # battery               # internal battery
    # wifi                  # wifi speed
    # example               # example user-defined segment (see prompt_example function below)
    # =========================[ Line #3 ]=========================
    newline
    status                  # exit code of the last command
    command_execution_time  # duration of the last command
    background_jobs         # presence of background jobs
    direnv                  # direnv status (https://direnv.net/)
    asdf                    # asdf version manager (https://github.com/asdf-vm/asdf)
    virtualenv              # python virtual environment (https://docs.python.org/3/library/venv.html)
    anaconda                # conda environment (https://conda.io/)
    pyenv                   # python environment (https://github.com/pyenv/pyenv)
    goenv                   # go environment (https://github.com/syndbg/goenv)
    nodenv                  # node.js version from nodenv (https://github.com/nodenv/nodenv)
    nvm                     # node.js version from nvm (https://github.com/nvm-sh/nvm)
    nodeenv                 # node.js environment (https://github.com/ekalinin/nodeenv)
    # node_version          # node.js version
    # go_version            # go version (https://golang.org)
    # rust_version          # rustc version (https://www.rust-lang.org)
    # dotnet_version        # .NET version (https://dotnet.microsoft.com)
    # php_version           # php version (https://www.php.net/)
    # laravel_version       # laravel php framework version (https://laravel.com/)
    # java_version          # java version (https://www.java.com/)
    # package               # name@version from package.json (https://docs.npmjs.com/files/package.json)
    rbenv                   # ruby version from rbenv (https://github.com/rbenv/rbenv)
    rvm                     # ruby version from rvm (https://rvm.io)
    fvm                     # flutter version management (https://github.com/leoafarias/fvm)
    luaenv                  # lua version from luaenv (https://github.com/cehoffman/luaenv)
    jenv                    # java version from jenv (https://github.com/jenv/jenv)
    plenv                   # perl version from plenv (https://github.com/tokuhirom/plenv)
    perlbrew                # perl version from perlbrew (https://github.com/gugod/App-perlbrew)
    phpenv                  # php version from phpenv (https://github.com/phpenv/phpenv)
    scalaenv                # scala version from scalaenv (https://github.com/scalaenv/scalaenv)
    haskell_stack           # haskell version from stack (https://haskellstack.org/)
    kubecontext             # current kubernetes context (https://kubernetes.io/)
    terraform               # terraform workspace (https://www.terraform.io)
    # terraform_version     # terraform version (https://www.terraform.io)
    aws                     # aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html)
    aws_eb_env              # aws elastic beanstalk environment (https://aws.amazon.com/elasticbeanstalk/)
    azure                   # azure account name (https://docs.microsoft.com/en-us/cli/azure)
    gcloud                  # google cloud cli account and project (https://cloud.google.com/)
    google_app_cred         # google application credentials (https://cloud.google.com/docs/authentication/production)
    toolbox                 # toolbox name (https://github.com/containers/toolbox)
    context                 # user@hostname
    nordvpn                 # nordvpn connection status, linux only (https://nordvpn.com/)
    ranger                  # ranger shell (https://github.com/ranger/ranger)
    yazi                    # yazi shell (https://github.com/sxyazi/yazi)
    nnn                     # nnn shell (https://github.com/jarun/nnn)
    lf                      # lf shell (https://github.com/gokcehan/lf)
    xplr                    # xplr shell (https://github.com/sayanarijit/xplr)
    vim_shell               # vim shell indicator (:sh)
    midnight_commander      # midnight commander shell (https://midnight-commander.org/)
    nix_shell               # nix shell (https://nixos.org/nixos/nix-pills/developing-with-nix-shell.html)
    chezmoi_shell           # chezmoi shell (https://www.chezmoi.io/)
    # vpn_ip                # virtual private network indicator
    # load                  # CPU load
    # disk_usage            # disk usage
    # ram                   # free RAM
    # swap                  # used swap
    todo                    # todo items (https://github.com/todotxt/todo.txt-cli)
    timewarrior             # timewarrior tracking status (https://timewarrior.net/)
    taskwarrior             # taskwarrior task count (https://taskwarrior.org/)
    per_directory_history   # Oh My Zsh per-directory-history local/global indicator
    # cpu_arch              # CPU architecture
    time                    # current time
  )

image.png

グローバルIP が見えてるから隠して
image.png

vi_mode を使えるように

上のスクショでは見えてなかったけどInsert モードじゃなければ見える

image.png

image.png

いや, Insert でもみたいやんってことで840行目付近を見てみる

.p10k.zsh
  ###########[ vi_mode: vi mode (you don't need this if you've enabled prompt_char) ]###########
  # Foreground color.
  typeset -g POWERLEVEL9K_VI_MODE_FOREGROUND=0
  # Text and color for normal (a.k.a. command) vi mode.
  typeset -g POWERLEVEL9K_VI_COMMAND_MODE_STRING=NORMAL
  typeset -g POWERLEVEL9K_VI_MODE_NORMAL_BACKGROUND=2
  # Text and color for visual vi mode.
  typeset -g POWERLEVEL9K_VI_VISUAL_MODE_STRING=VISUAL
  typeset -g POWERLEVEL9K_VI_MODE_VISUAL_BACKGROUND=4
  # Text and color for overtype (a.k.a. overwrite and replace) vi mode.
  typeset -g POWERLEVEL9K_VI_OVERWRITE_MODE_STRING=OVERTYPE
  typeset -g POWERLEVEL9K_VI_MODE_OVERWRITE_BACKGROUND=3
  # Text and color for insert vi mode.
  typeset -g POWERLEVEL9K_VI_INSERT_MODE_STRING=
  typeset -g POWERLEVEL9K_VI_MODE_INSERT_FOREGROUND=8
  # Custom icon.
  # typeset -g POWERLEVEL9K_VI_MODE_VISUAL_IDENTIFIER_EXPANSION='⭐'

POWERLEVEL9K_VI_INSERT_MODE_STRING=...
うん. そりゃ何もでん

そして # typeset -g POWERLEVEL9K_VI_MODE_VISUAL_IDENTIFIER_EXPANSION='⭐'アイコンも指定できるということで
※アイコンはNerd Fonts のチートシートで検索できるよ〜

.p10k.zsh
  ###########[ vi_mode: vi mode (you don't need this if you've enabled prompt_char) ]###########
  # Foreground color.
  typeset -g POWERLEVEL9K_VI_MODE_FOREGROUND=0
  # Text and color for normal (a.k.a. command) vi mode.
  typeset -g POWERLEVEL9K_VI_COMMAND_MODE_STRING=NORMAL
  typeset -g POWERLEVEL9K_VI_MODE_NORMAL_BACKGROUND=4
  # Text and color for visual vi mode.
  typeset -g POWERLEVEL9K_VI_VISUAL_MODE_STRING=VISUAL
  typeset -g POWERLEVEL9K_VI_MODE_VISUAL_BACKGROUND=3
  # Text and color for overtype (a.k.a. overwrite and replace) vi mode.
  typeset -g POWERLEVEL9K_VI_OVERWRITE_MODE_STRING=OVERTYPE
  typeset -g POWERLEVEL9K_VI_MODE_OVERWRITE_BACKGROUND=5
  # Text and color for insert vi mode.
  typeset -g POWERLEVEL9K_VI_INSERT_MODE_STRING=INSERT
  typeset -g POWERLEVEL9K_VI_MODE_INSERT_BACKGROUND=2
  # Custom icon.
  typeset -g POWERLEVEL9K_VI_MODE_VISUAL_IDENTIFIER_EXPANSION=''

image.png

image.png

image.png

完璧だ...

カレントディレクトリ毎に色分けできたら便利じゃね?

今いるディレクトリによってバックグラウンドが変わったら便利な気がするからやろう!
320行目くらいを見てみると

.p10k.zsh
  # POWERLEVEL9K_DIR_CLASSES allows you to specify custom icons and colors for different
  # directories. It must be an array with 3 * N elements. Each triplet consists of:
  #
  #   1. A pattern against which the current directory ($PWD) is matched. Matching is done with
  #      extended_glob option enabled.
  #   2. Directory class for the purpose of styling.
  #   3. An empty string.
  #
  # Triplets are tried in order. The first triplet whose pattern matches $PWD wins.
  #
  # If POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v3, non-writable and non-existent directories
  # acquire class suffix _NOT_WRITABLE and NON_EXISTENT respectively.
  #
  # For example, given these settings:
  #
  #   typeset -g POWERLEVEL9K_DIR_CLASSES=(
  #     '~/work(|/*)'  WORK     ''
  #     '~(|/*)'       HOME     ''
  #     '*'            DEFAULT  '')
  #
  # Whenever the current directory is ~/work or a subdirectory of ~/work, it gets styled with one
  # of the following classes depending on its writability and existence: WORK, WORK_NOT_WRITABLE or
  # WORK_NON_EXISTENT.

英語できんけど色々試した結果
ふむふむPOWERLEVEL9K_DIR_CLASSESをイジるとディレクトリ毎に色分けできるようになると
ディレクトリのマッチ, クラス付け, 空(アイコン)の順で設定できて上から優先して色付けしていくと

.p10k.zsh
  typeset -g POWERLEVEL9K_DIR_WORK_VISUAL_IDENTIFIER_EXPANSION='󰶳'
  typeset -g POWERLEVEL9K_DIR_WORK_BACKGROUND=2
  typeset -g POWERLEVEL9K_DIR_WORK_FOREGROUND=0
  typeset -g POWERLEVEL9K_DIR_WORK_SHORTENED_FOREGROUND=0
  typeset -g POWERLEVEL9K_DIR_WORK_ANCHOR_FOREGROUND=0

  # Styling for WORK_NOT_WRITABLE.
  # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_VISUAL_IDENTIFIER_EXPANSION='⭐'
  typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_BACKGROUND=1
  typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_FOREGROUND=0
  typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_SHORTENED_FOREGROUND=0
  typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_ANCHOR_FOREGROUND=0

  #   # Styling for WORK_NON_EXISTENT.
  # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_VISUAL_IDENTIFIER_EXPANSION='⭐'
  typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_BACKGROUND=4
  typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_FOREGROUND=254
  typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_SHORTENED_FOREGROUND=250
  typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_ANCHOR_FOREGROUND=255

こんな感じでPOWERLEVEL9K_DIR_クラス名_...で色々設定できると
POWERLEVEL9K_DIR_クラス名_NOT_WRITABLE_...で書き込み権限が無いところも変えられると
POWERLEVEL9K_DIR_クラス名_NON_EXISTENT_...でディレクトリが消えたときもいけるのね
image.png

ちなみに300行目くらいのPOWERLEVEL9K_LOCK_ICONで書き込み権限が無いときのデフォルトアイコンを設定できる

.p10k.zsh
  typeset -g POWERLEVEL9K_LOCK_ICON=''

  typeset -g POWERLEVEL9K_DIR_CLASSES=(
    '~/work(|/*)'  WORK     ''
    '~/School(|/*)'  SCHOOL     ''
    '~(|/*)'       HOME     ''
    '*'            DEFAULT  '')

  # Styling for WORK.
  typeset -g POWERLEVEL9K_DIR_WORK_VISUAL_IDENTIFIER_EXPANSION='󰶳'
  typeset -g POWERLEVEL9K_DIR_WORK_BACKGROUND=2
  typeset -g POWERLEVEL9K_DIR_WORK_FOREGROUND=0
  typeset -g POWERLEVEL9K_DIR_WORK_SHORTENED_FOREGROUND=0
  typeset -g POWERLEVEL9K_DIR_WORK_ANCHOR_FOREGROUND=0

  # Styling for WORK_NOT_WRITABLE.
  # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_VISUAL_IDENTIFIER_EXPANSION='⭐'
  typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_BACKGROUND=1
  typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_FOREGROUND=0
  typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_SHORTENED_FOREGROUND=0
  typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_ANCHOR_FOREGROUND=0

  # Styling for SCHOOL.
  typeset -g POWERLEVEL9K_DIR_SCHOOL_VISUAL_IDENTIFIER_EXPANSION='󰑴'
  typeset -g POWERLEVEL9K_DIR_SCHOOL_BACKGROUND=3
  typeset -g POWERLEVEL9K_DIR_SCHOOL_FOREGROUND=0
  typeset -g POWERLEVEL9K_DIR_SCHOOL_SHORTENED_FOREGROUND=0
  typeset -g POWERLEVEL9K_DIR_SCHOOL_ANCHOR_FOREGROUND=0

  # Styling for SCHOOL_NOT_WRITABLE.
  # typeset -g POWERLEVEL9K_DIR_SCHOOL_NOT_WRITABLE_VISUAL_IDENTIFIER_EXPANSION='⭐'
  typeset -g POWERLEVEL9K_DIR_SCHOOL_NOT_WRITABLE_BACKGROUND=1
  typeset -g POWERLEVEL9K_DIR_SCHOOL_NOT_WRITABLE_FOREGROUND=0
  typeset -g POWERLEVEL9K_DIR_SCHOOL_NOT_WRITABLE_SHORTENED_FOREGROUND=0
  typeset -g POWERLEVEL9K_DIR_SCHOOL_NOT_WRITABLE_ANCHOR_FOREGROUND=0

  # Styling for HOME.
  typeset -g POWERLEVEL9K_DIR_HOME_VISUAL_IDENTIFIER_EXPANSION='󰠤'
  typeset -g POWERLEVEL9K_DIR_HOME_BACKGROUND=4
  typeset -g POWERLEVEL9K_DIR_HOME_FOREGROUND=0
  typeset -g POWERLEVEL9K_DIR_HOME_SHORTENED_FOREGROUND=0
  typeset -g POWERLEVEL9K_DIR_HOME_ANCHOR_FOREGROUND=0

  # Styling for HOME_NOT_WRITABLE.
  # typeset -g POWERLEVEL9K_DIR_HOME_NOT_WRITABLE_VISUAL_IDENTIFIER_EXPANSION='⭐'
  typeset -g POWERLEVEL9K_DIR_HOME_NOT_WRITABLE_BACKGROUND=1
  typeset -g POWERLEVEL9K_DIR_HOME_NOT_WRITABLE_FOREGROUND=0
  typeset -g POWERLEVEL9K_DIR_HOME_NOT_WRITABLE_SHORTENED_FOREGROUND=0
  typeset -g POWERLEVEL9K_DIR_HOME_NOT_WRITABLE_ANCHOR_FOREGROUND=0

  # Styling for DEFAULT.
  typeset -g POWERLEVEL9K_DIR_DEFAULT_VISUAL_IDENTIFIER_EXPANSION=''
  typeset -g POWERLEVEL9K_DIR_DEFAULT_BACKGROUND=4
  typeset -g POWERLEVEL9K_DIR_DEFAULT_FOREGROUND=0
  typeset -g POWERLEVEL9K_DIR_DEFAULT_SHORTENED_FOREGROUND=0
  typeset -g POWERLEVEL9K_DIR_DEFAULT_ANCHOR_FOREGROUND=0

  # Styling for DEFAULT_NOT_WRITABLE.
  # typeset -g POWERLEVEL9K_DIR_DEFAULT_NOT_WRITABLE_VISUAL_IDENTIFIER_EXPANSION='⭐'
  typeset -g POWERLEVEL9K_DIR_DEFAULT_NOT_WRITABLE_BACKGROUND=1
  typeset -g POWERLEVEL9K_DIR_DEFAULT_NOT_WRITABLE_FOREGROUND=0
  typeset -g POWERLEVEL9K_DIR_DEFAULT_NOT_WRITABLE_SHORTENED_FOREGROUND=0
  typeset -g POWERLEVEL9K_DIR_DEFAULT_NOT_WRITABLE_ANCHOR_FOREGROUND=0

image.png

image.png

image.png

image.png

ええやん!!!!

真ん中の繋ぎもイジるぞ〜

image.png

真ん中の点線2行目に欲しいし, README みたいにしたいな...
うむ!
160行目くらいからの

.p10k.zsh
  typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR='·'
  typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_BACKGROUND=
  typeset -g POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_GAP_BACKGROUND=
  if [[ $POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR != ' ' ]]; then
    # The color of the filler. You'll probably want to match the color of POWERLEVEL9K_MULTILINE
    # ornaments defined above.
    typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_FOREGROUND=244
    # Start filler from the edge of the screen if there are no left segments on the first line.
    typeset -g POWERLEVEL9K_EMPTY_LINE_LEFT_PROMPT_FIRST_SEGMENT_END_SYMBOL='%{%}'
    # End filler on the edge of the screen if there are no right segments on the first line.
    typeset -g POWERLEVEL9K_EMPTY_LINE_RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL='%{%}'
  fi

お前らや!
POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_GAP_CHARを足して
if で色もイジってあげれば完璧だ!ってことで

.p10k.zsh
  typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR='─'
  typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_BACKGROUND=
  typeset -g POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_GAP_CHAR='·'
  typeset -g POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_GAP_BACKGROUND=
  if [[ $POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR != ' ' ]]; then
    # The color of the filler. You'll probably want to match the color of POWERLEVEL9K_MULTILINE
    # ornaments defined above.
    typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_FOREGROUND=244
    # Start filler from the edge of the screen if there are no left segments on the first line.
    typeset -g POWERLEVEL9K_EMPTY_LINE_LEFT_PROMPT_FIRST_SEGMENT_END_SYMBOL='%{%}'
    # End filler on the edge of the screen if there are no right segments on the first line.
    typeset -g POWERLEVEL9K_EMPTY_LINE_RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL='%{%}'
  fi

  if [[ $POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_GAP_CHAR != ' ' ]]; then
    # The color of the filler. You'll probably want to match the color of POWERLEVEL9K_MULTILINE
    # ornaments defined above.
    typeset -g POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_GAP_FOREGROUND=244
    # Start filler from the edge of the screen if there are no left segments on the first line.
    typeset -g POWERLEVEL9K_EMPTY_LINE_LEFT_PROMPT_NEWLINE_SEGMENT_END_SYMBOL='%{%}'
    # End filler on the edge of the screen if there are no right segments on the first line.
    typeset -g POWERLEVEL9K_EMPTY_LINE_RIGHT_PROMPT_NEWLINE_SEGMENT_START_SYMBOL='%{%}'
  fi

image.png

うぇ〜い!!!!

色を可愛くしちゃおう!

同じ色ばっかでちょ〜っと上がらない君へ
このコマンドで好きな色を探そう!

for i in {0..255}; do print -Pn "%K{$i}  %k%F{$i}${(l:3::0:)i}%f " ${${(M)$((i%6)):#3}:+$'\n'}; done

実行するとこんな感じに出てくるよ〜

image.png

この色を..._BACKGROUNDとか...FOREGROUNDに渡してカラフルにするぞ〜
例として$HOME下のディレクトリ表示を218(ピンク)にしてみるぞ〜
POWERLEVEL9K_DIR_HOME_BACKGROUND=218にするとできる!

  typeset -g POWERLEVEL9K_DIR_HOME_VISUAL_IDENTIFIER_EXPANSION='󰠤'
  typeset -g POWERLEVEL9K_DIR_HOME_BACKGROUND=218
  typeset -g POWERLEVEL9K_DIR_HOME_FOREGROUND=0
  typeset -g POWERLEVEL9K_DIR_HOME_SHORTENED_FOREGROUND=0
  typeset -g POWERLEVEL9K_DIR_HOME_ANCHOR_FOREGROUND=0

こんな感じに色んなやつを設定して〜
完成!

image.png

いい感じにカラフルになった〜

ちなみに

If your terminal supports truecolor, you can use 24-bit colors in the #RRGGBB format in addition to the numbered colors.

ターミナルがサポートしてるなら#000000でもかけるよ〜

もう疲れた...

色々設定したけど, もう十分や...
お腹いっぱい...

image.png

READMEを見ると分かるけど, めっちゃあるんよ...
p10k configureを使ったよってのはちらほらあったけど, ぱっと見オレオレカスタマイズしてる人いないんよね...
まあ, 探す前にREADME 見て.p10k.zshイジってたからあったところでだったけどw

選ばなかった設定知りたい

選ばなかった設定はinternal/wizard.zshに有りはするんで, 僕みたいに頑張る人は頑張れ!!

参考文献

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0