diff options
author | davidovski <david@davidovski.xyz> | 2022-05-16 00:48:34 +0100 |
---|---|---|
committer | davidovski <david@davidovski.xyz> | 2022-05-16 00:48:34 +0100 |
commit | 381aaffe4ed3caa0f1356b720f6d4fc0de5b1f8f (patch) | |
tree | dc8a619c66a8e538f94ac2701b6e42750d0d9406 /mkshrc | |
parent | 1406e81f40a5e0ef4632e7c518b0629514a79de3 (diff) |
removed bash and added mkshrc
Diffstat (limited to 'mkshrc')
-rw-r--r-- | mkshrc | 56 |
1 files changed, 56 insertions, 0 deletions
@@ -0,0 +1,56 @@ +#!/bin/mksh +case $- in + *i*) ;; + *) return;; +esac + +export VIMINIT="source ~/.config/vim/vimrc" +export NVIMINIT="source ~/.config/vim/vimrc" + +if [ -x /usr/bin/dircolors ]; then + test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" + alias ls='ls --color=auto' + alias dir='dir --color=auto' + alias vdir='vdir --color=auto' + + alias grep='grep --color=auto' + alias fgrep='fgrep --color=auto' + alias egrep='egrep --color=auto' +fi + +[ -f ~/.sh_aliases ] && . ~/.sh_aliases +[ -f ~/.profile ] && . ~/.profile + +# parse the current branch and status of git to be added to the prompt +function parse_git_branch() { + BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'` + if [ ! "${BRANCH}" == "" ] + then + STAT=`parse_git_dirty` + echo " [${BRANCH}${STAT}]" + else + echo "" + fi +} + +function parse_git_dirty { + status=`git status 2>&1 | tee` + dirty=`echo -n "${status}" 2> /dev/null | grep "modified:" &> /dev/null; echo "$?"` + untracked=`echo -n "${status}" 2> /dev/null | grep "Untracked files" &> /dev/null; echo "$?"` + ahead=`echo -n "${status}" 2> /dev/null | grep "Your branch is ahead of" &> /dev/null; echo "$?"` + newfile=`echo -n "${status}" 2> /dev/null | grep "new file:" &> /dev/null; echo "$?"` + renamed=`echo -n "${status}" 2> /dev/null | grep "renamed:" &> /dev/null; echo "$?"` + deleted=`echo -n "${status}" 2> /dev/null | grep "deleted:" &> /dev/null; echo "$?"` + bits='' + [ "${renamed}" == "0" ] && bits=">${bits}" + [ "${ahead}" == "0" ] && bits="*${bits}" + [ "${newfile}" == "0" ] && bits="+${bits}" + [ "${untracked}" == "0" ] && bits="?${bits}" + [ "${deleted}" == "0" ] && bits="x${bits}" + [ "${dirty}" == "0" ] && bits="!${bits}" + [ ! "${bits}" == "" ] && echo " ${bits}" || echo "" +} + +bind '^L=clear-screen' + +export PS1=$(echo -e "\e[0;97m\${PWD/#\$HOME/\~}\e[0;37m\`parse_git_branch\` > \e[0;0m") |