-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.shell_common
More file actions
212 lines (177 loc) · 4.88 KB
/
.shell_common
File metadata and controls
212 lines (177 loc) · 4.88 KB
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
# custom bash settings
# use vim as editor
export EDITOR=vim
export VISUAL=vim
export TERM=xterm
export PATH="$HOME/.fnm":$PATH
alias oldvim=/usr/bin/vim
alias vim=nvim
# allow to pipe result to vim
alias xargsvim="xargs bash -c '</dev/tty vim \"\$@\"' ignoreme"
# ask once for the ssh key
ssh-add -l > /dev/null || alias ssh='ssh-add -l > /dev/null || ssh-add && unalias ssh; ssh'
ssh-add -l > /dev/null && alias git='LANG=en git'
ssh-add -l > /dev/null || alias git='ssh-add -l > /dev/null || ssh-add && alias git="LANG=en git"; LANG=en git'
export LS_OPTIONS='--color=yes'
# increase history
HISTSIZE=10000
# open aliases
alias open='xdg-open'
alias o='xdg-open'
# some more ls aliases
alias ll='ls $LS_OPTION -lh --color'
alias l='ls $LS_OPTIONS -Ff --color'
alias la='ls $LS_OPTIONS -al --color'
alias ld='ls -d $LS_OPTIONS -af --color'
alias lad='ls -d $LS_OPTIONS -al --color'
alias grep='grep --colour'
# git alias
alias gitc='git log --graph --pretty=oneline --abbrev-commit --decorate'
alias git-branch-clean='git branch --merged | grep -v "\*" | grep -v master | xargs -n 1 git branch -d'
# Kill all running containers.
alias dockerkillall='docker kill $(docker ps -q)'
# Delete all stopped containers.
alias dockercleanc='printf "\n>>> Deleting stopped containers\n\n" && docker rm $(docker ps -a -q)'
# Delete all untagged images.
alias dockercleani='printf "\n>>> Deleting untagged images\n\n" && docker rmi $(docker images -q -f dangling=true)'
# Delete all stopped containers and untagged images.
alias dockerclean='dockercleanc || true && dockercleani'
# make some stuff english
alias make='LANG=en make'
# default java classpath
export CLASSPATH="bin:lib:.:lib/*:*:/usr/share/java/*"
alias junit='java -cp ${CLASSPATH} org.junit.runner.JUnitCore'
# Logins
alias logins='cat /var/log/auth.log | grep "user rf"'
#most used commands
# shellcheck disable=SC2142
alias most='history | awk '\''{print $2}'\'' | awk '\''BEGIN{FS="|"}{print $1}'\'' | sort | uniq -c | sort -n | tail -n 20 | sort -nr'
#vim confusion
alias :q='exit'
alias :wq='exit'
# create directories recursively if they do not exist
# do something with it, ie. move/copy files to it
# mkdo cp source destination
# mkdo mv source destination
function mkdo
{
if [ "$#" == 0 ]; then
echo "Usage: $0 command [source] destination [arguments]"
return 1
fi
command=$1
shift
if [ "$#" == 1 ]; then
dest=$1
else
dest=$2
fi
if [ -d "$dest" ]; then
$command "$*"
else
if [ ! -e "$dest" ]; then
mkdir -p "$dest";
$command "$*"
fi
fi
}
# backup file
function bak
{
cp -r "$1" "$1.bak"
}
function bakm
{
mv "$1" "$1.bak"
}
function unbak
{
bakfile=$1
ext=${bakfile##*.}
filepath=${bakfile%.*}
if [ "bak" == "${ext}" ]
then
cp -r "$bakfile" "$filepath"
fi
}
function unbakm
{
bakfile=$1
ext=${bakfile##*.}
filepath=${bakfile%.*}
if [ "bak" == "${ext}" ]
then
mv "$bakfile" "$filepath"
fi
}
# Set xterm title
function auto_title
{
if [ -z "$MYTITLE" ]
then
repo_name=$(git rev-parse --show-toplevel 2>> /dev/null)
if [ -z "${repo_name}" ]
then
pwd
else
replace="s#${repo_name}/##g"
if [ "$(pwd)" = "$repo_name" ]
then
basename "$repo_name"
else
echo "$(basename "$repo_name")" "$(pwd | sed "$replace")"
fi
fi
else
echo $MYTITLE
fi
}
function title
{
MYTITLE=$1
}
#Preload Files
alias preload_files='sudo less /var/lib/preload/preload.state'
#PDF verkleinern
function pdfsmall
{
command gs -sDEVICE=pdfwrite -sOutputFile="$2" -dBATCH -dNOPAUSE -dPDFSETTINGS=/ebook "$1"
}
#PDF deskew
function pdfdeskew
{
command convert -quality 50 -density 300 +deskew "$1" -compress jpeg "$2"
}
#Startup Check Counter
#counter "dev"
function counter
{
command sudo dumpe2fs -h "$1" | grep -i "mount count"
}
#counter_set "dev" "number"
function counter_set
{
command sudo tune2fs -C "$2" "$1"
}
#Notify when a job has finished
alias alert_helper='history|tail -n1|sed -e "s/^\s*[0-9]\+\s*//" -e "s/;\s*alert$//"'
alias alert='notify-send -i /usr/share/icons/gnome/32x32/apps/gnome-terminal.png "[$?] $(alert_helper)"'
#Statt für 3 Verzeichnisse cd ../../.. oder für 7 Verzeichnisse cd ../../../../../../.. aufzurufen, wird einfach up 3 oder up 7 aufgerufen. Diese #Funktion kann in die ~/.bashrc oder global in die /etc/bash.bashrc übernommen werden, um beim Starten einer Shell verfügbar zu sein.
function up {
[ "${1/[^0-9]/}" = "$1" ] && {
local ups=""
for _ in $(seq 1 "$1")
do
ups=$ups"../"
done
cd $ups
} || echo "usage: up INTEGER"
}
# remove orhpaned packages
orphans() {
pacman -Qdtq
}
if [ -e $HOME/.shell_local ]
then
source $HOME/.shell_local
fi