-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bashrc__general__aliases_exports
162 lines (130 loc) · 6.12 KB
/
.bashrc__general__aliases_exports
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
# this file should be available as ~/.bash_aliases (either as copy or as symlink)
# put these to extra file for easier support of different distribution's .bashrcs
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r $HOME/.dircolors && eval "$(dircolors -b $HOME/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
alias dir='ls --color=auto --format=vertical'
alias vdir='ls --color=auto --format=long'
fi
# prevent destruction
alias chgrp='chgrp --preserve-root'
alias chmod='chmod --preserve-root'
alias chown='chown --preserve-root'
# some more ls aliases
alias l.='ls -d .* --color=auto'
alias ll='ls -l --color=auto --time-style=+\ \ %Y-%m-%d\ %H:%M:%S\ \ '
alias la='ls -A --color=auto'
alias lla='ls -lA --color=auto --time-style=+\ \ %Y-%m-%d\ %H:%M:%S\ \ '
alias l='ls -CF --color=auto'
# quick directory changes
alias ..='cd ..'
alias 1..='cd ..'
alias 2..='cd ../..'
alias 3..='cd ../../..'
alias 4..='cd ../../../..'
alias 5..='cd ../../../../..'
alias 6..='cd ../../../../../..'
alias 7..='cd ../../../../../../..'
alias 8..='cd ../../../../../../../..'
alias 9..='cd ../../../../../../../../..'
# the most commonly used grep variants
alias grep='grep --color=auto'
alias ggrep='grep -inTs --color=auto'
alias igrep='grep -is --color=auto'
alias sgrep='grep -s --color=auto'
alias egrep='egrep --color=auto'
alias fgrep='fgrep -s --color=auto'
# some aliases to grep certain filename suffixes only
alias confgrep='grep -inTsr --color=auto --include=*.{cfg,conf,ini}'
alias cssgrep='grep -inTsr --color=auto --include=*.css'
alias htmlgrep='grep -inTsr --color=auto --include=*.{htm,html}'
alias phpgrep='grep -inTsr --color=auto --include=*.{phtml,php,php3,php4,php5}'
alias pphp='mkdir -p $HOME/xdebug && php -d xdebug.profiler_enable=1 -d xdebug.profiler_output_dir=$HOME/xdebug -d xdebug.profiler_output_name="cachegrind.%t--%s--%R.out" -d xdebug.profiler_append=On -d xdebug.trace_options=1 -d xdebug.collect_params=4 -d xdebug.collect_return=1 -d xdebug.collect_vars=0 '
alias pygrep='grep -inTsr --color=auto --include=*.{py,pyw}'
alias shgrep='grep -inTsr --color=auto --include=*.sh'
alias texgrep='grep -inTsr --color=auto --include=*.tex'
alias tplgrep='grep -inTsr --color=auto --include=*.{tpl,blade.php}'
alias xmlgrep='grep -inTsr --color=auto --include=*.{xml,xsd,xsl,xfo,dtd}'
alias py='/usr/bin/env python3 -u'
alias httpserver_python3='/usr/bin/env python3 -m http.server'
# quick overview over dir size in current directory
alias du1='du -h --max-depth=1'
# nice overview over commit history including branches
alias gg="git log --graph --full-history --all --pretty=format:'%Cred%h%Creset %ad %s %C(yellow)%d%Creset %C(bold blue)<%an>%Creset' --date=short"
# pull branch including submodules
alias gps="git pull && git submodule update --init --recursive"
# Add an "alert" alias for long running commands. Use like so:
# sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
# command reference
alias coref="okular $HOME/tutorials/linux/linux_command_reference.pdf &"
# quick search/show packages
alias apol='apt-cache policy'
alias asearch='echo && apt-cache search'
alias ashow='echo && apt-cache show'
# show current git user and mail on each git command
# commented out: causing several problems e.g. with autocompletion
# GIT_USER="$HOME/dotfiles/helpers/git-user.py"
# alias gu='echo "~/dotfiles/helpers/git-user.py does not exist"'
# if [ -f $GIT_USER ]; then
# PYTHON3_VERSION=$(/usr/bin/env python3 --version)
# if [ $? -eq 0 ]; then
# alias gu="$GIT_USER"
# alias git='aliaswrapperfunc(){ git "$@" && '$HOME'/dotfiles/helpers/git-user.py; unset -f aliaswrapperfunc; }; aliaswrapperfunc' # idea from https://unix.stackexchange.com/questions/3773/how-to-pass-parameters-to-an-alias
# fi
# fi
# quick activation of python virtual environments
alias activate='source ./venv/bin/activate'
# better debug output from bash scripts (bash -x);
# source: Linux-Magazin 10/12, pg. 87
export PS4='+${BASH_SOURCE##*/}:${LINENO}:${FUNCNAME[0]}: '
# wrapper to use colordiff instead of diff
if [ -f /usr/bin/colordiff ]; then
alias diff='/usr/bin/colordiff'
fi
# colored GCC warnings and errors
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
# on systems without git completion (e.g. CentOS) simply put file git-completion.bash into users root dir
# the file can be downloaded at https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash
if [ -f $HOME/git-completion.bash ]; then
source $HOME/git-completion.bash
fi
# add some root-only aliases
if [ "$(id -u)" == "0" ]; then
# switch for neo2<=>de on TTY1..6
alias asdf='/root/.neo2_layout/activate_numlock.sh; cd ~/.neo2_layout; loadkeys neo; cd ~'
alias uiae='loadkeys de'
# Some aliases to avoid making mistakes:
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
fi
# use self compiled vim if available (e.g. on CentOS there is no python3 support – but needed for vdebug)
if [ -d "$HOME/.local/vim/bin/" ] ; then
PATH="$HOME/.local/vim/bin/:$PATH"
VIM_EXECUTABLE=$HOME/.local/vim/bin/vim
else
VIM_EXECUTABLE=$(which vim)
fi
# needed for sudoedit using vim instead of vi (e.g. on CentOS)
# also used by mc for editor on <F4>
export EDITOR=$VIM_EXECUTABLE
# open file readonly
alias vimr="$VIM_EXECUTABLE -pR"
# open multiple files in tabs
alias vim="$VIM_EXECUTABLE -p"
# aliases for phpcs/phpcbf
alias pfix='vendor/bin/phpcbf --colors'
alias pfixmodified='git ls-files --modified | grep "\.php$" | xargs vendor/bin/phpcbf --colors'
alias psniff='vendor/bin/phpcs --colors'
alias psniffmodified='git ls-files --modified | grep "\.php$" | xargs vendor/bin/phpcs --colors'
# todo.txt
alias t="mkdir -p $HOME/.topydo && topydo -t $HOME/.topydo/todo.txt -d $HOME/.topydo/done.txt"
# notes
alias n="mkdir -p $HOME/notes && cd $HOME/notes && $VIM_EXECUTABLE -p *.md && git add . && git commit -m \"Autocommit\""
# get rid of sudo on docker commands
alias docker="sudo docker"
# and some user-only aliases
# if [ "$(id -u)" != "0" ]; then
# fi