-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaliases
105 lines (88 loc) · 2.31 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
97
98
99
100
101
102
103
104
105
#
# Start with `ls`, the greatest pain, and more important.
#
# If on OS X and I have "gls", then I have GNU coreutils.
if [ "$(uname)" = "Darwin" ] && thereis gls ; then
LS='gls'
DF='gdf'
CP='gcp'
alias dircolors='gdircolors'
else
LS='ls'
DF='df'
CP='cp'
fi
if [ "$TERM" != "dumb" ]; then
eval "`dircolors -b`"
LS=$LS' --color=auto'
fi
if thereis lsd ; then
LS='lsd'
fi
alias ls="$LS"
# Some more ls aliases. Another soup of logic because the lack of
# a feature of this or that in one implementation or the other.
if thereis lsd ; then
alias ll=$LS' -l'
alias l='ls -F'
elif [ "$(uname)" = "Linux" ] || thereis gls ; then
alias ll=$LS' -g --time-style=long-iso'
alias l='ls -CF'
else
alias ll=$LS' -g'
alias l='ls -CF'
fi
alias lh='ll -h'
alias la='ls -A'
alias lld='ls -ld */'
# Alias of common operations
alias cd..='cd ..'
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias mv='mv -i'
alias cp=$CP' -i'
alias df=$DF' -h -x devtmpfs -x tmpfs -x rootfs -x squashfs'
# Ideally this would be a git alias instead, but it's run in a subshell.
alias gcd='cd `git root`'
# I hope I don't repent on this. Open with the browser, or whatever nicely.
if [ "$(uname)" = "Darwin" ] ; then
alias o='open'
else
alias o='xdg-open'
fi
# Use colors when grepping
if [ "$(uname)" = "Linux" ]; then
alias grep='grep --color=auto'
fi
if thereis nvim ; then
alias vi=nvim
fi
alias apg='apg -m 18 -M sncl -s'
alias gdb='gdb -q'
# Save the command first, otherwise "su" might see "please" instead.
alias please='last=`fc -ln -1`; \
test -x /usr/bin/sudo && sudo -- $last || su -c "$last"'
alias figlet='figlet -f future'
# Decompress a raw zlib file (like a git object). http://unix.stackexchange.com/a/49066
zlibd()
{
printf "\x1f\x8b\x08\x00\x00\x00\x00\x00" | cat - $@ | gzip -dc
}
# Small function to change GIT_DIR and GIT_WORK_TREE at once. Why? Because:
# https://www.vikingsoftware.com/blog/multiple-git-repositories-in-the-same-tree/
# https://disperso.net/Git#git_dir_work_tree_uses
vrepo()
{
# TODO: handle a second argument passing the work tree?
if [ $# -gt 0 ]; then
# Make absolute
path=`(cd "$1" ; pwd)`
export GIT_DIR="$path"/.git
export GIT_WORK_TREE=$PWD
else
unset GIT_DIR
unset GIT_WORK_TREE
fi
}
# vim: set filetype=sh: