dot

packages and services management
Log | Files | Refs | README

commit fbc1393a9a4e31bfe6e21c4bd09841a3dfe26abd
parent 8505f7104931589167ff4445e96297b4b2eccc08
Author: josuah <mail@josuah.net>
Date:   Sun, 23 Oct 2016 21:42:44 -0400

Updated buffers

Diffstat:
Mbin/buffers | 100+++++++++++++++++++++++++++++++++++++++++++++++--------------------------------
Mbin/fig | 28++++++++++++++++++++++++++++
Mmail/.mailrc | 2+-
Mshell/.profile | 2+-
4 files changed, 89 insertions(+), 43 deletions(-)

diff --git a/bin/buffers b/bin/buffers @@ -6,10 +6,10 @@ # Run commands in detachable buffers # External: stest (dmenu), iomenu, abduco -# Busybox: mkdir, tee, sort, clear, tr, sed +# Busybox: mkdir, tee, sort, tr, sed help=' -USAGE: buffers COMMAND +Usage: buffers COMMAND COMMAND r[run] [CMD] Run CMD in an abduco session @@ -22,33 +22,51 @@ COMMAND #------------------------------------------------------------------------------- # -# Run a command with some arguments in an abduco session +# Update the cache and get the command to run. # -run() +get_command() { - local cmd="$1" opt path - - # Update the cache and get the command + # Get or create the cache file + cache="${XDG_CACHE_HOME:-$HOME/.cache}" + mkdir -p "$cache" + cache="$cache/dmenu_run" + + # Get the command name from cache or stest + if IFS=':' stest -dqr -n "$cache" $PATH + then + stest -flx $PATH | sort -u | tee "$cache" + else + tee < "$cache" + fi | iomenu +} - [ -z "$cmd" ] && cmd="$( - # Get or create the cache file - cache="${XDG_CACHE_HOME:-"$HOME/.cache"}" - mkdir -p "$cache" - cache="$cache/dmenu_run" +# +# Prompt for a file path. +# +path() +{ + local type="$1" + + ( + cd "$HOME" + find . -type "$type" ! -path '*/.git/*' ! -name '.git' | + sed 's/.\///' | + iomenu + ) +} - # Overwrite the prompt - printf '\033[1A' 1>&2 +# +# Run a command with some arguments in an abduco session +# +run() +{ + local cmd="$1" opt path name - # Get the command name from cache or stest - if IFS=':' stest -dqr -n "$cache" $PATH - then - stest -flx $PATH | sort -u | tee "$cache" - else - tee < "$cache" - fi | iomenu - )" + # Overwrite the prompt + printf '\033[1A' 1>&2 # Get command arguments and the session name + [ -z "$cmd" ] && cmd="$(get_command)" case "$cmd" in @@ -73,51 +91,51 @@ run() irc ) opt='-i' ;; - htop | s-nail | rirc | agenda | music ) + htop | mail | mailx | s-nail | rirc | agenda | music ) opt='' ;; # Single-buffer editor vi | vis | less | ex-vi | ex | ed ) - path="$(find . -type f ! -path '*/.git/*' | sed 's/.\///' | iomenu)" - + path="$(path f)" [ -z "$path" ] && exit 1 ;; # Multi-buffer editor vim ) - path="$(find . -type d ! -path '*/.git/*' ! -name .git | sed 's/.\///' | iomenu)" - cd "$path" - + path="$(path d)" [ -z "$path" ] && exit 0 ;; # Else, prompt for command * ) - read -p "$cmd > " opt + read -p "$cmd> " opt if [ -z "${opt##*\**}" -a "$opt" ] then - path="$(find . -type f ! -path '*/.git/*' | sed 's/.\///' | iomenu)" + path="$(path f)" opt="${opt##*\*} $path ${opt%%\**}" - [ -z "$path" ] && exit 1 fi ;; esac - # Make the path name pretty - path="$(cd "$path"; pwd)" - [ -z "${path##$HOME*}" ] && path="~${path#$HOME}" + # Build the name + if [ "$path" ] + then + path="$(cd "$path"; pwd)" + [ -z "${path##$HOME*}" ] && path="~${path#$HOME}" + fi + name="$cmd${path:+ $path}" - # Set the name of the abduco session - printf '\033]0;%s %s\007' "$cmd" "$path" + # Set terminal's name + printf '\033]0;%s\007' "$name" - # Remove nasty chars from abduco session name - path="$(printf '%s' "$path" | tr '/' '!')" + # Remove forbidden characters + name="$(printf '%s' "$name" | tr '/' '!')" # Run new or existing abduco session with this name - TERM=screen ABDUCO="$cmd" abduco -e '^z' -A "$cmd $path" $cmd $opt + TERM=screen ABDUCO="$cmd" abduco -e '^z' -A "$name" $cmd $opt } # @@ -159,7 +177,7 @@ a | attach ) exit 0 ;; esac -# + # Reset the screen, print reminder of current sessions printf '\033[2J\033[0;0f\033[0m\n' -abduco | tr '!' '/' | sort -t "$TAB" -k 3 | sed '1d; s/^/ /' +abduco | tr '!' '/' | sort -t "$TAB" -k 3 | sed '1d; s/^/\t/' diff --git a/bin/fig b/bin/fig @@ -622,6 +622,13 @@ fi | fold -w 1 | { l4="$l4"" ' " l5="$l5"' ' ;; + Q) + l1="$l1"' ,--.' + l2="$l2"' | |' + l3="$l3"' | |' + l4="$l4"' `--\' + l5="$l5"' ' + ;; R) l1="$l1"' ---.' l2="$l2"" |__'" @@ -762,6 +769,27 @@ fi | fold -w 1 | { l4="$l4"' *' l5="$l5"' ' ;; + '`') + l1="$l1"' \ ' + l2="$l2"' \' + l3="$l3"' ' + l4="$l4"' ' + l5="$l5"' ' + ;; + "'") + l1="$l1"' |' + l2="$l2"' |' + l3="$l3"' ' + l4="$l4"' ' + l5="$l5"' ' + ;; + '"') + l1="$l1"' | |' + l2="$l2"' | |' + l3="$l3"' ' + l4="$l4"' ' + l5="$l5"' ' + ;; ' ') l1="$l1"' ' l2="$l2"' ' diff --git a/mail/.mailrc b/mail/.mailrc @@ -16,7 +16,7 @@ set keepsave #------------------------------------------------------------------------------- # Do not send output to pager under this number of line, and also add colours if -set crt=10000 colour-pager +set crt colour-pager # Startup into interactive mode even if the (given) mailbox is empty set emptystart diff --git a/shell/.profile b/shell/.profile @@ -96,7 +96,7 @@ alias l='ls -F --color' alias ll='l -lh' alias la='l -A' alias lla='l -Alh' -alias m='$PAGER' +alias p='$PAGER' alias a='buffers attach' alias r='buffers run' alias v='buffers run $VISUAL'