aboutsummaryrefslogtreecommitdiffstats
path: root/.zprofile-abduco
diff options
context:
space:
mode:
authorkatherine <ageha@airen-no-jikken.icu>2020-08-30 12:03:49 -0700
committerkatherine <ageha@airen-no-jikken.icu>2020-08-30 12:03:49 -0700
commit248f7433a8fc56a131c0b6c512bd26296a758f39 (patch)
tree09711f8dc98d85ecd2568180d27283fa96d829ca /.zprofile-abduco
parentce3bed0df36499fcc0536154b4bca87d885733d9 (diff)
downloaddotfiles-248f7433a8fc56a131c0b6c512bd26296a758f39.tar.gz
add curses session-switcher
trying abduco for now, because dtach was a little messy; need to patch it to do contextually ^L or so, though
Diffstat (limited to '.zprofile-abduco')
-rw-r--r--.zprofile-abduco107
1 files changed, 107 insertions, 0 deletions
diff --git a/.zprofile-abduco b/.zprofile-abduco
new file mode 100644
index 0000000..6584928
--- /dev/null
+++ b/.zprofile-abduco
@@ -0,0 +1,107 @@
+local window_prompt
+local windows
+local input
+local char
+local i
+local seen
+local off
+
+[[ -z "$ABDUCO_SUB" ]] || return
+
+zmodload zsh/curses || return
+
+while true; do
+
+ window_prompt="$(abduco | tail -n +2)"
+
+ if [[ $window_prompt == $'' ]]; then
+ ABDUCO_SUB=true abduco -A "1" zsh
+ if [[ "$(abduco | tail -n +2)" == $'' ]]; then
+ clear && logout
+ fi
+ continue
+ fi
+
+ windows=( $(printf "%s\n" $window_prompt | sed -e $'s/.*\t//') )
+
+ zcurses init
+
+ function draw_main() {
+ zcurses clear stdscr redraw
+
+ width=$COLUMNS
+
+ zcurses attr stdscr +bold
+
+ if [[ $width -ge 16 ]]; then
+ zcurses move stdscr 0 $(($width / 2 - 8))
+ zcurses string stdscr "select a session"
+ else
+ zcurses move stdscr 0 0
+ zcurses string stdscr "sel"
+ fi
+
+ zcurses attr stdscr -bold
+
+ zcurses move stdscr 2 0
+ zcurses string stdscr $window_prompt
+ }
+
+ trap 'draw_main' WINCH
+
+ draw_main
+
+ input=""
+
+ while true; do
+ zcurses move stdscr $(($#windows + 2 + ($#windows != 0) )) 0
+ zcurses clear stdscr bot
+ zcurses string stdscr "-: $input"
+ zcurses refresh stdscr
+
+ char=""
+ sleep 0
+ zcurses timeout stdscr 100
+ zcurses input stdscr char
+
+ # clear
+ [[ $char == "" || $char == "" ]] && input="" && continue
+
+ # backspace
+ [[ $char == "" && $input != "" ]] && input=${input:0:-1} && continue
+
+ # tab complete
+ if [[ $char == $'\t' ]]; then
+ seen="false"
+
+ for i in {1..$#windows}; do
+ [[ $windows[$i] =~ "^${input}.*$" ]] || continue
+ [[ $seen == "true" ]] && seen="false" && break
+ seen="true"
+ off=$i
+ done
+
+ [[ $seen == "true" ]] && input=$windows[$off]
+
+ continue
+ fi
+
+ # select
+ [[ $char == $'\n' || $char == "" ]] && break
+
+ # add single alphanum
+ [[ $char =~ "^[a-zA-Z0-9]$" ]] || continue
+
+ input="$input$char"
+ done
+
+ zcurses 'end'
+
+ [[ $input == "" ]] && clear && logout
+
+ ABDUCO_SUB=true abduco -A "$input" zsh
+
+ if [[ "$(abduco | tail -n +2)" == $'' ]]; then
+ clear && logout
+ fi
+done