summaryrefslogtreecommitdiff
path: root/common/programs/bash.nix
blob: 1ad9e8018515b517b2650c732159fc7be17fbf91 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
{
  programs.bash = {
    enable = true;
    historySize = 10000;
    historyFile = "$HOME/.bash_history";
    historyControl = [
      "ignorespace"
      "erasedups"
    ];
    initExtra = ''
      shopt -s histappend

      bind "set completion-ignore-case on"
      bind "set show-all-if-ambiguous on"

      bind '"\e[Z": menu-complete-backward'

      bind '"\e[A": history-search-backward'
      bind '"\e[B": history-search-forward'


      if [ "$TERM" != "dumb" ] || [ -n "$INSIDE_EMACS" ]; then
       # Removed the '1;' prefix to disable bold
       PROMPT_COLOR="31m"
       ((UID)) && PROMPT_COLOR="32m"

       if [ -n "$INSIDE_EMACS" ]; then
         PS1="\[\033[$PROMPT_COLOR\]\u@\h:\w\\$\[\033[0m\] "
       else
         # PS1="\[\033[$PROMPT_COLOR\]\[\e]0;\u@\h: \w\a\]\u@\h:\w\\$\[\033[0m\] "
         PS1="\[\e[38;5;75m\]\u@\h \[\e[38;5;113m\]\w \[\e[38;5;189m\]\$ \[\e[0m\]"
       fi

       if test "$TERM" = "xterm"; then
         PS1="\[\033]2;\h:\u:\w\007\]$PS1"
       fi
      fi
    '';
  };

}