ZSHのカスタマイズ機能に基づいてTMUXウィンドウの名前を変更する

ZSHのカスタマイズ機能に基づいてTMUXウィンドウの名前を変更する

私のファイル~/.zshrcにカスタム機能があります。

function getCustomWindowName {
  # runs 'sed' on 'pwd' to get special dir name
  # and set it to $workspace
  if $workspace is valid; then
    echo $workspace
    return 0
  else
    echo ""
    return 1
  fi
}

私の~/.tmux.confプロフィールに考える次のようにしてください。

set-option -g status-interval 5
set-option -g automatic-rename on
set-option -g automatic-rename-format '#{getCustomWindowName}'

これを行う方法はありますか?

getCustomWindowNameボーナス質問:エコー(またはs)がない場合は、メインウィンドウ名として使用したいと思いますreturn 1。とにかくこれを行うことができますか?

ベストアンサー1

NotTheDr01dsからZSHでウィンドウの名前を変更できることを学んだので、次の方法を使用しました。

function getCustomWindowName {
  # runs 'sed' on 'pwd' to get special dir name
  # and set it to $workspace
  if $workspace is valid; then
    tmux rename-window $workspace
  fi
}

# only allow unique values in this array
typeset -U chpwd_functions
# run this function when current working directory changes.
# Variables $PWD and $OLDPWD.
chpwd_functions+=(getCustomWindowName)
# Try to update when a new window is opened.
getCustomWindowName

おすすめ記事