Commit 15fcf5c7 authored by Klaus Frank's avatar Klaus Frank

Update etc/bash.bashrc.d/prompt.sh, etc/bash.bashrc,...

Update etc/bash.bashrc.d/prompt.sh, etc/bash.bashrc, etc/bash.bashrc.d/ls-color.sh, etc/bash.bashrc.d/xclip.sh, etc/bash.bashrc.d/ssh-agent.sh files
Deleted etc/profile.d/prompt.sh
parent c8ddd74b
#
# /etc/bash.bashrc
#
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
[[ $DISPLAY ]] && shopt -s checkwinsize
PS1='[\u@\h \W]\$ '
[ -r /usr/share/bash-completion/bash_completion ] && . /usr/share/bash-completion/bash_completion
# Load bashrc scripts from /etc/bash.bashrc.d
if test -d /etc/bash.bashrc.d/
then
for profile in /etc/bash.bashrc.d/*.sh; do
test -r "$profile" && . "$profile"
done
unset profile
fi
alias ls="ls --color=auto"
# get current branch in git repo
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
}
# get current status of git repo
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=''
if [ "${renamed}" == "0" ]; then
bits=">${bits}"
fi
if [ "${ahead}" == "0" ]; then
bits="*${bits}"
fi
if [ "${newfile}" == "0" ]; then
bits="+${bits}"
fi
if [ "${untracked}" == "0" ]; then
bits="?${bits}"
fi
if [ "${deleted}" == "0" ]; then
bits="x${bits}"
fi
if [ "${dirty}" == "0" ]; then
bits="!${bits}"
fi
if [ ! "${bits}" == "" ]; then
echo " ${bits}"
else
echo ""
fi
}
function nonzero_return() {
RETVAL=$?
[ $RETVAL -ne 0 ] && echo "$RETVAL"
}
export PS1="\`nonzero_return\`\u@\h:\w\`parse_git_branch\`\\$ "
export SSH_AUTH_SOCK=$XDG_RUNTIME_DIR/ssh-agent.socket
alias xclip="xsel --clipboard"
#!/bin/bash
# Configure prompt to show more information
# Git Repository status
function parse_git_dirty {
status=`git status 2>&1 | tee`
dirty=`echo -n "${status}" 2> /dev/null | grep "modified:" &> /dev/null; printf "$?"`
untracked=`echo -n "${status}" 2> /dev/null | grep "Untracked files" &> /dev/null; printf "$?"`
ahead=`echo -n "${status}" 2> /dev/null | grep "Your branch is ahead of" &> /dev/null; printf "$?"`
newfile=`echo -n "${status}" 2> /dev/null | grep "new file:" &> /dev/null; printf "$?"`
renamed=`echo -n "${status}" 2> /dev/null | grep "renamed:" &> /dev/null; printf "$?"`
deleted=`echo -n "${status}" 2> /dev/null | grep "deleted:" &> /dev/null; printf "$?"`
bits=''
if [ "${renamed}" == "0" ]; then
bits=">${bits}"
fi
if [ "${ahead}" == "0" ]; then
bits="*${bits}"
fi
if [ "${newfile}" == "0" ]; then
bits="+${bits}"
fi
if [ "${untracked}" == "0" ]; then
bits="?${bits}"
fi
if [ "${deleted}" == "0" ]; then
bits="x${bits}"
fi
if [ "${dirty}" == "0" ]; then
bits="!${bits}"
fi
if [ ! "${bits}" == "" ]; then
printf "${bits}"
else
printf ""
fi
}
# Last exit code
function nonzero_return() {
RETVAL=$?
[ $RETVAL -ne 0 ] && printf "$RETVAL "
}
export PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'nonzero_return; parse_git_dirty'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment