[ADD] Common shell files

This commit is contained in:
Bruno BELANYI 2019-07-11 13:26:24 +02:00
parent d9ca7787bb
commit 795042b616
4 changed files with 152 additions and 0 deletions

38
scripts/i3exit Executable file
View file

@ -0,0 +1,38 @@
#!/bin/sh
function lock() {
# Date and time parameters
x_pos=100
y_pos=1040
datetime_color=FFFFFF80
i3lock -i ~/Pictures/wallpapers/roundabout-blues.png --force-clock \
--timepos="$x_pos:$y_pos" \
--timecolor="$datetime_color" \
--datecolor="$datetime_color"
}
case "$1" in
lock)
lock # Defined in the same folder
;;
logout)
i3-msg exit
;;
suspend)
lock && systemctl suspend
;;
hibernate)
lock && systemctl hibernate
;;
reboot)
systemctl reboot
;;
shutdown)
systemctl poweroff
;;
*)
echo "Usage: $0 {lock|logout|suspend|hibernate|reboot|shutdown}"
exit 2
esac
exit 0

33
shell/.aliases Normal file
View file

@ -0,0 +1,33 @@
# Useful when changing urxvt colors
alias ureload='xrdb -merge ~/.Xresources'
# Shortcut to script with configuration
alias lock='~/scripts/i3exit lock'
# Colorize output
alias ls='ls -CF --color=auto'
alias ll='ls -li'
alias la='ls -lisa'
alias lsl='ls -lhFA | less'
alias tree='tree -C'
alias grep='grep --color=auto'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias diff='diff --color=auto'
# Better defaults
alias df='df -ahiT --total'
alias cp='cp -i'
alias more='less'
#alias mkdir='mkdir -v'
alias userlist='cut -d: -f1 /etc/passwd'
alias fhere='find . -name '
alias free='free -mt'
alias du='du -ach | sort -h'
alias ps='ps auxf'
alias psgrep='ps aux | grep -v grep | grep -i -e VSZ -e'
alias wget='wget -c'
alias histg='history | grep'
alias myip='curl http://ipecho.net/plain; echo'
#alias logs="find /var/log -type f -exec file {} \; | grep 'text' | cut -d' ' -f1 | sed -e's/:$//g' | grep -v '[0-9]$' | xargs tail -f"
alias folders='find . -maxdepth 1 -type d -print0 | xargs -0 du -sk | sort -rn'

59
shell/.functions Normal file
View file

@ -0,0 +1,59 @@
# Creates an archive (*.tar.gz) from given directory.
function maketar() { tar cvzf "${1%%/}.tar.gz" "${1%%/}/"; }
# Create a ZIP archive of a file or folder.
function makezip() { zip -r "${1%%/}.zip" "$1" ; }
function extract {
if [ -z "$1" ]; then
# display usage if no parameters given
echo "Usage: extract <path/file_name>.<zip|rar|bz2|gz|tar|tbz2|tgz|Z|7z|xz|ex|tar.bz2|tar.gz|tar.xz>"
else
if [ -f $1 ] ; then
# NAME=${1%.*}
# mkdir $NAME && cd $NAME
case $1 in
*.tar.bz2) tar xvjf ../$1 ;;
*.tar.gz) tar xvzf ../$1 ;;
*.tar.xz) tar xvJf ../$1 ;;
*.lzma) unlzma ../$1 ;;
*.bz2) bunzip2 ../$1 ;;
*.rar) unrar x -ad ../$1 ;;
*.gz) gunzip ../$1 ;;
*.tar) tar xvf ../$1 ;;
*.tbz2) tar xvjf ../$1 ;;
*.tgz) tar xvzf ../$1 ;;
*.zip) unzip ../$1 ;;
*.Z) uncompress ../$1 ;;
*.7z) 7z x ../$1 ;;
*.xz) unxz ../$1 ;;
*.exe) cabextract ../$1 ;;
*) echo "extract: '$1' - unknown archive method" ;;
esac
else
echo "$1 - file does not exist"
fi
fi
}
# jump directorys upwards until it hits a directory with multiple folders
function up() {
local d=""
limit=$1
for ((i=1 ; i <= limit ; i++))
do
d=$d/..
done
d=$(echo $d | sed 's/^\///')
if [ -z "$d" ]; then
d=..
fi
cd $d
}
# create an directory and directly cd into it
function mcd () {
mkdir -p $1
cd $1
}

22
shell/.profile Normal file
View file

@ -0,0 +1,22 @@
# Add our scripts to the path
PATH="$HOME/scripts:$PATH"
# Export our favorite editor
export EDITOR=vim
export VISUAL=$EDITOR # Also use it when asking for a GUI
# Color ls output depending on filetype with dircolors
[ -e "/etc/DIR_COLORS" ] && DIR_COLORS="/etc/DIR_COLORS"
[ -e "$HOME/.dircolors" ] && DIR_COLORS="$HOME/.dircolors"
[ -e "$DIR_COLORS" ] || DIR_COLORS=""
eval "`dircolors -b $DIR_COLORS`"
# Allow for colorful man pages
export LESS=-R
export LESS_TERMCAP_mb=$'\E[1;31m' # begin blink
export LESS_TERMCAP_md=$'\E[1;36m' # begin bold
export LESS_TERMCAP_me=$'\E[0m' # reset bold/blink
export LESS_TERMCAP_so=$'\E[01;44;33m' # begin reverse video
export LESS_TERMCAP_se=$'\E[0m' # reset reverse video
export LESS_TERMCAP_us=$'\E[1;32m' # begin underline
export LESS_TERMCAP_ue=$'\E[0m' # reset underline