diff options
| author | 2015-08-25 20:39:11 +0200 | |
|---|---|---|
| committer | 2015-08-25 20:39:11 +0200 | |
| commit | 3d6f9d261ecee8805c763d5fc3aba7af5ed9610b (patch) | |
| tree | e2c4bcca5e088e29568f78d8113824ecf7d84c78 /bash/.bashrc | |
| parent | 344ce46b48a1b6920fcbbb4b308973f8441fa563 (diff) | |
| parent | ef52a18605b17a67eeed0a5772fb60d6d0106899 (diff) | |
| download | dotfiles-3d6f9d261ecee8805c763d5fc3aba7af5ed9610b.tar.gz dotfiles-3d6f9d261ecee8805c763d5fc3aba7af5ed9610b.tar.bz2 dotfiles-3d6f9d261ecee8805c763d5fc3aba7af5ed9610b.zip | |
Merge branch 'master' into hlwm_refactoring
Diffstat (limited to 'bash/.bashrc')
| -rwxr-xr-x | bash/.bashrc | 71 |
1 files changed, 33 insertions, 38 deletions
diff --git a/bash/.bashrc b/bash/.bashrc index e8a61fc..247955a 100755 --- a/bash/.bashrc +++ b/bash/.bashrc | |||
| @@ -5,14 +5,18 @@ | |||
| 5 | # If not running interactively, don't do anything | 5 | # If not running interactively, don't do anything |
| 6 | [[ $- != *i* ]] && return | 6 | [[ $- != *i* ]] && return |
| 7 | 7 | ||
| 8 | # Default PS1 | ||
| 8 | export PS1='[\d][\t]\u on \h\n\w $ ' | 9 | export PS1='[\d][\t]\u on \h\n\w $ ' |
| 9 | 10 | ||
| 11 | # Additional local paths | ||
| 10 | export PATH="$PATH:$HOME/.local/bin" | 12 | export PATH="$PATH:$HOME/.local/bin" |
| 11 | export PATH="$PATH:$HOME/.local/usr/bin" | 13 | export PATH="$PATH:$HOME/.local/usr/bin" |
| 12 | export PATH="$PATH:$HOME/.local/usr/local/bin" | 14 | export PATH="$PATH:$HOME/.local/usr/local/bin" |
| 13 | 15 | ||
| 16 | # Quit the shell like in vim | ||
| 14 | alias :q="exit" | 17 | alias :q="exit" |
| 15 | 18 | ||
| 19 | # Keep OS compatibility | ||
| 16 | case "$(uname)" in | 20 | case "$(uname)" in |
| 17 | Linux) | 21 | Linux) |
| 18 | alias ls="ls --color=auto" | 22 | alias ls="ls --color=auto" |
| @@ -28,6 +32,7 @@ case "$(uname)" in | |||
| 28 | ;; | 32 | ;; |
| 29 | esac | 33 | esac |
| 30 | 34 | ||
| 35 | # Colorfull manpages | ||
| 31 | man() { | 36 | man() { |
| 32 | env LESS_TERMCAP_mb=$'\E[01;31m' \ | 37 | env LESS_TERMCAP_mb=$'\E[01;31m' \ |
| 33 | LESS_TERMCAP_md=$'\E[01;38;5;74m' \ | 38 | LESS_TERMCAP_md=$'\E[01;38;5;74m' \ |
| @@ -39,6 +44,7 @@ man() { | |||
| 39 | man "$@" | 44 | man "$@" |
| 40 | } | 45 | } |
| 41 | 46 | ||
| 47 | # Helpfull functions | ||
| 42 | exists() { | 48 | exists() { |
| 43 | hash $@ 2> /dev/null | 49 | hash $@ 2> /dev/null |
| 44 | } | 50 | } |
| @@ -61,57 +67,39 @@ is_alias() { | |||
| 61 | fi | 67 | fi |
| 62 | } | 68 | } |
| 63 | 69 | ||
| 64 | if exists sudo; then | 70 | # Set autocomplete for sudo |
| 65 | sudo() { | ||
| 66 | # Allow functions and aliasses to be executed with sudo | ||
| 67 | if is_function $1 2> /dev/null; then | ||
| 68 | tmpfile="/tmp/$(date +%s).sh" | ||
| 69 | |||
| 70 | echo "#!$usr/bin/bash" > "$tmpfile" | ||
| 71 | echo "usr=$usr" >> "$tmpfile" | ||
| 72 | type $1 | grep -v "is a function" >> "$tmpfile" | ||
| 73 | echo "$@" >> "$tmpfile" | ||
| 74 | |||
| 75 | chmod +x "$tmpfile" | ||
| 76 | |||
| 77 | $usr/bin/sudo "$tmpfile" | ||
| 78 | |||
| 79 | rm "$tmpfile" | ||
| 80 | elif is_alias $1 2> /dev/null; then | ||
| 81 | alias=$(type $1 2> /dev/null | | ||
| 82 | sed -n "s/^$1\ is\ aliased\ to\ \`\(.*\)'$/\1/p") | ||
| 83 | |||
| 84 | $usr/bin/sudo "$alias" | ||
| 85 | else | ||
| 86 | $usr/bin/sudo "$@" | ||
| 87 | fi | ||
| 88 | } | ||
| 89 | fi | ||
| 90 | |||
| 91 | if exists complete && exists sudo; then | 71 | if exists complete && exists sudo; then |
| 92 | complete -cf sudo | 72 | complete -cf sudo |
| 93 | fi | 73 | fi |
| 94 | 74 | ||
| 75 | # Jupiterbroadcasting live stream | ||
| 95 | if exists mpv; then | 76 | if exists mpv; then |
| 96 | alias jblive='mpv rtmp://videocdn-us.geocdn.scaleengine.net/jblive/live/jblive.stream' | 77 | alias jblive='mpv rtmp://videocdn-us.geocdn.scaleengine.net/jblive/live/jblive.stream' |
| 97 | elif exists vlc; then | 78 | elif exists vlc; then |
| 98 | alias jblive='vlc rtmp://videocdn-us.geocdn.scaleengine.net/jblive/live/jblive.stream' | 79 | alias jblive='vlc rtmp://videocdn-us.geocdn.scaleengine.net/jblive/live/jblive.stream' |
| 99 | fi | 80 | fi |
| 100 | 81 | ||
| 101 | if exists vim; then | 82 | # Set the default editor |
| 83 | if exists nvim; then | ||
| 84 | export EDITOR="nvim" | ||
| 85 | elif exists vim; then | ||
| 102 | export EDITOR="vim" | 86 | export EDITOR="vim" |
| 103 | vim() { | 87 | elif exists vi; then |
| 104 | if [[ -z $@ ]]; then | 88 | export EDITOR="vi" |
| 105 | $usr/bin/vim | ||
| 106 | elif [[ -d $@ ]]; then | ||
| 107 | dir=$(pwd) | ||
| 108 | cd $@ && $usr/bin/vim && cd $dir | ||
| 109 | else | ||
| 110 | $usr/bin/vim $@ | ||
| 111 | fi | ||
| 112 | } | ||
| 113 | fi | 89 | fi |
| 114 | 90 | ||
| 91 | vim() { | ||
| 92 | if [[ -z $@ ]]; then | ||
| 93 | $EDITOR | ||
| 94 | elif [[ -d $@ ]]; then | ||
| 95 | dir=$(pwd) | ||
| 96 | cd $@ && $EDITOR && cd $dir | ||
| 97 | else | ||
| 98 | $EDITOR $@ | ||
| 99 | fi | ||
| 100 | } | ||
| 101 | |||
| 102 | # Programming language specifics | ||
| 115 | if exists go; then | 103 | if exists go; then |
| 116 | export GOPATH="$HOME/programming/go" | 104 | export GOPATH="$HOME/programming/go" |
| 117 | export PATH="$PATH:$GOPATH/bin" | 105 | export PATH="$PATH:$GOPATH/bin" |
| @@ -122,12 +110,14 @@ if exists gem; then | |||
| 122 | export PATH="$PATH:$GEM_HOME" | 110 | export PATH="$PATH:$GEM_HOME" |
| 123 | fi | 111 | fi |
| 124 | 112 | ||
| 113 | # Ezjail shortcuts | ||
| 125 | if exists ezjail-admin && exists sudo; then | 114 | if exists ezjail-admin && exists sudo; then |
| 126 | jl() { | 115 | jl() { |
| 127 | sudo ezjail-admin $1 $2\.tomvanderlee.com | 116 | sudo ezjail-admin $1 $2\.tomvanderlee.com |
| 128 | } | 117 | } |
| 129 | fi | 118 | fi |
| 130 | 119 | ||
| 120 | # Showbanned ipadresses | ||
| 131 | if exists pfctl && exists sudo; then | 121 | if exists pfctl && exists sudo; then |
| 132 | showbanned () | 122 | showbanned () |
| 133 | { | 123 | { |
| @@ -145,14 +135,17 @@ if exists pfctl && exists sudo; then | |||
| 145 | } | 135 | } |
| 146 | fi | 136 | fi |
| 147 | 137 | ||
| 138 | # Always use pacaur even if it is not installed | ||
| 148 | if (exists pacman && ! exists pacaur) && exists sudo; then | 139 | if (exists pacman && ! exists pacaur) && exists sudo; then |
| 149 | alias pacaur="sudo pacman" | 140 | alias pacaur="sudo pacman" |
| 150 | fi | 141 | fi |
| 151 | 142 | ||
| 143 | # Set the default pager | ||
| 152 | if exists less; then | 144 | if exists less; then |
| 153 | export PAGER="less" | 145 | export PAGER="less" |
| 154 | fi | 146 | fi |
| 155 | 147 | ||
| 148 | # Pip upgrade script | ||
| 156 | if exists pip; then | 149 | if exists pip; then |
| 157 | pip() { | 150 | pip() { |
| 158 | if [[ "$1" == "upgrade" ]] || [[ "$1" == "update" ]]; then | 151 | if [[ "$1" == "upgrade" ]] || [[ "$1" == "update" ]]; then |
| @@ -170,10 +163,12 @@ if exists pip; then | |||
| 170 | } | 163 | } |
| 171 | fi | 164 | fi |
| 172 | 165 | ||
| 166 | # Fancy bash prompt | ||
| 173 | if exists liquidprompt; then | 167 | if exists liquidprompt; then |
| 174 | source liquidprompt | 168 | source liquidprompt |
| 175 | fi | 169 | fi |
| 176 | 170 | ||
| 171 | # Fancy system info | ||
| 177 | if exists archey3; then | 172 | if exists archey3; then |
| 178 | archey3 | 173 | archey3 |
| 179 | elif exists screenfetch; then | 174 | elif exists screenfetch; then |
