January 18, 2011

Git Completion under Screen in Cygwin

I experienced that git tab completion doesn't work under screen in Cygwin.

1. I have git completion file placed at /etc/bash_completion.d/git
2. Git completion works under plain Cygwin shell (without screen)

To solve this problem, I added following line to my ~/.bashrc file
source /etc/bash_completion.d/git
And added shell definition to the /etc/screenrc file.
shell /bin/bash

No it works, hooray!

Strange thing is, that before any of my changes screen had shell /bin/sh
echo $0
/bin/sh


And /bin/sh and /bin/bash has same size:
$ls -la /bin/sh /bin/bash
-rwxr-xr-x 1 Alan root 470542 Aug 13 20:58 /bin/bash
-rwxr-xr-x 1 Alan root 470542 Aug 13 20:58 /bin/sh


And they have same content too, the diff command produces empty output:
$ diff /bin/sh /bin/bash

However, despite of this similarity, I cannot source git completion file under /bin/sh, but I'm able to do this under /bin/bash.

$ /bin/sh
$ source /etc/bash_completion.d/git
sh: /etc/bash_completion.d/git: line 123: syntax error near unexpected token `<'
sh: /etc/bash_completion.d/git: line 123: ` done < <(git config -z --get-regexp '^(svn-remote\..*\.url
|bash\.showupstream)$' 2>/dev/null | tr '\0\n' '\n ')'


$ /bin/bash
$ source /etc/bash_completion.d/git
$


Weird.