From 1ea3331a3a13c015196d79ae62bfe619c43bed59 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Thu, 14 Apr 2022 13:54:03 -0400 Subject: [PATCH 01/12] Add battery level into prompt. Has to be turned on by an env variable, and I only tested it on one laptop so far. --- tcshrc.colors | 1 + tcshrc.prompt.defs | 6 +++--- tcshrc.prompt.final | 38 +++++++++++++++++++++++++++++++++++++- 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/tcshrc.colors b/tcshrc.colors index d8b74ff..6aba697 100644 --- a/tcshrc.colors +++ b/tcshrc.colors @@ -22,6 +22,7 @@ set ansi_white='37' set bright="$csi$ansi_bright$ansi_color" set dim="$csi$ansi_dim$ansi_color" set reverse="$csi$ansi_reverse$ansi_color" +set blink="${csi}5${ansi_color}" set black="$csi$ansi_black$ansi_color" diff --git a/tcshrc.prompt.defs b/tcshrc.prompt.defs index 734ab0d..2efd9d4 100644 --- a/tcshrc.prompt.defs +++ b/tcshrc.prompt.defs @@ -97,12 +97,12 @@ set prompt_simple="${oldp_color_seq}[%n@%m: %c]%# " # Screens are almost certainly not a million chars wide. # If they are... oh well, that's a really weird one. -set date_prefix="%{${csi}A${csi}1000000G${csi}18D%}" -set date_suffix="%{${csi}G${csi}1B%}" +set align_prefix="%{${csi}A${csi}1000000G${csi}18D%}" +set align_suffix="%{${csi}G${csi}1B%}" #set screen_return="%{8%}" set date_prompt_core="${date_color_seq}%{%Y-%W-%D %}${time_color_seq}%{%P%}" set date_prompt_left="${date_prompt_core}" -set date_prompt="${date_prefix}${date_prompt_core}${date_suffix}" +set date_prompt="${date_prompt_core}" #unset edit if( $?CSHENV_DEBUG ) then diff --git a/tcshrc.prompt.final b/tcshrc.prompt.final index bf70099..771a1af 100644 --- a/tcshrc.prompt.final +++ b/tcshrc.prompt.final @@ -4,6 +4,13 @@ @ prompt_hcolor = $prompt_hcolor % ${#reference_colors} @ prompt_hsym = $prompt_hsym % ${#referencechars} +set critical_battery_level = 10 +set low_battery_level = 20 +set weak_battery_level = 33 +set medium_battery_level = 50 +set strong_battery_level = 75 + + if( ${prompt_hcolor} == 0 ) then #if( $?CSHENV_DEBUG ) then #echo colorshuffle @@ -30,6 +37,7 @@ if( $?CSHENV_DEBUG ) then echo "Setting prompt" endif + set prompt_reference_core="%{${reference_colors[${prompt_hcolor}]}%}${referencechars[${prompt_hsym}]}" #if( ${referencechars[${prompt_hsym}]} == `env LC_ALL=C.UTF-8 printf "\u2328"` ) then # set prompt_reference="%{${dim}%}<${prompt_reference_core} %{${dim}%}> " @@ -40,7 +48,35 @@ set prompt_reference="%{${dim}%}< ${prompt_reference_core} %{${dim}%}> " #set prompt_reference="%{${csi}0;48\;5\;7m%}(${prompt_reference_core}%{${csi}0;48\;5\;7m%})%{${dim}%}" #set prompt_reference="${prompt_reference_core}%{${text_color_seq}%} \- " -set prompt_cool="\n${date_prompt}${brace_color_seq}\[${prompt_reference}${line_prompt}${depth_prompt}${user_prompt}${at_color_seq}@${host_prompt}${text_color_seq}\: ${path_prompt}${brace_color_seq}\]${end_prompt}" +if( $?CSHENV_SHOW_BATTERY_LEVEL ) then + set battery_level=`cat /sys/class/power_supply/BAT1/capacity` + if( ${battery_level} < ${critical_battery_level} ) then + set battery_color=${red}${blink} + else if( ${battery_level} < ${low_battery_level} ) then + set battery_color=${red} + else if( ${battery_level} < ${weak_battery_level} ) then + set battery_color=${yellow} + else if( ${battery_level} < ${medium_battery_level} ) then + set battery_color=${bright_yellow} + else if( ${battery_level} < ${strong_battery_level} ) then + set battery_color=${green} + else + set battery_color=${bright_green} + endif + + if( ${battery_level} < 10 ) then + set battery_level=" ${battery_level}" + else if( ${battery_level} < 100 ) then + set battery_level=" ${battery_level}" + endif + + #set battery_prompt="%{${battery_color}%}%{${battery_level}${at_color}\%%}%{${dim}%} " + set battery_prompt="%{${csi}28D${blue}Battery Level: ${battery_color}${battery_level}${at_color}\%${dim} %}" +else + set battery_prompt="" +endif + +set prompt_cool="%{\n%}${align_prefix}${battery_prompt}${date_prompt}${align_suffix}${brace_color_seq}\[${prompt_reference}${line_prompt}${depth_prompt}${user_prompt}${at_color_seq}@${host_prompt}${text_color_seq}\: ${path_prompt}${brace_color_seq}\]${end_prompt}" if( ! ${?cshenv_user_prompt_override} ) then set prompt="$prompt_cool" From 9395659d4e448cbb21aea301af58000950d5f03d Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Thu, 14 Apr 2022 13:55:21 -0400 Subject: [PATCH 02/12] Added a few C++ lib types to syntax highlighting --- vim/after/syntax/cpp.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vim/after/syntax/cpp.vim b/vim/after/syntax/cpp.vim index c32e564..8c7b994 100644 --- a/vim/after/syntax/cpp.vim +++ b/vim/after/syntax/cpp.vim @@ -52,7 +52,7 @@ syn keyword cxxStlKeywords contained containedin=cxxAttribute noreturn carries_d syn keyword cxxStlKeywords contained containedin=cxxStlLibrary,cxxBoostLibrary mutex condition_variable thread lock_guard scoped_lock unique_lock " Strings -syn keyword cxxStlKeywords containedin=cxxStlLibrary string contained +syn keyword cxxStlKeywords containedin=cxxStlLibrary wstring string contained syn keyword cxxStlKeywords contained containedin=cxxStlLibrary byte syn keyword cxxStlKeywords contained containedin=cxxStlLibrary,cxxBoostLibrary string_view @@ -60,7 +60,7 @@ syn keyword cxxStlKeywords containedin=cxxStlLibrary,cxxBoostLibrary function co syn keyword cxxStlTypes containedin=cxxStlLibrary iostream istream ostream fstream ifstream ofstream contained syn keyword cxxStlTypes containedin=cxxStlLibrary stringstream istringstream ostringstream contained -syn keyword cxxStlTypes containedin=cxxStlLibrary iostream basic_string vector deque list pair queue priority_queue stack map multimap set multiset contained +syn keyword cxxStlTypes containedin=cxxStlLibrary iostream basic_string vector deque forward_list list pair queue priority_queue stack map multimap set multiset contained syn keyword cxxStlTypes containedin=cxxStlLibrary,cxxBoostLibrary array contained syn keyword cxxStlTypes containedin=cxxStlLibrary,cxxBoostLibrary unordered_map unordered_multimap contained From 69e71ce4d19475c2c446a9400e073b288a40d018 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Thu, 14 Apr 2022 16:40:49 -0400 Subject: [PATCH 03/12] Make battery device configurable --- tcshrc.prompt.final | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tcshrc.prompt.final b/tcshrc.prompt.final index 771a1af..e453945 100644 --- a/tcshrc.prompt.final +++ b/tcshrc.prompt.final @@ -49,7 +49,11 @@ set prompt_reference="%{${dim}%}< ${prompt_reference_core} %{${dim}%}> " #set prompt_reference="${prompt_reference_core}%{${text_color_seq}%} \- " if( $?CSHENV_SHOW_BATTERY_LEVEL ) then - set battery_level=`cat /sys/class/power_supply/BAT1/capacity` + if( $?CSHENV_BATTERY_DEVICE ) then + set battery_level=`cat ${CSHENV_BATTERY_DEVICE}` + else + set battery_level=`cat /sys/class/power_supply/BAT1/capacity` + endif if( ${battery_level} < ${critical_battery_level} ) then set battery_color=${red}${blink} else if( ${battery_level} < ${low_battery_level} ) then From 5174b9bee6b24e03769d5c5dfe547d31b4d56d57 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Fri, 15 Apr 2022 15:02:59 -0400 Subject: [PATCH 04/12] Configurable battery level source file --- tcshrc.prompt.final | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tcshrc.prompt.final b/tcshrc.prompt.final index 771a1af..e453945 100644 --- a/tcshrc.prompt.final +++ b/tcshrc.prompt.final @@ -49,7 +49,11 @@ set prompt_reference="%{${dim}%}< ${prompt_reference_core} %{${dim}%}> " #set prompt_reference="${prompt_reference_core}%{${text_color_seq}%} \- " if( $?CSHENV_SHOW_BATTERY_LEVEL ) then - set battery_level=`cat /sys/class/power_supply/BAT1/capacity` + if( $?CSHENV_BATTERY_DEVICE ) then + set battery_level=`cat ${CSHENV_BATTERY_DEVICE}` + else + set battery_level=`cat /sys/class/power_supply/BAT1/capacity` + endif if( ${battery_level} < ${critical_battery_level} ) then set battery_color=${red}${blink} else if( ${battery_level} < ${low_battery_level} ) then From 7758c2b961bedfcdf4a50bbc9e6db5c61b596f75 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Fri, 15 Apr 2022 15:10:18 -0400 Subject: [PATCH 05/12] Vim touchscreen scrolling support. Use the environment variable to turn it on. --- vim/vimrc | 4 ++++ vim/vimrc.mousescroll | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 vim/vimrc.mousescroll diff --git a/vim/vimrc b/vim/vimrc index 533641f..b838cb5 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -23,5 +23,9 @@ source ~/.vim/vimrc.functions source ~/.vim/vimrc.fileprefs source ~/.vim/vimrc.statusline +if exists('$CSHENV_TOUCHSCREEN') + source ~/.vim/vimrc.mousescroll +endif + set shell=/bin/tcsh "set t_Co=1 diff --git a/vim/vimrc.mousescroll b/vim/vimrc.mousescroll new file mode 100644 index 0000000..86094d9 --- /dev/null +++ b/vim/vimrc.mousescroll @@ -0,0 +1,41 @@ +function! MouseScrollTouch() + "mark b is the current cursor position + "mark a is the previous cursor position + norm mb + let currPos= line('.') + norm `a + let prevPos= line('.') + let amt= 1 + abs(currPos - prevPos) / 2 + "norm `bma + while amt > 0 + if currPos>prevPos + norm  + elseif currPos 0 + if currPos>prevPos + norm  + elseif currPos ma:call MouseScrollTouch() From 39d82161981461aaf65b7dc991d18e55f84d79c3 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Fri, 15 Apr 2022 15:12:20 -0400 Subject: [PATCH 06/12] Use GBP symbol for Escape, to work with GNOME touchscreen. --- vim/vimrc.defkeymaps | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vim/vimrc.defkeymaps b/vim/vimrc.defkeymaps index d167eb2..25def8c 100644 --- a/vim/vimrc.defkeymaps +++ b/vim/vimrc.defkeymaps @@ -36,3 +36,8 @@ imap [A imap [B imap [C imap [D + +" On my touchscreen laptop, the gnome keyboard doesn't have special keys... +" So we map a key I'll never use to 'escape' +imap £ +map £ From d53a244b5f32a146f9c3ac39cba131493d5bb191 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Fri, 15 Apr 2022 15:13:00 -0400 Subject: [PATCH 07/12] Make battery level label italic and more visible. --- tcshrc.prompt.final | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tcshrc.prompt.final b/tcshrc.prompt.final index e453945..9db349c 100644 --- a/tcshrc.prompt.final +++ b/tcshrc.prompt.final @@ -75,7 +75,7 @@ if( $?CSHENV_SHOW_BATTERY_LEVEL ) then endif #set battery_prompt="%{${battery_color}%}%{${battery_level}${at_color}\%%}%{${dim}%} " - set battery_prompt="%{${csi}28D${blue}Battery Level: ${battery_color}${battery_level}${at_color}\%${dim} %}" + set battery_prompt="%{${csi}28D${csi}38;2;128;128;255;3mBattery Level:${dim} ${battery_color}${battery_level}${at_color}\%${dim} %}" else set battery_prompt="" endif From 51e339ce74633c409db08c4b528bf80f97e16a9e Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Fri, 15 Apr 2022 15:31:44 -0400 Subject: [PATCH 08/12] Fix prompt shuffling when `shuf` is not found. --- tcshrc.prompt.defs | 5 +++++ tcshrc.prompt.final | 17 ++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/tcshrc.prompt.defs b/tcshrc.prompt.defs index 2efd9d4..d95a60e 100644 --- a/tcshrc.prompt.defs +++ b/tcshrc.prompt.defs @@ -6,6 +6,11 @@ if( $?CSHENV_DEBUG ) then echo "Sourcing prompt setup and definitions..." endif +which shuf >& /dev/null +if( $? == 0 ) then + setenv CSHENV_DETECTED_SHUF +endif + if( ! $?unknown_tty ) then set unknown_tty="?" if( $?CSHENV_DEBUG ) then diff --git a/tcshrc.prompt.final b/tcshrc.prompt.final index 9db349c..9800044 100644 --- a/tcshrc.prompt.final +++ b/tcshrc.prompt.final @@ -16,7 +16,13 @@ if( ${prompt_hcolor} == 0 ) then #echo colorshuffle #endif #echo  - set reference_colors=`shuf -e $reference_colors` + # Shuffle, if supported + if( $?CSHENV_DETECTED_SHUF ) then + set reference_colors=`shuf -e $reference_colors` + else + #echo "FALLBACK COLOR!" + set reference_colors=`echo $reference_colors | sed -e 's/ /\n/' | sort -R | xargs` + endif endif @@ -25,8 +31,13 @@ if( ${prompt_hsym} == 0 ) then # && ${prompt_hcolor} == 0 ) then echo symbolshuffle endif #echo  - set referencechars=`shuf -e $referencechars` - #set reference_colors=`shuf -e $reference_colors` + if( $?CSHENV_DETECTED_SHUF ) then + set referencechars=`shuf -e $referencechars` + #set reference_colors=`shuf -e $reference_colors` + else + #echo "FALLBACK CHAR!" + set referencechars=`echo $referencechars | sed -e 's/ /\n/' | sort -R | xargs` + endif endif @ prompt_hcolor = ${prompt_hcolor} + 1 From 2f353a600dbeea856b501ca05d26758351908c17 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Fri, 15 Apr 2022 15:52:44 -0400 Subject: [PATCH 09/12] Fix the prompt tagging in macosx. Something is dumb with the unicode Terminal... so I'm punting for now. --- tcshrc.prompt.defs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tcshrc.prompt.defs b/tcshrc.prompt.defs index d95a60e..4de75f6 100644 --- a/tcshrc.prompt.defs +++ b/tcshrc.prompt.defs @@ -92,6 +92,12 @@ foreach ch ($referencechars_raw) set referencechars=( $referencechars `env LC_ALL=C.UTF-8 printf "\u${ch}"` ) end +if( $CSHENV_SYSTEM == "Darwin" ) then + # Macos seems to dislike using printf to construct unicode chars. + # So you get a dumb set of ABCDXYZ + set referencechars="A B C D X Y Z" +endif + # Rotation alias precmd 'source ${CSHENV_DIR}/tcshrc.prompt.final' #alias postcmd echo doit From 5c7b5f3ff8210c4730635c72a4a881aed8988724 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Fri, 15 Apr 2022 15:53:50 -0400 Subject: [PATCH 10/12] DUH.... `sed` replaces with global... --- tcshrc.prompt.final | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tcshrc.prompt.final b/tcshrc.prompt.final index 9800044..49918a8 100644 --- a/tcshrc.prompt.final +++ b/tcshrc.prompt.final @@ -21,7 +21,7 @@ if( ${prompt_hcolor} == 0 ) then set reference_colors=`shuf -e $reference_colors` else #echo "FALLBACK COLOR!" - set reference_colors=`echo $reference_colors | sed -e 's/ /\n/' | sort -R | xargs` + set reference_colors=`echo $reference_colors | sed -e 's/ /\n/g' | sort -R | xargs` endif endif @@ -36,7 +36,7 @@ if( ${prompt_hsym} == 0 ) then # && ${prompt_hcolor} == 0 ) then #set reference_colors=`shuf -e $reference_colors` else #echo "FALLBACK CHAR!" - set referencechars=`echo $referencechars | sed -e 's/ /\n/' | sort -R | xargs` + set referencechars=`echo $referencechars | sed -e 's/ /\n/g' | sort -R | xargs` endif endif From f725a1d9e0a122f874c2e0abb76cd0394dcf1070 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Fri, 15 Apr 2022 15:58:34 -0400 Subject: [PATCH 11/12] Adjust for dumbness in how macos sed replaces things. `tr` is more straightforward. --- tcshrc.prompt.final | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tcshrc.prompt.final b/tcshrc.prompt.final index 49918a8..10309cb 100644 --- a/tcshrc.prompt.final +++ b/tcshrc.prompt.final @@ -21,7 +21,7 @@ if( ${prompt_hcolor} == 0 ) then set reference_colors=`shuf -e $reference_colors` else #echo "FALLBACK COLOR!" - set reference_colors=`echo $reference_colors | sed -e 's/ /\n/g' | sort -R | xargs` + set reference_colors=`echo $reference_colors | tr " " "\n" | sort -R | xargs` endif endif @@ -36,7 +36,7 @@ if( ${prompt_hsym} == 0 ) then # && ${prompt_hcolor} == 0 ) then #set reference_colors=`shuf -e $reference_colors` else #echo "FALLBACK CHAR!" - set referencechars=`echo $referencechars | sed -e 's/ /\n/g' | sort -R | xargs` + set referencechars=`echo $referencechars | tr " " "\n" | sort -R | xargs` endif endif From 8672bf09e974a4a27b4b4a1d52874760343d5b96 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Fri, 15 Apr 2022 15:59:26 -0400 Subject: [PATCH 12/12] Battery level support for macosx. --- tcshrc.prompt.final | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tcshrc.prompt.final b/tcshrc.prompt.final index 10309cb..40aa90b 100644 --- a/tcshrc.prompt.final +++ b/tcshrc.prompt.final @@ -60,7 +60,9 @@ set prompt_reference="%{${dim}%}< ${prompt_reference_core} %{${dim}%}> " #set prompt_reference="${prompt_reference_core}%{${text_color_seq}%} \- " if( $?CSHENV_SHOW_BATTERY_LEVEL ) then - if( $?CSHENV_BATTERY_DEVICE ) then + if( $CSHENV_SYSTEM == "Darwin" ) then + set battery_level=`pmset -g batt | grep -Eo "\d+%" | cut -d% -f1` + else if( $?CSHENV_BATTERY_DEVICE ) then set battery_level=`cat ${CSHENV_BATTERY_DEVICE}` else set battery_level=`cat /sys/class/power_supply/BAT1/capacity`