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