iTerm 2 profiles

前端 未结 7 1714
庸人自扰
庸人自扰 2021-01-29 23:10

I have recently switched over to iTerm2 and love it. I am wondering though if there is a way to use profiles to correspond to what environment/specific machine you are on.

相关标签:
7条回答
  • 2021-01-29 23:45

    for zsh users

    lets say you have 2 profiles, one named mac (for your primary machine) and one for linux (your remote machine)

    when entering the session, we need to tell zsh to load our profile

    1. connect to remote linux
    2. in ~/.zshrc add echo -e "\033]50;SetProfile=linux\a"
    3. source your files for immediate effect: source ~/.zshrc
    4. your new theme should be visible within the iterm session.

    when exiting the session, we need to tell zsh to switch back to our original profile

    1. connect to remote linux
    2. in linux ~/.zlogout add the following
    if [ "$SHLVL" = 1 ]; then
      echo -e "\033]50;SetProfile=mac\a"
      clear
    fi
    

    now you can swap profiles with ease <3.

    if you are using bash, i believe the steps are similar but you would instead modify ~/.bashrc and ~/.bash_logout

    demo

    demo of session based profiles in iterm2

    0 讨论(0)
提交回复
热议问题