initial commit

This commit is contained in:
Felix Buehler 2017-01-26 13:48:55 +01:00
commit 86a1da2632
35 changed files with 1162 additions and 0 deletions

100
shell/aliases.sh Executable file
View file

@ -0,0 +1,100 @@
#!/bin/sh
#alias definitions
alias chmox="chmod +x"
alias cd..="cd .."
alias gits="git status"
alias gl="git log --oneline --all --abbrev-commit --graph --decorate --color"
alias subl='subl3'
alias ddd="killall -USR1 dd"
alias sddd="sudo killall -USR1 dd"
alias killlall="killall"
alias kilall="killall"
alias kilal="killall"
alias killlal="killall"
alias les="less"
alias quit="exit"
alias :q="exit"
alias :qa="exit"
alias :q!="exit"
alias :qw="exit"
alias vim="vim -p"
alias vi="vim -p"
alias cp='cp -v'
alias mv='mv -v'
alias youtube-dl='youtube-dl -o "%(title)s.%(ext)s"'
alias yta='youtube-dl -o "%(title)s.%(ext)s" --extract-audio'
alias yt3='youtube-dl -o "%(title)s.%(ext)s" --extract-audio --audio-format mp3'
alias grep="grep --color=auto"
alias ls='ls --color=auto'
alias fuck="sudo !!"
alias fu='sudo "$BASH" -c "$(history -p !!)"'
# open any file wihtout the knowledge of what type it is
alias of="xdg-open"
if [ ! -z "$(type sudo 2>/dev/null)" -a "$USER" != 'root' ]; then
#create sudo aliases WITHOUT leading s
for sudo in wifi-menu netctl mount umount pacman shutdown reboot iftop fsadm lvchange lvconvert lvcreate lvdisplay lvextend lvm lvmchange lvmconf lvmconfig lvmdiskscan lvmdump lvmetad lvmsadc lvmsar lvreduce lvremove lvrename lvresize lvs lvscan pvchange pvck pvcreate pvdisplay pvmove pvremove pvresize pvs pvscan vgcfgbackup vgcfgrestore vgchange vgck vgconvert vgcreate vgdisplay vgexport vgextend vgimport vgimportclone vgmerge vgmknodes vgreduce vgremove vgrename vgs vgscan vgsplit;
do
type $sudo > /dev/null 2>&1 && alias $sudo="sudo $sudo";
done
unset sudo
#create sudo aliases WITH leading s
for sudo in ps vim chown chmod;
do
type $sudo > /dev/null 2>&1 && alias s$sudo="sudo $sudo";
done
unset sudo
fi
alias mon-update="xrandr --auto"
alias pwedit="svim -p /etc/{passwd,group,shadow,gshadow}"
alias cmdlist='find $(echo $PATH | tr ":" "\n")'
alias makepasswd='makepasswd --minchars=10 --maxchars=25 --count=10'
alias shuttle='sshuttle --dns -v -r uberspace 0/0'
alias backupnow='sudo borgmatic -v 1 && echo $(date +"%Y%m%d") > ~/.borgbackup.log'
alias syncbackupto='sudo rsync -aPzchv backup:/home/felix/data/ '
alias notify='notify-send Terminal "Process has been finished"'
alias screen-off='xset -display :0.0 dpms force off'
# DEBIAN:
alias sag='sudo apt-get'
alias key-renew='apt-key adv --keyserver keyserver.ubuntu.com --recv-keys'
alias key-repair-all='wget -q http://archive.getdeb.net/getdeb-archive.key -O- | sudo apt-key add - '
# ARCH:
alias pacman-update='sudo pacman -Syu'
alias pacaur-update='pacaur -Syua'
alias pacman-clean='sudo pacman -Sc'
# TEE:
alias ttime_green="sh -c \"sleep 180 && notify-send -u critical 'The tea is ready'\" &"
alias ttime_black="sh -c \"sleep 300 && notify-send -u critical 'The tea is ready'\" &"
# scan your local network with nmap
#
# usage:
# snet <nmap-args>
# example: (scan for every HP printer in the network)
# snet -p jetdirect --open
#
# - get all non-linklocal IP addrs from ip
# - pipe the IPs through ipcalc to get the network ID
# - this is neccessary to prevent scanning the same network twice
# - likely to experience if connected via wifi and ethernet
# - xargs it to nmap at the end
alias snet="ip addr | \\grep -v "inet6" | \\grep inet | cut -d \" \" -f 6 | \\grep -v '127\\.0\\.[0-1]\\.[0-1]' | xargs -n 1 ipcalc | awk '/Network:/{print \$2}' | sort -u | xargs nmap"
#END alias-definitions

13
shell/cd.sh Executable file
View file

@ -0,0 +1,13 @@
#!/bin/sh
#correct some fast tipped cds
function c {
if [ $1 == "d.." ]; then
cd ..;
pwd;
fi
if [ -d $1 ]; then
cd $1;
pwd;
fi
return 0;
}

2
shell/command-not-found.sh Executable file
View file

@ -0,0 +1,2 @@
#!/bin/sh
[ -r /etc/profile.d/cnf.sh ] && . /etc/profile.d/cnf.sh

58
shell/extract.sh Executable file
View file

