From 352fe1c31a12484e932c323b44f05070c6076705 Mon Sep 17 00:00:00 2001 From: Samir Benmendil Date: Tue, 23 Oct 2012 04:41:29 +0200 Subject: [PATCH] add bashrc stuff --- Makefile | 14 +++++++--- bash_aliases | 45 ++++++++++++++++++++++++++++++++ bash_colors | 33 +++++++++++++++++++++++ bash_logout | 7 +++++ bashrc | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 170 insertions(+), 3 deletions(-) create mode 100644 bash_aliases create mode 100644 bash_colors create mode 100644 bash_logout create mode 100644 bashrc diff --git a/Makefile b/Makefile index 8f85fd5..af701e0 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,17 @@ -.PHONY: install +.PHONY: install update install: - cp -f vimrc ~/.vimrc + cp -f bashrc ~/.bashrc + cp -f bash_aliases ~/.bash_aliases + cp -f bash_colors ~/.bash_colors + cp -f bash_logout ~/.bash_logout cp -f flexget/config.yml ~/.flexget/config.yml + cp -f vimrc ~/.vimrc update: - cp -f ~/.vimrc vimrc + cp -f ~/.bashrc bashrc + cp -f ~/.bash_aliases bash_aliases + cp -f ~/.bash_colors bash_colors + cp -f ~/.bash_logout bash_logout cp -f ~/.flexget/config.yml flexget/config.yml + cp -f ~/.vimrc vimrc diff --git a/bash_aliases b/bash_aliases new file mode 100644 index 0000000..381813e --- /dev/null +++ b/bash_aliases @@ -0,0 +1,45 @@ +# this will allow aliasing any command after sudo +alias sudo='sudo ' + +alias l='ls --color=auto -F' +alias ls='ls --color=auto -F' +alias ll='ls -lh --color=auto -F' +alias la='ls -lha --color=auto -F' + +#alias grep='grep --color=tty -d skip' + +alias cp='cp -i' # confirm before overwriting something +alias df='df -h' # human-readable sizes +alias free='free -m' # show sizes in MB + +alias vi='vim' +alias svi='sudo vim' +#alias vp='vim PKGBUILD' # I have a script for that in ~/bin +alias vs='vim SPLITBUILD' + +# colours, I want more colours +alias diff='colordiff' + +# colours and case insensitive search +export LESS='-Ri' + +#systemd aliases +alias sctl='systemctl' +#complete -F _systemctl sctl doesn't work with new bash-completion + +# httpd and mysqld +alias start.http='sudo rc.d start httpd mysqld' + +# suspend screensaver when vlc is running +alias vlc-suspend='xdg-screensaver suspend $(xprop -name vlc | grep "WM_CLIENT_LEADER(WINDOW)" | sed "s/.*\(0x\d*\)/\1/")' + +# Pacman alias examples +alias pacupg='sudo pacman -Syu' +alias pacin='sudo pacman -S' +alias pacu='sudo pacman -U' +alias pacre='sudo pacman -R' +alias pacrem='sudo pacman -Rns' +alias pacrep='pacman -Si' +alias pacreps='pacman -Ss' +alias pacloc='pacman -Qi' +alias paclocs='pacman -Qs' diff --git a/bash_colors b/bash_colors new file mode 100644 index 0000000..de03646 --- /dev/null +++ b/bash_colors @@ -0,0 +1,33 @@ +local txtblk='\e[0;30m' # Black - Regular +local txtred='\e[0;31m' # Red +local txtgrn='\e[0;32m' # Green +local txtylw='\e[0;33m' # Yellow +local txtblu='\e[0;34m' # Blue +local txtpur='\e[0;35m' # Purple +local txtcyn='\e[0;36m' # Cyan +local txtwht='\e[0;37m' # White +local bldblk='\e[1;30m' # Black - Bold +local bldred='\e[1;31m' # Red +local bldgrn='\e[1;32m' # Green +local bldylw='\e[1;33m' # Yellow +local bldblu='\e[1;34m' # Blue +local bldpur='\e[1;35m' # Purple +local bldcyn='\e[1;36m' # Cyan +local bldwht='\e[1;37m' # White +local unkblk='\e[4;30m' # Black - Underline +local undred='\e[4;31m' # Red +local undgrn='\e[4;32m' # Green +local undylw='\e[4;33m' # Yellow +local undblu='\e[4;34m' # Blue +local undpur='\e[4;35m' # Purple +local undcyn='\e[4;36m' # Cyan +local undwht='\e[4;37m' # White +local bakblk='\e[40m' # Black - Background +local bakred='\e[41m' # Red +local bakgrn='\e[42m' # Green +local bakylw='\e[43m' # Yellow +local bakblu='\e[44m' # Blue +local bakpur='\e[45m' # Purple +local bakcyn='\e[46m' # Cyan +local bakwht='\e[47m' # White +local txtrst='\e[0m' # Text Reset diff --git a/bash_logout b/bash_logout new file mode 100644 index 0000000..de4f5f7 --- /dev/null +++ b/bash_logout @@ -0,0 +1,7 @@ +# ~/.bash_logout: executed by bash(1) when login shell exits. + +# when leaving the console clear the screen to increase privacy + +if [ "$SHLVL" = 1 ]; then + [ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q +fi diff --git a/bashrc b/bashrc new file mode 100644 index 0000000..cf52ff5 --- /dev/null +++ b/bashrc @@ -0,0 +1,74 @@ +if [ -f /etc/bash_completion ]; then + . /etc/bash_completion +fi + +xhost +local:root > /dev/null 2>&1 + +shopt -s cdspell +shopt -s checkwinsize +shopt -s cmdhist +shopt -s dotglob +shopt -s expand_aliases +shopt -s extglob +shopt -s histappend +shopt -s hostcomplete +# shopt -s nocaseglob # never! lost a file cause of this shit + +export HISTSIZE=10000 +export HISTFILESIZE=${HISTSIZE} +export HISTCONTROL=ignoreboth + +# ex - archive extractor +# usage: ex +ex () +{ + if [ -f $1 ] ; then + case $1 in + *.tar.bz2) tar xjf $1 ;; + *.tar.gz) tar xzf $1 ;; + *.tar.xz) tar -x --xz -f $1 ;; + *.bz2) bunzip2 $1 ;; + *.rar) unrar x $1 ;; + *.gz) gunzip $1 ;; + *.tar) tar xf $1 ;; + *.tbz2) tar xjf $1 ;; + *.tgz) tar xzf $1 ;; + *.zip) unzip $1 ;; + *.Z) uncompress $1 ;; + *.7z) 7z x $1 ;; + *) echo "'$1' cannot be extracted via ex()" ;; + esac + else + echo "'$1' is not a valid file" + fi +} + +# vim stuff +export EDITOR=vim +export VISUAL=vim + +# prompt +prompt () +{ + . ~/.bash_colors + PS1="[\u@\[${bldred}\]\h\[${bldblu}\] \W\[${txtrst}\]]\[${txtrst}\]\$ " +} +prompt +unset prompt + +# Stuff from ubuntu +# make less more friendly for non-text input files, see lesspipe(1) +[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" + +# Alias definitions. +# You may want to put all your additions into a separate file like +# ~/.bash_aliases, instead of adding them here directly. +# See /usr/share/doc/bash-doc/examples in the bash-doc package. +if [ -f ~/.bash_aliases ]; then + . ~/.bash_aliases +fi + +# set PATH so it includes user's private bin if it exists +if [ -d "$HOME/bin" ] ; then + PATH="$HOME/bin:$PATH" +fi -- 2.48.1