]> arthur.barton.de Git - ConfigScripts.git/blob - sys/bashrc
12f19415d48dec7b8739cbcb2c9eb46f461e56f2
[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 #echo "/etc/bash.bashrc ..."
24 BASHRCREAD="true"
25
26 [ -z "$PROFILEREAD" -a -r /etc/profile ] && source /etc/profile
27
28 # Interactive shell?
29 if [ ! "$PS1" ]; then
30         [ -r "/var/lib/$ME/bash.bashrc" ] && source /var/lib/$ME/bash.bashrc
31         return
32 fi
33
34 # Shell options
35 shopt -s checkwinsize
36 shopt -s cdspell
37 shopt -s histappend
38 set mark-directories on
39 set mark-symlinked-directories on
40 HISTCONTROL=ignoredups
41
42 # Shell functions
43 sshnew() {
44         ssh -o "StrictHostKeyChecking no" "$@"
45 }
46 sshtmp() {
47         ssh -o "StrictHostKeyChecking no" -o "UserKnownHostsFile /dev/null" "$@"
48 }
49
50 # Shell prompt
51 prefix="${chroot_name:+($chroot_name)}"
52 [ "$UID" -eq 0 ] \
53         && PS1="${prefix}\h:\w \\\$ " \
54         || PS1="${prefix}\u@\h:\w \\\$ "
55
56 # Enable bash completion, if available
57 [ -r /etc/bash_completion ] && source /etc/bash_completion
58
59 # If the command-not-found package is installed, use it
60 if [ -x /usr/lib/command-not-found ]; then
61         function command_not_found_handle {
62                 # Check because c-n-f could've been removed in the meantime
63                 if [ -x /usr/lib/command-not-found ]; then
64                         /usr/bin/python /usr/lib/command-not-found -- $1
65                         return $?
66                 else
67                         return 127
68                 fi
69         }
70 fi
71
72 # Common command aliases
73 alias ","="clear && logout"
74 alias ".."="cd .."
75 alias "ls"="ls -F"
76 alias "ll"="ls -l"
77 alias "l"="ll -a"
78 alias "lasth"="last | head -n \`expr \\\$LINES - 2\`"
79
80 # less filter
81 type -p lesspipe >/dev/null 2>&1 && eval `lesspipe`
82
83 # Enable color support of ls and also add handy aliases
84 if [ "$TERM" != "dumb" ]; then
85         type -p dircolors >/dev/null 2>&1 && eval `dircolors -b`
86         ls --color / >/dev/null 2>&1
87         if [ $? -eq 0 ]; then
88                 # "GNU style"
89                 alias ls="ls --color=auto -F"
90         else
91                 ls -G / >/dev/null 2>&1
92                 if [ $? -eq 0 ]; then
93                         # "BSD style"
94                         alias ls="ls -FG"
95                 fi
96         fi
97 fi
98
99 # If this is an xterm set the title to user@host:dir
100 case $TERM in
101 xterm*|rxvt|screen)
102         PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
103         ;;
104 *)
105         ;;
106 esac
107
108 # Source local files, if readable
109 [ -r "/etc/bashrc.local" ] && source /etc/bashrc.local
110 [ -r "/etc/bash.bashrc.local" ] && source /etc/bash.bashrc.local
111 [ -r "/var/lib/$ME/bash.bashrc" ] && source /var/lib/$ME/bash.bashrc
112
113 # -eof-