-
Notifications
You must be signed in to change notification settings - Fork 0
/
_bashrc
51 lines (45 loc) · 1.63 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
if [ ! `uname` = Darwin ] ; then
if [ `pgrep -u ${USER} ssh-agent | wc -l` = '0' ] ; then
eval `ssh-agent -s`
echo $SSH_AUTH_SOCK > /tmp/.${USER}_auth_sock
echo $SSH_AGENT_PID > /tmp/.${USER}_agent_pid
else
export SSH_AUTH_SOCK=`cat /tmp/.${USER}_auth_sock`
export SSH_AGENT_PID=`cat /tmp/.${USER}_agent_pid`
fi
fi
if [ "`ssh-add -l | grep id_root_rsa | wc -l`" = "0" ] ; then
ssh-add ~/.ssh/id_root_rsa
fi
#autojump
_autojump()
{
local cur
cur=${COMP_WORDS[*]:1}
while read i
do
COMPREPLY=("${COMPREPLY[@]}" "${i}")
done < <(autojump --bash --completion $cur)
}
complete -F _autojump j
data_dir=$([ -e ~/.local/share ] && echo ~/.local/share || echo ~)
export AUTOJUMP_HOME=${HOME}
if [[ "$data_dir" = "${HOME}" ]]
then
export AUTOJUMP_DATA_DIR=${data_dir}
else
export AUTOJUMP_DATA_DIR=${data_dir}/autojump
fi
if [ ! -e "${AUTOJUMP_DATA_DIR}" ]
then
mkdir "${AUTOJUMP_DATA_DIR}"
mv ~/.autojump_py "${AUTOJUMP_DATA_DIR}/autojump_py" 2>>/dev/null #migration
mv ~/.autojump_py.bak "${AUTOJUMP_DATA_DIR}/autojump_py.bak" 2>>/dev/null
mv ~/.autojump_errors "${AUTOJUMP_DATA_DIR}/autojump_errors" 2>>/dev/null
fi
AUTOJUMP='{ [[ "$AUTOJUMP_HOME" == "$HOME" ]] && (autojump -a "$(pwd -P)"&)>/dev/null 2>>${AUTOJUMP_DATA_DIR}/autojump_errors;} 2>/dev/null'
if [[ ! $PROMPT_COMMAND =~ autojump ]]; then
export PROMPT_COMMAND="${PROMPT_COMMAND:-:} ; $AUTOJUMP"
fi
alias jumpstat="autojump --stat"
function j { new_path="$(autojump $@)";if [ -n "$new_path" ]; then echo -e "\\033[31m${new_path}\\033[0m"; cd "$new_path";else false; fi }