1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

sshで本番環境に接続したとき、iTerm2の背景を現場猫に変える方法

Posted at

データ入れ替えようとしてtruncateしたら本番環境だった・・・

なんてことは何がなんでも避けたいですよね。
sshは手軽に接続できますが、その分間違えていたらと思う方には、
本番環境に接続したら背景が現場猫に変える方法があります。

Moving.gif

前提

  1. iTerm2使っていること
  2. zsh(bashでも大丈夫です、修正するファイルが違うだけなので参考のURLを見てください)
  3. .sshにconfigファイルの設定がされていること

手順

1. シェルの作成

以下コピペしてシェルを保存します。
保存先はどこでも大丈夫です、後から3で使用します。

#!/bin/bash
echo -ne "\033]1337;SetProfile=$@\a"
/usr/bin/ssh "$@"
echo -ne "\033]1337;SetProfile=Default\a"

2. iTerm2の設定

  1. iTerm2を起動します
  2. コマンドキー+,でPreferencesを起動し、Profilesを表示します。
  3. 左下の+ボタンを押して、新規にプロファイルを作成し、Nameにsshのconfigで設定している接続先(ssh hogeserverのhogeserver)を登録します。Preferences_と_-zsh_と_Slack___rememory___curiosity.png
  4. Windowを選択しEnableにチェックを入れ、背景に表示したい現場猫を設定します。Blendingとかをいじると好みな感じなるかもしれません。
    Preferences_と_-zsh_と_Slack___rememory___curiosity.png
  5. Prefrencesを閉じて、Profiles -> 設定したProfileのName を選択します。こんな感じで表示されていれば成功です。Cursor_と_-zsh.png

3. aliasの設定

.zshrc に以下を1行追加します。
(私は1のshellをbin配下に保存しています)

alias ssh='~/bin/ssh-change-profile.sh'

4. 確認

ssh hogeserver で接続して、見た目が変われば成功です。
変わらない場合、profileのNameの文字が間違っていないか見直してみてください。

参考

もはや私の記事を読むよりこっちの方がわかりやすいという説はあります。
https://dev.classmethod.jp/articles/iterm2-ssh-change-profile/

1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?