download

Sign in or create your account | Project List | Help

download Git Source Tree

Root/ch_term_color.sh

1#!/bin/sh
2########################
3#
4# shell script to change terminal color.
5# for osx, zsh or bash.
6#
7# source this script in your terminal configuration file.
8# for example,
9# . ch_term_color.sh
10#
11#
12# color name list
13# "red", "green", "blue", "cyan", "magenta", "yellow", "purple", "black"
14#
15#
16# advweb@jcom.home.ne.jp
17# http://members.jcom.home.ne.jp/advweb/
18#
19########################
20
21# get last char
22lc=$(tty | sed -e 's#.*\(.\)$#\1#')
23
24# switch case
25case ${lc} in
26    1|5|9|d)
27        background="black"
28        cursor="green"
29        normal_text="yellow"
30        bold_text="red"
31    ;;
32    2|6|a|e)
33        background="red"
34        cursor="black"
35        normal_text="green"
36        bold_text="yellow"
37    ;;
38    3|7|b|f)
39        background="yellow"
40        cursor="red"
41        normal_text="black"
42        bold_text="green"
43    ;;
44    4|8|c|0)
45        background="green"
46        cursor="yellow"
47        normal_text="red"
48        bold_text="black"
49    ;;
50    *)
51        echo "unknown tty last char"
52        exit 1
53    ;;
54esac
55
56# run applescript
57osascript << EOF
58tell application "Terminal"
59    tell window 1
60        set background color to "${background}"
61        set cursor color to "${cursor}"
62        set normal text color to "${normal_text}"
63        set bold text color to "${bold_text}"
64    end tell
65end tell
66EOF
67
68

Archive Download this file

Branches:
master