Iterm2 更换背景图片&ssh后命令行高亮显示

更换背景图片 :(两种方式)

  • 打开apple script
tell application "iTerm"
	tell current session of current window
		set background image to "图片的位置"
	end tell
end tell

直接执行即可.

  • 创建一个以.scpt为后缀的文件 eg:bg_change.scpt
tell application "iTerm"
	tell current session of current window
		set background image to "图片的位置"
	end tell
end tell

将以上的内容写入你创建的文件中

创建一个.sh 文件 eg:change_bg.sh

写入以下内容,路径需要存储你脚本的路径

#!/bin/bash
osascript
/usr/local/opt/bg_change.scpt

chmod 755 change_bg.sh

执行./change_bg.sh即可看到你的命令行界面图片变了

jpg

ssh后高亮

sudo touch ssh-background

里面写入以下内容

set_color() {
  local HEX_FG=$1
  local HEX_BG=$2
  local OPACITY=$3

  local FG_R=`echo $HEX_FG | sed 's/../0x&,/g' | awk -F "," '{printf("%d",$1 * 257)}'`
  local FG_G=`echo $HEX_FG | sed 's/../0x&,/g' | awk -F "," '{printf("%d",$2 * 257)}'`
  local FG_B=`echo $HEX_FG | sed 's/../0x&,/g' | awk -F "," '{printf("%d",$3 * 257)}'`
  local BG_R=`echo $HEX_BG | sed 's/../0x&,/g' | awk -F "," '{printf("%d",$1 * 257)}'`
  local BG_G=`echo $HEX_BG | sed 's/../0x&,/g' | awk -F "," '{printf("%d",$2 * 257)}'`
  local BG_B=`echo $HEX_BG | sed 's/../0x&,/g' | awk -F "," '{printf("%d",$3 * 257)}'`

  /usr/bin/osascript <<EOF
tell application "iTerm"
   tell current session of current terminal
      set foreground color to {$FG_R, $FG_G, $FG_B}
      set background color to {$BG_R, $BG_G, $BG_B} 
      set transparency to "$OPACITY" 
   end tell
end tell
EOF
}

if [[ "$@" =~ host0.example.com ]]; then
   set_color ffffff 330000 0.2 
elif [[ "$@" =~ host1.example.com ]]; then
   set_color ffffff 000033 0.2
fi

ssh $@

set_color ffffff 000000 0.2
chmod 755 /path/ssh-background
alias ssh=/path/bin/ssh-background

接下来ssh即可

如图

转载于:https://my.oschina.net/kakoi/blog/806185

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值