@ -0,0 +1,58 @@
x() {
for zipfile in $*; do
local extractor
if [ -f "$zipfile" ]; then
case "$zipfile" in
*.tar.lrz)
extractor="lrztar -d" ;;
*.lrz)
extractor="lrunzip" ;;
*.tar.bz2)
extractor="bsdtar xjf" ;;
*.bz2)
extractor="bunzip2" ;;
*.tar.gz)
extractor="bsdtar xzf" ;;
*.gz)
extractor="gunzip" ;;
*.tar.xz)
extractor="bsdtar Jxf" ;;
*.xz)
extractor="xz -d" ;;
*.rar)
extractor="unrar e" ;;
*.tar)
extractor="bsdtar xf" ;;
*.tbz2)
extractor="bsdtar xjf" ;;
*.tgz)
extractor="bsdtar xzf" ;;
*.zip)
extractor="unzip" ;;
*.Z)
extractor="uncompress" ;;
*.7z)
extractor="7z x" ;;
*)
echo "Cannot extract '$zipfile': No extractor for filetype known ..." >&2
return 1
;;
esac
if ! command -v `echo $extractor | awk '{print $1}'` >/dev/null 2>/dev/null; then
echo "Cannot extract '$zipfile': Cannot find extractor '`echo $extractor | awk '{print $1}'`'." >&2
return 1
fi
echo "Extracting '$zipfile'..." >&2
eval $extractor $zipfile
elif [ ! -e "$zipfile" ]; then
echo "Cannot extract '$zipfile': File does not exist!"
return 1
else
echo "Cannot extract '$zipfile': Not a valid file!"
return 1
fi
done
}

19
shell/gitrepo-commited.sh Executable file
View file

@ -0,0 +1,19 @@
#!/bin/sh
case "$-" in
*i*)
# This shell is interactive, if not ignore this part
# If printing this in non-interactive shells, it'll may prevent scp to work
cfgrepo=`readlink ~/.profile.d/10-gitrepo-commited.sh`
repo=`dirname $cfgrepo`
changes=`git -C $repo status --porcelain | wc -l`
if [ $changes -gt 0 ]; then
echo -e '\e[01;31m' >&2
echo -e '####################################' >&2
echo -e '# GIT-config-Repo is not commited! #' >&2
echo -e '####################################' >&2
echo -e '\e[0m' >&2
fi
;;
esac

11
shell/keychain.sh Executable file
View file

@ -0,0 +1,11 @@
#!/bin/sh
# array to process, either folders or directories for recursive processing
KEYPATHS+=("$HOME/.ssh/keys" "$HOME/.ssh/gitlab_rsa" "$HOME/.ssh/id_rsa")
if command -v keychain 2>&1 >/dev/null; then
eval \
`find ${KEYPATHS[@]} -type f -not -name '*.pub' 2>/dev/null \
| xargs keychain -q --nogui --agents ssh --timeout 600 --eval`
fi
unset KEYPATHS

16
shell/liquidprompt.sh Executable file
View file

@ -0,0 +1,16 @@
#LP_ENABLE_RUNTIME=1
LP_ENABLE_TITLE=1
LP_ENABLE_SSH_COLORS=1
LP_ENABLE_VCS_ROOT=1
LP_DISABLED_VCS_PATH=""
LP_ENABLE_TEMP=0
LP_ENABLE_BATT=0
LP_ENABLE_SVN=0
LP_ENABLE_HG=0
LP_ENABLE_BZR=0
LP_ENABLE_FOSSIL=0
LP_ENABLE_SUDO=1
# if in git folder, the prompt takes very long to rebuild
mountpoint $HOME 2> /dev/null > /dev/null && LP_DISABLED_VCS_PATH="$HOME"
source ~/.liquidprompt/liquidprompt

6
shell/load Executable file
View file

@ -0,0 +1,6 @@
#!/bin/sh
for profile in ~/.profile.d/*.sh; do
if [ -x "$profile" ]; then
source $profile
fi
done

39
shell/mysqlpw.sh Executable file
View file

@ -0,0 +1,39 @@
#!/bin/sh
#The function will find the given user and search for a mysql-password
#in the home-directory, which will get printed out!
#arg1: user where to find a config-file
# if not given, it uses the current user in the $HOME and $USER-Variable
function mysqlpw() {
local H=$HOME
local U=$USER
# use different user, if arg1 given
if [ ! -z $1 ]; then
# check if given user is even existing
if ! id $1 >/dev/null 2>/dev/null; then
echo user $1 not existing >&2
return 1
fi
U=$1
H=`grep ^$1: /etc/passwd | cut -d ":" -f 6`
fi;
local mysql_cnf="$H/.my.cnf"
if [ ! -e $mysql_cnf ]; then
echo $mysql_cnf not existing >&2 && return 1
fi
if [ ! -r $mysql_cnf ]; then
echo $mysql_cnf not readable >&2 && return 1
fi
local PW=`(grep "password=" $mysql_cnf || echo undefined) | cut -d "=" -f 2`
echo MySQL-Password for user $U is $PW
}

25
shell/paths.sh Executable file
View file

@ -0,0 +1,25 @@
#!/bin/sh
function set_path(){
if [[ -d "$1" ]]; then
export PATH=$1:$PATH
fi
}
set_path ~/.local/bin/
set_path ~/.bin
if which ruby >/dev/null 2>&1 && which gem >/dev/null 2>&1; then
set_path $(ruby -rubygems -e 'puts Gem.user_dir')/bin
fi
# PERL cpan modules
set_path $HOME/.perl/5/bin
export PERL5LIB="$HOME/.perl/5/lib/perl5:$PERL5LIB"
export PERL_LOCAL_LIB_ROOT="$HOME/.perl/5:$PERL_LOCAL_LIB_ROOT"
export PERL_MB_OPT="--install_base \"$HOME/.perl/5\""
export PERL_MM_OPT="INSTALL_BASE=$HOME/.perl/5"
export GOPATH=$HOME/.go
export GOBIN=$HOME/.gobin
set_path $GOPATH/bin
set_path $GOBIN

4
shell/vars.sh Executable file
View file

@ -0,0 +1,4 @@
#!/bin/sh
export EDITOR=vim
export VISUAL=vim
export BROWSER=firefox