summaryrefslogtreecommitdiff
path: root/.local/bin/prompt
diff options
context:
space:
mode:
authorMehdi Sadeghi <mehdi@mehdix.org>2022-06-07 08:06:48 +0200
committerMehdi Sadeghi <mehdi@mehdix.org>2022-06-07 08:57:56 +0200
commitf8759897293de64c101a69bec3af2705b7c84902 (patch)
treee5734dccee1b500acbdd8ce6b36d38873521da7b /.local/bin/prompt
parentdbb661005d7e6ccc0e33316323d02d60062be9a0 (diff)
Separate sh history. Add hist count to prompt.
sh history is written to ~/.sh_history now. The reason is that I am chasing the cause of a history truncation issue.
Diffstat (limited to '.local/bin/prompt')
-rwxr-xr-x.local/bin/prompt3
1 files changed, 2 insertions, 1 deletions
diff --git a/.local/bin/prompt b/.local/bin/prompt
index d4d6592..920a5ef 100755
--- a/.local/bin/prompt
+++ b/.local/bin/prompt
@@ -1,7 +1,8 @@
#!/bin/sh
BRANCH=$(git branch --show-current 2>/dev/null)
BRANCH=$(test -n "$BRANCH" && echo "($BRANCH)")
-PROMPT="$USER@$(cat /proc/sys/kernel/hostname):$( test "$PWD" = $HOME && echo '~' || echo "$PWD")$BRANCH"
+HIST_COUNT=$(grep -v '^#' ~/.bash_history | wc -l)
+PROMPT="$USER@$(cat /proc/sys/kernel/hostname)[$HIST_COUNT]:$( test "$PWD" = $HOME && echo '~' || echo "$PWD")$BRANCH"
case $(id -u) in
0) echo -e "$PROMPT\\n# " ;;
*) echo -e "$PROMPT\\n$ " ;;