-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbash.env
More file actions
53 lines (47 loc) · 1.3 KB
/
Copy pathbash.env
File metadata and controls
53 lines (47 loc) · 1.3 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
# Color
export COLORTERM=truecolor
# alias
alias cd1='cd ..'
alias cd2='cd ../..'
alias rl='realpath'
# vi/vim/nvim/helix
if command -v hx &> /dev/null; then
alias vi='hx'
elif command -v nvim &> /dev/null; then
alias vi='nvim'
elif command -v vim &> /dev/null; then
alias vi='vim'
fi
# editor
export EDITOR=hx
# network
# export TUNNEL_GATEWAY="ip@addr"
export SSH_TUNNEL_ADDR=127.0.0.1
export SSH_TUNNEL_PORT=7701
function ssh_tunnel() {
echo "Current $SSH_TUNNEL_PORT process: $(ps -ef | grep $SSH_TUNNEL_PORT)"
read -p "Continue? (Y/N): " userInput
if [[ "$userInput" == "Y" ]]; then
echo "Running ssh..."
/bin/bash -c \
"ssh -qTfnN -D $SSH_TUNNEL_PORT $TUNNEL_GATEWAY -o \"ServerAliveInterval 30\" -o \"TCPKeepAlive yes\""
fi
}
function proxy_on() {
export http_proxy=$SSH_TUNNEL_ADDR:$SSH_TUNNEL_PORT
export https_proxy=$http_proxy
export all_proxy=$http_proxy
echo -e "terminal proxy start"
}
function proxy_off() {
unset http_proxy https_proxy all_proxy
echo -e "terminal proxy stop"
}
# alias for yazi
function ya() {
local tmp="$(mktemp -t "yazi-cwd.XXXXXX")" cwd
yazi "$@" --cwd-file="$tmp"
IFS= read -r -d '' cwd < "$tmp"
[ -n "$cwd" ] && [ "$cwd" != "$PWD" ] && builtin cd -- "$cwd"
rm -f -- "$tmp"
}