From 8f8792508e7d1e7f34d279692da22c17d1607913 Mon Sep 17 00:00:00 2001 From: Determinant Date: Fri, 22 May 2020 17:57:37 -0400 Subject: add more commands --- name2color.py | 7 +++++++ termcolor_256.sh | 11 +++++++++++ tmux-colortag-prompt.sh | 12 ++++++++++++ 3 files changed, 30 insertions(+) create mode 100755 termcolor_256.sh 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 " 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 -- cgit v1.2.3