dot

packages and services management
Log | Files | Refs | README

commit e66a10da47b9891386c1c5bca38c124acb487a30
parent 48d28ab6228404fe8c27a181c73892e3f1ffdb79
Author: josuah <mail@josuah.net>
Date:   Fri, 28 Oct 2016 13:00:49 -0400

Simpler buffer script, with tr rather than sed.

Diffstat:
Mbin/buffers | 38++++++++------------------------------
Mshell/.profile | 5+----
2 files changed, 9 insertions(+), 34 deletions(-)

diff --git a/bin/buffers b/bin/buffers @@ -6,7 +6,7 @@ # Manage abduco sessions like buffers. # External: stest (dmenu), iomenu, abduco -# Busybox: mkdir, tee, sort, sed +# Busybox: mkdir, tee, sort, sed, tr help=' Usage: buffers COMMAND @@ -14,7 +14,6 @@ Usage: buffers COMMAND COMMAND r[run] [CMD] Run CMD in an abduco session a[ttach] Interactively prompt buffer to attach, display. - s[ession] Start a wrapper session to start other buffers in. ' NL=' ' TAB=' ' @@ -139,7 +138,7 @@ run() printf '\033]0;%s\007' "$name" # Remove forbidden characters - name="$(printf '%s' "$name" | sed 'y/\//!/')" + name="$(printf '%s' "$name" | tr / !)" # Run new or existing abduco session with this name TERM='screen' ABDUCO="$cmd" abduco -e '^z' -A "$name" $cmd $opt @@ -153,7 +152,7 @@ attach() # If already on a session, print its name and exit. if [ "$ABDUCO" ] then - printf '[ %s ]\n' "$ABDUCO" | sed 'y/!/\//' + printf '[ %s ]\n' "$ABDUCO" | tr ! / exit 1 fi @@ -161,34 +160,17 @@ attach() printf '\033[1A' # Get the session name by prompting the user. - name="$( - abduco | - sed '/session/ d; y/!/\//' | - sort -k 4 | - iomenu | - sed 's/.*\t//; y/\//!/' - )" + name="$(abduco | tail -n +2 | tr ! / | sort -k 4 | iomenu | tr / !)" + name="${name##*$TAB}" + printf '%s\n' "$name" # Set the name of the terminal. - printf '\033]0;%s\007' "$name" | sed 'y/!/\//' + printf '\033]0;%s\007' "$name" | tr ! / # Attach to the session. [ "$name" ] && TERM='screen' ABDUCO="$name" abduco -e '^z' -a "$name" } -# -# Attach or create a master abduco session. -# -session() -{ - clear - - if [ -z "$SESSION" ] - then - SESSION='session' TERM='screen' abduco -e '^\' -A 'session' $@ - fi -} - # ALGORITHM #------------------------------------------------------------------------------- @@ -201,10 +183,6 @@ r | run ) a | attach ) attach ;; -s | session ) - shift - session $@ - ;; * ) printf '%s\n' "$help" exit 0 @@ -213,4 +191,4 @@ esac # Reset the screen, print reminder of current sessions printf '\033[2J\033[0;0f\033[0m\n' -abduco | sed 'y/!/\//' | sort -t "$TAB" -k 3 | sed '1d; s/^/\t/' +abduco | tr ! / | sort -t "$TAB" -k 3 | tail -n +2 diff --git a/shell/.profile b/shell/.profile @@ -49,7 +49,7 @@ alias p='$PAGER' alias a='buffers attach' alias r='buffers run' alias v='buffers run $VISUAL' -alias s='buffers session "$SHELL"' +alias s='buffers run $SHELL' alias t='tmux attach &>/dev/null || tmux new' alias f='find . -type f ! -path "*/.git/*" | sed "s/^\\.\\///" | iomenu' alias d='find . -type d ! -path "*/.git/*" | sed "s/^\\.\\///" | iomenu' @@ -67,6 +67,3 @@ then theme pink setfont "$CONFIG/fonts/terminus/ter-v16b.psf.gz" fi - -# Always run in an abduco session. -buffers session "$SHELL"