From 05da4e290c64cfd284f013f7bdf66105cf3c0ff0 Mon Sep 17 00:00:00 2001 From: Jona Reichmann <34141868+jreichmann@users.noreply.github.com> Date: Sat, 23 Dec 2017 00:50:50 +0100 Subject: [PATCH] Polished status bar a bit, added costum prompt to SCM --- .tmux.conf | 4 ++-- costumPrompt.sh | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 costumPrompt.sh diff --git a/.tmux.conf b/.tmux.conf index 33edcd8..a54bb6b 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -12,8 +12,8 @@ set -g set-titles on set -g set-titles-string "tmux: [#H] [#S] [#W:#D #I:#P]" # Install tmux-plugin-manager, first run `git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm` -set -g @plugin 'tmux-plugins/tpm' -set -g @plugin 'tmux-plugins/tmux-sensible' +#set -g @plugin 'tmux-plugins/tpm' +#set -g @plugin 'tmux-plugins/tmux-sensible' # Tweak currently highlighted pane setw -g window-status-current-fg colour236 diff --git a/costumPrompt.sh b/costumPrompt.sh new file mode 100644 index 0000000..40b9808 --- /dev/null +++ b/costumPrompt.sh @@ -0,0 +1,43 @@ +function last_cmd_state { + if [ "$1" == 0 ]; then + echo "\[$(tput setaf 40)\]👍\[$(tput sgr0)\]" + else + if [ "$1" == 127 ]; then + local meaning=" - Not found" + fi + echo "\[$(tput setaf 196)\]👎\\[\$1 "$meaning"\]\[$(tput sgr0)\]" + fi +} + +function list_background_tasks { + local jobs_count=$(jobs | wc -l) + local sessions=$(tmux list-sessions 2>/dev/null | wc -l) + local job_info="" + local session_info="" + if [ ! "$jobs_count" == "0" ]; then + job_info="[Jobs: ${jobs_count}]" + fi + if [ ! "$sessions" == "0" ]; then + session_info="[TMux-Sessions: ${sessions}]" + fi + if [ ! "${job_info}${session_info}" == "0" ]; then + echo " \[$(tput setaf 199)\]╟──\[$(tput sgr0)\]${job_info}${session_info}" + fi +} + +function show_user_info { + echo "\[$(tput setaf 199)\]═╦═\[$(tput sgr0)\][\[$(tput setaf 21)\]\\u\[$(tput sgr0)\]@\[$(tput setaf 40)\]\\H::\\l\[$(tput sgr0)\]]═[\[$(tput setaf 118)\]\\t\[$(tput sgr0)\]]" +} + +function show_location { + echo " \[$(tput setaf 199)\]╟──\[$(tput sgr0)\][\\w]" +} + +function last_line { + echo " \[$(tput setaf 199)\]╙─⚧ \[$(tput sgr0)\]" +} + +function _prompt_command { + local status="$?" + PS1="$(show_user_info)─[$(last_cmd_state $status)]\n$(list_background_tasks)\n$(show_location)\n$(last_line)" +}