-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathshell_helpers
77 lines (74 loc) · 1.97 KB
/
shell_helpers
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
# vim:ft=sh
# sourced in .bashrc or .zshrc
function h {
type atuin >/dev/null && { atuin search --cmd-only "$1" && return $?; }
history | grep --color=auto -i "$1"
}
function cd {
builtin cd "$@" || return
test -f 'environ' || return
_try_source_environ_file
}
function _try_source_environ_file {
# security. don't autosource third party code
test -z "$PS1" && return
local okfiles h confirm
okfiles="$HOME/.config/autosourced_on_cd"
test -e "$okfiles" || touch "$okfiles" || return 1
h="$(pwd -P)"
grep "^$h$" <"$okfiles" && {
. ./environ
return $?
}
echo "Add $h to $okfiles? [y/N]"
read -r confirm
test "$confirm" = y && echo "$h" >>"$okfiles" && . ./environ
}
function gomod {
local mod="${1:-os}"
local l="$(python -c "import os, $mod;print(os.path.dirname($mod.__file__))")"
cd "$l"
pwd
}
function ack {
echo 'NOT respect gitignore' >&2
set -x
rg --glob '!*.min.js' --glob '!*.min.css' --glob='!spell' --no-ignore --glob '!*arch/*' --glob '!*build/*' --glob '!*node_modules/*' --glob '!*dist/*' "$@"
set +x
}
alias ff='fd --no-ignore --hidden'
alias fff='fd --no-ignore --hidden --follow'
alias gc='git commit'
alias gs='git status'
alias gd='git diff --color'
alias gp='git pull'
alias gP='git push'
alias lg='lazygit'
alias mm='micromamba'
alias scu='systemctl --user'
unalias ll 2>/dev/null
function ll {
"$HOME/micromamba/envs/tools/bin/eza" \
--color-scale-mode fixed \
--color=always \
--group-directories-first \
--icons \
--reverse \
--sort newest \
-g \
-l \
--time-style=relative --no-user --no-permissions \
"$@" |
sed -e 's/ minutes/m/g' |
sed -e 's/ minute\o033\[0m /m/g' |
sed -e 's/ hours\o033\[0m /h/g' |
sed -e 's/ hour\o033\[0m /h/g' |
sed -e 's/ days\o033\[0m /d/g' |
sed -e 's/ day\o033\[0m /d/g' |
sed -e 's/ weeks\o033\[0m /w/g' |
sed -e 's/ week\o033\[0m /w/g' |
sed -e 's/ months\o033\[0m /M/g' |
sed -e 's/ month\o033\[0m /M/g' |
sed -e 's/ years\o033\[0m /Y/g' |
sed -e 's/ year\o033\[0m /Y/g'
}