-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.aliases
79 lines (58 loc) · 3.05 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
#!/usr/bin/env bash
###############################################################################
# Search #
###############################################################################
# Detect which `ls` flavor is in use and colorize for readability
if ls --color > /dev/null 2>&1; then # GNU `ls`
colorflag="--color"
else # macOS `ls`
colorflag="-G"
fi
alias ll='ls -alrh ${colorflag}' # for "low-level" navigation, separating dot config files
alias lt='ls -alrht ${colorflag}' # for "high-level" navigation, listing by recency
###############################################################################
# Navigation #
###############################################################################
# Print each PATH entry on a separate line
alias path='echo -e ${PATH//:/\\n}'
# Combine with ~/.gitconfig `root` command to change directory to repository root
alias cdgr='cd "$(git root)"'
# Display current directory structure with child depth 3
alias treee='tree -L 3'
###############################################################################
# Edit #
###############################################################################
# Enable aliases to be sudo’ed
alias sudo='sudo '
# Protect against overwriting
alias cp='cp -i'
alias mv='mv -i'
###############################################################################
# Maintenance #
###############################################################################
if [ "$(uname -s)" = 'Darwin' ]; then
# Update macOS software, Homebrew, and Homebrew packages
alias update="sudo softwareupdate -i -a; brew update; brew outdated; mas upgrade; brew upgrade; brew cleanup -s --prune=0; tldr --update"
elif [ "$(uname -s)" = 'Linux' ]; then
# Update Linux software
alias update="sudo apt update; sudo apt dist-upgrade; sudo apt autoremove"
else
echo "Update command not configured for this operating system"
exit 1
fi
# Recursively delete .DS_Store files
alias cleanup="find . -type f -name '*.DS_Store' -ls -delete"
###############################################################################
# General Utility #
###############################################################################
# Mirror stdout to stderr, useful for seeing data going through a pipe
alias peek='tee >(cat 1>&2)'
###############################################################################
# Network #
###############################################################################
# Show active network interfaces
alias ifactive="ifconfig | pcregrep -M -o '^[^\t:]+:([^\n]|\n\t)*status: active'"
# Mirror a website
alias mirror='wget -m -k -K -E -e robots=off'
# Blacklist servers
alias block='$VISUAL /etc/hosts'