-
Notifications
You must be signed in to change notification settings - Fork 0
/
.aliases
96 lines (83 loc) · 2.96 KB
/
.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
#!/bin/sh
# prevent bash issues such as this: if we have just uninstalled gnu grep and we source 'bash_profile' in the same shell,
# we might get the error "/usr/local/bin/grep: No such file or directory" when we use grep just a few lines bellow and elsewhere
hash -r
# basic aliases
alias d='cd ${HOME}/Desktop'
alias p='cd ${PROJECT_HOME}'
alias s='echo $?'
alias dotcd='cd ${DOTFILES}'
alias dsync='set -- -f; . ${DOTFILES}/bootstrap.sh'
if ! command -v code >/dev/null 2>&1 && command -v code-insiders >/dev/null 2>&1; then
alias code="code-insiders "
fi
if command -v code >/dev/null 2>&1; then
alias dotop='code ${DOTFILES}'
alias dot='dotcd && dotop'
fi
# grep alias
if printf "test" | GREP_OPTIONS="" command grep --color=auto "test" >/dev/null 2>&1; then # test for grep color option
alias grep="grep --color=auto"
fi
# ls aliases
lscmd="ls"
colorflag=""
group_dir_flag=""
if command gls --version >/dev/null 2>&1; then # gnu 'ls' is installed with prefix 'g'
lscmd="gls"
colorflag="--color=auto"
group_dir_flag="--group-directories-first"
elif command ls --color >/dev/null 2>&1; then # gnu 'ls' flavor is installed
colorflag="--color=auto"
group_dir_flag="--group-directories-first"
elif command ls -G >/dev/null 2>&1; then # macos/*bsd 'ls' flavor is installed
colorflag="-G"
fi
# shellcheck disable=SC2139
{
alias ls="$lscmd -F $colorflag $group_dir_flag"
alias lsa="$lscmd -AF $colorflag $group_dir_flag" # include dot files
}
unset lscmd colorflag
# shellcheck disable=SC2262
if ! command -v python >/dev/null 2>&1 && command -v python3 >/dev/null 2>&1; then
alias python=python3
if command -v pip3 >/dev/null 2>&1; then
alias pip=pip3
fi
elif command -v python >/dev/null 2>&1; then
python_version="$(python -c 'import sys; print(sys.version_info.major)')"
if [ -n "$python_version" ] && ! [ "$python_version" -eq 3 ]; then
if command -v python3 >/dev/null 2>&1; then
alias python=python3
fi
if command -v pip3 >/dev/null 2>&1; then
alias pip=pip3
fi
fi
fi
unset python_version
# macos-like pbcopy/pbpaste aliases for other systems that have xclip installed
if ! command -v pbcopy >/dev/null 2>&1 && ! command -v pbpaste >/dev/null 2>&1 && command -v xclip >/dev/null 2>&1; then
alias pbcopy="xclip -selection c"
alias pbpaste="xclip -selection clipboard -o"
fi
# internetworking aliases
if command -v ipconfig >/dev/null 2>&1; then
alias iploc="ipconfig getifaddr en0"
if command -v cut >/dev/null 2>&1 && command -v nmap >/dev/null 2>&1; then
alias ipcheck="nmap -sn \$(iploc | cut -d '.' -f 1-3).0/24"
alias ipports="nmap \$(iploc | cut -d '.' -f 1-3).0/24"
fi
fi
if command -v lsof >/dev/null 2>&1; then
alias iplist='lsof -i | command grep -i listen'
fi
if command -v lsof >/dev/null 2>&1; then
alias iplistall='sudo lsof -i | command grep -i listen'
fi
if command -v curl >/dev/null 2>&1; then
alias ipext="curl https://checkip.amazonaws.com"
fi
# lsvirtualenv alias
command -v lsvirtualenv >/dev/null 2>&1 && alias lsv="lsvirtualenv -b | less"