]> arthur.barton.de Git - ConfigScripts.git/blob - sys/bashrc
fe509e369ccf3c7d30a3781d7236933e098e9b08
[ConfigScripts.git] / sys / bashrc
1 #
2 # /etc/bash.bashrc: System-wide rc file for interactive bash(1) shells.
3 #
4 # 2008-08-07, alex@barton.de
5 #  - ls: Detech BSD color support (-G).
6 #  - Support /etc/chroot_name
7 # 2008-07-09, alex@barton.de
8 #  - Added support for /usr/lib/command-not-found.
9 # 2008-06-06, alex@barton.de
10 #  - Source /etc/[bash].bashrc.local as well, if readable.
11 # 2007-04-05, alex@barton.de
12 #  - Define shell functions sshtmp() and sshnew().
13 # 2006-01-04, alex@barton.de
14 #  - Only call dircolors(1) and lesspipe(1) if they are available.
15 #  - Check wether ls(1) knows something about "--color".
16 # 2005-12-29, alex@barton.de
17 #  - Enabled bash completion
18 # 2004-09-13, alex@Arthur.Ath.CX
19 #  - Made script more generic ...
20 # 2004-05-27, alex@Arthur.Ath.CX
21 #
22
23 [ -e /tmp/ConfigDebug.$USER ] && echo " >> /etc/bash.bashrc ..."
24
25 BASHRCREAD="true"
26
27 [ -z "$PROFILEREAD" -a -r /etc/profile ] && source /etc/profile
28
29 # Interactive shell?
30 if [ ! "$PS1" ]; then
31         [ -r "/var/lib/$ME/bash.bashrc" ] && source /var/lib/$ME/bash.bashrc
32         return
33 fi
34
35 # Shell options
36 shopt -s checkwinsize
37 shopt -s cdspell
38 shopt -s histappend
39 set mark-directories on
40 set mark-symlinked-directories on
41 HISTCONTROL=ignoredups
42
43 # Shell functions
44 sshnew() {
45         ssh -o "StrictHostKeyChecking no" "$@"
46 }
47 sshtmp() {
48         ssh -o "StrictHostKeyChecking no" -o "UserKnownHostsFile /dev/null" "$@"
49 }
50
51 # Shell prompt
52 prefix="${chroot_name:+($chroot_name)}"
53 [ "$UID" -eq 0 ] \
54         && PS1="${prefix}\h:\w \\\$ " \
55         || PS1="${prefix}\u@\h:\w \\\$ "
56
57 # Enable bash completion, if available
58 [ -r /etc/bash_completion ] && source /etc/bash_completion
59
60 # If the command-not-found package is installed, use it
61 if [ -x /usr/lib/command-not-found ]; then
62         function command_not_found_handle {
63                 # Check because c-n-f could've been removed in the meantime
64                 if [ -x /usr/lib/command-not-found ]; then
65                         /usr/bin/python /usr/lib/command-not-found -- $1
66                         return $?
67                 else
68                         return 127
69                 fi
70         }
71 fi
72
73 # Common command aliases
74 alias ","="clear && logout"
75 alias ".."="cd .."
76 alias "ls"="ls -F"
77 alias "ll"="ls -l"
78 alias "l"="ll -a"
79 alias "lasth"="last | head -n \`expr \\\$LINES - 2\`"
80
81 # less filter
82 type -p lesspipe >/dev/null 2>&1 && eval `lesspipe`
83
84 # Enable color support of ls and also add handy aliases
85 if [ "$TERM" != "dumb" ]; then
86         type -p dircolors >/dev/null 2>&1 && eval `dircolors -b`
87         ls --color / >/dev/null 2>&1
88         if [ $? -eq 0 ]; then
89                 # "GNU style"
90                 alias ls="ls --color=auto -F"
91         else
92                 ls -G / >/dev/null 2>&1
93                 if [ $? -eq 0 ]; then
94                         # "BSD style"
95                         alias ls="ls -FG"
96                 fi
97         fi
98 fi
99
100 # If this is an xterm set the title to user@host:dir
101 case $TERM in
102 xterm*|rxvt|screen)
103         PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
104         ;;
105 *)
106         ;;
107 esac
108
109 # Source local files, if readable
110 [ -r "/etc/bashrc.local" ] && source /etc/bashrc.local
111 [ -r "/etc/bash.bashrc.local" ] && source /etc/bash.bashrc.local
112 [ -r "/var/lib/$ME/bash.bashrc" ] && source /var/lib/$ME/bash.bashrc
113
114 # -eof-