-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbashrc.gitbash
57 lines (43 loc) · 1.29 KB
/
bashrc.gitbash
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
#!/bin/bash
hash -p /usr/bin/openssl openssl
export LANG=en_US.UTF-8
# SSH completions
_ssh_hosts () {
if [ "$1" = ssh ]; then trailing=''; else trailing='":"'; fi
opts=$(awk "/^Host\\>/ {print \$2${trailing}}" ~/.ssh/config)
COMPREPLY=( $(compgen -W "$opts" -- "$2") )
}
export COMP_WORDBREAKS=${COMP_WORDBREAKS//:}
complete -F _ssh_hosts ssh
complete -F _ssh_hosts sftp
complete -F _ssh_hosts -f scp
# user defined alias
case "$TERM" in xterm*) # inside Git Bash
alias powershell="winpty powershell.exe"
alias python="winpty python.exe"
alias wsl="wslbridge -t"
;; esac
alias ls="ls -I 'ntuser.*' -I 'NTUSER.*' --color=auto -F"
alias la="ls -a"
alias man="wsl man"
alias tldr="wsl tldr"
# start ssh-agent
# use ~/.ssh/.env for terminal tools
_SSH_ENV_FILE=~/.ssh/.env
[ -f $_SSH_ENV_FILE ] && source $_SSH_ENV_FILE
# catch connection failure
if [ "$(ssh-add -l >/dev/null 2>&1; echo $?)" = 2 ]; then
# clean remnants of prior runs
rm -rf /tmp/ssh-*
for pid in $(ps aux | awk '/ssh-agent/ {print $1}'); do
kill $pid
done
# update $_SSH_ENV_FILE - silent
echo "$(ssh-agent -s | head -n2)" >$_SSH_ENV_FILE
source $_SSH_ENV_FILE
# setting vars for windows tools
winpty setx SSH_AUTH_SOCK $SSH_AUTH_SOCK
winpty setx SSH_AGENT_PID $SSH_AGENT_PID
# add key
ssh-add
fi