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

More than 5 years have passed since last update.

ssh接続する際にTerminalの色を変える(Ubuntu版)

Last updated at Posted at 2020-02-01

はじめに

人間は必ずミスを犯すものです。
少しでもミスを減らす為、出来ることはしましょう。
他にいい案があれば教えていただけると嬉しいです。
(macOS版はこちら

環境

Ubuntuにデフォルトで入っているTerminal

スクリプト

少しでもミスを減らしたいのでaliasでコマンドを置き換えるなどせず、環境毎にスクリプトを作成するのがいいと思っているのでそれ用のスクリプトです。
適時自分の環境に書き換えてください。

ssh_color_change_ubuntu.sh
# !/bin/bash

# ssh connection script for ubuntu

################################################
# style guide
# http://google.github.io/styleguide/shell.xml
################################################

# colors list
white="#ffffff"
sky_blue="#00ccff"
red="#ff4b00"
default="#300a24" # default ubuntu back color

################################################
# color change function
# Globals:
#   None
# Arguments:
#   1:word color
#   2:back color
# Returns:
#   None
################################################
function color_change() {
  word=$1
  back=$2
  echo -ne "\e]10;${word}\a\e]11;${back}\a"
}

# Ctr-c processing
# default terminal color
trap "color_change \"${white}\" \"${default}\"" 2

color_change "${white}" "${red}"

# command
ssh username@hostname

# end
color_change "${white}" "${default}"
exit 0
1
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
1
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?