【tmux】Powerlineでステータスバーをカスタマイズ

2022.03.19
2024.03.24
開発環境
powerlinetmux

はじめに

tmuxでPowerlineを設定する方法を紹介します。

今回導入するPowerlineは下記になります。

GitHub - powerline/powerline: Powerline is a statusline plugin for vim, and provides statuslines and prompts for several other applications, including zsh, bash, tmux, IPython, Awesome and Qtile.

GitHub - powerline/powerline: Powerline is a statusline plugin for vim, and provides statuslines and prompts for several other applications, including zsh, bash, tmux, IPython, Awesome and Qtile.

Powerline is a statusline plugin for vim, and provides statuslines and prompts for several other applications, including zsh, bash, tmux, IPython, Awesome and Qtile. - powerline/powerline

tmux-powerlineというのもありますが、今は積極的な開発が行われておらず、上記のPowerlineを紹介しています。

GitHub - erikw/tmux-powerline: ⚡️ A tmux plugin giving you a hackable status bar consisting of dynamic & beautiful looking powerline segments, written purely in bash.

GitHub - erikw/tmux-powerline: ⚡️ A tmux plugin giving you a hackable status bar consisting of dynamic & beautiful looking powerline segments, written purely in bash.

⚡️ A tmux plugin giving you a hackable status bar consisting of dynamic & beautiful looking powerline segments, written purely in bash. - erikw/tmux-powerline

tmuxの基本的な部分については、下記で解説しています。

【入門】tmux始めてみる

【入門】tmux始めてみる

はじめに tmuxについて、**基本的なことを理解して使えるようになるまで**を解説していこうと

【tmux】プラグインを使ってみる

【tmux】プラグインを使ってみる

はじめに tmuxでの**プラグインの導入方法**と参考用に現在利用しているプラグインとその設定

完成系

今回設定するのは画像のようなtmuxのステータスバーになります。

powerlineのインストール

まずはPowerlineをインストールします。

1pip install powerline-status

フォントのインストール

Powerlineで使用するフォントをインストールします。

1git clone https://github.com/powerline/fonts.git --depth=1
2cd fonts
3./install.sh
4cd ..
5rm -rf fonts

インストールしたフォントの中から好きなものを選び、ターミナルのフォントに設定します。

iTerm2の場合は下記のようになります。

tmuxの設定

.tmux.confに設定を追加します。

まずはインストールしたpowerline-statusのパスをpip showで確認します。

1❯ pip show powerline-status
2Name: powerline-status
3Version: 2.7
4Summary: The ultimate statusline/prompt utility.
5Home-page: https://github.com/powerline/powerline
6Author: Kim Silkebaekken
7Author-email: [email protected]
8License: MIT
9Location: /usr/local/lib/python3.9/site-packages # インストールされているディレクトリを確認
10Requires:
11Required-by: powerline-k8s, powerline-kubernetes

.tmux.confに下記の設定を追記します。

1source "{インストールされているディレクトリ}/powerline/bindings/tmux/powerline.conf"
2run-shell "powerline-daemon -q"

.tmux.confを読み込めばデフォルトの設定でPowerlineが表示されるかと思います。

1tmux source ~/.tmux.conf

Powerlineの設定

ここからPowerlineのカスタマイズをしていきます。

powerline_mem_segmentのインストール

はじめに、メモリの使用量を表示するためのツールをインストールしておきます。

1pip install powerline-mem-segment
GitHub - mKaloer/powerline_mem_segment

GitHub - mKaloer/powerline_mem_segment

Contribute to mKaloer/powerline_mem_segment development by creating an account on GitHub.

設定ファイルのディレクトリ

インストールしたpowerline/config_files配下にデフォルトの設定ファイルが揃っています。

1pwd
2/usr/local/lib/python3.9/site-packages/powerline/config_files
3
4❯ tree -L 2
5.
6├── config.json # メインの設定ファイル
7├── colors.json # 色の定義
8├── colorschemes # 表示内容ごとの色設定
9│   ├── default.json
10│   ├── ipython
11│   ├── pdb
12│   ├── shell
13│   ├── solarized.json
14│   ├── tmux
15│   └── vim
16└── themes # 表示する項目の設定
17    ├── ascii.json
18    ├── ipython
19    ├── pdb
20    ├── powerline.json
21    ├── powerline_terminus.json
22    ├── powerline_unicode7.json
23    ├── shell
24    ├── tmux
25    ├── unicode.json
26    ├── unicode_terminus.json
27    ├── unicode_terminus_condensed.json
28    ├── vim
29    └── wm

設定のカスタマイズをする場合は~/.config/powerline配下に同じ構成のファイルを配置することでカスタマイズが可能です。

今回作成する設定ファイルは下記の通りです。

1pwd
2~/.config/powerline
3
4❯ tree .
5├── config.json
6├── colors.json
7├── colorschemes
8│   └── tmux
9│       └── tmux-colorscheme.json
10└── themes
11    └── tmux
12        └── tmux-theme.json

基本的にデフォルトの設定ファイルを参考にカスタマイズしています。

color.json

まずは~/.config/powerline/color.jsonを作成します。

今後変更する可能性があるためファイルを作成しましたが、内容はデフォルトと同じにしています。

1{
2	"colors": {
3		"black": 16,
4		"white": 231,
5
6		"green": 2,
7		"darkestgreen": 22,
8		"darkgreen": 28,
9		"mediumgreen": 70,
10		"brightgreen": 148,
11
12		"darkestcyan": 23,
13		"darkcyan": 74,
14		"mediumcyan": 117,
15		"brightcyan": 159,
16
17		"darkestblue": 24,
18		"darkblue": 31,
19
20		"red": 1,
21		"darkestred": 52,
22		"darkred": 88,
23		"mediumred": 124,
24		"brightred": 160,
25		"brightestred": 196,
26
27		"darkestpurple": 55,
28		"mediumpurple": 98,
29		"brightpurple": 189,
30
31		"darkorange": 94,
32		"mediumorange": 166,
33		"brightorange": 208,
34		"brightestorange": 214,
35
36		"yellow": 11,
37		"brightyellow": 220,
38
39		"gray0": 233,
40		"gray1": 235,
41		"gray2": 236,
42		"gray3": 239,
43		"gray4": 240,
44		"gray5": 241,
45		"gray6": 244,
46		"gray7": 245,
47		"gray8": 247,
48		"gray9": 250,
49		"gray10": 252,
50
51		"gray11": 234,
52		"gray90": 254,
53
54		"gray70": [249, "b3b3b3"],
55
56		"lightyellowgreen": 106,
57		"gold3": 178,
58		"orangered": 202,
59
60		"steelblue": 67,
61		"darkorange3": 166,
62		"skyblue1": 117,
63		"khaki1": 228,
64
65		"solarized:base03": [8, "002b36"],
66		"solarized:base02": [0, "073642"],
67		"solarized:base01": [10, "586e75"],
68		"solarized:base00": [11, "657b83"],
69		"solarized:base0": [12, "839496"],
70		"solarized:base1": [14, "93a1a1"],
71		"solarized:base2": [7, "eee8d5"],
72		"solarized:base3": [15, "fdf6e3"],
73		"solarized:yellow": [3, "b58900"],
74		"solarized:orange": [9, "cb4b16"],
75		"solarized:red": [1, "dc322f"],
76		"solarized:magenta": [5, "d33682"],
77		"solarized:violet": [13, "6c71c4"],
78		"solarized:blue": [4, "268bd2"],
79		"solarized:cyan": [6, "2aa198"],
80		"solarized:green": [2, "859900"]
81	},
82	"gradients": {
83		"dark_GREEN_Orange_red": [
84			[22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 94, 94, 94, 94, 94, 94, 94, 88, 52],
85			["006000", "006000", "006000", "006000", "006000", "006000", "006000", "006000", "006000", "036000", "076000", "0a6000", "0d6000", "106000", "126000", "146000", "166000", "186000", "1a6000", "1b6000", "1d6000", "1e6000", "206000", "216000", "236000", "246000", "256000", "266000", "286000", "296000", "2a6000", "2b6000", "2c6100", "2d6100", "2f6100", "306100", "316100", "326100", "336100", "346100", "356100", "366100", "376100", "386100", "386100", "396100", "3a6100", "3b6100", "3c6100", "3d6100", "3e6100", "3f6100", "406100", "406100", "416100", "426000", "436000", "446000", "456000", "456000", "466000", "476000", "486000", "496000", "496000", "4a6000", "4b6000", "4c6000", "4d6000", "4d6000", "4e6000", "4f6000", "506000", "506000", "516000", "526000", "536000", "536000", "546000", "556000", "566000", "566000", "576000", "586000", "596000", "596000", "5a6000", "5d6000", "616000", "646000", "686000", "6b6000", "6f6000", "726000", "766000", "796000", "7d6000", "806000", "7e5500", "6f3105", "5d0001"]
86		],
87		"GREEN_Orange_red": [
88			[2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1],
89			["005f00", "015f00", "025f00", "035f00", "045f00", "055f00", "065f00", "075f00", "085f00", "095f00", "0b5f00", "0c5f00", "0d5f00", "0e5f00", "0f5f00", "105f00", "115f00", "125f00", "135f00", "145f00", "165f00", "175f00", "185f00", "195f00", "1a5f00", "1b5f00", "1c5f00", "1d5f00", "1e5f00", "1f5f00", "215f00", "225f00", "235f00", "245f00", "255f00", "265f00", "275f00", "285f00", "295f00", "2a5f00", "2c5f00", "2d5f00", "2e5f00", "2f5f00", "305f00", "315f00", "325f00", "335f00", "345f00", "355f00", "375f00", "385f00", "395f00", "3a5f00", "3b5f00", "3c5f00", "3d5f00", "3e5f00", "3f5f00", "415f00", "425f00", "435f00", "445f00", "455f00", "465f00", "475f00", "485f00", "495f00", "4a5f00", "4c5f00", "4d5f00", "4e5f00", "4f5f00", "505f00", "515f00", "525f00", "535f00", "545f00", "555f00", "575f00", "585f00", "595f00", "5a5f00", "5b5f00", "5c5f00", "5d5f00", "5e5f00", "615f00", "655f00", "685f00", "6c5f00", "6f5f00", "735f00", "765f00", "7a5f00", "7d5f00", "815f00", "845f00", "815200", "702900"]
90		],
91		"green_yellow_red": [
92			[190, 184, 178, 172, 166, 160],
93			["8ae71c", "8ce71c", "8fe71c", "92e71c", "95e71d", "98e71d", "9ae71d", "9de71d", "a0e71e", "a3e71e", "a6e71e", "a8e71e", "abe71f", "aee71f", "b1e71f", "b4e71f", "b6e720", "b9e720", "bce720", "bfe720", "c2e821", "c3e721", "c5e621", "c7e521", "c9e522", "cbe422", "cde322", "cfe222", "d1e223", "d3e123", "d5e023", "d7df23", "d9df24", "dbde24", "dddd24", "dfdc24", "e1dc25", "e3db25", "e5da25", "e7d925", "e9d926", "e9d626", "e9d426", "e9d126", "e9cf27", "e9cc27", "e9ca27", "e9c727", "e9c528", "e9c228", "e9c028", "e9bd28", "e9bb29", "e9b829", "e9b629", "e9b329", "e9b12a", "e9ae2a", "e9ac2a", "e9a92a", "eaa72b", "eaa42b", "eaa22b", "ea9f2b", "ea9d2c", "ea9b2c", "ea982c", "ea962c", "ea942d", "ea912d", "ea8f2d", "ea8d2d", "ea8a2e", "ea882e", "ea862e", "ea832e", "ea812f", "ea7f2f", "ea7c2f", "ea7a2f", "eb7830", "eb7530", "eb7330", "eb7130", "eb6f31", "eb6c31", "eb6a31", "eb6831", "eb6632", "eb6332", "eb6132", "eb5f32", "eb5d33", "eb5a33", "eb5833", "eb5633", "eb5434", "eb5134", "eb4f34", "eb4d34", "ec4b35"]
94		],
95		"green_yellow_orange_red": [
96			[2, 3, 9, 1],
97			["719e07", "739d06", "759c06", "779c06", "799b06", "7b9a05", "7d9a05", "7f9905", "819805", "839805", "859704", "879704", "899604", "8b9504", "8d9504", "8f9403", "919303", "949303", "969203", "989102", "9a9102", "9c9002", "9e9002", "a08f02", "a28e01", "a48e01", "a68d01", "a88c01", "aa8c01", "ac8b00", "ae8a00", "b08a00", "b28900", "b58900", "b58700", "b68501", "b78302", "b78102", "b87f03", "b97d04", "b97b04", "ba7905", "bb7806", "bb7606", "bc7407", "bd7208", "bd7008", "be6e09", "bf6c0a", "bf6a0a", "c0690b", "c1670c", "c1650c", "c2630d", "c3610e", "c35f0e", "c45d0f", "c55b10", "c55a10", "c65811", "c75612", "c75412", "c85213", "c95014", "c94e14", "ca4c15", "cb4b16", "cb4a16", "cc4917", "cc4818", "cd4719", "cd4719", "ce461a", "ce451b", "cf441c", "cf441c", "d0431d", "d0421e", "d1411f", "d1411f", "d24020", "d23f21", "d33e22", "d33e22", "d43d23", "d43c24", "d53b25", "d53b25", "d63a26", "d63927", "d73828", "d73828", "d83729", "d8362a", "d9352b", "d9352b", "da342c", "da332d", "db322e", "dc322f"]
98		],
99		"yellow_red": [
100			[220, 178, 172, 166, 160],
101			["ffd700", "fdd500", "fbd300", "fad200", "f8d000", "f7cf00", "f5cd00", "f3cb00", "f2ca00", "f0c800", "efc700", "edc500", "ebc300", "eac200", "e8c000", "e7bf00", "e5bd00", "e3bb00", "e2ba00", "e0b800", "dfb700", "ddb500", "dbb300", "dab200", "d8b000", "d7af00", "d7ad00", "d7ab00", "d7aa00", "d7a800", "d7a700", "d7a500", "d7a300", "d7a200", "d7a000", "d79f00", "d79d00", "d79b00", "d79a00", "d79800", "d79700", "d79500", "d79300", "d79200", "d79000", "d78f00", "d78d00", "d78b00", "d78a00", "d78800", "d78700", "d78500", "d78300", "d78200", "d78000", "d77f00", "d77d00", "d77b00", "d77a00", "d77800", "d77700", "d77500", "d77300", "d77200", "d77000", "d76f00", "d76d00", "d76b00", "d76a00", "d76800", "d76700", "d76500", "d76300", "d76200", "d76000", "d75f00", "d75b00", "d75700", "d75300", "d74f00", "d74c00", "d74800", "d74400", "d74000", "d73c00", "d73900", "d73500", "d73100", "d72d00", "d72900", "d72600", "d72200", "d71e00", "d71a00", "d71600", "d71300", "d70f00", "d70b00", "d70700"]
102		],
103		"yellow_orange_red": [
104			[3, 9, 1],
105			["b58900", "b58700", "b58600", "b68501", "b68401", "b78202", "b78102", "b88003", "b87f03", "b87d03", "b97c04", "b97b04", "ba7a05", "ba7805", "bb7706", "bb7606", "bc7507", "bc7307", "bc7207", "bd7108", "bd7008", "be6e09", "be6d09", "bf6c0a", "bf6b0a", "c06a0b", "c0680b", "c0670b", "c1660c", "c1650c", "c2630d", "c2620d", "c3610e", "c3600e", "c35e0e", "c45d0f", "c45c0f", "c55b10", "c55910", "c65811", "c65711", "c75612", "c75412", "c75312", "c85213", "c85113", "c94f14", "c94e14", "ca4d15", "ca4c15", "cb4b16", "cb4a16", "cb4a17", "cc4917", "cc4918", "cc4818", "cd4819", "cd4719", "cd471a", "ce461a", "ce461b", "ce451b", "cf451c", "cf441c", "cf441d", "d0431d", "d0431e", "d0421e", "d1421f", "d1411f", "d14120", "d24020", "d24021", "d23f21", "d33f22", "d33e22", "d33e23", "d43d23", "d43d24", "d43c24", "d53c25", "d53b25", "d53b26", "d63a26", "d63a27", "d63927", "d73928", "d73828", "d73829", "d83729", "d8372a", "d8362a", "d9362b", "d9352b", "d9352c", "da342c", "da342d", "da332d", "db332e"]
106		],
107		"blue_red": [
108			[39, 74, 68, 67, 103, 97, 96, 132, 131, 167, 203, 197],
109			["19b4fe", "1bb2fc", "1db1fa", "1faff8", "22aef6", "24adf4", "26abf2", "29aaf0", "2ba9ee", "2da7ec", "30a6ea", "32a5e8", "34a3e6", "36a2e4", "39a0e2", "3b9fe1", "3d9edf", "409cdd", "429bdb", "449ad9", "4798d7", "4997d5", "4b96d3", "4d94d1", "5093cf", "5292cd", "5490cb", "578fc9", "598dc7", "5b8cc6", "5e8bc4", "6089c2", "6288c0", "6487be", "6785bc", "6984ba", "6b83b8", "6e81b6", "7080b4", "727eb2", "757db0", "777cae", "797aac", "7b79ab", "7e78a9", "8076a7", "8275a5", "8574a3", "8772a1", "89719f", "8c709d", "8e6e9b", "906d99", "926b97", "956a95", "976993", "996791", "9c668f", "9e658e", "a0638c", "a3628a", "a56188", "a75f86", "a95e84", "ac5c82", "ae5b80", "b05a7e", "b3587c", "b5577a", "b75678", "ba5476", "bc5374", "be5273", "c05071", "c34f6f", "c54e6d", "c74c6b", "ca4b69", "cc4967", "ce4865", "d14763", "d34561", "d5445f", "d7435d", "da415b", "dc4059", "de3f58", "e13d56", "e33c54", "e53a52", "e83950", "ea384e", "ec364c", "ee354a", "f13448", "f33246", "f53144", "f83042", "fa2e40"]
110		],
111		"white_red": [
112			[231, 255, 223, 216, 209, 202, 196],
113			["ffffff", "fefefe", "fdfdfd", "fdfdfd", "fcfcfc", "fbfbfb", "fafafa", "fafafa", "f9f9f9", "f8f8f8", "f7f7f7", "f7f7f7", "f6f6f6", "f5f5f5", "f4f4f4", "f4f3f4", "f3f3f3", "f2f2f2", "f1f1f1", "f0f0f0", "f0f0f0", "efefef", "eeeeee", "efecea", "f1eae4", "f2e8de", "f3e6d8", "f5e4d3", "f6e2cd", "f7e0c7", "f8dec2", "f9dcbc", "fadab6", "fad8b1", "fbd5ac", "fbd2a9", "fbcea5", "fbcaa1", "fbc79e", "fbc39a", "fbc097", "fbbc93", "fbb88f", "fbb58c", "fab188", "faad85", "faaa81", "fba67e", "fba37a", "fb9f76", "fb9c73", "fb986f", "fb946c", "fb9168", "fa8d65", "fa8961", "fa865c", "fa8256", "fb7f4f", "fb7b48", "fb7841", "fb743a", "fb7133", "fb6d2c", "fa6a23", "fa661a", "fa620e", "fa5f03", "fa5d03", "fa5b03", "fa5a03", "fa5803", "fa5703", "fa5503", "fa5303", "fa5103", "fa4f03", "fa4e03", "fa4c03", "fa4a04", "fa4804", "fa4604", "fa4404", "fa4204", "fa3f04", "fa3d04", "fa3b04", "fa3805", "fa3605", "fa3305", "fb3105", "fb2e05", "fb2a05", "fb2705", "fb2306", "fb1f06", "fb1b06", "fb1506", "fb0e06", "fa0506", "fa0007"]
114		],
115		"dark_green_gray": [
116			[70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247],
117			["51b000", "52b000", "54b000", "55b002", "56b007", "57b00d", "58b011", "59af15", "5aaf18", "5caf1b", "5daf1e", "5eaf21", "5faf23", "60ae25", "61ae27", "62ae2a", "63ae2c", "64ae2e", "65ae30", "66ae31", "67ad33", "68ad35", "69ad37", "69ad38", "6aad3a", "6bad3c", "6cac3d", "6dac3f", "6eac40", "6fac42", "70ac44", "70ac45", "71ab47", "72ab48", "73ab49", "74ab4b", "75ab4c", "75ab4e", "76aa4f", "77aa51", "78aa52", "79aa53", "79aa55", "7aaa56", "7ba957", "7ca959", "7ca95a", "7da95b", "7ea95d", "7fa95e", "7fa85f", "80a861", "81a862", "81a863", "82a865", "83a766", "83a767", "84a768", "85a76a", "85a76b", "86a66c", "87a66d", "87a66f", "88a670", "89a671", "89a672", "8aa574", "8ba575", "8ba576", "8ca577", "8da579", "8da47a", "8ea47b", "8ea47c", "8fa47d", "90a47f", "90a380", "91a381", "91a382", "92a384", "93a385", "93a286", "94a287", "94a288", "95a28a", "95a18b", "96a18c", "97a18d", "97a18e", "98a190", "98a091", "99a092", "99a093", "9aa094", "9aa096", "9b9f97", "9b9f98", "9c9f99", "9c9f9a", "9d9e9c", "9d9e9d"]
118		],
119		"light_green_gray": [
120			[148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 187, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250],
121			["a3d900", "a4d800", "a4d800", "a5d805", "a5d80d", "a6d714", "a6d719", "a6d71d", "a7d621", "a7d625", "a8d628", "a8d62b", "a8d52e", "a9d531", "a9d533", "aad536", "aad438", "aad43a", "abd43d", "abd33f", "abd341", "acd343", "acd345", "acd247", "add249", "add24b", "add14d", "aed14f", "aed151", "aed152", "afd054", "afd056", "afd058", "b0d059", "b0cf5b", "b0cf5d", "b1cf5e", "b1ce60", "b1ce62", "b1ce63", "b2ce65", "b2cd67", "b2cd68", "b3cd6a", "b3cc6b", "b3cc6d", "b3cc6e", "b4cc70", "b4cb71", "b4cb73", "b4cb75", "b5ca76", "b5ca78", "b5ca79", "b5ca7a", "b6c97c", "b6c97d", "b6c97f", "b6c880", "b6c882", "b7c883", "b7c885", "b7c786", "b7c788", "b7c789", "b8c68a", "b8c68c", "b8c68d", "b8c68f", "b8c590", "b9c591", "b9c593", "b9c494", "b9c496", "b9c497", "b9c498", "bac39a", "bac39b", "bac39d", "bac29e", "bac29f", "bac2a1", "bac2a2", "bac1a4", "bbc1a5", "bbc1a6", "bbc0a8", "bbc0a9", "bbc0aa", "bbc0ac", "bbbfad", "bbbfae", "bbbfb0", "bbbeb1", "bcbeb3", "bcbeb4", "bcbdb5", "bcbdb7", "bcbdb8", "bcbdb9", "bcbcbb"]
122		]
123	}
124}

