2017-06-05 19:50:20 +03:00
|
|
|
export SSH_AUTH_SOCK="${HOME}/.ssh/ssh_auth_sock"
|
2017-03-01 19:14:32 +02:00
|
|
|
|
|
|
|
completion_path='/usr/share/bash-completion/bash_completion'
|
|
|
|
[[ -r "${completion_path}" ]] && . "${completion_path}"
|
|
|
|
|
2017-05-30 19:49:03 +03:00
|
|
|
# grc
|
|
|
|
colorize() {
|
|
|
|
local cmds cmd
|
|
|
|
cmds=(\
|
|
|
|
cc configure cvs df diff dig gcc gmake id ip last lsof make mount \
|
|
|
|
mtr netstat ping ping6 ps tcpdump traceroute traceroute6 \
|
|
|
|
)
|
|
|
|
for cmd in ${cmds[@]}; do
|
|
|
|
alias ${cmd}="command grc -es --colour=auto ${cmd}"
|
|
|
|
done
|
|
|
|
}
|
2017-06-05 19:50:20 +03:00
|
|
|
if [[ -x $(type -P grc) ]]; then
|
2017-05-30 19:49:03 +03:00
|
|
|
colorize
|
2017-06-05 19:50:20 +03:00
|
|
|
unset -f colorize
|
2017-05-30 19:49:03 +03:00
|
|
|
fi
|
2017-05-22 16:30:13 +03:00
|
|
|
|
2017-03-01 19:14:32 +02:00
|
|
|
# because fuck you thats' why
|
2017-01-18 18:50:31 +02:00
|
|
|
fuck() { echo 'no, fuck you'; }
|
|
|
|
|
2017-03-01 19:14:32 +02:00
|
|
|
# some cool git stuff
|
2017-01-24 18:48:45 +02:00
|
|
|
gdiff() { /usr/bin/git diff --color "$@"; }
|
|
|
|
|
|
|
|
gdf()
|
|
|
|
{
|
|
|
|
local fancydiff='/usr/bin/diff-so-fancy'
|
|
|
|
local githighlight='/usr/share/git/diff-highlight/diff-highlight'
|
|
|
|
if [[ -x ${fancydiff} ]]; then
|
2017-01-26 16:12:09 +02:00
|
|
|
gdiff "$@" | ${fancydiff} | less --tabs=4 -RSFX
|
2017-01-24 18:48:45 +02:00
|
|
|
elif [[ -x ${githighlight} ]]; then
|
2017-01-26 16:12:09 +02:00
|
|
|
gdiff "$@" | ${githighlight} | less --tabs=4 -RSFX
|
2017-01-24 18:48:45 +02:00
|
|
|
else
|
|
|
|
gdiff "$@"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2017-08-08 14:02:56 +03:00
|
|
|
is_git_repo()
|
|
|
|
{
|
|
|
|
local curr_dir="$PWD"
|
|
|
|
while [[ -n "${curr_dir}" ]]; do
|
|
|
|
if [[ -r "${curr_dir}/.git/HEAD" ]]; then
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
curr_dir="${curr_dir%/*}"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2017-03-01 19:14:32 +02:00
|
|
|
git_prompt()
|
2016-12-13 01:08:47 +02:00
|
|
|
{
|
2017-03-01 19:14:32 +02:00
|
|
|
prompt_command
|
2017-03-12 09:47:40 +02:00
|
|
|
|
2017-08-08 14:02:56 +03:00
|
|
|
is_git_repo || return 0
|
|
|
|
|
|
|
|
local raw_status="$(git status --porcelain -bu 2>/dev/null)"
|
2017-06-14 13:11:28 +03:00
|
|
|
local branch_info full_status IFS=
|
|
|
|
local git_status=''
|
|
|
|
local staged_count=0
|
|
|
|
local unstaged_count=0
|
|
|
|
local untracked_count=0
|
|
|
|
local unmerged_count=0
|
2016-12-13 01:08:47 +02:00
|
|
|
|
2017-03-01 19:14:32 +02:00
|
|
|
while read line; do
|
2017-06-14 13:11:28 +03:00
|
|
|
[[ "${line:0:2}" == '##' ]] && branch_info="${line:3}"
|
2017-06-14 13:14:54 +03:00
|
|
|
[[ "${line:0:2}" == '??' ]] && (( untracked_count++ ))
|
2017-06-14 13:11:28 +03:00
|
|
|
[[ "${line:0:2}" =~ .[MD] ]] && (( unstaged_count++ ))
|
|
|
|
[[ "${line:0:2}" =~ [MDARC]. ]] && (( staged_count++ ))
|
2017-03-01 19:14:32 +02:00
|
|
|
[[ "${line:0:2}" =~ (U[ADU]|A[AU]|D[DU]) ]] && (( unmerged_count++ ))
|
|
|
|
done <<< "${raw_status}"
|
|
|
|
|
2017-06-14 13:11:28 +03:00
|
|
|
(( unstaged_count )) && git_status+="${ppurple}~${unstaged_count}"
|
|
|
|
(( staged_count )) && git_status+="${pblue}+${staged_count}"
|
|
|
|
(( untracked_count )) && git_status+="${pred}-${untracked_count}"
|
|
|
|
(( unmerged_count )) && git_status+="${porange}*${unmerged_count}"
|
2017-03-12 09:47:40 +02:00
|
|
|
[[ -z "${git_status}" ]] && git_status="${pgreen}ok"
|
|
|
|
|
|
|
|
full_status="{ ${pgray3}${branch_info}${preset} | ${git_status}${preset} }"
|
2017-03-01 19:14:32 +02:00
|
|
|
|
2017-03-01 19:26:42 +02:00
|
|
|
if [[ -n "${OLD_PROMPT}" ]]; then
|
|
|
|
PS1="${ps_line1} ${full_status}\n${ps_line2}"
|
|
|
|
else
|
|
|
|
echo ${full_status}
|
|
|
|
fi
|
2016-12-13 01:08:47 +02:00
|
|
|
}
|
|
|
|
|
2017-03-01 19:14:32 +02:00
|
|
|
gitmode()
|
2016-12-13 01:08:47 +02:00
|
|
|
{
|
2017-03-01 19:14:32 +02:00
|
|
|
if [[ -n "${OLD_PROMPT}" ]]; then
|
|
|
|
PROMPT_COMMAND=${OLD_PROMPT}
|
|
|
|
unset OLD_PROMPT
|
|
|
|
else
|
|
|
|
OLD_PROMPT=${PROMPT_COMMAND}
|
|
|
|
PROMPT_COMMAND=git_prompt
|
2016-12-13 01:08:47 +02:00
|
|
|
fi
|
|
|
|
}
|
2017-03-01 19:26:42 +02:00
|
|
|
|
|
|
|
gitmode
|