Skip to content

Commit 83e69b6

Browse files
committed
bashrc: hist, bashvars, POSIX test
1 parent 142c166 commit 83e69b6

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

bashrc

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,25 @@
77
# By Jeff Bai and Arthur Wang
88

99
# System wide aliases and functions.
10-
[ "$BASH" ] || alias shopt=false
10+
[ "$BASH" ] || shopt(){ return ${shopt_def-0}; }
11+
_is_posix(){ shopt -oq posix; }
12+
1113
# System wide environment variables and startup programs should go into
1214
# /etc/profile. Personal environment variables and startup programs
1315
# should go into ~/.bash_profile. Personal aliases and functions should
1416
# go into ~/.bashrc
1517

1618
. /etc/profile
1719

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-
2220
# Provides prompt for non-login shells, specifically shells started
2321
# in the X environment.
2422

25-
2623
# Make bash append rather than overwrite the history on disk
2724
# Allows user to edit a failed hist exp.
2825
# Allows user to verify the results of hist exp.
2926
shopt -s histappend histreedit histverify
27+
HISTIGNORE='&:[bf]g:exit'
28+
HISTCONTROL='ignorespace'
3029

3130
# When changing directory small typos can be ignored by bash
3231
# Chdirs into it if command is a dir
@@ -63,8 +62,7 @@ CYAN='\[\e[1;36m\]'
6362
_ret_prompt() {
6463
case $? in
6564
0|130) # Input C-c
66-
printf '\$'
67-
;;
65+
((EUID)) && printf '$' || printf '#' ;;
6866
127) # Command not found
6967
printf '\e[1;36m?'
7068
;;
@@ -86,9 +84,9 @@ declare -f _repo_status >/dev/null || ! echo _repo_status not declared, making s
8684

8785
# Use "\w" if you want the script to display full path
8886
# How about using cut to "\w($PWD)" to give path of a certain depth?
89-
# Well, forget it.
87+
# Well, forget it.
9088

91-
if [[ $EUID == 0 ]] ; then
89+
if [[ "$EUID" == 0 ]] ; then
9290
PS1="$RED\u $NORMAL[ \W\$(_repo_status) ]$RED \$(_ret_prompt) $NORMAL"
9391
else
9492
PS1="$GREEN\u $NORMAL[ \W\$(_repo_status) ]$GREEN \$(_ret_prompt) $NORMAL"
@@ -103,7 +101,11 @@ alias ...='cd ../..'
103101
alias ....='cd ../../..'
104102
alias nano='nano -w'
105103
alias ed='ed -p: -v' # ED for Eununchs hackers.
104+
_is_posix || which(){ (alias; declare -F) | /usr/bin/which -i --read-functions "$@"; }
106105

106+
# Misc stuffs
107+
FIGNORE='~'
108+
TIMEFORMAT=$'\nreal\t%3lR\t%P%%\nuser\t%3lU\nsys\t%3lS'
107109
# Last directory recoding measure.
108110
_lastdir_go() {
109111
if [ -s ~/.last_directory ]; then

0 commit comments

Comments
 (0)