summaryrefslogtreecommitdiff
path: root/config/bash.nix
diff options
context:
space:
mode:
authorRaghuram Subramani <raghus2247@gmail.com>2024-06-02 09:43:20 +0530
committerRaghuram Subramani <raghus2247@gmail.com>2024-06-02 09:43:20 +0530
commit4050ba0a89a3a97b29d4f281b7570495cf5596d9 (patch)
treef0473e4a555db3b2ea1f8fa8b474c196fd3b72db /config/bash.nix
parent74c3f173fb766190c6cef3cb93ebc88f596249fc (diff)
update
Diffstat (limited to 'config/bash.nix')
-rw-r--r--config/bash.nix19
1 files changed, 18 insertions, 1 deletions
diff --git a/config/bash.nix b/config/bash.nix
index 56adf63..e8eaccf 100644
--- a/config/bash.nix
+++ b/config/bash.nix
@@ -2,7 +2,24 @@
programs.bash = {
enable = true;
initExtra= ''
- export PS1="\[\e[38;5;243m\]\h \[\e[38;5;254m\]\w \[\033[0m\]> "
+ function timer_start {
+ timer=$\{timer:-$SECONDS}
+ }
+
+ function timer_stop {
+ timer_show=$(($SECONDS - $timer))
+ unset timer
+ }
+
+ trap 'timer_start' DEBUG
+
+ if [ "$PROMPT_COMMAND" == "" ]; then
+ PROMPT_COMMAND="timer_stop"
+ else
+ PROMPT_COMMAND="$PROMPT_COMMAND; timer_stop"
+ fi
+ export PS1='\[\e[38;5;243m\]($\{timer_show}s) \h \[\e[38;5;254m\]\w \[\033[0m\]> '
+
bind "set completion-ignore-case on"
if [[ -n "$IN_NIX_SHELL" ]]; then