dotfiles

Alpine Linux dotfiles

git clone git://git.lin.moe/dotfiles.git

 1alias ls='ls --color=auto'
 2alias l='ls'
 3alias ll='ls -lh'
 4
 5alias tt='tmux new -A -s'
 6
 7alias rs='rsync -rz --info=progress2'
 8alias rrs='RSYNC_PASSWORD=$(pass tool/rsyncd/lindsay) rsync-ssl -rz --info=progress2'
 9
10alias ppgrep='ps aux | grep -v grep |  grep $@'
11
12[ -x "$(command -v edit)" ] && alias e=edit
13
14alias ssh-gpg='ssh -f -N -o ControlPath="$HOME/.ssh/controlmaster/%n|$o_addr|%r@%h|%p.gpg" -o RemoteForward="$HOME/.gnupg/S.gpg-agent $HOME/.gnupg/S.gpg-agent.extra"'
15
16###############################
17# generate random password
18_passgen() {
19	length=$1
20	shift
21	{ </dev/urandom LC_ALL=C grep -ao "[${(j::)@}]" | head -n$(($length - $#))
22          for grp in $@; do
23		  echo ${grp:$((RANDOM % ${#grp})):1}
24	  done
25	} | shuf | tr -d '\n'
26}
27
28function passgen() {
29	local o_copy o_help
30	local usage=(
31		"$0 [-h|--help]"
32		"$0 [-c|--copy] [length]"
33	)
34
35	zmodload zsh/zutil
36	zparseopts -D -F -K -- \
37		   {h,-help}=o_help \
38		   {c,-copy}=o_copy \
39		   {n,-nosym}=o_nosym || return 1
40
41	[[ -z "$o_help" ]] || { print -l $usage && return }
42
43	groups=('0123456789' 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')
44	[[ -n "$o_nosym" ]] || groups+='!@?%^_=*#&'
45	
46	_pass=`_passgen ${1:=$((RANDOM %8 + 10))} $groups`
47	[[ -z "$o_copy" ]] || { echo $_pass | wl-copy -n }
48	
49	echo $_pass
50}
51
52# netns
53enternet()  { doas ip netns exec $1 su $USER -c "zsh -l" }
54createnet() { doas ip netns add $1 }
55
56_enternet_completion() {
57    local -a ns_list
58    if [[ -d /var/run/netns ]]; then
59        ns_list=($(ls /var/run/netns))
60        [ -z "$ns_list" ] || _values 'network namespaces' $ns_list
61    fi
62}
63
64compdef _enternet_completion enternet