From 4d1f7305ee20558390396598addbfdd6fb537fc2 Mon Sep 17 00:00:00 2001 From: Fernando Schauenburg Date: Wed, 30 Oct 2019 18:43:49 +0100 Subject: [PATCH] Refactor terminal customization for readability --- dotfiles/.bashrc | 90 ++++++++++++++++++++++-------------------------- 1 file changed, 42 insertions(+), 48 deletions(-) diff --git a/dotfiles/.bashrc b/dotfiles/.bashrc index cdb4a16..039d64d 100644 --- a/dotfiles/.bashrc +++ b/dotfiles/.bashrc @@ -203,58 +203,52 @@ bashrc_update_colors() { tmux source-file "$HOME/.tmux.conf" fi - # Format string for sending an OSC (Operating System Commmand) to the terminal. - if [ -n "$TMUX" ]; then - # http://permalink.gmane.org/gmane.comp.terminal-emulators.tmux.user/1324 - local format='\033Ptmux;\033\033]%s\007\033\\' - # local format='\033Ptmux;\033\033]%s\033\033\\\033\\' - elif [ "${TERM%%[-.]*}" = "screen" ]; then - # GNU screen (screen, screen-256color, screen-256color-bce) - local format='\033P\033]%s\007\033\\' - else - local format='\033]%s\033\\' + # Terminal OSC (Operating System Commmand) definition + local osc='\033]%s\033\\' + if [ -n "$TMUX" ]; then osc='\033Ptmux;\033\033]%s\007\033\\' + elif [ ${TERM%%[-.]*} = screen ]; then osc='\033P\033]%s\007\033\\' fi - # Solarize the terminal: - # - 4;n;#rrggbb (e.g. https://github.com/mintty/mintty/wiki/Tips#changing-colours) - printf "$format" "4;0;#$Base02_RGB" - printf "$format" "4;1;#$Red_RGB" - printf "$format" "4;2;#$Green_RGB" - printf "$format" "4;3;#$Yellow_RGB" - printf "$format" "4;4;#$Blue_RGB" - printf "$format" "4;5;#$Magenta_RGB" - printf "$format" "4;6;#$Cyan_RGB" - printf "$format" "4;7;#$Base2_RGB" - printf "$format" "4;8;#$Base03_RGB" - printf "$format" "4;9;#$Orange_RGB" - printf "$format" "4;10;#$Base01_RGB" - printf "$format" "4;11;#$Base00_RGB" - printf "$format" "4;12;#$Base0_RGB" - printf "$format" "4;13;#$Violet_RGB" - printf "$format" "4;14;#$Base1_RGB" - printf "$format" "4;15;#$Base3_RGB" + # Solarize the terminal: 4;n;#rrggbb + local n rgb comment + while read n rgb comment; do printf "$osc" "4;$n;#$rgb"; done <