-
Notifications
You must be signed in to change notification settings - Fork 0
/
.aliases
116 lines (99 loc) · 4.07 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
#!/usr/bin/env sh
# shellcheck shell=sh source=.functions
# add shell functions
if [ -r "${HOME}/.functions" ]; then
# shellcheck source=.functions
. "${HOME}/.functions"
fi
debuglog "begin loading .aliases"
# Recursively delete `.DS_Store` files
alias cleanup='find . -name "*.DS_Store" -type f -ls -delete'
# remove broken symlinks
alias clsym='find -L . -name . -o -type d -prune -o -type l -exec rm {} +'
# remove __pycache__ recursive
alias clpy='find . -name __pycache__ -type d -print0 | xargs -0 /bin/rm -rf'
# list the PATH separated by new lines
alias lspath='echo $PATH | tr ":" "\n"'
# use eza as modern ls-replacement if available
if validate_command eza; then
eza --git >/dev/null 2>&1 && eza_git="true"
# shellcheck disable=SC2139
alias ls="eza --icons --group-directories-first ${eza_git:+--git} --accessed --modified --created"
elif [ "$(uname -s || true)" = "Darwin" ]; then
alias ls='ls -G'
else
alias ls='ls --color=auto --group-directories-first'
fi
# ls aliases
alias l='ls -ah'
alias ll='l -lg'
alias lll='ll -@'
alias lr='ls -R'
alias llr='lr -l'
# replace cat with bat, but disable paging to make it behave like cat
if validate_command batcat && ! validate_command bat; then
alias bat='$(which batcat)'
debuglog "batcat aliased to bat"
fi
if validate_command bat; then
alias cat="bat --paging=never"
debuglog "cat aliased to bat without pager"
fi
# don't know why, but this is fixing autocompletion
if validate_command git; then
alias git='command git'
fi
# dotfiles management
if [ "${HOME-false}" != "false" ] && [ -d "${HOME}/.cfg" ] && validate_command git; then
alias config='git --git-dir="${HOME}/.cfg" --work-tree="${HOME}"'
debuglog "aliased config to handle the bare repository"
if validate_command link-dotfiles && validate_command code; then
# link dotfiles to ~/.dotfiles and open in code
alias dotfiles='link-dotfiles && code "${HOME}/.dotfiles"'
debuglog "aliased dotfiles to creade dotfile links and open in code"
fi
fi
# Copy public SSH Key
if validate_command pbcopy && [ -r "${HOME}/.ssh/id_ed25519.pub" ]; then
alias pubkey='pbcopy < "${HOME}/.ssh/id_ed25519.pub"'
debuglog "aliased pubkey to copy your public key to the clipboard"
fi
# dump Brewfile
if [ "${HOMEBREW_BUNDLE_FILE-false}" != "false" ]; then
alias dump-brewfile='brew bundle dump --file="${HOMEBREW_BUNDLE_FILE}" --force'
debuglog "aliased dump-brewfile dump your installed packages to %s" "${HOMEBREW_BUNDLE_FILE}"
fi
# install or match Brewfile (match removes everything whats not in the Brewfile)
if [ -f "${HOMEBREW_BUNDLE_FILE}" ]; then
alias install-brewfile='brew bundle install --file="${HOMEBREW_BUNDLE_FILE}"'
debuglog "aliased install-brewfile to %s" "$(alias install-brewfile)"
alias match-brewfile='brew bundle --force cleanup --file="${HOMEBREW_BUNDLE_FILE}"'
debuglog "aliased match-brewfile to %s" "$(alias match-brewfile)"
fi
# add getidf alias if ~/esp/esp-idf exists
IDF_PATH="${HOME}/esp/esp-idf"
if [ -f "${IDF_PATH}/export.sh" ]; then
export ESPIDF="${IDF_PATH}"
alias getidf='. ${ESPIDF}/export.sh'
debuglog "aliased getidf to %s" "$(alias getidf)"
else
unset IDF_PATH
fi
# register-python-argcomplete
if validate_command register-python-argcomplete3; then
alias register-python-argcomplete='register-python-argcomplete3'
debuglog "aliased register-python-argcomplete to %s" "$(alias register-python-argcomplete)"
fi
# always add gh auth token to act
if validate_command act; then
alias act='act -s GITHUB_TOKEN="$(gh auth token)"'
# add alias to use gh act as act if gh-act is installed and act isnt found
elif gh extension list | grep -q "nektos/gh-act"; then
alias act='gh act -s GITHUB_TOKEN="$(gh auth token)"'
# alias act='export DOCKER_CERT_PATH="$(docker context inspect --format "{{.Storage.TLSPath}}")/docker" DOCKER_HOST="$(docker context inspect --format {{.Endpoints.docker.Host}})" && act -s GITHUB_TOKEN="$(gh auth token)"'
fi
# load local aliases if exist
if [ -r ~/.aliases.local ]; then
. ~/.aliases.local
fi
debuglog "done loading .aliases"