ordinary (scrot) (+1 likes)
greentrojan Mar 24, 2014 (shells/bash)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 | # ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
case $- in
*i*) ;;
*) return;;
esac
# Add vim as default editor
export EDITOR=vim
export TERMINAL=urxvt
export BROWSER=qupzilla
export PROMPT_COMMAND='echo -ne "\033]0;$PWD\007"'
# 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=1000
HISTFILESIZE=2000
# set pager
export PAGER=/usr/bin/most
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# Gtk themes
export GTK2_RC_FILES="$HOME/.gtkrc-2.0"
xhost +local:root > /dev/null 2>&1
complete -cf sudo
complete -cf man
# Shopt
shopt -s autocd
shopt -s cdspell
shopt -s cmdhist
shopt -s dotglob
shopt -s expand_aliases
shopt -s extglob
shopt -s hostcomplete
shopt -s nocaseglob
# Colour chart
T='123' # The test text
echo -e "\n 40m 41m 42m 43m\
44m 45m 46m 47m";
for FGs in ' m' ' 1m' ' 30m' '1;30m' ' 31m' '1;31m' ' 32m' \
'1;32m' ' 33m' '1;33m' ' 34m' '1;34m' ' 35m' '1;35m' \
' 36m' '1;36m' ' 37m' '1;37m';
do FG=${FGs// /}
echo -en " $FGs \033[$FG $T "
for BG in 40m 41m 42m 43m 44m 45m 46m 47m;
do echo -en "$EINS \033[$FG\033[$BG $T \033[0m";
done
echo;
done
echo
# 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
color_prompt=yes
# Bash Completion
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
# Alias definitions.
if [ -x ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
# Function definitions.
if [ -x ~/.bash_functions ]; then
. ~/.bash_functions
fi
# Prompt definitions.
if [ -x ~/.bash_prompt ]; then
. ~/.bash_prompt
fi
## MISC ALIASES ##
alias ls='ls --group-directories-first --time-style=+"%d.%m.%Y %H:%M" --color=auto -F'
alias ll='ls -l --group-directories-first --time-style=+"%d.%m.%Y %H:%M" --color=auto -F'
alias la='ls -la --group-directories-first --time-style=+"%d.%m.%Y %H:%M" --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 vp='vim PKGBUILD'
alias update='sudo pacman -Syu'
alias install='sudo pacman -S'
alias uninstall='sudo pacman -Rs'
alias search='pacman -Ss'
alias show='pacman -Si'
alias need='pacman -Qi'
alias missing='pacman -Qk'
alias trash='pacman -Qdt'
alias youtube-mp3='youtube-dl --extract-audio --audio-format mp3'
alias speedtest='speedtest-cli'
alias tint2='killall -SIGUSR1 tint2'
alias wvdial='sudo wvdial'
# Color man pages
man() {
env \
LESS_TERMCAP_mb=$(printf "\e[1;31m") \
LESS_TERMCAP_md=$(printf "\e[1;31m") \
LESS_TERMCAP_me=$(printf "\e[0m") \
LESS_TERMCAP_se=$(printf "\e[0m") \
LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
LESS_TERMCAP_ue=$(printf "\e[0m") \
LESS_TERMCAP_us=$(printf "\e[1;32m") \
man "$@"
}
## COMPRESSION FUNCTION ##
function compress_() {
# Credit goes to: Daenyth
FILE=$1
shift
case $FILE in
*.tar.bz2) tar cjf $FILE $* ;;
*.tar.gz) tar czf $FILE $* ;;
*.tgz) tar czf $FILE $* ;;
*.zip) zip $FILE $* ;;
*.rar) rar $FILE $* ;;
*) echo "Filetype not recognized" ;;
esac
}
## EXTRACT FUNCTION ##
extract ()
{
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $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 extract()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
# test if a file should be opened normally, or as root (edit)
argc () {
count=0;
for arg in "$@"; do
if [[ ! "$arg" =~ '-' ]]; then count=$(($count+1)); fi;
done;
echo $count;
}
edit () { if [[ `argc "$@"` > 1 ]]; then vim $@;
elif [ $1 = '' ]; then vim;
elif [ ! -f $1 ] || [ -w $1 ]; then vim $@;
else
echo -n "File is Read-only. Edit as root? (Y/n): "
read -n 1 yn; echo;
if [ "$yn" = 'n' ] || [ "$yn" = 'N' ];
then vim $*;
else sudo vim $*;
fi
fi
}
# cd and ls in one
cl() {
dir=$1
if [[ -z "$dir" ]]; then
dir=$HOME
fi
if [[ -d "$dir" ]]; then
cd "$dir"
ls
else
echo "bash: cl: '$dir': Directory not found"
fi
}
# test encode & decode base64
decode () {
echo "$1" | base64 -d ; echo
}
encode () {
echo "$1" | base64 - ; echo
}
# access translate.google.com from terminal
translate () {
# adjust to taste
DEFAULT_TARGET_LANG=en
if [[ $1 = -h || $1 = --help ]]
then
echo "$help"
exit
fi
if [[ $3 ]]; then
source="$2"
target="$3"
elif [[ $2 ]]; then
source=auto
target="$2"
else
source=auto
target="$DEFAULT_TARGET_LANG"
fi
echo $i" " $text
result=$(curl -s -i --user-agent "" -d "sl=$source" -d "tl=$target" --data-urlencode "text=$1" http://translate.google.com)
encoding=$(awk '/Content-Type: .* charset=/ {sub(/^.*charset=["'\'']?/,""); sub(/[ "'\''].*$/,""); print}' <<<"$result")
iconv -f $encoding <<<"$result" | awk 'BEGIN {RS="</div>"};/<span[^>]* id=["'\'']?result_box["'\'']?/' | html2text
}
# prompt
PS1="\[\e[01;37m\]┌─[\t][$]: \w\[\e[01;37m\]\n\[\e[01;37m\]└──\[\e[01;37m\]──╼\[\e[0m\] "
|
x
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 | # ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
case $- in
*i*) ;;
*) return;;
esac
# Add vim as default editor
export EDITOR=vim
export TERMINAL=urxvt
export BROWSER=qupzilla
export PROMPT_COMMAND='echo -ne "\033]0;$PWD\007"'
# 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=1000
HISTFILESIZE=2000
# set pager
export PAGER=/usr/bin/most
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# Gtk themes
export GTK2_RC_FILES="$HOME/.gtkrc-2.0"
xhost +local:root > /dev/null 2>&1
complete -cf sudo
complete -cf man
# Shopt
shopt -s autocd
shopt -s cdspell
shopt -s cmdhist
shopt -s dotglob
shopt -s expand_aliases
shopt -s extglob
shopt -s hostcomplete
shopt -s nocaseglob
# Colour chart
T='123' # The test text
echo -e "\n 40m 41m 42m 43m\
44m 45m 46m 47m";
for FGs in ' m' ' 1m' ' 30m' '1;30m' ' 31m' '1;31m' ' 32m' \
'1;32m' ' 33m' '1;33m' ' 34m' '1;34m' ' 35m' '1;35m' \
' 36m' '1;36m' ' 37m' '1;37m';
do FG=${FGs// /}
echo -en " $FGs \033[$FG $T "
for BG in 40m 41m 42m 43m 44m 45m 46m 47m;
do echo -en "$EINS \033[$FG\033[$BG $T \033[0m";
done
echo;
done
echo
# 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
color_prompt=yes
# Bash Completion
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
# Alias definitions.
if [ -x ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
# Function definitions.
if [ -x ~/.bash_functions ]; then
. ~/.bash_functions
fi
# Prompt definitions.
if [ -x ~/.bash_prompt ]; then
. ~/.bash_prompt
fi
## MISC ALIASES ##
alias ls='ls --group-directories-first --time-style=+"%d.%m.%Y %H:%M" --color=auto -F'
alias ll='ls -l --group-directories-first --time-style=+"%d.%m.%Y %H:%M" --color=auto -F'
alias la='ls -la --group-directories-first --time-style=+"%d.%m.%Y %H:%M" --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 vp='vim PKGBUILD'
alias update='sudo pacman -Syu'
alias install='sudo pacman -S'
alias uninstall='sudo pacman -Rs'
alias search='pacman -Ss'
alias show='pacman -Si'
alias need='pacman -Qi'
alias missing='pacman -Qk'
alias trash='pacman -Qdt'
alias youtube-mp3='youtube-dl --extract-audio --audio-format mp3'
alias speedtest='speedtest-cli'
alias tint2='killall -SIGUSR1 tint2'
alias wvdial='sudo wvdial'
# Color man pages
man() {
env \
LESS_TERMCAP_mb=$(printf "\e[1;31m") \
LESS_TERMCAP_md=$(printf "\e[1;31m") \
LESS_TERMCAP_me=$(printf "\e[0m") \
LESS_TERMCAP_se=$(printf "\e[0m") \
LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
LESS_TERMCAP_ue=$(printf "\e[0m") \
LESS_TERMCAP_us=$(printf "\e[1;32m") \
man "$@"
}
## COMPRESSION FUNCTION ##
function compress_() {
# Credit goes to: Daenyth
FILE=$1
shift
case $FILE in
*.tar.bz2) tar cjf $FILE $* ;;
*.tar.gz) tar czf $FILE $* ;;
*.tgz) tar czf $FILE $* ;;
*.zip) zip $FILE $* ;;
*.rar) rar $FILE $* ;;
*) echo "Filetype not recognized" ;;
esac
}
## EXTRACT FUNCTION ##
extract ()
{
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $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 extract()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
# test if a file should be opened normally, or as root (edit)
argc () {
count=0;
for arg in "$@"; do
if [[ ! "$arg" =~ '-' ]]; then count=$(($count+1)); fi;
done;
echo $count;
}
edit () { if [[ `argc "$@"` > 1 ]]; then vim $@;
elif [ $1 = '' ]; then vim;
elif [ ! -f $1 ] || [ -w $1 ]; then vim $@;
else
echo -n "File is Read-only. Edit as root? (Y/n): "
read -n 1 yn; echo;
if [ "$yn" = 'n' ] || [ "$yn" = 'N' ];
then vim $*;
else sudo vim $*;
fi
fi
}
# cd and ls in one
cl() {
dir=$1
if [[ -z "$dir" ]]; then
dir=$HOME
fi
if [[ -d "$dir" ]]; then
cd "$dir"
ls
else
echo "bash: cl: '$dir': Directory not found"
fi
}
# test encode & decode base64
decode () {
echo "$1" | base64 -d ; echo
}
encode () {
echo "$1" | base64 - ; echo
}
# access translate.google.com from terminal
translate () {
# adjust to taste
DEFAULT_TARGET_LANG=en
if [[ $1 = -h || $1 = --help ]]
then
echo "$help"
exit
fi
if [[ $3 ]]; then
source="$2"
target="$3"
elif [[ $2 ]]; then
source=auto
target="$2"
else
source=auto
target="$DEFAULT_TARGET_LANG"
fi
echo $i" " $text
result=$(curl -s -i --user-agent "" -d "sl=$source" -d "tl=$target" --data-urlencode "text=$1" http://translate.google.com)
encoding=$(awk '/Content-Type: .* charset=/ {sub(/^.*charset=["'\'']?/,""); sub(/[ "'\''].*$/,""); print}' <<<"$result")
iconv -f $encoding <<<"$result" | awk 'BEGIN {RS="</div>"};/<span[^>]* id=["'\'']?result_box["'\'']?/' | html2text
}
# prompt
PS1="\[\e[01;37m\]┌─[\t][#]: \w\[\e[01;37m\]\n\[\e[01;37m\]└──\[\e[01;37m\]──╼\[\e[0m\] "
|
x
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | !BLACK
*color0: #1A1A1A
*color8: #404040
!RED
*color1: #9f6767
*color9: #9f6767
!GREEN
*color2: #92ac68
*color10: #92ac68
!YELLOW
*color3: #d0d293
*color11: #d0d293
!BLUE
*color4: #9aacc3
*color12: #9aacc3
!MAGENTA
*color5: #bb77a4
*color13: #bb77a4
!CYAN
*color6: #77bbb5
*color14: #77bbb5
!WHITE
*color7: #BBBBBB
*color15: #BBBBBB
!-- TRUE TRANSPARENCY -- !
!urxvt*depth: 32
!urxvt*background: rgba:0000/0000/0200/c800
!-- URxvt SETTINGS -- !
URxvt*title: Console
URxvt*termName: rxvt-unicode-256color
URxvt*geometry: 80x25
URxvt*fading: 10
urxvt*shading: 10
urxvt*loginShell: true
!-- URxvt INTERFACE -- !
urxvt*background: 0
urxvt*foreground: 7
!-- Xft SETTINGS -- !
Xft.dpi: 96
Xft.antialias: false
Xft.rgba: rgb
Xft.hinting: true
Xft.hintstyle: hintfull
! -- FONTS -- !
URxvt*font: xft:terminus:size=8
URxvt*boldFont: xft:terminus:size=8
URxvt*italicFont: xft:terminus:size=8
URxvt*boldItalicFont: xft:terminus:size=8
!-- FONT COLOUR: BOLD/ITALIC -- !
URxvt.colorBD: 7
URxvt.colorIT: 7
! -- SCROLLBAR -- !
URxvt*scrollBar: false
URxvt*scrollBar_right: true
URxvt*scrollColor: 7
URxvt*scrollstyle: urxvt
URxvt*saveLines: 1000
! -- SCROLL -- ! Need: urxvt-vtwheel
URxvt.perl-ext-common: default,matcher,tabbed,vtwheel,clipboard
URxvt*url-launcher: /usr/bin/qupzilla
URxvt*matcher.button: 1
! -- CURSOR -- !
urxvt*cursorColor: 7
urxvt*cursorBlink: true
urxvt*urgentOnBell: true
urxvt*cursorUnderline: true
! -- URL -- !
URxvt.colorUL: 4
! -- TAB -- !
URxvt.tabbed.tabbar-fg: 7
URxvt.tabbed.tabbar-bg: 0
URxvt.tabbed.tab-fg: 7
URxvt.tabbed.tab-bg: 0
! -- COPY & PASTE -- !
URxvt.keysym.Control-Shift-C: perl:clipboard:copy
URxvt.keysym.Control-Shift-V: perl:clipboard:paste
URxvt.iso14755: False
|
x
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | !BLACK
*color0: #1A1A1A
*color8: #404040
!RED
*color1: #9f6767
*color9: #9f6767
!GREEN
*color2: #92ac68
*color10: #92ac68
!YELLOW
*color3: #d0d293
*color11: #d0d293
!BLUE
*color4: #9aacc3
*color12: #9aacc3
!MAGENTA
*color5: #bb77a4
*color13: #bb77a4
!CYAN
*color6: #77bbb5
*color14: #77bbb5
!WHITE
*color7: #BBBBBB
*color15: #BBBBBB
!-- TRUE TRANSPARENCY -- !
!urxvt*depth: 32
!urxvt*background: rgba:0000/0000/0200/c800
!-- URxvt SETTINGS -- !
URxvt*title: Console
URxvt*termName: rxvt-unicode-256color
URxvt*geometry: 80x25
URxvt*fading: 10
urxvt*shading: 10
urxvt*loginShell: true
!-- URxvt INTERFACE -- !
urxvt*background: 0
urxvt*foreground: 7
!-- Xft SETTINGS -- !
Xft.dpi: 96
Xft.antialias: false
Xft.rgba: rgb
Xft.hinting: true
Xft.hintstyle: hintfull
! -- FONTS -- !
URxvt*font: xft:terminus:size=8
URxvt*boldFont: xft:terminus:size=8
URxvt*italicFont: xft:terminus:size=8
URxvt*boldItalicFont: xft:terminus:size=8
!-- FONT COLOUR: BOLD/ITALIC -- !
URxvt.colorBD: 7
URxvt.colorIT: 7
! -- SCROLLBAR -- !
URxvt*scrollBar: false
URxvt*scrollBar_right: true
URxvt*scrollColor: 7
URxvt*scrollstyle: urxvt
URxvt*saveLines: 1000
! -- SCROLL -- ! Need: urxvt-vtwheel
URxvt.perl-ext-common: default,matcher,tabbed,vtwheel,clipboard
URxvt*url-launcher: /usr/bin/qupzilla
URxvt*matcher.button: 1
! -- CURSOR -- !
urxvt*cursorColor: 7
urxvt*cursorBlink: true
urxvt*urgentOnBell: true
urxvt*cursorUnderline: true
! -- URL -- !
URxvt.colorUL: 4
! -- TAB -- !
URxvt.tabbed.tabbar-fg: 7
URxvt.tabbed.tabbar-bg: 0
URxvt.tabbed.tab-fg: 7
URxvt.tabbed.tab-bg: 0
! -- COPY & PASTE -- !
URxvt.keysym.Control-Shift-C: perl:clipboard:copy
URxvt.keysym.Control-Shift-V: perl:clipboard:paste
URxvt.iso14755: False
|
x
Notes
- copy your .Xdefaults and .Xresources to root cheers