Windows Command Prompt (cmd) behaviour emulation in Linux terminal (Bash)

cmd / Terminal

Update 2008-03-25 @ 00:32: This post was originally titled "Emulate Command Prompt (cmd) tab auto-completion behaviour in Linux terminal (Bash)" (originally posted on 2008-03-20 @ 23:45), and have since been updated to cover more grounds.

Being a long time Windows command prompt (cmd) user, there are 2 things that the Linux terminal really annoyed me – tab auto-completion and case-sensitivity.

For instance, if you have "file-1.txt", "file-2.txt" and you do "fi[tab]", you’d get "file-", instead of "file-1.txt". And if you try doing something like "ls -l File*" you wouldn’t get anything returned…

Luckily, you can change the above behaviour by editing 2 files.

Tab-completion:

In order to get the windows command prompt’s tab-completion behaviour, you can edit / adding the following to "/etc/inputrc" (or "~/.inputrc"):

# Tab
TAB: menu-complete
# Shift-Tab (reverse menu-complete)
"e[Z": "e--t"

# Ignores the case of the letter
set completion-ignore-case on

According to the blog entry where I got this from, the "–" part of the Shift-TAB entry acts as an argument to the menu-complete function. In this case, it takes the previous entry of menu-complete.

Also, to enhance the terminal, you can also make the following amendments:

# The old style auto-complete (now mapped to Ctrl+space) - so you can still use it...
Control-SPACE: complete

# Automatically show everything instead of you having to press Ctrl+Space (as configured here) twice...
set show-all-if-ambiguous on
set show-all-if-unmodified on

# Display a "/" at the end for symlinked directories
set mark-symlinked-directories on

# Shut the bell up...
set bell-style none

Case-insensitive expansion ("globbing"):

If you want "ls -ld File*" to also display "file-1.txt", "file-2.txt", as well as "FiLe.txt" and "FILE.txt", you can add the following to "/etc/bash.bashrc":

# Disable case sensitive expansion - for command like "ls ld a*" to list "A_file"
# Note for things like "ls -ld a_file.txt", we still need to force it to glob by "ls -ld [a]_file.txt"
shopt -s nocaseglob

However, as mentioned in the comments, listing a complete filename is still sensitive – you’d have to force it to glob by doing "ls -ld [a]_file.txt".

If you know of any other useful modifications, drop me a comment!

Posted in Tips. 2 Comments »

Padded street furniture, you kidding me!?

Padded lamppost

Are you frigging kidding me? Has it really gotten to a point where we need to pad street furnitures for people on the phone who can’t be asked to look at where they’re going?

Not only does the padding make the street look stupid, it also puts out the wrong message to people – please, just walk however you like and go wherever you want, you don’t have to be careful and watch where you’re going!

I’m sure one day, those people will learn the lesson the hard way when they get run over by a car or something – and in that case, should we also attach giant-ass cushion in front of cars? I don’t think so.

<rant>
I’d rather the money be used to lower the cost of travel – it costs me £11.30 to go into Guildford in the morning and returning in the afternoon with young persons rail-card discount! That’s just crazy!
</rant>

Here’s the video of the scheme, watch it, you’ll realize how stupid it is: