0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

iTerm2 でタブの番号をプロンプトに表示する

Posted at

iTerm2 で、タブの番号をプロンプトに表示します。

(注意)
iTrem2 のタブに表示される tab numbers は、タブの追加・削除をする度に、⌘1 からrenumber されますが、これは、タブを開いた順番の番号です。
私にとっては、こちらの方が都合が良いです😊

# .bash_profile

# iterm2 の ITERM_SESSION_ID を取得
SESSION_ID="$ITERM_SESSION_ID"

# 例: ITERM_SESSION_ID=w0t0p0:EE4A9197-47EB-4369-B046-0101A23BE89D
# ":" で分割して配列に格納
IFS=':' read -ra SESSION_PARTS <<< "$SESSION_ID"

# 配列の要素を取得して必要な部分を抽出
PART_WITH_T1="${SESSION_PARTS[0]}"

# "t0" の部分を抽出
T_PART="${PART_WITH_T1#*t}"

# ":" で分割して "0" の部分を取得
IFS='p' read -ra T_PARTS <<< "$T_PART"
TAB_NUM="${T_PARTS[0]}"

export PS1="\[\e[0;34m\]\h \[\e[0;36m\][$((TAB_NUM + 1))]\[\e[0m\] \w:$ "
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?