1
0
Fork 0

Fix zsh ssh-agent stuff

main
Mari 3 years ago
parent d024a27672
commit 07bdcc3dc0
  1. 19
      zsh/customizations/zsh_aliases.zsh

@ -13,11 +13,14 @@ export PAGER='less --mouse'
export BROWSER='firefox -P Mari --class Firefox.Main' export BROWSER='firefox -P Mari --class Firefox.Main'
# Set up the vim config path # Set up the vim config path
export VIM_CONFIG_DIR=$__COMMON_CONFIGS/vim export VIM_CONFIG_DIR=$__COMMON_CONFIGS/vim
# Set the SSH auth sock to the central location # Run an SSH agent if one doesn't already exist and link the (new or existing) SSH auth socket to the central location
if [[ -n $SSH_AUTH_SOCK ]] && [[ $SSH_AUTH_SOCK != $HOME/.ssh/ssh_auth_sock ]]; then if [[ ! -S $HOME/.ssh/ssh_auth_sock ]] && [[ ! -S $SSH_AUTH_SOCK ]] ; then
eval $(ssh-agent -s | head -n1)
fi
if [[ -S $SSH_AUTH_SOCK ]] && [[ $SSH_AUTH_SOCK != $HOME/.ssh/ssh_auth_sock ]]; then
ln -sf "$SSH_AUTH_SOCK" "$HOME/.ssh/ssh_auth_sock" ln -sf "$SSH_AUTH_SOCK" "$HOME/.ssh/ssh_auth_sock"
fi fi
export SSH_AUTH_SOCK="$HOME/.ssh/ssh_auth_sock" SSH_AUTH_SOCK="$HOME/.ssh/ssh_auth_sock"; export SSH_AUTH_SOCK
# Set potentially-destructive commands to use interactive modes # Set potentially-destructive commands to use interactive modes
alias rm='rm -i' alias rm='rm -i'
@ -40,14 +43,14 @@ function __common_configs_in_sync() {
# Failure modes, in order: # Failure modes, in order:
# exit 9: Problem cd'ing or getting commit hashes - things that should never fail # exit 9: Problem cd'ing or getting commit hashes - things that should never fail
cd $__COMMON_CONFIGS || exit 9 cd $__COMMON_CONFIGS || exit 9
localCommit=$(git show-ref --verify --hash refs/heads/master) || exit 9 localCommit=$(git show-ref --verify --hash refs/heads/main) || exit 9
if [[ $1 == --force-fetch ]] || [[ ! -f .last-fetch ]] || [[ $(date --reference=.last-fetch +%s) -lt $(date --date='5 minutes ago' +%s) ]]; then if [[ $1 == --force-fetch ]] || [[ ! -f .last-fetch ]] || [[ $(date --reference=.last-fetch +%s) -lt $(date --date='5 minutes ago' +%s) ]]; then
git fetch --quiet origin && touch .last-fetch git fetch --quiet origin && touch .last-fetch
fi fi
remoteCommit=$(git show-ref --verify --hash refs/remotes/origin/master) || exit 9 remoteCommit=$(git show-ref --verify --hash refs/remotes/origin/main) || exit 9
# exit 1: master is not the commit which is checked out. # exit 1: main is not the commit which is checked out.
[[ $(git symbolic-ref HEAD) == "refs/heads/master" ]] || exit 1 [[ $(git symbolic-ref HEAD) == "refs/heads/main" ]] || exit 1
# exit 2: master and origin/master are different. # exit 2: main and origin/main are different.
[[ $localCommit == $remoteCommit ]] || exit 2 [[ $localCommit == $remoteCommit ]] || exit 2
# exit 3: There are staged changes. # exit 3: There are staged changes.
git diff-index --cached --exit-code --quiet HEAD || exit 3 git diff-index --cached --exit-code --quiet HEAD || exit 3

Loading…
Cancel
Save