Commit 1da0424efb9aa77073d20b10de823279d0dded1e
1 parent
ac784730c8
Exists in
master
and in
2 other branches
bashrc: small changes
Showing 1 changed file with 7 additions and 1 deletions Inline Diff
templates/bashrc.sh
| 1 | #@IgnoreInspection AddShebang | 1 | #@IgnoreInspection AddShebang |
| 2 | 2 | ||
| 3 | export ZCFG=$HOME/.config/zsh-config | 3 | export ZCFG=$HOME/.config/zsh-config |
| 4 | 4 | ||
| 5 | # If not running interactively, don't do anything | 5 | # If not running interactively, don't do anything |
| 6 | case $- in | 6 | case $- in |
| 7 | *i*) ;; | 7 | *i*) ;; |
| 8 | *) return;; | 8 | *) return;; |
| 9 | esac | 9 | esac |
| 10 | 10 | ||
| 11 | ######################## | 11 | ######################## |
| 12 | # ******************** # | 12 | # ******************** # |
| 13 | # * * # | 13 | # * * # |
| 14 | # * COMPLETION * # | 14 | # * COMPLETION * # |
| 15 | # * * # | 15 | # * * # |
| 16 | # ******************** # | 16 | # ******************** # |
| 17 | ######################## | 17 | ######################## |
| 18 | 18 | ||
| 19 | # enable bash completion in interactive shells | 19 | # enable bash completion in interactive shells |
| 20 | if [ -f /etc/bash_completion ]; then | 20 | if [ -f /etc/bash_completion ]; then |
| 21 | . /etc/bash_completion | 21 | . /etc/bash_completion |
| 22 | fi | 22 | fi |
| 23 | 23 | ||
| 24 | # if the command-not-found package is installed, use it | 24 | # if the command-not-found package is installed, use it |
| 25 | if [ -x /usr/lib/command-not-found ]; then | 25 | if [ -x /usr/lib/command-not-found ]; then |
| 26 | function command_not_found_handle { | 26 | function command_not_found_handle { |
| 27 | # check because c-n-f could've been removed in the meantime | 27 | # check because c-n-f could've been removed in the meantime |
| 28 | if [ -x /usr/lib/command-not-found ]; then | 28 | if [ -x /usr/lib/command-not-found ]; then |
| 29 | /usr/bin/python /usr/lib/command-not-found -- $1 | 29 | /usr/bin/python /usr/lib/command-not-found -- $1 |
| 30 | return $? | 30 | return $? |
| 31 | else | 31 | else |
| 32 | return 127 | 32 | return 127 |
| 33 | fi | 33 | fi |
| 34 | } | 34 | } |
| 35 | fi | 35 | fi |
| 36 | 36 | ||
| 37 | ######################## | 37 | ######################## |
| 38 | # ******************** # | 38 | # ******************** # |
| 39 | # * * # | 39 | # * * # |
| 40 | # * HISTORY * # | 40 | # * HISTORY * # |
| 41 | # * * # | 41 | # * * # |
| 42 | # ******************** # | 42 | # ******************** # |
| 43 | ######################## | 43 | ######################## |
| 44 | 44 | ||
| 45 | # Eternal bash history. | 45 | # Eternal bash history. |
| 46 | # --------------------- | 46 | # --------------------- |
| 47 | export HISTFILESIZE= | 47 | export HISTFILESIZE= |
| 48 | export HISTSIZE= | 48 | export HISTSIZE= |
| 49 | export HISTTIMEFORMAT="[%F %T] " | 49 | export HISTTIMEFORMAT="[%F %T] " |
| 50 | # Change the file location | 50 | # Change the file location |
| 51 | export HISTFILE=~/.config/new_bash_history | 51 | export HISTFILE=~/.config/new_bash_history |
| 52 | # Force prompt to write history after every command | 52 | # Force prompt to write history after every command |
| 53 | PROMPT_COMMAND="history -a; $PROMPT_COMMAND" | 53 | PROMPT_COMMAND="history -a; $PROMPT_COMMAND" |
| 54 | 54 | ||
| 55 | ######################## | ||
| 56 | # ******************** # | ||
| 57 | # * * # | ||
| 58 | # * MISC * # | ||
| 59 | # * * # | ||
| 60 | # ******************** # | ||
| 61 | ######################## | ||
| 55 | 62 | ||
| 56 | # check the window size after each command | 63 | # check the window size after each command |
| 57 | shopt -s checkwinsize | 64 | shopt -s checkwinsize |
| 58 | 65 | ||
| 59 | # If set, the pattern "**" used in a pathname expansion context will | 66 | # If set, the pattern "**" used in a pathname expansion context will |
| 60 | # match all files and zero or more directories and subdirectories. | 67 | # match all files and zero or more directories and subdirectories. |
| 61 | #shopt -s globstar | 68 | #shopt -s globstar |
| 62 | 69 | ||
| 63 | # set variable identifying the chroot you work in (used in the prompt below) | 70 | # set variable identifying the chroot you work in (used in the prompt below) |
| 64 | if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then | 71 | if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then |
| 65 | debian_chroot=$(cat /etc/debian_chroot) | 72 | debian_chroot=$(cat /etc/debian_chroot) |
| 66 | fi | 73 | fi |
| 67 | 74 | ||
| 68 | # set a fancy prompt | 75 | # set a fancy prompt |
| 69 | case "$TERM" in | 76 | case "$TERM" in |
| 70 | xterm-color) color_prompt=yes;; | 77 | xterm-color) color_prompt=yes;; |
| 71 | esac | 78 | esac |
| 72 | 79 | ||
| 73 | # colored prompt | 80 | # colored prompt |
| 74 | force_color_prompt=yes | 81 | force_color_prompt=yes |
| 75 | 82 | ||
| 76 | if [ -n "$force_color_prompt" ]; then | 83 | if [ -n "$force_color_prompt" ]; then |
| 77 | if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then | 84 | if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then |
| 78 | # We have color support; assume it's compliant with Ecma-48 | 85 | # We have color support; assume it's compliant with Ecma-48 |
| 79 | # (ISO/IEC-6429). (Lack of such support is extremely rare, and such | 86 | # (ISO/IEC-6429). (Lack of such support is extremely rare, and such |
| 80 | # a case would tend to support setf rather than setaf.) | 87 | # a case would tend to support setf rather than setaf.) |
| 81 | color_prompt=yes | 88 | color_prompt=yes |
| 82 | else | 89 | else |
| 83 | color_prompt= | 90 | color_prompt= |
| 84 | fi | 91 | fi |
| 85 | fi | 92 | fi |
| 86 | 93 | ||
| 87 | if [ "$color_prompt" = yes ]; then | 94 | if [ "$color_prompt" = yes ]; then |
| 88 | PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' | 95 | PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' |
| 89 | else | 96 | else |
| 90 | PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' | 97 | PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' |
| 91 | fi | 98 | fi |
| 92 | #unset color_prompt force_color_prompt | 99 | #unset color_prompt force_color_prompt |
| 93 | 100 | ||
| 94 | # enable color support of ls and also add handy aliases | 101 | # enable color support of ls and also add handy aliases |
| 95 | if [ -x /usr/bin/dircolors ]; then | 102 | if [ -x /usr/bin/dircolors ]; then |
| 96 | test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" | 103 | test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" |
| 97 | alias ls='ls --color=auto' | 104 | alias ls='ls --color=auto' |
| 98 | alias dir='dir --color=auto' | 105 | alias dir='dir --color=auto' |
| 99 | alias vdir='vdir --color=auto' | 106 | alias vdir='vdir --color=auto' |
| 100 | 107 | ||
| 101 | alias grep='grep --color=auto' | 108 | alias grep='grep --color=auto' |
| 102 | alias fgrep='fgrep --color=auto' | 109 | alias fgrep='fgrep --color=auto' |
| 103 | alias egrep='egrep --color=auto' | 110 | alias egrep='egrep --color=auto' |
| 104 | fi | 111 | fi |
| 105 | 112 | ||
| 106 | # Environment | 113 | # Environment |
| 107 | if [ -f $ZCFG/dotfiles/environment.sh ]; then | 114 | if [ -f $ZCFG/dotfiles/environment.sh ]; then |
| 108 | . $ZCFG/dotfiles/environment.sh | 115 | . $ZCFG/dotfiles/environment.sh |
| 109 | fi | 116 | fi |
| 110 | 117 | ||
| 111 | |||
| 112 | # Alias definitions | 118 | # Alias definitions |
| 113 | if [ -f $ZCFG/templates/bash_aliases.sh ]; then | 119 | if [ -f $ZCFG/templates/bash_aliases.sh ]; then |
| 114 | . $ZCFG/templates/bash_aliases.sh | 120 | . $ZCFG/templates/bash_aliases.sh |
| 115 | fi | 121 | fi |
| 116 | 122 | ||
| 117 | # Start zsh if in OpenVZ CT | 123 | # Start zsh if in OpenVZ CT |
| 118 | if [ -d /proc/vz ] && [ ! -d /proc/vz/beancounter ]; then | 124 | if [ -d /proc/vz ] && [ ! -d /proc/vz/beancounter ]; then |
| 119 | cd && zsh && exit | 125 | cd && zsh && exit |
| 120 | fi | 126 | fi |