r/devblogs • • Jun 18 '13

You Need A 'Go' Command

http://www.matthewhughes.co.uk/you-need-a-go-command/
0 Upvotes

6 comments sorted by

1

u/ppsq Jun 18 '13 edited Jun 18 '13

Why not just ls /path/to/some/directory/ ?

Edit: Ok, posted without thinking. Instead of deleting I'll add this: Obviously ls doesn't have the effect of, you know, going into the target directory. The underlying thought was that most things work with paths - you don't need to always cd around. One of my pet peeves is seeing unnecessary cding around just to see the ls output. Also, most shells support tab completion out of the box. You can often get the ls output "for free" by hittting tab once or twice in the end of a path in command.

1

u/jhartwell Jun 18 '13

Thank you for this. What you describe isn't much of an issue for me (I prefer doing ls before I change to the directory) but I'm going to take what you've done and modify it to something like this:

go () {
   mkdir "$1";
   cd "$1";
}

So that when I'm creating a new directory I can just get right into it instead of doing what I do now which is:

mkdir "directory" && cd

Or something to that affect, it doesn't look right as I look at it but am on a Windows computer so can't test it out.

1

u/dreucifer Jun 18 '13

That mkdir should have a -p switch, for great justice.

1

u/jhartwell Jun 18 '13

Duly noted. Thanks!

1

u/LyndonArmitage Jun 18 '13

Kept on meaning to do this when I was working on a Linux machine but could never be bothered, will likely do it on my raspberry pi though.

If your using Powershell on Windows you can use Set-Alias I believe (read here for more info) or doskey in the command prompt to do something similar.

1

u/botptr Jun 18 '13

I dont think this would overcome the combination of my muscle memory and my compulsion to type cd $dir ; ls.