2010-10-26

remove the ".exe" suffix of commands in bash on Cygwin when completing

Because I think the extra ".exe" takes too much space when multiple pipelines are used in a one-liner task.

Basically it's a small change to the file lib/readline/complete.c in bash's source code.

Find the definition of the function "make_quoted_replacement" and change the line

replacement = match;


to

if(strstr(match, ".exe") != NULL) {
replacement = (char *) xmalloc(strlen(match) - 4 + 1);
memset(replacement, 0, strlen(match) - 4 + 1);
strncpy(replacement, match, strlen(match) -4);
} else {
replacement = match;
}


Then recompile it to deploy.

2010-03-30

change the case sensitivity of pathname completion in bash

I don't like bash being case-sensitive when cd to different directories because when there are upper-case letters in directory names usually either the capslock or the shift key has to be pressed which slows speed of switching paths. Thus in all my boxes where bash exists(linux machines, cygwin on windows boxes & my macbook running Snow Leopard) I have set up the ~/.inputrc file to contain this line to turn off the case-sensitivity:

set completion-ignore-case on


But there were cases that I'm using somebody else's bash shell instead of my own, which does not disable that case-sensitivity and would cause inconvenience for me(yes, to some extent). And today an idea occurred to me that bash may very likely support some kind of volatile switching this feature on and off. So I tried `man bash` and found a rather ugly solution:

1. create a tmp file, let's say "/tmp/inputrc" and type that line above in it.
2. in this bash shell, set the $iNPUTRC env variable by type in the command `export INPUTRC=/tmp/inputrc`
3. also in this bash shell, press the keybinding C-x C-r(which runs the readline command "re-read-init-file") to load the setting just typed in.

and now this bash shell is enabled with case-insensitivy.

It's rather a tedious and ugly solution.

PS: I tried to run this command

set completion-ignore-case on


in the bash shell as described in this cyberciti page. But it proved no effect at all.