Created
April 18, 2012 12:21
-
-
Save pstray/2413207 to your computer and use it in GitHub Desktop.
Statusbar prompt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_status_init() { | |
_status_line=$(tput lines) | |
echo -ne "\e[s\e[1;$[_status_line-1]r\e[u" | |
} | |
_status_set() { | |
[ -z "$_status_line" ] && _status_init | |
_status_data="$(echo -ne "\e[s\e[$_status_line;1H\e[1;44;36m[\e[37m$(date +%H:%M)\e[36m][\e[37mstatus...\e[36m]\e[K\e[u")" | |
} | |
_add_prompt_cmd _status_set 99 | |
_winch_hook() { | |
local lines=$(tput lines) | |
if [ -n "$_status_line" ]; then | |
echo -ne "\e[s" | |
echo -ne "\e[$lines;1H\e[K" | |
_status_line=$lines | |
echo -ne "\e[1;$[_status_line-1]r" | |
echo -ne "\e[u" | |
fi | |
} | |
trap -- _winch_hook SIGWINCH | |
PS1="\[\$_status_data\]$PS1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment