-
Notifications
You must be signed in to change notification settings - Fork 0
/
.shrc
140 lines (129 loc) · 3.12 KB
/
.shrc
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
set -o emacs 2> /dev/null
umask 022
unalias -a
alias ali='. "$ENV"'
alias cd..="cd .."
alias cdup="cd .."
alias cls=clear
alias del=rm
alias dir=ls
alias h="fc -l"
alias j=jobs
alias l='$PAGER'
alias lk="ls -l | grep ^d"
alias ll="ls -l"
alias r="fc -e -"
alias whereami="uname -n"
alias fixperms='chmod -R go-rwx "$HOME/.ssh" "$HOME/mail"'
alias pushdotfiles='scp "$HOME/.bash_profile" "$HOME/.bashrc" "$HOME/.exrc" "$HOME/.profile" "$HOME/.shrc" "$HOME/.vimrc"'
alias resettitle='printf "\033]0;`uname -n 2> /dev/null || echo $SHELL`\a"'
if [ ! -x "`command -v cedict`" ]
then
alias getcedict='curl -o "$HOME/tmp/cedict_1_0_ts_utf-8_mdbg.zip" https://www.mdbg.net/chinese/export/cedict/cedict_1_0_ts_utf-8_mdbg.zip && unzip "$HOME/tmp/cedict_1_0_ts_utf-8_mdbg.zip" -d "$HOME/tmp"'
cedict() {
if [ ! -f "$HOME/tmp/cedict_ts.u8" ]
then
echo "Dictionary not found: getcedict first!" 1>&2
return
fi
if [ "$1" = "-m" -a -n "$2" ]
then
cedict `echo $2 | sed 's/./& /g'`
shift
shift
fi
numberToMark=cat
if command -v node > /dev/null && test -x $HOME/bin/pinyin.js
then
numberToMark="$HOME/bin/pinyin.js"
fi
while [ -n "$1" ]
do
egrep "^[^ ]+ $1 " "$HOME/tmp/cedict_ts.u8" | cut -d\ -f2- | $numberToMark
shift
done
unset numberToMark
}
fi
if [ ! -x "`command -v fortune`" ]
then
alias getfortunes='curl -o "$HOME/tmp/fortunes" https://raw.githubusercontent.com/openbsd/src/master/games/fortune/datfiles/fortunes2 && grep '^%$' "$HOME/tmp/fortunes" | wc -l > "$HOME/tmp/fortunes.count"'
fortune() {
if [ ! -f "$HOME/tmp/fortunes" -o ! -f "$HOME/tmp/fortunes.count" ]
then
echo "Fortune not found: getfortunes first!" 1>&2
return
fi
awk 'BEGIN { srand(); x=int(rand() * '`cat "$HOME/tmp/fortunes.count"`') } /^%$/ { x--;next } x==0' "$HOME/tmp/fortunes"
}
fi
if [ -s "$HOME/.nvm/nvm.sh" ]
then
export NVM_DIR="$HOME/.nvm"
. "$NVM_DIR/nvm.sh"
case "$SHELL" in
*bash*)
[ -r "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion"
;;
*)
;;
esac
fi
case "$SHELL" in
*ksh*)
;;
*)
whence() {
command -v "$@" | sed 's/^alias [^=]*=//'
}
;;
esac
case "`uname 2> /dev/null`" in
MINGW*)
alias gradlew="winpty ./gradlew.bat"
alias ifconfig="winpty ipconfig"
alias node="winpty node"
alias npm="winpty npm.cmd"
alias npx="winpty npx.cmd"
alias nslookup="winpty nslookup"
alias php="winpty php"
alias ping="winpty ping"
alias python="winpty python"
alias traceroute="winpty tracert"
alias wsl="winpty wsl"
;;
Darwin)
alias start="open"
case "$SHELL" in
*bash*)
[ -r /Library/Developer/CommandLineTools/usr/share/git-core/git-completion.bash ] && . /Library/Developer/CommandLineTools/usr/share/git-core/git-completion.bash
;;
*)
;;
esac
;;
Linux)
alias ls="ls --color=never"
if [ -f /etc/fedora-release -a ! -x /usr/bin/vim ]
then
alias vi="vi -c 'set nocompatible' -u $HOME/.vimrc"
fi
case "$SHELL" in
*bash*)
bind "set completion-ignore-case on"
unset PROMPT_COMMAND
;;
*)
;;
esac
;;
*)
;;
esac
case "`uname -n 2> /dev/null`" in
sdf)
alias git="git --exec-path=$HOME/pkg/git/libexec/git-core"
;;
*)
;;
esac