aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDeterminant <tederminant@gmail.com>2020-05-22 17:57:37 -0400
committerDeterminant <tederminant@gmail.com>2020-05-22 17:57:37 -0400
commit8f8792508e7d1e7f34d279692da22c17d1607913 (patch)
treede61c5bd268aa87d8b0e900b50b095ca89ce29a1
parent21430f45aa2d26704c479141b48b6a5571f0c5ac (diff)
add more commands
-rwxr-xr-xname2color.py7
-rwxr-xr-xtermcolor_256.sh11
-rwxr-xr-xtmux-colortag-prompt.sh12
3 files changed, 30 insertions, 0 deletions
diff --git a/name2color.py b/name2color.py
index a473301..f1df2a2 100755
--- a/name2color.py
+++ b/name2color.py
@@ -30,6 +30,7 @@ parser.add_argument('--color-name', type=int, help='manually change the color ma
parser.add_argument('--clear-idx', action='store_true')
parser.add_argument('--clear-name', action='store_true')
parser.add_argument('--clear', action='store_true')
+parser.add_argument('--show-state', action='store_true')
args = parser.parse_args()
state = {}
@@ -55,6 +56,12 @@ if len(args.name) > 100:
if args.idx < 0 or args.idx >= 1024:
error("invalid idx")
+if args.show_state:
+ print("ColorTag: manual coloring for session \"{}\"".format(args.session))
+ for (k, v) in state.items():
+ print("{} => colour{}".format(k, v))
+ sys.exit(0)
+
if args.clear_idx:
try:
del state[args.idx]
diff --git a/termcolor_256.sh b/termcolor_256.sh
new file mode 100755
index 0000000..8453b0c
--- /dev/null
+++ b/termcolor_256.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+# http://askubuntu.com/questions/821157/print-a-256-color-test-pattern-in-the-terminal
+echo "ColorTag: available color code"
+echo
+for i in {0..255} ; do
+ printf "\x1b[48;5;%sm%3d\e[0m " "$i" "$i"
+ if (( i == 15 )) || (( i > 15 )) && (( (i-15) % 6 == 0 )); then
+ printf "\n";
+ fi
+done
+read -n 1 -s -r -p "[Press any key to exit]"
diff --git a/tmux-colortag-prompt.sh b/tmux-colortag-prompt.sh
index 874a29f..0cdc01b 100755
--- a/tmux-colortag-prompt.sh
+++ b/tmux-colortag-prompt.sh
@@ -7,6 +7,10 @@ run_python() {
fi
}
+run_python_long() {
+ "$CURRENT_DIR/name2color.py" "$session" "$idx" "$name" "$@" || echo "ColorTag: invalid argument"
+}
+
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
case "$1" in
prompt)
@@ -27,16 +31,24 @@ case "$1" in
clear-all)
run_python --clear
;;
+ manual-colors)
+ run_python_long --show-state
+ ;;
+ colors)
+ tmux new-window -n '[colors]' "$CURRENT_DIR/termcolor_256.sh"
+ ;;
'') ;;
help)
echo "# Tmux ColorTag"
echo "# Ted Yin <tederminant@gmail.com>"
echo "Note: color overriding order: color-idx > color-name > auto"
+ echo "colors: show all available color codes"
echo "color-idx <0-255>: manually set the color for the window index"
echo "color-name <0-255>: manually set the color for the name"
echo "clear-idx: clears the preivous color of the index"
echo "clear-name: clears the preivous color of the name"
echo "clear-all: use auto-coloring for all window tags"
+ echo "manual-colors: show all memorized coloring for this session"
;;
*) tmux display "ColorTag: invalid command"; exit 0;;
esac