2018-11-26 14:32:27 +00:00
|
|
|
# vim: set noexpandtab :miv #
|
2017-08-19 06:48:08 +00:00
|
|
|
alias hello='echo "Hello :)"'
|
|
|
|
alias w='watch -t -d -n 1'
|
|
|
|
alias setclip='xclip -selection c'
|
|
|
|
alias getclip='xclip -selection clipboard -o'
|
2019-10-17 17:08:36 +00:00
|
|
|
alias r='ranger'
|
|
|
|
alias rr='(ranger)'
|
2019-12-05 10:00:28 +00:00
|
|
|
alias ro='(f=$(tempfile); $(which ranger) --choosefiles $f; rifle $(cat $f); rm $f)'
|
2017-08-19 06:48:08 +00:00
|
|
|
export HISTIGNORE='ls:clear:history'
|
2018-11-28 11:52:08 +00:00
|
|
|
# alias cmatrix='cmatrix -b -C `r.choose green red blue white yellow cyan magenta black`'
|
2017-08-19 06:48:08 +00:00
|
|
|
alias oneko='oneko -speed 20 -fg "#2f2f2f" -cursor 2 -name neko'
|
|
|
|
alias sakura='oneko -bg "#ffddee" -sakura -name sakura'
|
|
|
|
alias tmux='tmux -2'
|
|
|
|
alias pi='ssh pi -t ''tmux a -t home \|\| tmux new-session -s home'''
|
|
|
|
alias server='ssh server -t ''tmux a -t home \|\| tmux new-session -s home'''
|
|
|
|
alias ltc='getclip | luac -l -'
|
2018-03-09 13:57:04 +00:00
|
|
|
alias sign='gpg --armor --no-version --detach-sign --local-user darkwiiplayer'
|
2018-11-07 12:30:49 +00:00
|
|
|
alias workspace='cd ~/workspace'
|
2019-02-25 12:47:29 +00:00
|
|
|
alias shit='git'
|
2019-03-16 09:40:18 +00:00
|
|
|
alias ranger='source ranger'
|
2019-06-15 12:44:48 +00:00
|
|
|
alias ta='tmux a -t'
|
2019-12-17 16:13:48 +00:00
|
|
|
alias co='checkout'
|
2018-11-07 12:30:49 +00:00
|
|
|
|
2017-08-19 06:48:08 +00:00
|
|
|
stty -ixon
|
2017-11-04 09:19:44 +00:00
|
|
|
|
|
|
|
# Enable Vi editing mode
|
|
|
|
set -o vi
|
2018-11-06 12:12:15 +00:00
|
|
|
|
2020-01-07 09:38:05 +00:00
|
|
|
git__fetch() {
|
|
|
|
if [ -f $1/.git/FETCH_HEAD ]; then
|
|
|
|
diff=$(($(date +%s) - $(stat -c %Y $1/.git/FETCH_HEAD)))
|
|
|
|
else
|
|
|
|
diff=9999
|
|
|
|
fi
|
|
|
|
if [ $diff -gt 60 ]; then
|
|
|
|
touch $1/.git/FETCH_HEAD
|
|
|
|
nohup git fetch > /dev/null 2>&1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2018-11-19 18:47:03 +00:00
|
|
|
git__prompt () {
|
2020-01-07 09:38:05 +00:00
|
|
|
top=$(git rev-parse --show-toplevel 2>/dev/null)
|
|
|
|
if [ -n "$top" ]
|
2018-11-19 17:54:42 +00:00
|
|
|
then
|
2020-01-07 09:38:05 +00:00
|
|
|
if [ $BASH_AUTOFETCH ]; then
|
|
|
|
git__fetch $top
|
|
|
|
fi
|
2019-05-29 06:33:38 +00:00
|
|
|
echo -ne ' \033[00;33mδ'
|
2018-11-26 14:32:27 +00:00
|
|
|
status=`git status --short 2>/dev/null`
|
2018-12-09 12:52:47 +00:00
|
|
|
branch=`git branch | grep -Po '(?<=\* )[[:alnum:]_-]*'`
|
2018-11-26 14:14:41 +00:00
|
|
|
modif=`echo "$status" | grep -Po '^\s*M' | wc -l`
|
|
|
|
untracked=`echo "$status" | grep -Po '^\?\?' | wc -l`
|
|
|
|
added=`echo "$status" | grep -Po '^\s*[A]' | wc -l`
|
|
|
|
deleted=`echo "$status" | grep -Po '^\s*[D]' | wc -l`
|
2018-11-26 14:32:27 +00:00
|
|
|
renamed=`echo "$status" | grep -Eo '^\s*R' | wc -l`
|
2018-11-19 18:47:03 +00:00
|
|
|
stat=`git branch -vv | grep -P '^\*' | grep -Po '\[.*\]'`
|
|
|
|
ahead=`echo $stat | grep -Po '(?<=ahead )\d*'`
|
|
|
|
behind=`echo $stat | grep -Po '(?<=behind )\d*'`
|
|
|
|
gray='\033[01;30m'
|
|
|
|
blue='\033[01;34m'
|
|
|
|
yellow='\033[01;33m'
|
|
|
|
red='\033[01;31m'
|
|
|
|
green='\033[01;32m'
|
2019-06-25 07:58:33 +00:00
|
|
|
purple='\033[01;35m'
|
2018-11-19 17:54:42 +00:00
|
|
|
|
2018-11-26 14:32:27 +00:00
|
|
|
# SYNC
|
2018-11-26 14:14:41 +00:00
|
|
|
if [ -z $ahead ] && [ -z $behind ]
|
|
|
|
then
|
|
|
|
echo -ne "" # Nothing to do here
|
|
|
|
elif [ -z $ahead ]
|
|
|
|
then
|
|
|
|
echo -ne " ${yellow}↓${behind}"
|
|
|
|
elif [ -z $behind ]
|
|
|
|
then
|
|
|
|
echo -ne " ${green}↑${ahead}"
|
|
|
|
else
|
2019-06-25 07:58:33 +00:00
|
|
|
echo -ne " ${red}↓${behind}${red}↑${ahead}"
|
2018-11-26 14:14:41 +00:00
|
|
|
fi
|
|
|
|
|
2018-11-26 14:32:27 +00:00
|
|
|
# BRANCH
|
2018-11-19 20:20:55 +00:00
|
|
|
if [ -z $branch ]
|
|
|
|
then
|
2018-11-26 14:32:27 +00:00
|
|
|
head=`git rev-parse --short HEAD 2>&1`
|
2018-12-04 09:31:34 +00:00
|
|
|
if [[ "$head" =~ fatal* ]]
|
2018-11-26 14:32:27 +00:00
|
|
|
then
|
|
|
|
branch='{no commits}'
|
2018-12-04 09:31:34 +00:00
|
|
|
else
|
|
|
|
branch='#'"$head"
|
2018-11-26 14:32:27 +00:00
|
|
|
fi
|
2018-11-19 20:20:55 +00:00
|
|
|
fi
|
2018-11-26 14:32:27 +00:00
|
|
|
if [ "$branch" = 'master' ]
|
2018-11-19 17:54:42 +00:00
|
|
|
then
|
2018-11-19 20:33:37 +00:00
|
|
|
echo -ne " $blue$branch"
|
2018-11-26 14:32:27 +00:00
|
|
|
elif [ "${branch:0:1}" = '#' ]
|
2018-11-19 20:33:37 +00:00
|
|
|
then
|
|
|
|
echo -ne " $red$branch"
|
2018-11-19 17:54:42 +00:00
|
|
|
else
|
2018-11-19 20:33:37 +00:00
|
|
|
echo -ne " $yellow$branch"
|
2018-11-19 17:54:42 +00:00
|
|
|
fi
|
|
|
|
|
2018-11-26 14:32:27 +00:00
|
|
|
# CHANGES
|
2018-11-19 18:47:03 +00:00
|
|
|
if [ $modif = 0 ]
|
2018-11-19 17:54:42 +00:00
|
|
|
then
|
2018-11-26 14:14:41 +00:00
|
|
|
echo -ne # "${gray}:\033[01;36m$modif" # No modified files
|
2018-11-19 17:54:42 +00:00
|
|
|
else
|
2018-11-26 14:14:41 +00:00
|
|
|
echo -ne "${gray}:\033[01;33m$modif" # Modified files
|
2018-11-19 17:54:42 +00:00
|
|
|
fi
|
2018-11-19 18:47:03 +00:00
|
|
|
if [ $added -ne 0 ]
|
2018-11-19 17:54:42 +00:00
|
|
|
then
|
2018-11-26 14:14:41 +00:00
|
|
|
echo -ne " ${green}+$added"
|
2018-11-19 18:47:03 +00:00
|
|
|
fi
|
2018-11-19 20:30:40 +00:00
|
|
|
if [ $deleted -ne 0 ]
|
|
|
|
then
|
2018-11-26 14:14:41 +00:00
|
|
|
echo -ne " ${red}-$deleted"
|
2018-11-19 20:30:40 +00:00
|
|
|
fi
|
2018-11-26 14:14:41 +00:00
|
|
|
if [ $renamed -ne 0 ]
|
2018-11-19 18:47:03 +00:00
|
|
|
then
|
2018-11-26 14:14:41 +00:00
|
|
|
echo -ne " ${yellow}$renamed→$renamed"
|
2018-11-19 18:47:03 +00:00
|
|
|
fi
|
2018-11-26 14:14:41 +00:00
|
|
|
if [ $untracked -ne 0 ]
|
2018-11-19 17:54:42 +00:00
|
|
|
then
|
2019-06-25 07:58:33 +00:00
|
|
|
echo -ne " ${purple}+$untracked"
|
2018-11-19 17:54:42 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2019-05-29 06:33:38 +00:00
|
|
|
PS1n='\[\033[00;34m\]┌─╼ \[\033[01;35m\]\u\[\033[00;34m\]@\[\033[01;35m\]\h \[\033[00;33m\]\$ \[\033[01;35m\]\w \[\033[01;34m\]`find -mindepth 1 -maxdepth 1 -type d | wc -l`\[\033[00;34m\]d \[\033[01;32m\]`find -maxdepth 1 -type f | wc -l`\[\033[00;32m\]f\[\033[00m\]`git__prompt`
|
2018-11-06 19:02:35 +00:00
|
|
|
\[\033[00;34m\]└╼ \[\033[00m\]'
|
2018-12-23 20:23:00 +00:00
|
|
|
|
2018-12-30 12:28:43 +00:00
|
|
|
PS1c='\[\033[00;34m\]┌─╼ \[\033[00;33m\]\$ \[\033[01;35m\]\u`git__prompt` \[\033[01;35m\]`basename \`dirs +0\`` \[\033[01;34m\]`find -mindepth 1 -maxdepth 1 -type d | wc -l`\[\033[00;34m\]d \[\033[01;32m\]`find -maxdepth 1 -type f | wc -l`\[\033[00;32m\]f\[\033[00m\]
|
2018-12-23 20:23:00 +00:00
|
|
|
\[\033[00;34m\]└╼ \[\033[00m\]'
|
|
|
|
|
|
|
|
PS1=$PS1n
|
2018-12-23 20:40:14 +00:00
|
|
|
|
|
|
|
cd() {
|
|
|
|
if [ -f .bashcdout ]
|
|
|
|
then
|
|
|
|
source .bashcdout
|
|
|
|
fi
|
|
|
|
builtin cd "$@" || return
|
|
|
|
if [ -f .bashcd ]
|
|
|
|
then
|
|
|
|
source .bashcd
|
|
|
|
fi
|
|
|
|
}
|
2019-02-25 12:47:29 +00:00
|
|
|
|
|
|
|
export GPG_TTY="$(tty)" # This is necessary for the gpg-agent, apparently
|