Explorar el Código

tidy zshrc, move some settings into their own files

Weiyi Lou hace 13 años
padre
commit
8e579ac97e
Se han modificado 3 ficheros con 62 adiciones y 59 borrados
  1. 12 0
      zsh/oh-my-zsh-custom/git.zsh
  2. 47 0
      zsh/oh-my-zsh-custom/ssh-agent.zsh
  3. 3 59
      zsh/zshrc

+ 12 - 0
zsh/oh-my-zsh-custom/git.zsh

@@ -0,0 +1,12 @@
+## preferred git shortcuts not in the git plugin
+alias ga.='git add .'
+alias gs='git status'
+alias gd='git diff'
+alias gds='git diff --staged'
+alias gl='git log --graph --date=relative --pretty="format:%C(yellow)%h %Cblue[%cn] %Creset%s... %cd"'
+alias gls='git log --graph --stat'
+alias glp='git log -p'
+alias gr='git rebase'
+# useful git plugin built-in ones include:
+#   ga, gc, gco, gb, gba, gm, grhh, ggpull, ggpush
+# ggpull translates into `git pull origin <current branch>`, same for ggpush

+ 47 - 0
zsh/oh-my-zsh-custom/ssh-agent.zsh

@@ -0,0 +1,47 @@
+# Keep ssh-agent persisting, even when in screen
+# Have not solved the issue of being unable to connect to ssh-agent in ubuntu
+# Have not had time to investigate oh-my-zsh's own ssh-agent plugin
+
+#############
+# SSH AGENT #
+#############
+
+# Don't do for OSX, as it has it's own handling of ssh-agent
+if [ `uname` != Darwin ]; then
+
+  # Check to see if SSH Agent is already running
+  agent_pid="$(ps -ef | grep "ssh-agent" | grep -v "grep" | awk '{print($2)}')"
+
+  # If the agent is not running (pid is zero length string)
+  if [[ -z "$agent_pid" ]]; then
+    # Start up SSH Agent
+
+    # this seems to be the proper method as opposed to `exec ssh-agent bash`
+    eval "$(ssh-agent)"
+
+    # if you have a passphrase on your key file you may or may
+    # not want to add it when logging in, so comment this out
+    # if asking for the passphrase annoys you
+    #ssh-add
+
+  # If the agent is running (pid is non zero)
+  else
+    # Connect to the currently running ssh-agent
+
+    # this doesn't work because for some reason the ppid is 1 both when
+    # starting from ~/.profile and when executing as `ssh-agent bash`
+    #agent_ppid="$(ps -ef | grep "ssh-agent" | grep -v "grep" | awk '{print($3)}')"
+    agent_ppid="$(($agent_pid - 1))"
+
+    # and the actual auth socket file name is simply numerically one less than
+    # the actual process id, regardless of what `ps -ef` reports as the ppid
+    agent_sock="$(find /tmp -path "*ssh*" -type s -iname "agent.$agent_ppid")"
+
+    echo "Agent pid $agent_pid"
+    export SSH_AGENT_PID="$agent_pid"
+
+    echo "Agent sock $agent_sock"
+    export SSH_AUTH_SOCK="$agent_sock"
+  fi
+fi
+

+ 3 - 59
zsh/zshrc

@@ -36,6 +36,9 @@ source $ZSH/oh-my-zsh.sh
 
 # Customize to your needs...
 
+## hosts file
+alias hosts='sudo vim /etc/hosts'
+
 ## history
 alias h='history'
 ## don't show expansions, just execute, e.g. for !! and !$
@@ -64,65 +67,6 @@ alias cp='nocorrect cp'
 alias touch='nocorrect touch'
 alias ln='nocorrect ln'
 
-## host file
-alias hosts='vim /etc/hosts'
-
-## preferred git shortcuts not in the git plugin
-alias ga.='git add .'
-alias gs='git status'
-alias gd='git diff'
-alias gds='git diff --staged'
-alias gl='git log --graph --date=relative --pretty="format:%C(yellow)%h %Cblue[%cn] %Creset%s... %cd"'
-alias gls='git log --graph --stat'
-alias glp='git log -p'
-alias gr='git rebase'
-# useful git plugin built-in ones include:
-#   gc, gco, gb, gba, gm, grhh, ggpull, ggpush
-# ggpull translates into `git pull origin <current branch>`, same for ggpush
-
-#############
-# SSH AGENT #
-#############
-
-# Don't do for OSX, as it has it's own handling of ssh-agent
-if [ `uname` != Darwin ]; then
-
-  # Check to see if SSH Agent is already running
-  agent_pid="$(ps -ef | grep "ssh-agent" | grep -v "grep" | awk '{print($2)}')"
-
-  # If the agent is not running (pid is zero length string)
-  if [[ -z "$agent_pid" ]]; then
-    # Start up SSH Agent
-
-    # this seems to be the proper method as opposed to `exec ssh-agent bash`
-    eval "$(ssh-agent)"
-
-    # if you have a passphrase on your key file you may or may
-    # not want to add it when logging in, so comment this out
-    # if asking for the passphrase annoys you
-    #ssh-add
-
-  # If the agent is running (pid is non zero)
-  else
-    # Connect to the currently running ssh-agent
-
-    # this doesn't work because for some reason the ppid is 1 both when
-    # starting from ~/.profile and when executing as `ssh-agent bash`
-    #agent_ppid="$(ps -ef | grep "ssh-agent" | grep -v "grep" | awk '{print($3)}')"
-    agent_ppid="$(($agent_pid - 1))"
-
-    # and the actual auth socket file name is simply numerically one less than
-    # the actual process id, regardless of what `ps -ef` reports as the ppid
-    agent_sock="$(find /tmp -path "*ssh*" -type s -iname "agent.$agent_ppid")"
-
-    echo "Agent pid $agent_pid"
-    export SSH_AGENT_PID="$agent_pid"
-
-    echo "Agent sock $agent_sock"
-    export SSH_AUTH_SOCK="$agent_sock"
-  fi
-fi
-
 ## include settings specific to this machine
 if [[ -r ~/.zshlocal ]]; then
     source ~/.zshlocal