Bladeren bron

Move sshrc logics into zshrc

Kevin Heinicke 7 jaren geleden
bovenliggende
commit
46e07bef85
3 gewijzigde bestanden met toevoegingen van 14 en 38 verwijderingen
  1. 0 1
      install.conf.yaml
  2. 0 21
      sshrc
  3. 14 16
      zshrc

+ 0 - 1
install.conf.yaml

@@ -28,7 +28,6 @@
     ~/.zprezto:
         relink: true
         path: external/prezto/
-    ~/.ssh/rc: sshrc
     ~/.atom:
         relink: true
         path: atom/

+ 0 - 21
sshrc

@@ -1,21 +0,0 @@
-#!/bin/bash
-
-# based on/using http://stackoverflow.com/questions/21378569 and
-# https://gist.github.com/martijnvermaat/8070533
-
-# Fix SSH auth socket location so agent forwarding works with tmux
-if test "$SSH_AUTH_SOCK" ; then
-  ln -sf $SSH_AUTH_SOCK ~/.ssh/ssh_auth_sock
-fi
-
-# Taken from the sshd(8) manpage.
-if read proto cookie && [ -n "$DISPLAY" ]; then
-    if [ `echo $DISPLAY | cut -c1-10` = 'localhost:' ]; then
-            # X11UseLocalhost=yes
-            echo add unix:`echo $DISPLAY |
-                cut -c11-` $proto $cookie
-    else
-            # X11UseLocalhost=no
-            echo add $DISPLAY $proto $cookie
-    fi | xauth -q -
-fi

+ 14 - 16
zshrc

@@ -49,22 +49,6 @@ mountremote () {
   unset mountpoint
 }
 
-# use the symlinked ssh-auth-sock if inside tmux session otherwise update the
-# symlink
-# if [[ -f "$HOME/.ssh/ssh_auth_sock" ]]; then
-#     export SSH_AUTH_SOCK=$HOME/.ssh/ssh_auth_sock;
-# fi
-
-# if we have a working socket, everything is fine
-if [[ -f "$SSH_AUT_SOCK" ]]; then
-    # if the socket is working, symlink it for other uses
-    if ssh-add -l; then
-        ln -sf $SSH_AUTH_SOCK $HOME/.ssh/ssh_auth_sock;
-    fi
-elif [[ -f "$HOME/.ssh/ssh_auth_sock" ]]; then
-    export SSH_AUTH_SOCK=$HOME/.ssh/ssh_auth_sock
-fi
-
 # make the clipboard working on remote
 if [[ -n "$SSH_CLIENT" ]]; then
   SSH_IP=$(echo $SSH_CLIENT | awk '{print $1}')
@@ -96,3 +80,17 @@ fi
 if [[ -n "$ITERM_INTEGRATION" && -f ~/.iterm2_shell_integration.zsh ]]; then
   test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"
 fi
+
+# a new attempt to forward ssh sockets to tmux
+
+if [[ -n "$SSH_AUTH_SOCK" ]]; then
+    # based on/using http://stackoverflow.com/questions/21378569 and
+    # https://gist.github.com/martijnvermaat/8070533
+
+    # Fix SSH auth socket location so agent forwarding works with tmux
+    if [[ -z "$TMUX" ]] ; then
+        ln -sf $SSH_AUTH_SOCK ~/.ssh/ssh_auth_sock
+    else
+        export SSH_AUTH_SOCK=~/.ssh/ssh_auth_sock
+    fi
+fi