Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm running zsh on OSX and on occasion I have to work on a mounted sshfs volume. However, git is REALLY slow over sshfs mounts. My prompt makes use of the vc mode stuff that zsh provides built in, but in this case I want to skip that part.

I'd like to selectively disable vc integration any time my CWD is on a mounted filesystem. How can I do that?

I'm currently enabling git info in my prompt using (roughly) this snippet of my .zshrc (well, .oh-my-zsh/themes, but you get the idea):

zstyle ':vcs_info:*' enable hg git bzr svn p4

zstyle ':vcs_info:(hg*|git*):*' get-revision true
zstyle ':vcs_info:(hg*|git*):*' check-for-changes true

# rev+changes branch misc
zstyle ':vcs_info:hg*' formats "[%i%u %b%m]"
zstyle ':vcs_info:hg*' actionformats "(%{$fg_bold[red]%}%a%{$reset_color%})[%i%u %b%m]"

# hash changes branch misc
zstyle ':vcs_info:git*' formats "[%{$fg[yellow]%}%12.12i%{$reset_color%} %u %{$fg[magenta]%}%b%{$reset_color%}%m]"
zstyle ':vcs_info:git*' actionformats "(%a)[%{$fg[yellow]%}%12.12i%{$reset_color%} %u %{$fg[magenta]%}%b%{$reset_color%}%m]"

zstyle ':vcs_info:git*+set-message:*' hooks git-st git-stash

zstyle ':vcs_info:hg*:netbeans' use-simple true

zstyle ':vcs_info:hg*:*' get-bookmarks true

zstyle ':vcs_info:hg*:*' get-mq true
zstyle ':vcs_info:hg*:*' get-unapplied true
zstyle ':vcs_info:hg*:*' patch-format " mq(%g):%{$fg[green]%}%n%{$reset_color%}/%{$fg_bold[blue]%}%c%{$reset_color%} %{$fg[green]%}%p%{$reset_color%}"
zstyle ':vcs_info:hg*:*' nopatch-format ""

zstyle ':vcs_info:hg*:*' unstagedstr " ?"
zstyle ':vcs_info:hg*:*' hgrevformat "%{$fg[yellow]%}%r%{$reset_color%}" # only show local rev.
zstyle ':vcs_info:hg*:*' branchformat "%{$fg[magenta]%}%b%{$reset_color%}" # only show branch

# Show remote ref name and number of commits ahead-of or behind
function +vi-git-st() {
    local ahead behind remote
    local -a gitstatus

    # Are we on a remote-tracking branch?
    remote=${$(git rev-parse --verify ${hook_com[branch]}@{upstream} \
        --symbolic-full-name 2>/dev/null)/refs\/remotes\/}

    if [[ -n ${remote} ]] ; then
        # for git prior to 1.7
        # ahead=$(git rev-list origin/${hook_com[branch]}..HEAD | wc -l)
        ahead=$(git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l | tr -s ' ')
        (( $ahead )) && gitstatus+=( " ${c3}+${ahead}${c2}" )

        # for git prior to 1.7
        # behind=$(git rev-list HEAD..origin/${hook_com[branch]} | wc -l)
        behind=$(git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l | tr -s ' ')
        (( $behind )) && gitstatus+=( " ${c4}-${behind}${c2}" )

        hook_com[branch]="${hook_com[branch]} [${remote}${(j:/:)gitstatus}]"

# Show count of stashed changes
function +vi-git-stash() {
    local -a stashes

    if [[ -s ${hook_com[base]}/.git/refs/stash ]] ; then
        stashes=$(git stash list 2>/dev/null | wc -l)
        hook_com[misc]+=" (${stashes} stashed)"

precmd () { vcs_info }
%{$(get_prompt_user_color)%}%n%{$reset_color%} at %{$(get_prompt_host_color)%}%m%{$reset_color%} in %{$fg_bold[green]%}%~%{$reset_color%} ${vcs_info_msg_0_}
$(virtualenv_info)$(prompt_char) '
share|improve this question
Maybe this will help... – Joe Internet Sep 30 '11 at 21:57
No, it's not completions that are an issue – Chris R Sep 30 '11 at 22:13
Okay, sorry for the "rtfm" answer... see section 26.4 of the manual... it should help...… – Joe Internet Oct 1 '11 at 0:26
Can you add the relevant zshrc sections that you used to enable this? – polynomial Oct 1 '11 at 4:58

Have a look at Version-Control-Information

Search for the section on 'disable-patterns' (roughly 20% down the page).
Assuming your remote mounts are fixed, or relatively fixed, i.e. /mnt/remote/* or you can list them all, you should be able to come up with a regex for them.

The example at the link is disabling vcs_info under ~/.zsh/, via:

zstyle ':vcs_info:*' disable-patterns "$HOME/.zsh(|/*)"

I guess you could make the zshrc or equivalent (sorry - bash user) figure out which are remote at startup (or periodically, or ...) and update the zstyle accordingly.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.