-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bash_aliases
73 lines (62 loc) · 1.56 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
# Some useful aliases.
alias comp="docker compose"
alias ..="cd .."
alias updatetime="sudo ntpdate ntp.ubuntu.com"
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
alias ll='ls -alF'
alias la='ls -A'
alias gb='git branch'
alias gc='git checkout'
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$//'\'')"'
# Dotenv
dotenv() {
export $(grep -v "^#" .env | xargs)
}
unset_dotenv() {
unset $(grep -v '^#' .env | sed -E 's/(.*)=.*/\1/' | xargs)
}
#
# Csh compatibility:
#
alias unsetenv=unset
function setenv() {
export $1="$2"
}
# Function which adds an alias to the current shell and to
# the ~/.bash_aliases file.
add-alias() {
local name=$1 value="$2"
echo alias $name=\'$value\' >>~/.bash_aliases
eval alias $name=\'$value\'
alias $name
}
# "repeat" command. Like:
#
# repeat 10 echo foo
repeat() {
local count="$1" i
shift
for i in $(_seq 1 "$count"); do
eval "$@"
done
}
# Subfunction needed by `repeat'.
_seq() {
local lower upper output
lower=$1 upper=$2
if [ $lower -ge $upper ]; then return; fi
while [ $lower -lt $upper ]; do
echo -n "$lower "
lower=$(($lower + 1))
done
echo "$lower"
}
# Options
set -o vi