-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path.everythingrc
More file actions
executable file
·106 lines (86 loc) · 2.57 KB
/
.everythingrc
File metadata and controls
executable file
·106 lines (86 loc) · 2.57 KB
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
# Bash: .bash_profile (macOS default) -> .profile (Ubuntu default) -> .bashrc -> .everythingrc
# zsh: .zshrc (always executed) -> .everythingrc
SHELL=$(which "$(ps -o comm= $$ | sed 's/^-*//')")
##### Bash #####
# Reload this file after change
reload() {
exec "${SHELL}"
}
##### Misc #####
__bashrc_misc() {
# `which` but better
# https://emmer.dev/blog/reliably-finding-files-in-path/
pinpoint() {
while read -r DIR; do
if [[ -f "${DIR}/$1" ]]; then
echo "${DIR}/$1"
return 0
fi
done <<< "$(echo "${PATH}" | tr ':' '\n')"
return 1
}
# Don't be a savage
if command -v nano &> /dev/null; then
EDITOR=$(pinpoint nano)
export EDITOR
fi
# Navigation helpers
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
# Colorize various commands
# shellcheck disable=SC2139,SC2262
alias ls="command ls $(if ls --color &> /dev/null; then echo "--color"; else echo "-G"; fi)"
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
command -v tree > /dev/null && alias tree='tree -C'
# cat shortcuts
cathex() {
xxd -p "$@" | tr -d '\n' | awk '{print $1}'
}
# ls shortcuts
alias ll="ls -alF"
lsd() {
for DIR in "${@:-.}"/*; do
if [[ -d "${DIR}" ]]; then
echo "${DIR}"
fi
done
}
lsf() {
for FILE in "${@:-.}"/*; do
if [[ ! -d "${FILE}" ]]; then
echo "${FILE}"
fi
done
}
# Jokes
alias please="sudo"
alias yeet="rm -rf"
# Polyfills
if ! command -v beep &> /dev/null; then
alias beep="echo -ne '\007'"
fi
}
__bashrc_misc
##### IDEs #####
__bashrc_ides() {
if [[ -d "/Applications/Visual Studio Code.app/Contents/Resources/app/bin" ]]; then
export PATH="$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
fi
if [[ -d "/Applications/VSCodium.app/Contents/Resources/app/bin" ]]; then
export PATH="$PATH:/Applications/VSCodium.app/Contents/Resources/app/bin"
alias code=codium
fi
}
__bashrc_ides
##### Everything Else #####
shell_basename="$(basename "${SHELL}")"
while read -r file; do
if [[ "${file}" == *".sh" || "${file}" == *".${shell_basename}" ]]; then
# shellcheck disable=SC1090
source "${file}"
fi
done <<< "$(find ~/.dotpack -maxdepth 1 -follow -type f -name ".*" | sort --version-sort)"