themesの設定

次に表示する項目を設定する~/.config/powerline/themes/tmux/tmux-colorscheme.jsonを作成します。

1{
2    "segments": {
3        "right": [
4            {
5                "function": "powerlinemem.mem_usage.mem_usage",
6                "before": "MEM: ",
7                "args": {
8                    "short": true
9                },
10                "priority": 50
11            },
12            {
13                "function": "powerline.segments.common.sys.cpu_load_percent",
14                "before": "CPU: ",
15                "priority": 50
16            },
17            {
18                "function": "powerline.segments.common.net.network_load",
19                "args": {
20                    "recv_format": " \uf0ab {value:>8}",
21                    "sent_format": " \uf0aa {value:>8}",
22                    "recv_max": 1000000,
23                    "sent_max": 1000000
24                },
25                "priority": 100
26            },
27            {
28                "function": "powerline.segments.common.bat.battery",
29                "priority": 100
30            },
31            {
32                "function": "powerline.segments.common.time.date",
33                "args": {
34                  "format": "%Y/%m/%d(%a)"
35                },
36                "priority": 10
37            },
38            {
39                "function": "powerline.segments.common.time.date",
40                "args": {
41                    "format": "%H:%M",
42                    "istime": true
43                },
44                "priority": 10
45            },
46            {
47                "function": "powerline.segments.common.env.user",
48                "priority": 10
49            }
50		]
51	}
52}

