-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshell.local.example
More file actions
101 lines (82 loc) · 2.73 KB
/
shell.local.example
File metadata and controls
101 lines (82 loc) · 2.73 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
#
# ~/.shell.local
#
# Adjust as needed
export LC_ALL=en_GB.UTF-8
# A more colourful prompt
export PS1='\[\033[1;31m\]\h#\[\033[0m\] '
# W3C Tidy
alias tidy="tidy -config ${HOME}/.tidyrc"
# Umlauts!
alias _umlaute="echo ä ö ü ß Ä Ö Ü ẞ ™ ® © ≠ ∈ ∉ π € £ ∞ °"
# Combine pwgen & passwdqc
pwgen_check() { pwgen "$@" | pwqcheck -1 --multi; }
# dmesg filter to omit printk timestamps (if dmesg -t is not available yet)
npk() { sed 's/^\[[ 0-9\.]*\] //'; }
# Epoch-to-time
e2t() { perl -pe 's/(\d+)/localtime($1)/e'; }
# MacOS X
if [ -d /opt/local/bin ]; then
export PATH=/opt/local/sbin:/opt/local/bin:${PATH}
fi
# On MacOS X, TMPDIR changes every time Terminal.app starts
export SCREENDIR=${HOME}/.screen
# More MacOS X shortcuts
alias top="top -o cpu"
alias df="df -P"
alias shuf="perl -MList::Util=shuffle -e 'print shuffle(<STDIN>);'"
alias _history="HISTTIMEFORMAT='' history" # Because HISTTIMEFORMAT is so slow on macOS
alias macssl="/usr/bin/openssl"
alias mdl="markdownlint --disable MD013 --"
# Enable "Secure Keyboard" for MacOS X
# > How secure is “Secure Keyboard Entry” in Mac OS X's Terminal?
# > https://security.stackexchange.com/q/47749
#
# > Technical Note TN2150: Using Secure Event Input Fairly
# > https://developer.apple.com/library/archive/technotes/tn2150/
defaults write com.apple.Terminal SecureKeyboardEntry 1
# > tobym/pwdx_for_mac.bash
# > https://gist.github.com/tobym/648188
pwdx() { lsof -a -p "${1}" -d cwd -n | tail -1 | awk '{print $NF}'; }
# https://www.funtoo.org/Keychain
# eval $(keychain --eval --quiet)
# dmesg: translate relative printk time stamps to absolute time stamps
# kmsg() {
# dmesg | perl -ne "BEGIN{\$a= time()- qx!cat /proc/uptime!}; s/\[\s*(\d+)\.\d+\]/localtime(\$1 + \$a)/e; print \$_;"
# }
# Can we find page count of a file in Unix/Linux?
# https://unix.stackexchange.com/a/143932/31256
_pc() {
perl -MPOSIX=ceil -nle 'END{print ceil($./56)}'
}
#
# Great for adding colons to TLS serial numbers
# > echo | openssl s_client -connect www.example.net:443 2>/dev/null | \
# openssl x509 -noout -serial | cut -d= -f2 | _tocolon
# 07:DA:5B:4C:84:92:5F:D3:1F:AB:71:9D:96:09:61:52
#
_tocolon() {
sed 's/../&:/g;s/:$//'
}
#
# Great for removing colons to TLS serial numbers
# > echo 07:DA:5B:4C:84:92:5F:D3:1F:AB:71:9D:96:09:61:52 | _fromcolon
# 07DA5B4C84925FD31FAB719D96096152
_fromcolon() {
sed 's/://g' | tr [a-z] [A-Z]
}
#
# Convert TLS serial numbers from hexadecimal to decimal
# > _certdec 07DA5B4C84925FD31FAB719D96096152
# 10438368447298263904886733588962828626
#
_certdec() {
echo "ibase=16; ${1}" | bc -l
}
#
# And back to hexadecimal again
# > _certhex 10438368447298263904886733588962828626
# 07DA5B4C84925FD31FAB719D96096152
_certhex() {
echo "obase=16; ${1}" | bc -l
}