-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.bashrc
147 lines (124 loc) · 2.84 KB
/
.bashrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#
# Portable KSH dot file
# Works with BASH, MKSH and (PD)KSH
# (c) Tobias Farrenkopf
#
USER=${USER:-`id -un`}
LOGNAME=${LOGNAME:-$USER}
EDITOR=vi
VISUAL=vi
FCEDIT=vi
EXINIT='set autoindent'
PAGER=less
LESS="-MIRFx4sX"
more='less'
LC_ALL=
LC_CTYPE=en_US.UTF-8
LANG=en_US.UTF-8
unix=`uname -s`
case $unix in
Linux) HOSTNAME=${HOSTNAME:-`hostname --fqdn`}
;;
Darwin) HOSTNAME=${HOSTNAME:-`uname -n`}
;;
*BSD) HOSTNAME=${HOSTNAME:-`uname -n`}
export PERL_BADLANG=0
;;
*) HOSTNAME=${HOSTNAME:-`hostname`}
LC_ALL=C
LANG=C
;;
esac
export USER LOGNAME MAIL EDITOR VISUAL PAGER LESS LANG LC_ALL LC_CTYPE
# Interactive Settings:
case "$-" in *i*)
HISTSIZE=10000
#Prompt
if [ $(id -u) -eq 0 ]; then
PS1='${USER}@${HOSTNAME%%\.*} [${PWD}] ${?#0}# '
else
PS1='$(local_or_remote) [${PWD#${PWD%/*/*/*/*/*}/}]$(parse_git_branch) ${?#0}> '
fi
unalias -a
alias ll='ls -alF'
alias cp='cp -i'
alias mv='mv -i'
alias rm='rm -i'
alias l='ls -crtl'
alias h='history'
#alias d='pwd'
alias reload='. $HOME/.shrc'
alias realias='$EDITOR $HOME/.aliases.sh; . $HOME/.bashrc'
alias tzoom='$(tmux_zoom)'
# Read ~/.aliases.sh if the file exists
if [ -f $HOME/.aliases.sh ]; then
. $HOME/.aliases.sh
fi
case $unix in
*BSD)
alias reboot='shutdown -r now'
alias halt='shutdown -h now'
;;
esac
#[[ -s $MAIL ]] && print "You have mail."
umask 002
set -o vi
#noclobber
set -C
stty -ixon
if [ -n "$BASH" ]; then
shopt -s cdspell
shopt -s direxpand
shopt -s dirspell
fi
# KSH88
#stty erase '^?'
##stty susp '^Z'
##stty sane susp '^Z'
##stty kill '^C'
# KSH93
#typeset -A Keytable
#trap 'eval "${Keytable[${.sh.edchar}]}"' KEYBD
#function keybind # key [action]
#{
# typeset key=$(print -f "%q" "$2")
# case $# in
# 2) Keytable[$1]=' .sh.edchar=${.sh.edmode}'"$key"
# ;;
# 1) unset Keytable[$1]
# ;;
# *) print -u2 "Usage: $0 key [action]"
# return 2 # usage errors return 2 by default
# ;;
# esac
#}
#keybind $'\t' $'\E\E'
#keybind $'' 'echo -ne "\E[H\E[J"'$'\r'
# SPECIAL ^^ CHARARACTER HERE
# PDKSH
#bind '^I'=complete
#bind '^I'=complete-list
#bind -m '^L'='clear^M'
# Bind POS1, END and DEL keys
# For DEL see http://monkey.org/openbsd/archive/misc/0310/msg00504.html
#bind '^XH'=beginning-of-line # POS1/HOME
#bind '^XF'=end-of-line # END
#bind "^[[3"=prefix-2 # DEL
#bind "^[[3~"=delete-char-forward # DEL
date
uptime
who
;;
esac
unset unix
## Functions
parse_git_branch() {
git branch 2> /dev/null | cut -c 1-25 | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
local_or_remote() {
if [ -n "$REMOTE_SESSION" ]; then
echo ${USER}@${HOSTNAME%%\.*}
else
echo "$USER"
fi
}