aboutsummaryrefslogtreecommitdiffstats
path: root/bash/.bashrc
diff options
context:
space:
mode:
authorGravatar Tom van der Lee <t0m.vd.l33@gmail.com>2015-08-25 20:39:11 +0200
committerGravatar Tom van der Lee <t0m.vd.l33@gmail.com>2015-08-25 20:39:11 +0200
commit3d6f9d261ecee8805c763d5fc3aba7af5ed9610b (patch)
treee2c4bcca5e088e29568f78d8113824ecf7d84c78 /bash/.bashrc
parent344ce46b48a1b6920fcbbb4b308973f8441fa563 (diff)
parentef52a18605b17a67eeed0a5772fb60d6d0106899 (diff)
downloaddotfiles-3d6f9d261ecee8805c763d5fc3aba7af5ed9610b.tar.gz
dotfiles-3d6f9d261ecee8805c763d5fc3aba7af5ed9610b.tar.bz2
dotfiles-3d6f9d261ecee8805c763d5fc3aba7af5ed9610b.zip
Merge branch 'master' into hlwm_refactoring
Diffstat (limited to 'bash/.bashrc')
-rwxr-xr-xbash/.bashrc71
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
8export PS1='[\d][\t]\u on \h\n\w $ ' 9export PS1='[\d][\t]\u on \h\n\w $ '
9 10
11# Additional local paths
10export PATH="$PATH:$HOME/.local/bin" 12export PATH="$PATH:$HOME/.local/bin"
11export PATH="$PATH:$HOME/.local/usr/bin" 13export PATH="$PATH:$HOME/.local/usr/bin"
12export PATH="$PATH:$HOME/.local/usr/local/bin" 14export PATH="$PATH:$HOME/.local/usr/local/bin"
13 15
16# Quit the shell like in vim
14alias :q="exit" 17alias :q="exit"
15 18
19# Keep OS compatibility
16case "$(uname)" in 20case "$(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 ;;
29esac 33esac
30 34
35# Colorfull manpages
31man() { 36man() {
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
42exists() { 48exists() {
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
64if 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 }
89fi
90
91if exists complete && exists sudo; then 71if exists complete && exists sudo; then
92 complete -cf sudo 72 complete -cf sudo
93fi 73fi
94 74
75# Jupiterbroadcasting live stream
95if exists mpv; then 76if 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'
97elif exists vlc; then 78elif 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'
99fi 80fi
100 81
101if exists vim; then 82# Set the default editor
83if exists nvim; then
84 export EDITOR="nvim"
85elif exists vim; then
102 export EDITOR="vim" 86 export EDITOR="vim"
103 vim() { 87elif 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 }
113fi 89fi
114 90
91vim() {
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
115if exists go; then 103if 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"
123fi 111fi
124 112
113# Ezjail shortcuts
125if exists ezjail-admin && exists sudo; then 114if 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 }
129fi 118fi
130 119
120# Showbanned ipadresses
131if exists pfctl && exists sudo; then 121if exists pfctl && exists sudo; then
132 showbanned () 122 showbanned ()
133 { 123 {
@@ -145,14 +135,17 @@ if exists pfctl && exists sudo; then
145 } 135 }
146fi 136fi
147 137
138# Always use pacaur even if it is not installed
148if (exists pacman && ! exists pacaur) && exists sudo; then 139if (exists pacman && ! exists pacaur) && exists sudo; then
149 alias pacaur="sudo pacman" 140 alias pacaur="sudo pacman"
150fi 141fi
151 142
143# Set the default pager
152if exists less; then 144if exists less; then
153 export PAGER="less" 145 export PAGER="less"
154fi 146fi
155 147
148# Pip upgrade script
156if exists pip; then 149if 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 }
171fi 164fi
172 165
166# Fancy bash prompt
173if exists liquidprompt; then 167if exists liquidprompt; then
174 source liquidprompt 168 source liquidprompt
175fi 169fi
176 170
171# Fancy system info
177if exists archey3; then 172if exists archey3; then
178 archey3 173 archey3
179elif exists screenfetch; then 174elif exists screenfetch; then