dot

packages and services management
Log | Files | Refs | README

commit e4cd5dd569887c845be124f509b33ca763bcd039
parent 86c1d370f19a8c2cf9f85049f23410bdfb4fb7a6
Author: josuah <mail@josuah.net>
Date:   Tue,  1 Nov 2016 04:45:55 -0400

Added status line everywhere

Diffstat:
Mbin/buffers | 2+-
Abin/status | 35+++++++++++++++++++++++++++++++++++
Mdvtm/dvtm-status | 8++++----
Mshell/.profile | 65+++++++++++++++++++++++++++++++++++++++++++++++++++++++----------
Mxorg/.xinitrc | 8++++----
5 files changed, 99 insertions(+), 19 deletions(-)

diff --git a/bin/buffers b/bin/buffers @@ -190,7 +190,7 @@ main() esac # reset the screen, print reminder of current sessions - printf '\033[2J\033[0;0f\033[0m\n' + printf '\033[2J\033[2;0f\033[0m\n' abduco | tr ! / | sort -t "$TAB" -k 3 | sed 1d } diff --git a/bin/status b/bin/status @@ -0,0 +1,35 @@ +#!/bin/sh +# | | +# ,--- |-- ,--. |-- , , ,--- +# `--. | ,--| | | | `--. +# ---' ' `--` ' `--` ---' 2016-11-01 +#------------------------------------------------------------------------------- +# Plain text status line for wherever useful + +BLACK=0 RED=1 GREEN=2 YELLOW=3 BLUE=4 MAGENTA=5 CYAN=6 WHITE=7 + +mail="$( + count="$(find "$MAIL/new" -type f 2>/dev/null | wc -l)" + [ "$count" -gt 0 ] && printf '%s mails' "$count" +)" + +date="$( + date +'%Y-%m-%d %H:%M' +)" + +battery="$( + cat "$(find -L /sys/class/ -maxdepth 3 -name capacity 2> /dev/null)" +)%" + +main() { + while [ "$#" -gt 0 ] + do + printf '%s' "$1" + + [ "$1" -a "$#" -gt 1 ] && printf ' | ' + + shift + done +} + +main "$mail" "$battery" "$date" diff --git a/dvtm/dvtm-status b/dvtm/dvtm-status @@ -1,15 +1,15 @@ #!/bin/sh -STATUS_FIFO="/tmp/dvtm-status.$$" -CMD_FIFO="/tmp/dvtm-cmd.$$" +export STATUS_FIFO="/tmp/dvtm-status.$$" +export CMD_FIFO="/tmp/dvtm-cmd.$$" [ -p "$STATUS_FIFO" ] || mkfifo -m 600 "$STATUS_FIFO" || exit 1 [ -p "$CMD_FIFO" ] || mkfifo -m 600 "$CMD_FIFO" || exit 1 while true do - printf '%s\n' "$(date +'%d/%m/%y %H:%M')" - sleep 30 + status + sleep 10 done > "$STATUS_FIFO" & STATUS_PID=$! diff --git a/shell/.profile b/shell/.profile @@ -17,22 +17,67 @@ #------------------------------------------------------------------------------- PS1='$( - code="$?" + ps1 "$?" +)' +PS2=' > ' +PS3=' > ' + +ps1() +{ + local code="$1" pwd status col color pwd="$(pwd)" - # Error code + # Path + [ -z "${pwd##$HOME*}" ] && pwd="~${pwd#$HOME}" + + # Error code and actual prompt [ "$code" -eq 0 ] && color=32 || color=31 printf "\n \033[1;30m>\033[0;%sm>\033[1m>\033[0m " "$color" - # Print path - [ -z "${PWD##$HOME*}" ] && pwd="~${PWD#$HOME}" || pwd="$PWD" - printf "\033]0;%s\007" "$pwd" - - # Update tmux status line at each new prompt + # tmux/dvtm status line [ "$TMUX" ] && tmux refresh-client -S -)' -PS2=' > ' -PS3=' > ' + [ "$DVTM" ] && status > "$STATUS_FIFO" + + # Terminal name + printf "\033]0;%s %s\007" "$pwd" "$git" + + # Status line + local status="$(status)" + local col="$(stty size | cut -d ' ' -f 2)" + printf '\033[s\033[0;0H\033[K' + printf '\033[%sC%s' "$(($col - ${#status}))" "$status" + printf '\033[0;0H%s %s' "$pwd" "$(git_status)" + printf '\033[u' +} + +git_status() +{ + # Git status + if git rev-parse &> /dev/null + then + local branch="$(git branch | sed -n 's/^\* // p')" + local status="$(git status --porcelain)" + + local M="$(printf %s "$status" | grep '^ M' | wc -l)" + local A="$(printf %s "$status" | grep '^ A' | wc -l)" + local D="$(printf %s "$status" | grep '^ D' | wc -l)" + local R="$(printf %s "$status" | grep '^ R' | wc -l)" + local U="$(printf %s "$status" | grep '^??' | wc -l)" + + [ "${M#0}" ] && M=" \033[33m~$M\033[0m" || M='' + [ "${A#0}" ] && A=" \033[32m+$A\033[0m" || A='' + [ "${D#0}" ] && D=" \033[31m-$D\033[0m" || D='' + [ "${R#0}" ] && R=" \033[36m>$R\033[0m" || R='' + [ "${U#0}" ] && U=" \033[34m?$U\033[0m" || U='' + + printf "\033[1m$branch\033\0m$M$D$U" + fi +} + +while true +do + sleep 10 +done & # ALIAS #------------------------------------------------------------------------------- diff --git a/xorg/.xinitrc b/xorg/.xinitrc @@ -1,16 +1,16 @@ #!/bin/sh setxkbmap -layout us -option compose:ralt -variant dvorak +feh --bg-fill ~/Images/interstellar-2.png while true do - xsetroot -name "$(date +'%y-%m-%d %H:%M')" - sleep 20 + xsetroot -name "$(status)" + sleep 10 done & - nm-applet & xfce4-power-manager & -feh --bg-fill ~/Images/interstellar-2.png unagi & +st & exec dwm