7
7
# By Jeff Bai and Arthur Wang
8
8
9
9
# System wide aliases and functions.
10
- [ " $BASH " ] || alias shopt=false
10
+ [ " $BASH " ] || shopt (){ return ${shopt_def-0} ; }
11
+ _is_posix (){ shopt -oq posix; }
12
+
11
13
# System wide environment variables and startup programs should go into
12
14
# /etc/profile. Personal environment variables and startup programs
13
15
# should go into ~/.bash_profile. Personal aliases and functions should
14
16
# go into ~/.bashrc
15
17
16
18
. /etc/profile
17
19
18
- # Systemd specific, as cutting off output sounds like a silly idea.
19
-
20
- # which(){ (alias; declare -F) | /usr/bin/which -i --read-functions "$@"; }
21
-
22
20
# Provides prompt for non-login shells, specifically shells started
23
21
# in the X environment.
24
22
25
-
26
23
# Make bash append rather than overwrite the history on disk
27
24
# Allows user to edit a failed hist exp.
28
25
# Allows user to verify the results of hist exp.
29
26
shopt -s histappend histreedit histverify
27
+ HISTIGNORE=' &:[bf]g:exit'
28
+ HISTCONTROL=' ignorespace'
30
29
31
30
# When changing directory small typos can be ignored by bash
32
31
# Chdirs into it if command is a dir
@@ -63,8 +62,7 @@ CYAN='\[\e[1;36m\]'
63
62
_ret_prompt () {
64
63
case $? in
65
64
0|130) # Input C-c
66
- printf ' \$'
67
- ;;
65
+ (( EUID)) && printf ' $' || printf ' #' ;;
68
66
127) # Command not found
69
67
printf ' \e[1;36m?'
70
68
;;
@@ -86,9 +84,9 @@ declare -f _repo_status >/dev/null || ! echo _repo_status not declared, making s
86
84
87
85
# Use "\w" if you want the script to display full path
88
86
# How about using cut to "\w($PWD)" to give path of a certain depth?
89
- # Well, forget it.
87
+ # Well, forget it.
90
88
91
- if [[ $EUID == 0 ]] ; then
89
+ if [[ " $EUID " == 0 ]] ; then
92
90
PS1=" $RED \u $NORMAL [ \W\$ (_repo_status) ]$RED \$ (_ret_prompt) $NORMAL "
93
91
else
94
92
PS1=" $GREEN \u $NORMAL [ \W\$ (_repo_status) ]$GREEN \$ (_ret_prompt) $NORMAL "
@@ -103,7 +101,11 @@ alias ...='cd ../..'
103
101
alias ....=' cd ../../..'
104
102
alias nano=' nano -w'
105
103
alias ed=' ed -p: -v' # ED for Eununchs hackers.
104
+ _is_posix || which (){ (alias; declare -F) | /usr/bin/which -i --read-functions " $@ " ; }
106
105
106
+ # Misc stuffs
107
+ FIGNORE=' ~'
108
+ TIMEFORMAT=$' \n real\t %3lR\t %P%%\n user\t %3lU\n sys\t %3lS'
107
109
# Last directory recoding measure.
108
110
_lastdir_go () {
109
111
if [ -s ~ /.last_directory ]; then
0 commit comments