aboutsummaryrefslogtreecommitdiff
path: root/config/shell/funcs
blob: d1231bd885a4daf7dc1ff26f076d5fc56b5aae24 (plain)
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
#!/usr/bin/env zsh

reload() {
	source ~/.zprofile
	source $ZDOTDIR/.zshrc
}

proxy_enabled=0
PS2=$PS1
toggle_proxy() {
	if [[ "$proxy_connect" -eq 0 ]]; then
		export http_proxy="http://127.0.0.1:2080"
		export https_proxy=$http_proxy
		proxy_connect=1
		echo "proxy enabled"
		PS2=$PS1
		PS1="%{$fg[red]%}[v] $PS1"
	else
		unset http_proxy
		unset https_proxy
		proxy_connect=0
		echo "proxy disabled"
		PS1=$PS2
	fi
}

generate_pass() {
	local len=8
	[ $# -eq 1 ] && len=$1
	tr -cd '[:graph:]' < /dev/urandom | head -c $len | xargs -0
}