DarkFeather
3253c180fc
Adding session dependence to Ansible Ensuring EtcFiles/profile.d/shadowarch-ssh.sh starts ssh-agent user service
46 lines
1.1 KiB
Bash
46 lines
1.1 KiB
Bash
### SSH ###
|
|
# Tell shell about ssh-agent -- enable with 'systemctl --user enable --now ssh-agent.service'
|
|
if [ `ps -u "$USER" | grep -c ssh-agent` -eq 0 ]; then
|
|
systemctl --user start ssh-agent.service
|
|
sleep 1
|
|
fi
|
|
export SSH_AGENT_PID="$(pgrep -fu "$USER" ssh-agent)"
|
|
if [ -n "$SSH_AGENT_PID" ]; then
|
|
export SSH_AUTH_SOCK="/run/user/$EUID/ssh-agent.socket"
|
|
echo ssh-agent PID is $SSH_AGENT_PID
|
|
fi
|
|
if [ -n "$SSH_AUTH_SOCK" ] && [ `ssh-add -L | grep -c no\ identities` -eq 1 ]; then
|
|
ssh-add
|
|
ssh-add -L
|
|
fi
|
|
|
|
# Tmux help
|
|
function tssh () {
|
|
tmux new-window -n "$1" "/bin/bash -ilc 'ssh $1'"
|
|
}
|
|
|
|
### GIT ###
|
|
source /usr/share/git/completion/git-prompt.sh
|
|
|
|
function git_prompt_var() {
|
|
### If $PWD is a Git repo, add URL and branch to PS1
|
|
url=`git config remote.origin.url 2>/dev/null`
|
|
if [ -n "$url" ]; then
|
|
branch=`__git_ps1 '%s'`
|
|
url=`basename "$url"`
|
|
echo " $url($branch)"
|
|
fi
|
|
}
|
|
|
|
### User-directory .gitbare Support (Git) ###
|
|
if [ -d ~/.git ]; then
|
|
cd
|
|
printf "~/.git: "
|
|
if [ $SHLVL -eq 1 ] && [ -z "$TMUX" ]; then
|
|
git pull
|
|
else
|
|
git rev-parse --short HEAD
|
|
fi
|
|
git status
|
|
fi
|