From 3b1cdbce9dac95e9a93c8acdfdf89a7c5bec565c Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Tue, 11 Nov 2014 11:36:05 +0900 Subject: [PATCH] Show prompt dollars accordiong to SHLVL --- shrc | 15 ++++++++++++--- tmux.conf | 1 + 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/shrc b/shrc index 5a3cc5f..5ba34c5 100755 --- a/shrc +++ b/shrc @@ -637,7 +637,7 @@ memo(){ else _memo="$1/memo.txt" fi - $EDITOR "$_memo" + $EDITOR "$_memo" if test -z "`cat "$_memo"`" then echo "$_memo is empty. Removing." @@ -1193,6 +1193,15 @@ __my_ps1_jobs(){ fi } +__my_ps1_dollar(){ + if test -z "$SHLVL" + then + printf "$1" + else + perl -e 'while($ARGV[0]-- > 0){print "$ARGV[1]";}' $SHLVL "$1" + fi +} + __my_alert_fail(){ test $laststatus -eq 0 || \ echo "STATUS:${laststatus}" @@ -1322,13 +1331,13 @@ if $inzsh then PROMPT="\ ${__my_ps1_beg}[${__my_c2}%n@%M${__my_cdef}:${__my_c1}%~/${__my_cdef}]\$(__my_ps1_info1) -${__my_ps1_beg}\$(__my_ps1_info2) %# " +${__my_ps1_beg}\$(__my_ps1_info2) $(__my_ps1_dollar %#) " RPROMPT="%D{%Y/%m/%d %H:%M}" elif $inbash then PS1="\ ${__my_ps1_beg}[${__my_c2}\u@\H${__my_cdef}:${__my_c1}\w/${__my_cdef}]\$(__my_ps1_info1)\n\ -${__my_ps1_beg}\D{%Y/%m/%d %H:%M} \$(__my_ps1_info2)${__my_ps1_right} \$ " +${__my_ps1_beg}\D{%Y/%m/%d %H:%M} \$(__my_ps1_info2)${__my_ps1_right} $(__my_ps1_dollar \\$) " else true # PS1="$(printf $(whoami)@$(hostname)$ )" diff --git a/tmux.conf b/tmux.conf index 9704cb5..86f777f 100644 --- a/tmux.conf +++ b/tmux.conf @@ -21,6 +21,7 @@ setw -g mode-mouse off #set -g default-command /bin/bash #set -g default-path "$HOME" +set-environment -u SHLVL # try to set title of terminal tmux is running on # set -g set-titles off