]> arthur.barton.de Git - ConfigScripts.git/blob - sys/bashrc
Don't read /var/lib/$ME/bash.bashrc in non-interactive shells
[ConfigScripts.git] / sys / bashrc
1 #
2 # /etc/bash.bashrc: System-wide rc file for interactive bash(1) shells.
3 # Written 2003-2010 by Alexander Barton (alex@barton.de)
4 #
5
6 [ -e ~/.ConfigScripts.debug ] && echo " >> /etc/bash.bashrc ..."
7
8 BASHRCREAD="true"
9
10 [ -z "$PROFILEREAD" -a -r /etc/profile ] && source /etc/profile
11
12 # Interactive shell?
13 [ "$PS1" ] || return
14
15 # Shell options
16 shopt -s checkwinsize
17 shopt -s cdspell
18 shopt -s histappend
19 set mark-directories on
20 set mark-symlinked-directories on
21 HISTCONTROL=ignoredups
22
23 # Shell functions
24 sshnew() {
25         ssh -o "StrictHostKeyChecking no" "$@"
26 }
27 sshtmp() {
28         ssh -o "StrictHostKeyChecking no" -o "UserKnownHostsFile /dev/null" "$@"
29 }
30
31 # Shell prompt
32 [ "$UID" -eq 0 ] \
33         && PS1="\h:\w \\\$ " \
34         || PS1="\u@\h:\w \\\$ "
35 if [ "\$(type -t __git_ps1)" ]; then
36         PS1="\$(__git_ps1 '(%s) ')$PS1"
37 fi
38 PS1="${chroot_name:+[$chroot_name] }$PS1"
39
40 # Enable bash completion, if available
41 [ -z "$BASH_COMPLETION" -a -r /etc/bash_completion ] \
42         && source /etc/bash_completion
43 [ -z "$BASH_COMPLETION" -a -r /opt/homebrew/etc/bash_completion ] \
44         && source /opt/homebrew/etc/bash_completion
45 [ -z "$BASH_COMPLETION" -a -r /opt/local/etc/bash_completion ] \
46         && source /opt/local/etc/bash_completion
47
48 # If the command-not-found package is installed, use it
49 if [ -r /etc/bash_command_not_found ]; then
50         . /etc/bash_command_not_found
51 elif [ -x /usr/lib/command-not-found ]; then
52         function command_not_found_handle {
53                 # Check because c-n-f could've been removed in the meantime
54                 if [ -x /usr/lib/command-not-found ]; then
55                         /usr/bin/python /usr/lib/command-not-found -- $1
56                         return $?
57                 else
58                         return 127
59                 fi
60         }
61 fi
62
63 # Common command aliases
64 alias ","="clear && logout"
65 alias ".."="cd .."
66 alias "ls"="ls -F"
67 alias "ll"="ls -l"
68 alias "l"="ll -a"
69 alias "lasth"="last | head -n \`expr \\\$LINES - 2\`"
70
71 # Aliases for screen(1), if installed
72 type -p screen >/dev/null 2>&1
73 if [ $? -eq 0 ]; then
74         alias "s"="screen"
75         alias "sr"="screen -dr"
76         alias "sx"="screen -x"
77 fi
78
79 # less(1) filter, if available
80 type -p lesspipe >/dev/null 2>&1 && eval `lesspipe`
81
82 # Initialize ccache(1), if installed
83 if [ -d "/usr/lib/ccache" ]; then
84         PATH="/usr/lib/ccache:$PATH"
85         # Set the cache directory to local storage, if available
86         [ -w "/usr/local/home/$USER" ] \
87                 && export CCACHE_DIR="/usr/local/home/$USER/.ccache"
88 fi
89
90 # Setup slrn(1) and cleanscore(1), if installed
91 type -p cleanscore >/dev/null 2>&1
92 [ $? -eq 0 ] && alias slrn="cleanscore -f ~/.slrnscore && slrn"
93
94 # Enable color support of ls(1) and also add handy aliases
95 if [ "$TERM" != "dumb" ]; then
96         type -p dircolors >/dev/null 2>&1 && eval `dircolors -b`
97         ls --color / >/dev/null 2>&1
98         if [ $? -eq 0 ]; then
99                 # "GNU style"
100                 alias ls="ls --color=auto -F"
101         else
102                 ls -G / >/dev/null 2>&1
103                 if [ $? -eq 0 ]; then
104                         # "BSD style"
105                         alias ls="ls -FG"
106                 fi
107         fi
108 fi
109
110 # If this is an xterm set the title to user@host:dir
111 case $TERM in
112 xterm*|rxvt|screen)
113         PROMPT_COMMAND='printf "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
114         ;;
115 *)
116         ;;
117 esac
118
119 # Source local files, if readable
120 [ -r "/etc/bashrc.local" ] && source /etc/bashrc.local
121 [ -r "/etc/bash.bashrc.local" ] && source /etc/bash.bashrc.local
122 [ -r "/var/lib/$ME/bash.bashrc" ] && source /var/lib/$ME/bash.bashrc
123
124 # -eof-