iTerm 2 profiles

前端 未结 7 1725
庸人自扰
庸人自扰 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:30

    The latest iTerm2 nightly (Build 2.9.20150329-nightly at the time of writing) allows you to do that easily. You can download it here.

    Once you've installed and opened it:

    1. Log in to your remote machine via ssh and click iTerm2 (the app menu) > Install Shell Integration. It will download a script with curl and install it. Do the same on your local machine.
    2. Go to Preferences > Profiles.
    3. Create a new profile for your local machine. Customize it to fit your needs (change background color, name, etc)
    4. Go to the Advanced tab and scroll to the bottom.
    5. In Automatic Profile Switching, click '+' and add the hostname of your local machine. The hostname is the one you get when running echo $HOST on the target machine. It is not always the one you see in your prompt.
    6. Create another profile, this time for your remote machine, and customize it.
    7. Add the hostname of the remote machine in Automatic Profile Switching.
    8. Now, if you ssh into the remote machine, your profile will change, and if you exit out of the ssh session, you will be back to your local profile.

    You can combine this solution with @esod's answer seamlessly.
    Note: it didn't work for me until I created a profile specifically for the desktop instead of using the default profile.

    See the documentation for more info.

提交回复
热议问题