colorschemesの設定

表示する項目の色を設定する~/.config/powerline/colorschemes/tmux/tmux-colorscheme.jsonを作成します。

1{
2  "name": "Default",
3  "groups": {
4    "information:additional":     { "fg": "gray9", "bg": "gray4", "attrs": [] },
5    "information:regular":        { "fg": "gray10", "bg": "gray4", "attrs": ["bold"] },
6    "information:highlighted":    { "fg": "white", "bg": "gray4", "attrs": [] },
7    "information:priority":       { "fg": "brightyellow", "bg": "mediumorange", "attrs": [] },
8    "warning:regular":            { "fg": "white", "bg": "brightred", "attrs": ["bold"] },
9    "critical:failure":           { "fg": "white", "bg": "darkestred", "attrs": [] },
10    "critical:success":           { "fg": "white", "bg": "darkestgreen", "attrs": [] },
11    "background":                 { "fg": "white", "bg": "gray0", "attrs": [] },
12    "background:divider":         { "fg": "gray5", "bg": "gray0", "attrs": [] },
13    "date":                       { "fg": "gray8", "bg": "gray2", "attrs": [] },
14    "time":                       { "fg": "gray10", "bg": "gray2", "attrs": ["bold"] },
15    "time:divider":               { "fg": "gray5", "bg": "gray2", "attrs": [] },
16    "email_alert":                "warning:regular",
17    "email_alert_gradient":       { "fg": "white", "bg": "yellow_orange_red", "attrs": ["bold"] },
18    "hostname":                   { "fg": "black", "bg": "gray10", "attrs": ["bold"] },
19    "weather":                    { "fg": "gray8", "bg": "gray0", "attrs": [] },
20    "weather_temp_gradient":      { "fg": "blue_red", "bg": "gray0", "attrs": [] },
21    "weather_condition_hot":      { "fg": "khaki1", "bg": "gray0", "attrs": [] },
22    "weather_condition_snowy":    { "fg": "skyblue1", "bg": "gray0", "attrs": [] },
23    "weather_condition_rainy":    { "fg": "skyblue1", "bg": "gray0", "attrs": [] },
24    "uptime":                     { "fg": "gray8", "bg": "gray0", "attrs": [] },
25    "external_ip":                { "fg": "gray8", "bg": "gray0", "attrs": [] },
26    "internal_ip":                { "fg": "gray8", "bg": "gray0", "attrs": [] },
27    "network_load":               { "fg": "gray8", "bg": "gray0", "attrs": [] },
28    "network_load_gradient":      { "fg": "green_yellow_orange_red", "bg": "gray0", "attrs": [] },
29    "network_load_sent_gradient": "network_load_gradient",
30    "network_load_recv_gradient": "network_load_gradient",
31    "network_load:divider":       "background:divider",
32    "system_load":                { "fg": "gray8", "bg": "gray0", "attrs": [] },
33    "system_load_gradient":       { "fg": "green_yellow_orange_red", "bg": "gray0", "attrs": [] },
34    "environment":                { "fg": "gray8", "bg": "gray0", "attrs": [] },
35    "cpu_load_percent":           { "fg": "gray8", "bg": "gray0", "attrs": [] },
36    "cpu_load_percent_gradient":  { "fg": "green_yellow_orange_red", "bg": "gray0", "attrs": [] },
37    "battery":                    { "fg": "gray8", "bg": "gray0", "attrs": [] },
38    "battery_gradient":           { "fg": "green_yellow_orange_red", "bg": "gray0", "attrs": [] },
39    "battery_full":               { "fg": "green", "bg": "gray0", "attrs": [] },
40    "battery_empty":              { "fg": "red", "bg": "gray0", "attrs": [] },
41    "player":                     { "fg": "gray10", "bg": "black", "attrs": [] },
42    "user":                       { "fg": "white", "bg": "darkblue", "attrs": ["bold"] },
43    "branch":                     { "fg": "gray9", "bg": "gray2", "attrs": [] },
44    "branch_dirty":               { "fg": "brightyellow", "bg": "gray2", "attrs": [] },
45    "branch_clean":               { "fg": "gray9", "bg": "gray2", "attrs": [] },
46    "branch:divider":             { "fg": "gray7", "bg": "gray2", "attrs": [] },
47    "stash":                      "branch_dirty",
48    "stash:divider":              "branch:divider",
49    "cwd":                        "information:additional",
50    "cwd:current_folder":         "information:regular",
51    "cwd:divider":                { "fg": "gray7", "bg": "gray4", "attrs": [] },
52    "virtualenv":                 { "fg": "white", "bg": "darkcyan", "attrs": [] },
53    "attached_clients":           { "fg": "gray8", "bg": "gray0", "attrs": [] },
54    "mem_usage":                 { "fg": "gray8", "bg": "gray0", "attrs": [] },
55    "mem_usage_gradient":        { "fg": "green_yellow_orange_red", "bg": "gray0", "attrs": [] },
56    "active_window_status": {"fg": "darkblue",   "bg": "gray0",    "attrs": []},
57    "window_status":        {"fg": "gray70",     "bg": "gray0",    "attrs": []},
58    "activity_status":      {"fg": "yellow",     "bg": "gray0",    "attrs": []},
59    "bell_status":          {"fg": "red",        "bg": "gray0",    "attrs": []},
60    "window":               {"fg": "gray6",      "bg": "gray0",    "attrs": []},
61    "window:divider":       {"fg": "gray4",      "bg": "gray0",    "attrs": []},
62    "window:current":       {"fg": "mediumcyan", "bg": "darkblue", "attrs": []},
63    "window_name":          {"fg": "white",      "bg": "darkblue", "attrs": ["bold"]},
64    "session":              {"fg": "black",      "bg": "gray90",   "attrs": ["bold"]},
65    "session:prefix":       {"fg": "gray90",     "bg": "darkblue", "attrs": ["bold"]}
66  }
67}

