-
Notifications
You must be signed in to change notification settings - Fork 2
/
.bash_aliases
142 lines (124 loc) · 3.9 KB
/
.bash_aliases
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
###############################################################################
######################### Custom alias definitions ############################
###############################################################################
# Colors
export COLOR_NC='\e[0m' # No Color
export COLOR_WHITE='\e[1;37m'
export COLOR_BLACK='\e[0;30m'
export COLOR_BLUE='\e[0;34m'
export COLOR_LIGHT_BLUE='\e[1;34m'
export COLOR_GREEN='\e[0;32m'
export COLOR_LIGHT_GREEN='\e[1;32m'
export COLOR_CYAN='\e[0;36m'
export COLOR_LIGHT_CYAN='\e[1;36m'
export COLOR_RED='\e[0;31m'
export COLOR_LIGHT_RED='\e[1;31m'
export COLOR_PURPLE='\e[0;35m'
export COLOR_LIGHT_PURPLE='\e[1;35m'
export COLOR_BROWN='\e[0;33m'
export COLOR_YELLOW='\e[1;33m'
export COLOR_GRAY='\e[0;30m'
export COLOR_LIGHT_GRAY='\e[0;37m'
export PAGER=less
export LESS_TERMCAP_mb=$'\E[01;33m' # begin bold
export LESS_TERMCAP_md=$'\E[01;31m' # begin blink
export LESS_TERMCAP_me=$'\E[0m' # reset bold/blink
export LESS_TERMCAP_so=$'\E[01;42;30m' # begin reverse video
export LESS_TERMCAP_se=$'\E[0m' # reset reverse video
export LESS_TERMCAP_us=$'\E[01;32m' # begin underline
export LESS_TERMCAP_ue=$'\E[0m' # reset underline
export GROFF_NO_SGR=1 # for konsole and gnome-terminal
export LESS=-iMFXRj.5a#1
export GREP_COLOR="1;31"
# Make bash history global
export PROMPT_COMMAND="history -a; history -r"
# Colorised aliases
alias ll='grc ls -lFha --color'
alias la='grc ls -A --color'
alias l='grc ls -CFlh --color'
alias dir='dir --color'
alias vdir='vdir --color'
alias ping="grc ping"
alias netstat="grc netstat"
alias ifconfig="grc ifconfig"
# Short aliases
alias u='cd ..'
alias uu='cd ../..'
alias uuu='cd ../../..'
alias uuuu='cd ../../../..'
alias uuuuu='cd ../../../../..'
alias uuuuuu='cd ../../../../../..'
alias uuuuuuu='cd ../../../../../../..'
alias uuuuuuuu='cd ../../../../../../../..'
alias uuuuuuuuu='cd ../../../../../../../../..'
alias uuuuuuuuuu='cd ../../../../../../../../../..'
alias b='cd - &> /dev/null'
alias c='clear'
alias q='exit'
alias h='history'
alias s='subl'
alias g='grep'
alias p='ping -c 1'
alias m='meld'
alias d='list_dirs_only'
alias f='fff_cd'
# Git aliases
alias gits='git status'
alias gitd='git diff'
alias gitl='git log --decorate --graph'
alias gitb='git branch'
alias gitm='git meld'
alias gitk='gitk_without_grabbing_console'
# Additional aliases
alias sudo='sudo ' # For using aliases by sudo
alias mc='EDITOR="subl" . /usr/lib/mc/mc-wrapper.sh'
alias shutdown='sudo shutdown -h now'
alias reboot='sudo reboot'
alias untar='tar xvf'
# Functions
parse_git_branch() { # Show git branch
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
gitk_without_grabbing_console() { # Used as alias for gitk but with parameters
\gitk $@ &> /dev/null &
}
list_dirs_only() { # Show only directories in the specified dir
if [ ! -z $1 ]; then
$1="$1/"
fi
grc ls -lad $1*/ --color
}
gitsubl() {
git config --global core.editor "subl -n -w"
}
gitvim() {
git config --global core.editor "vim"
}
fff_cd()
{
fff "$@"
cd "$(cat "${XDG_CACHE_HOME:=${HOME}/.cache}/fff/.fff_d")"
}
# Force color prompt
force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
# Set PS1
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;33m\]$(parse_git_branch)\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(parse_git_branch)\$ '
fi
unset color_prompt force_color_prompt
# Work specific custom aliases and funcs
if [ -f ~/.bash_aliases_work ]; then
. ~/.bash_aliases_work
fi