]> arthur.barton.de Git - ConfigScripts.git/blob - sys/bashrc
77bc8372866f75732f7d23e448c8a32282e5c47e
[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 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 [ "$UID" -eq 0 ] \
36         && PS1="\h:\w \\\$ " \
37         || PS1="\u@\h:\w \\\$ "
38 if [ "\$(type -t __git_ps1)" ]; then
39         PS1="\$(__git_ps1 '(%s) ')$PS1"
40 fi
41 PS1="${chroot_name:+[$chroot_name] }$PS1"
42
43 # Enable bash completion, if available
44 [ -z "$BASH_COMPLETION" -a -r /etc/bash_completion ] \
45         && source /etc/bash_completion
46 [ -z "$BASH_COMPLETION" -a -r /opt/homebrew/etc/bash_completion ] \
47         && source /opt/homebrew/etc/bash_completion
48 [ -z "$BASH_COMPLETION" -a -r /opt/local/etc/bash_completion ] \
49         && source /opt/local/etc/bash_completion
50
51 # If the command-not-found package is installed, use it
52 if [ -r /etc/bash_command_not_found ]; then
53         . /etc/bash_command_not_found
54 elif [ -x /usr/lib/command-not-found ]; then
55         function command_not_found_handle {
56                 # Check because c-n-f could've been removed in the meantime
57                 if [ -x /usr/lib/command-not-found ]; then
58                         /usr/bin/python /usr/lib/command-not-found -- $1
59                         return $?
60                 else
61                         return 127
62                 fi
63         }
64 fi
65
66 # Common command aliases
67 alias ","="clear && logout"
68 alias ".."="cd .."
69 alias "ls"="ls -F"
70 alias "ll"="ls -l"
71 alias "l"="ll -a"
72 alias "lasth"="last | head -n \`expr \\\$LINES - 2\`"
73
74 # Aliases for screen(1), if installed
75 type -p screen >/dev/null 2>&1
76 if [ $? -eq 0 ]; then
77         alias "s"="screen"
78         alias "sr"="screen -dr"
79         alias "sx"="screen -x"
80 fi
81
82 # less(1) filter, if available
83 type -p lesspipe >/dev/null 2>&1 && eval `lesspipe`
84
85 # Initialize ccache(1), if installed
86 if [ -d "/usr/lib/ccache" ]; then
87         PATH="/usr/lib/ccache:$PATH"
88         # Set the cache directory to local storage, if available
89         [ -w "/usr/local/home/$USER" ] \
90                 && export CCACHE_DIR="/usr/local/home/$USER/.ccache"
91 fi
92
93 # Setup slrn(1) and cleanscore(1), if installed
94 type -p cleanscore >/dev/null 2>&1
95 [ $? -eq 0 ] && alias slrn="cleanscore -f ~/.slrnscore && slrn"
96
97 # Enable color support of ls(1) and also add handy aliases
98 if [ "$TERM" != "dumb" ]; then
99         type -p dircolors >/dev/null 2>&1 && eval `dircolors -b`
100         ls --color / >/dev/null 2>&1
101         if [ $? -eq 0 ]; then
102                 # "GNU style"
103                 alias ls="ls --color=auto -F"
104         else
105                 ls -G / >/dev/null 2>&1
106                 if [ $? -eq 0 ]; then
107                         # "BSD style"
108                         alias ls="ls -FG"
109                 fi
110         fi
111 fi
112
113 # If this is an xterm set the title to user@host:dir
114 case $TERM in
115 xterm*|rxvt|screen)
116         PROMPT_COMMAND='printf "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
117         ;;
118 *)
119         ;;
120 esac
121
122 # Source local files, if readable
123 [ -r "/etc/bashrc.local" ] && source /etc/bashrc.local
124 [ -r "/etc/bash.bashrc.local" ] && source /etc/bash.bashrc.local
125 [ -r "/var/lib/$ME/bash.bashrc" ] && source /var/lib/$ME/bash.bashrc
126
127 # -eof-