-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.aliases
131 lines (108 loc) · 2.9 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/usr/bin/env bash
# Aliases and typo remediation!
alias xlt='xautolock -toggle'
if [ "$TERM" = 'alacritty' ]; then
alias se='TERM=xterm-256color sudoedit'
else
alias se='sudoedit'
fi
alias vim='nvim'
alias cim='nvim'
alias bim='nvim'
alias car='cat'
alias packer='packer-io'
# Directory traversal
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias tmp='cd /tmp'
# Colorize ls
if [ "$(uname)" = 'Linux' ]; then
alias ls='ls --color=auto'
else
alias ls='ls -G'
fi
alias la='ls -a'
alias lal='ls -lha'
alias ll='ls -lh'
alias sl='ls'
alias lls='ls'
alias ks='ls'
# Always ask before overwriting a file with mv or cp
alias mv='mv -i'
alias cp='cp -i'
# Open pcmanfm in current directory
alias pc='2>/dev/null 1>&2 pcmanfm & disown'
# Allow sudo-ing aliases...no idea why this works
alias sudo='sudo '
# Clean up LaTeX build files
alias latexclean='rm -rf *.{aux,fdb_latexmk,fls,log,out,synctex.gz} _minted*'
# ZFS Aliases
alias zsnap='zfs list -t snap'
alias zsnaps='zfs list -t snap'
alias zprops='zfs get all'
# Like cat but more fun
alias dog='pygmentize -g'
# Fix bug where slack becomes unresponsive when dpms suspend occurs
# Per aur.archlinux.org/packages/slack-desktop/
# under '1ouis commented on 2018-11-15 06:36'
alias slack='slack --disable-gpu'
# cats out all files in child directories. get it cat child heh heh
kittens () {
tree
find . -type f -exec echo -e "\\n***************{}***************" \; -exec cat {} \;
}
# Removes duplicate ssh known_hosts entries
host-clear () {
sed -i "$1d" "$HOME/.ssh/known_hosts"
}
# Create directory and cd into it
mkcd () {
mkdir "$1"
cd "$1" || exit
}
# git status -> vim
# Finds untracked, added, and modified files in git repo and opens them in vim
gsv () {
if git status &> /dev/null; then
mapfile -t changed_files < <(git status --short | grep -E '^(\?\?|A | M) ' | cut -c '4-')
vim "${changed_files[@]}"
else
echo "Working directory is not a git repository, exiting."
fi
}
# Fuzzy find opener
# Passes result of fzf to command specified as arg
ff () {
CMD=$1
# vim -> nvim alias not recognized inhis function, so account for it
if nvim -v > /dev/null 2>&1 && [ "$1" == "vim" ]; then
CMD="nvim"
fi
# If command is 'cd', remove the filename and go to the parent dir,
# else execute command as is
if [ "$1" == "cd" ]; then
"$CMD" "$(dirname "$(fzf)")"
else
"$CMD" "$(fzf)"
fi
}
note () {
NOTE_DIR=${NOTE_DIR:-"$HOME/notes"}
[ -d "$NOTE_DIR" ] || mkdir "$NOTE_DIR"
vim "$NOTE_DIR/${*// /_}"
}
mon_brightness () {
for d in $(ddcutil detect | sed -n 's/^Display \([0-9]\)/\1/p'); do
ddcutil setvcp 10 "$1" -d "$d"
done
}
if [ "$(uname)" != "Darwin" ]; then
alias open="xdg-open"
fi
# Cargo aliases
alias cbd="cargo build"
alias crd="cargo run"
alias cb="cargo build --release"
alias cr="cargo run --release"
alias ct="cargo test"