Skip to main content
.. make `zsh` compatible again(?)
Source Link
hoijui
  • 4.1k
  • 2
  • 39
  • 47

Copied from the bash completion file, the following is a naive way to do it

# Copyright (C) 2006,2007 Shawn O. Pearce <[email protected]> # Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/). # Distributed under the GNU General Public License, version 2.0. if [ -d .git ]; then echo .gitgit; else git rev-parse --git-dir 2> /dev/nullnull; fifi; 

You could either wrap that in a function or use it in a script.

Condensed into a one line condition suitable for bash and zsh

[ -d .git ] && echo .git || git rev-parse --git-dir > /dev/null 2>&1 

Copied from the bash completion file, the following is a naive way to do it

# Copyright (C) 2006,2007 Shawn O. Pearce <[email protected]> # Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/). # Distributed under the GNU General Public License, version 2.0. if [ -d .git ]; then echo .git else git rev-parse --git-dir 2> /dev/null fi 

You could either wrap that in a function or use it in a script.

Condensed into a one line condition suitable for bash and zsh

[ -d .git ] && echo .git || git rev-parse --git-dir > /dev/null 2>&1 

Copied from the bash completion file, the following is a naive way to do it

# Copyright (C) 2006,2007 Shawn O. Pearce <[email protected]> # Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/). # Distributed under the GNU General Public License, version 2.0. if [ -d .git ]; then echo .git; else git rev-parse --git-dir 2> /dev/null; fi; 

You could either wrap that in a function or use it in a script.

Condensed into a one line condition suitable for bash and zsh

[ -d .git ] && echo .git || git rev-parse --git-dir > /dev/null 2>&1 
fixed as mentioned by @ndbroadbent
Source Link
hoijui
  • 4.1k
  • 2
  • 39
  • 47

Copied from the bash completion file, the following is a naive way to do it

# Copyright (C) 2006,2007 Shawn O. Pearce <[email protected]> # Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/). # Distributed under the GNU General Public License, version 2.0. if [ -d .git ]; then echo .git;git else git rev-parse --git-dir 2> /dev/null;null fi;fi 

You could either wrap that in a function or use it in a script.

Condensed into a one line condition suitable for bash or zshbash and zsh

[ -d .git ] && echo .git || git rev-parse --git-dir > /dev/null 2>&1 

Copied from the bash completion file the following is a naive way to do it

# Copyright (C) 2006,2007 Shawn O. Pearce <[email protected]> # Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/). # Distributed under the GNU General Public License, version 2.0. if [ -d .git ]; then echo .git; else git rev-parse --git-dir 2> /dev/null; fi; 

You could either wrap that in a function or use it in a script.

Condensed into a one line condition suitable for bash or zsh

[ -d .git ] || git rev-parse --git-dir > /dev/null 2>&1 

Copied from the bash completion file, the following is a naive way to do it

# Copyright (C) 2006,2007 Shawn O. Pearce <[email protected]> # Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/). # Distributed under the GNU General Public License, version 2.0. if [ -d .git ]; then echo .git else git rev-parse --git-dir 2> /dev/null fi 

You could either wrap that in a function or use it in a script.

Condensed into a one line condition suitable for bash and zsh

[ -d .git ] && echo .git || git rev-parse --git-dir > /dev/null 2>&1 
added 1 characters in body; deleted 5 characters in body
Source Link
Esteban Küber
  • 37k
  • 15
  • 82
  • 97

Copied from the bash completion file the following is a naive way to do it

# Copyright (C) 2006,2007 Shawn O. Pearce <[email protected]> # Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/). # Distributed under the GNU General Public License, version 2.0. 

...

  if [ -d .git ]; thethen echo .git; else git rev-parse --git-dir 2> /dev/null; fi; 

You could either wrap that in a function or use it in a script.

Condensed into a one line condition suitable for bash or zsh

[ -d .git ] || git rev-parse --git-dir > /dev/null 2>&1 

Copied from the bash completion file the following is a naive way to do it

# Copyright (C) 2006,2007 Shawn O. Pearce <[email protected]> # Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/). # Distributed under the GNU General Public License, version 2.0. 

...

if [ -d .git ]; the echo .git; else git rev-parse --git-dir 2> /dev/null; fi; 

You could either wrap that in a function or use it in a script.

Condensed into a one line condition suitable for bash or zsh

[ -d .git ] || git rev-parse --git-dir > /dev/null 2>&1 

Copied from the bash completion file the following is a naive way to do it

# Copyright (C) 2006,2007 Shawn O. Pearce <[email protected]> # Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/). # Distributed under the GNU General Public License, version 2.0.   if [ -d .git ]; then echo .git; else git rev-parse --git-dir 2> /dev/null; fi; 

You could either wrap that in a function or use it in a script.

Condensed into a one line condition suitable for bash or zsh

[ -d .git ] || git rev-parse --git-dir > /dev/null 2>&1 
added a one line conditional implementation that does away with the echoing of the actual git dir
Source Link
jabbie
  • 2.7k
  • 1
  • 17
  • 9
Loading
Source Link
jabbie
  • 2.7k
  • 1
  • 17
  • 9
Loading