表示していない項目の設定も後々変更するときのために残しています。

config.json

カスタマイズしたColorSchemeとThemeを使うように全体設定のファイル~/.config/powerline/config.jsonを作成します。

1{
2	"common": {
3		"term_truecolor": false
4	},
5	"ext": {
6		"tmux": {
7			"colorscheme": "tmux-colorscheme",
8			"theme": "tmux-theme"
9		}
10	}
11}

設定反映

最後に.tmux.confを読み込むことで設定が反映されます。

1tmux source ~/.tmux.conf

ネットワークやCPUの情報が表示されない場合

正しく設定してもCPUの利用料とネットワークの情報が表示されないという現象が発生しました。

これらの設定にはpsutilが必要なので、インストールされていない場合はインストールしてください。

1pip install psutil

また、私の場合はインストールしても表示されず、OSのアップデートをしたところ表示されるようになりました。

下記のissueでもOSのアップデートをしたら表示されるようになったとありますが、私の場合はこのissueに記載されているバージョンでも表示されていなかったので、OSのバージョンアップというより再起動で表示されるようになるのかもしれません。

some segments not showing in tmux on macOS · Issue #2191 · powerline/powerline

some segments not showing in tmux on macOS · Issue #2191 · powerline/powerline

Hi there, I just set up a new mac book and some of the segments are not showing in tmux. my configuration: ~/.config/powerline/themes/tmux/default.json { "segments": { "right": [ { "function": "pow...

実際に別のPCでは再起動で表示されるようになりました。

左側のステータスバーを変更したい

左側のステータスバーのデフォルトで表示されている内容を変更したい場合は、powerline/bindings/tmuxにあるファイルを変更すると変えることができます。

無理矢理な変更な気がするので、より良い方法がわかったら更新したいと思います。

1pwd
2/usr/local/lib/python3.9/site-packages/powerline/bindings/tmux
3
4ls
5__init__.py                   powerline-base.conf           powerline_tmux_1.7_plus.conf  powerline_tmux_1.8_minus.conf powerline_tmux_1.9_plus.conf
6__pycache__                   powerline.conf                powerline_tmux_1.8.conf       powerline_tmux_1.8_plus.conf  powerline_tmux_2.1_plus.conf

私はウィンドウ番号の横の「*」や「-」を表示したくなかったので、無理矢理変更しました。

dotfiles

あまり整備できてないですが、dotfilesとしてGithubにもあるので参考にしてください。

GitHub - monda00/dotfiles: my dotfiles

GitHub - monda00/dotfiles: my dotfiles

my dotfiles. Contribute to monda00/dotfiles development by creating an account on GitHub.

参考

Support

\ この記事が役に立ったと思ったら、サポートお願いします! /

buy me a coffee
Share

Profile

author

Masa

都内のIT企業で働くエンジニア
自分が学んだことをブログでわかりやすく発信していきながらスキルアップを目指していきます!

buy me a coffee