-
Notifications
You must be signed in to change notification settings - Fork 0
/
alias.sh
104 lines (90 loc) · 2.48 KB
/
alias.sh
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
#!/bin/bash
# Basic Editor Commands
# Not sure why Apple doesn't include these editor commands.
alias edit="\$EDITOR"
alias sudoedit="sudo -e"
# Conditionally alias vi to vim, if vim exists.
if command -v vim >/dev/null 2>&1; then
alias vi='vim'
fi
# Prompt before removing or overwriting files with common commands.
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# ls Aliases
alias ls='ls --color=auto'
alias la='ls -a'
alias ll='ls -l'
alias lh='ls -lh'
alias lla='ls -la'
alias llh='ls -lh'
alias llha='ls -lha'
# Git Aliases
alias gs='git status'
alias gc='git commit'
alias gcl='git clone'
alias gck='git checkout'
alias gf='git fetch'
alias gp='git pull'
alias gps='git push'
alias ga='git add'
alias gaa='git add .'
alias gb='git branch'
alias gl='git log'
alias glg='git log --graph --oneline --decorate --all'
alias gld='git log --pretty=format:"%h %ad %s" --date=short --all'
alias gbl='git blame'
alias gmg='git merge'
alias gmgne='git merge --no-edit'
alias grm='git rm'
alias grmf='git rm -f'
alias gr='git reset'
alias gst='git stash'
alias gsta='git stash apply'
alias gstd='git stash drop'
alias gstl='git stash list'
alias gstp='git stash pop'
alias gsts='git stash save'
# iCloud Helper
if [ "$(uname)" = "Darwin" ]; then
alias cdicloud='cd ~/Library/Mobile\ Documents/com\~apple\~CloudDocs'
fi
# SSH known hosts helper - forget hosts by name
unknown_host () {
if [ "$#" -ne 1 ]; then
echo "<!> ERROR: Expected one positional argument: line number." 1>&2
return 1
elif ! [ -f ~/.ssh/known_hosts ]; then
echo "<!> ERROR: no ~/.ssh/known_hosts file." 1>&2
return 1
elif [ "$(wc -l < ~/.ssh/known_hosts)" -lt "$1" ]; then
echo "<!> ERROR: invalid line number." 1>&2
return 1
fi
echo "This will delete line $1 from your ~/.ssh/known_hosts file."
echo
echo "Contents of line $1:"
sed "$1q;d" ~/.ssh/known_hosts
echo
echo "Press return to confirm deletion or ^C to cancel."
read -r
if [ "$(uname)" = "Darwin" ]; then
sed -i .bak "$1d" ~/.ssh/known_hosts
rm -i ~/.ssh/known_hosts.bak
else
sed -i "$1d" ~/.ssh/known_hosts
fi
}
# XCode update helper. Runs in subshell, since function block is () not {}.
if [ "$(uname)" = "Darwin" ]; then
xcfix () (
set -x
xcode-select --install
set -e
xcode-select -p
sudo xcodebuild -license accept
sudo xcodebuild -runFirstLaunch
sudo -k
xcodebuild -runFirstLaunch
)
fi