jugglinmike / command-the-command-line

Educational material covering usage and administration of Unix-like systems.
https://jugglinmike.github.io/command-the-command-line/
Other
2 stars 0 forks source link

Think it's worth mentioning `cd -` ? #6

Open gnarf opened 8 years ago

gnarf commented 8 years ago

To return to the last directory you were in?

jugglinmike commented 8 years ago

I considered it, but I have concerns about discussing cd - with entry-level users. Understanding it involves recognizing the - value as a cd-specific feature. In other words, after explaining that "cd - means, 'return to the previous directory,'" I would feel obliged to continue, "...but ls - does not mean, 'inspect the previous directory.'"

For students just getting their bearings in the environment, I think it would be distracting to be presented with this distinction.

Compare this with the ~ shorthand (which is currently covered). Since that's provided by the shell, the abstraction is much more consistent.

I think I would be more amenable to covering this feature if it provided some substantive expressive power, or if it were common in scripts found on the web. As it stands, I think it's best to discover this feature on your own--hopefully at a time in your learning that you are ready for it :)

gnarf commented 8 years ago

I had similar thoughts, but I love that command, especially when you CD to a directory via an absolute or long path and realize you want to go back

On Jul 22, 2016 7:59 PM, "jugglinmike" notifications@github.com wrote:

I considered it, but I have concerns about discussing cd - with entry-level users. Understanding it involves recognizing the - value as a cd-specific feature. In other words, after explaining that "cd - means, 'return to the previous directory,'" I would feel obliged to continue, "...but ls - does not mean, 'inspect the previous directory.'"

For students just getting their bearings in the environment, I think it would be distracting to be presented with this distinction.

Compare this with the ~ shorthand (which is currently covered). Since that's provided by the shell, the abstraction is much more consistent.

I think I would be more amenable to covering this feature if it provided some substantive expressive power, or if it were common in scripts found on the web. As it stands, I think it's best to discover this feature on your own--hopefully at a time in your learning that you are ready for it :)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bocoup-education/speaking-nix/issues/6#issuecomment-234684433, or mute the thread https://github.com/notifications/unsubscribe-auth/AAhh60L55klV0HWfjNQUPP79kGjbEg1uks5qYVlcgaJpZM4JTFx4 .

tbranyen commented 8 years ago

Don't forget this works great with Git too git checkout -. Might be worth talking about *nix conventions/bashisms, which this probably falls under. A similar convention you could talk along side it, is -- to end arguments?