-
Notifications
You must be signed in to change notification settings - Fork 0
/
.functions
41 lines (34 loc) · 995 Bytes
/
.functions
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
# Checks if a command exists, something like 'which' could be used
# instead of 'command -v' but 'which' is non-standard and shellcheck
# will report it as such and will suggest 'command -v'.
#
# This function is mainly used to test for commands with 'it' statements like so:
# if _command_exists pyenv; then
# echo "Command exists so do something"
# fi
installed() {
command -v "$1" >/dev/null 2>&1
}
# Get the env vars of a running process
# Example: penv docker
#
# NOTE: Using the sudo/doas alias '_' here rather than hard-coding to
# one orr the other.
penv() {
_ sh -c "tr '\0' '\n' < /proc/$(pgrep "$1")/environ"
}
# Show files open by a running process, also useful for finding the absolute
# path of a process.
# Example: pspath ssh-agent
pspath() {
lsof -p $(pgrep "$1")
}
# Create a new Clojure application using Boot: https://boot-clj.com
# Example: bna myapp
bna() {
boot -d boot/new new -t app -n "$1"
}
# Emacsclient
e() {
emacsclient -c -n -a '' $1
}