mirror of
https://github.com/kastdeur/dotfiles.git
synced 2025-06-01 20:09:13 +02:00
Possiblity of having special setups for hostnames
For .Bashrc aswell as generic .Profile
This commit is contained in:
parent
0fd6e855bf
commit
37123ca4cd
31 changed files with 3148 additions and 51 deletions
37
bash/bashrc
Normal file
37
bash/bashrc
Normal file
|
@ -0,0 +1,37 @@
|
|||
# ~/.bashrc: executed by bash(1) for non-login shells.
|
||||
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
|
||||
# for examples
|
||||
|
||||
# If not running interactively, don't do anything
|
||||
[ -z "$PS1" ] && return
|
||||
|
||||
[ ! -z "$DOTFILES" ] && DOTBASH="$DOTFILES/bash"
|
||||
|
||||
# make less more friendly for non-text input files, see lesspipe(1)
|
||||
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
|
||||
|
||||
|
||||
# enable programmable completion features (you don't need to enable
|
||||
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
|
||||
# sources /etc/bash.bashrc).
|
||||
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
|
||||
. /etc/bash_completion
|
||||
fi
|
||||
|
||||
# Load main things
|
||||
if [ -d "$DOTBASH/main" ]; then
|
||||
for f in $DOTBASH/main/*; do
|
||||
source "$f"
|
||||
done
|
||||
fi
|
||||
|
||||
# Try custom bashrc
|
||||
#if [[ $HOSTNAME == 'hg'* && -r "hg.bashrc"]]; then
|
||||
# source "hg.bashrc"
|
||||
#fi
|
||||
|
||||
# Try hostname bashrcs
|
||||
if [ -r "$DOTBASH/$HOSTNAME.bashrc" ]; then
|
||||
source "$DOTBASH/$HOSTNAME.bashrc"
|
||||
fi
|
||||
|
1
bash/main/50-ps
Symbolic link
1
bash/main/50-ps
Symbolic link
|
@ -0,0 +1 @@
|
|||
../scriptlets/50-ps
|
39
bash/main/aliases
Normal file
39
bash/main/aliases
Normal file
|
@ -0,0 +1,39 @@
|
|||
# enable color support of ls and also add handy aliases
|
||||
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
|
||||
|
||||
# some more ls aliases
|
||||
alias ll='ls -l'
|
||||
alias la='ls -A'
|
||||
alias l='ls -CF'
|
||||
|
||||
# Use vim if possible instead of vi
|
||||
if [[ $(command -v vim) ]]; then
|
||||
alias vi='vim'
|
||||
fi
|
||||
|
||||
# Reload bashrc
|
||||
alias bashreload="source ~/.bashrc"
|
||||
|
||||
# Easy calculator instead of bc
|
||||
alias pc='python -ic "from __future__ import division; from math import *"'
|
||||
|
||||
# Moving around
|
||||
alias ~='cd ~'
|
||||
alias ..='cd ..'
|
||||
|
||||
|
||||
#Aliases for RU
|
||||
alias lilo='ssh lilo'
|
||||
alias MC='cd ~/MC; echo "Welcome to Marie Curie"'
|
||||
alias MCMail='~/MC/www/mailer/mariemailer.psql.pl'
|
||||
alias DocMail='~/MC/www/mailer/docentmailer.pl'
|
||||
|
17
bash/main/colours
Normal file
17
bash/main/colours
Normal file
|
@ -0,0 +1,17 @@
|
|||
### Colors to Vars ### {{{
|
||||
## Inspired by http://wiki.archlinux.org/index.php/Color_Bash_Prompt#List_of_colors_for_prompt_and_Bash
|
||||
## Terminal Control Escape Sequences: http://www.termsys.demon.co.uk/vtansi.htm
|
||||
## Consider using some of: https://gist.github.com/bcap/5682077#file-terminal-control-sh
|
||||
## Can unset with `unset -v {,B,U,I,BI,On_,On_I}{Bla,Red,Gre,Yel,Blu,Pur,Cya,Whi} RCol`
|
||||
RCol='\[\e[0m\]' # Text Reset
|
||||
|
||||
# Regular Bold Underline High Intensity BoldHigh Intensity Background High Intensity Backgrounds
|
||||
Bla='\[\e[0;30m\]'; BBla='\[\e[1;30m\]'; UBla='\[\e[4;30m\]'; IBla='\[\e[0;90m\]'; BIBla='\[\e[1;90m\]'; On_Bla='\e[40m'; On_IBla='\[\e[0;100m\]';
|
||||
Red='\[\e[0;31m\]'; BRed='\[\e[1;31m\]'; URed='\[\e[4;31m\]'; IRed='\[\e[0;91m\]'; BIRed='\[\e[1;91m\]'; On_Red='\e[41m'; On_IRed='\[\e[0;101m\]';
|
||||
Gre='\[\e[0;32m\]'; BGre='\[\e[1;32m\]'; UGre='\[\e[4;32m\]'; IGre='\[\e[0;92m\]'; BIGre='\[\e[1;92m\]'; On_Gre='\e[42m'; On_IGre='\[\e[0;102m\]';
|
||||
Yel='\[\e[0;33m\]'; BYel='\[\e[1;33m\]'; UYel='\[\e[4;33m\]'; IYel='\[\e[0;93m\]'; BIYel='\[\e[1;93m\]'; On_Yel='\e[43m'; On_IYel='\[\e[0;103m\]';
|
||||
Blu='\[\e[0;34m\]'; BBlu='\[\e[1;34m\]'; UBlu='\[\e[4;34m\]'; IBlu='\[\e[0;94m\]'; BIBlu='\[\e[1;94m\]'; On_Blu='\e[44m'; On_IBlu='\[\e[0;104m\]';
|
||||
Pur='\[\e[0;35m\]'; BPur='\[\e[1;35m\]'; UPur='\[\e[4;35m\]'; IPur='\[\e[0;95m\]'; BIPur='\[\e[1;95m\]'; On_Pur='\e[45m'; On_IPur='\[\e[0;105m\]';
|
||||
Cya='\[\e[0;36m\]'; BCya='\[\e[1;36m\]'; UCya='\[\e[4;36m\]'; ICya='\[\e[0;96m\]'; BICya='\[\e[1;96m\]'; On_Cya='\e[46m'; On_ICya='\[\e[0;106m\]';
|
||||
Whi='\[\e[0;37m\]'; BWhi='\[\e[1;37m\]'; UWhi='\[\e[4;37m\]'; IWhi='\[\e[0;97m\]'; BIWhi='\[\e[1;97m\]'; On_Whi='\e[47m'; On_IWhi='\[\e[0;107m\]';
|
||||
### End Color Vars ### }}}
|
17
bash/main/history
Normal file
17
bash/main/history
Normal file
|
@ -0,0 +1,17 @@
|
|||
# don't put duplicate lines or lines starting with space in the history.
|
||||
# See bash(1) for more options
|
||||
HISTCONTROL=ignoreboth
|
||||
# append to the history file, don't overwrite it
|
||||
shopt -s histappend
|
||||
|
||||
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
|
||||
HISTSIZE=10000
|
||||
HISTFILESIZE=20000
|
||||
|
||||
# check the window size after each command and, if necessary,
|
||||
# update the values of LINES and COLUMNS.
|
||||
shopt -s checkwinsize
|
||||
|
||||
# If set, the pattern "**" used in a pathname expansion context will
|
||||
# match all files and zero or more directories and subdirectories.
|
||||
#shopt -s globstar
|
4
bash/scriptlets/00-marietje
Normal file
4
bash/scriptlets/00-marietje
Normal file
|
@ -0,0 +1,4 @@
|
|||
# Get Marietje and shizzle
|
||||
if [ -f /vol/impuls/marcur/bashrc ]; then
|
||||
. /vol/impuls/marcur/bashrc
|
||||
fi
|
242
bash/scriptlets/50-ps
Normal file
242
bash/scriptlets/50-ps
Normal file
|
@ -0,0 +1,242 @@
|
|||
# .bash_files
|
||||
# /PS
|
||||
|
||||
# uncomment for a colored prompt, if the terminal has the capability; turned
|
||||
# off by default to not distract the user: the focus in a terminal window
|
||||
# should be on the output of commands, not on the prompt
|
||||
force_color_prompt=yes
|
||||
|
||||
if [ -n "$force_color_prompt" ]; then
|
||||
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
|
||||
# We have color support; assume it's compliant with Ecma-48
|
||||
# (ISO/IEC-6429). (Lack of such support is extremely rare, and
|
||||
# a case would tend to support setf rather than setaf.)
|
||||
color_prompt=yes
|
||||
else
|
||||
color_prompt=
|
||||
fi
|
||||
fi
|
||||
|
||||
# Old PS1
|
||||
#if [ "$color_prompt" = yes ]; then
|
||||
# PS1='${debian_chroot:+($debian_chroot)}\[\033[00;32m\]\u@\H\[\033[00m\] \[\033[0;33;40m\](\t)\[\033[00m\] \[\033[01;34m\]\[$(ls |wc -l)\]@\W\[\033[00m\]:\$ '
|
||||
#else
|
||||
# PS1='${debian_chroot:+($debian_chroot)}\u@\H (\t) \[$(ls | wc -l)\]@\W:\$ '
|
||||
#fi
|
||||
|
||||
|
||||
function color() {
|
||||
if [ -n "$force_color_prompt" ] ; then
|
||||
if [ -n "$color_prompt" ] ; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
export PROMPT_COMMAND=__prompt_command
|
||||
|
||||
function __prompt_command() {
|
||||
local RETVAL=$?
|
||||
if [ ! $RETVAL -ne 0 ]; then
|
||||
RETVAL=0
|
||||
fi
|
||||
|
||||
PS1="${debian_chroot:+($debian_chroot)}"
|
||||
|
||||
#Return Value
|
||||
if [ -n $RETVAL ]; then
|
||||
PS1+="$(retval ${RETVAL})"
|
||||
fi
|
||||
### Add Git Status ###
|
||||
if [[ $(command -v git) ]]; then
|
||||
PS1+="$(git_status) "
|
||||
fi
|
||||
|
||||
|
||||
#user@hostname
|
||||
if color ; then
|
||||
PS1+="${Gre}\u${RCol}"
|
||||
else
|
||||
PS1+="\u"
|
||||
fi
|
||||
|
||||
PS1+="@"
|
||||
|
||||
if color ; then
|
||||
if [[ $HOSTNAME == 'lilo'* ]]; then
|
||||
PS1+="${BWhi}\H${RCol}"
|
||||
elif [[ $HOSTNAME == 'hg'* ]]; then
|
||||
PS1+="${BRed}\H${RCol}"
|
||||
else
|
||||
PS1+="${Blu}${On_Whi}\H${RCol}"
|
||||
fi
|
||||
else
|
||||
PS1+="\H"
|
||||
fi
|
||||
|
||||
#time w/ seconds
|
||||
if color ; then
|
||||
PS1+="${Yel}${On_Bla}"
|
||||
fi
|
||||
|
||||
PS1+="(\t)"
|
||||
|
||||
if color ; then
|
||||
PS1+="${RCol}"
|
||||
fi
|
||||
PS1+=" "
|
||||
#dir count, pwd
|
||||
if color ; then
|
||||
PS1+="${BBlu}"
|
||||
fi
|
||||
|
||||
PS1+="\[$(ls |wc -l)\]@\W"
|
||||
|
||||
if color ; then
|
||||
PS1+="${RCol}"
|
||||
fi
|
||||
PS1+=" "
|
||||
#UID
|
||||
PS1+=':\$ '
|
||||
}
|
||||
|
||||
function retval() {
|
||||
### Determine Return Value
|
||||
local PS1
|
||||
if [ -z "$color_prompt" ]; then
|
||||
PS1="[$1] "
|
||||
else
|
||||
if [ ! $1 == 0 ]; then
|
||||
PS1="${Red}×${RCol}"
|
||||
else
|
||||
PS1="${Gre}+${RCol}"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "${PS1} "
|
||||
}
|
||||
|
||||
function git_status() {
|
||||
### Determine Git Status
|
||||
local PS1
|
||||
local GStat="$(git status --porcelain -b 2>/dev/null | tr '\n' ':')"
|
||||
|
||||
if [ "$GStat" ]; then
|
||||
### Fetch Time Check ### {{{
|
||||
local LAST=$(stat -c %Y $(git rev-parse --git-dir 2>/dev/null)/FETCH_HEAD 2>/dev/null)
|
||||
if [ "${LAST}" ]; then
|
||||
local TIME=$(echo $(date +"%s") - ${LAST} | bc)
|
||||
## Check if more than 60 minutes since last
|
||||
if [ "${TIME}" -gt "3600" ]; then
|
||||
git fetch 2>/dev/null
|
||||
PS1+=' +'
|
||||
## Refresh var
|
||||
local GStat="$(git status --porcelain -b 2>/dev/null | tr '\n' ':')"
|
||||
fi
|
||||
fi
|
||||
### End Fetch Check ### }}}
|
||||
|
||||
### Test For Changes ### {{{
|
||||
## Change this to test for 'ahead' or 'behind'!
|
||||
local GChanges="$(echo ${GStat} | tr ':' '\n' | grep -v "^$" | grep -v "^\#\#" | wc -l | tr -d ' ')"
|
||||
if [ "$GChanges" == "0" ]; then
|
||||
local GitCol=$Gre
|
||||
else
|
||||
local GitCol=$Red
|
||||
fi
|
||||
### End Test Changes ### }}}
|
||||
|
||||
### Find Branch ### {{{
|
||||
local GBra="$(echo ${GStat} | tr ':' '\n' | grep "^##" | cut -c4- | grep -o "^[a-zA-Z]\{1,\}[^\.]")"
|
||||
if [ "$GBra" ]; then
|
||||
if [ "$GBra" == "master" ]; then
|
||||
local GBra="M" # Because why waste space
|
||||
fi
|
||||
else
|
||||
local GBra="ERROR" # It could happen supposedly?
|
||||
fi
|
||||
### End Branch ### }}}
|
||||
|
||||
PS1+=" ${GitCol}[$GBra]${RCol}" # Add result to prompt
|
||||
|
||||
### Find Commit Status ### {{{
|
||||
## Test Modified and Untracked for "0"
|
||||
# # local GDel="$(echo ${GStat} | tr ':' '\n' | grep -c "^[ MARC]D")"
|
||||
|
||||
local GAhe="$(echo ${GStat} | tr ':' '\n' | grep "^##" | grep -o "ahead [0-9]\{1,\}" | grep -o "[0-9]\{1,\}")"
|
||||
if [ "$GAhe" ]; then
|
||||
PS1+="${Gre}↑${RCol}${GAhe}" # Ahead
|
||||
fi
|
||||
|
||||
## Needs a `git fetch`
|
||||
local GBeh="$(echo ${GStat} | tr ':' '\n' | grep "^##" | grep -o "behind [0-9]\{1,\}" | grep -o "[0-9]\{1,\}")"
|
||||
if [ "$GBeh" ]; then
|
||||
PS1+="${Red}↓${RCol}${GBeh}" # Behind
|
||||
fi
|
||||
|
||||
local GMod="$(echo ${GStat} | tr ':' '\n' | grep -c "^[ MARC]M")"
|
||||
if [ "$GMod" -gt "0" ]; then
|
||||
PS1+="${Pur}≠${RCol}${GMod}" # Modified
|
||||
fi
|
||||
|
||||
local GUnt="$(echo ${GStat} | tr ':' '\n' | grep -c "^\?")"
|
||||
if [ "$GUnt" -gt "0" ]; then
|
||||
PS1+="${Yel}?${RCol}${GUnt}" # Untracked
|
||||
fi
|
||||
### End Commit Status ### }}}
|
||||
|
||||
echo "${PS1}"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# Git
|
||||
# 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
|
||||
}
|
8
bash/scriptlets/70_wttr
Normal file
8
bash/scriptlets/70_wttr
Normal file
|
@ -0,0 +1,8 @@
|
|||
#This file should be cronned from: wttr.in/<place>
|
||||
#For example:
|
||||
#27 */2 * * * curl -s wttr.in/Voorthuizen | sed -n 3,7p > .wttr 2>&1
|
||||
WTTR=~/.wttr
|
||||
if [ -f $WTTR ]; then
|
||||
cat $WTTR
|
||||
alias wttr='cat $WTTR'
|
||||
fi
|
6
bash/scriptlets/alias-ru
Normal file
6
bash/scriptlets/alias-ru
Normal file
|
@ -0,0 +1,6 @@
|
|||
#Aliases for RU
|
||||
alias lilo='ssh lilo'
|
||||
alias MC='cd ~/MC; echo "Welcome to Marie Curie"'
|
||||
alias MCMail='~/MC/www/mailer/mariemailer.psql.pl'
|
||||
alias DocMail='~/MC/www/mailer/docentmailer.pl'
|
||||
|
3
bash/scriptlets/fortune
Normal file
3
bash/scriptlets/fortune
Normal file
|
@ -0,0 +1,3 @@
|
|||
if [[ $(command -v fortune) ]]; then
|
||||
fortune -so
|
||||
fi
|
Loading…
Add table
Add a link
Reference in a new issue