Live data from Hacker News

Linux Terminal Tools [pdf]

ketancmaheshwari.github.io

41–50 of 57 posts

Re: Linux Terminal Tools [pdf]

#42
post #35

Should include CTRL-Q and CTRL-S, as I've encountered students who accidentally hit CTRL-S instead of CTRL-X and then stare at a hung terminal wonder WTF just happened.

I'm of the opinion that those should just be disabled these days. Aside from the occasional AMD motherboard that has a very slow scrolling non-text-mode framebuffer, Ctrl-Q and Ctrl-S aren't so useful with the GUI terminal programs or console terminals nowdays.

I still use them. E.g., for build processes that scroll by just a little too fast.

Re: Linux Terminal Tools [pdf]

#43
Good list. But when you write about xargs, you should absolutely warn that it has problems working with filenames with spaces in them, and the -0 option to fix that.

Re: Linux Terminal Tools [pdf]

#44
post #36

The secret that I never see brought up on any of the linux command line tools is "esc + ." - It's by far one of the most valuable tricks I've learned, it will insert the last thing from the last command ls /foo/bar/this_is_the_file.txt cat "esc + ." which expands to cat /foo/bar/this_is_the_file.txt

ok this is going to sound stupid, but I don't care. learning time, for me.

do you type the literal characters "esc + ." or do you press CTRL+[ then period, or do you push the escape key, then period, or do you push escape and period at the same time?

I'm not at a terminal to try any of this and find out for myself.

Re: Linux Terminal Tools [pdf]

#45

Earlier quoted context omitted.

I think by that analogy the title should have been "Computer Operating Systems Terminal Tools". The tools presented in the slides have been tested on a Linux System, which motivated the title name.

That would be incorrect: it's too general. These tools don't apply to Windows; yet some do apply to MacOS, due to its BSD/UNIX (not Linux) roots.

there are many ways in which these do apply on Windows, these days.

please work on separating the semantics of someone's statement from the pragmatics. don't bother with the "how they phrased it" bit, and instead try to focus on the "what are they trying to say" part more. you may be, like I did all too often in my youth, over-emphasizing English correctness, missing the message being communicated entirely.

maybe you're not doing that! maybe you are. only you can know for sure. if you are, then try to work on that. it will help you communicate and it will help others communicate with you. we all grow as people over time, and no one is flawless, and that's fine. just try to be better every day.

Re: Linux Terminal Tools [pdf]

#46

Earlier quoted context omitted.

If we're being picky then you probably also want `mkdir -p -- "$1"` in case they want to create a directory named `-m`, `-v`, etc. Surprisingly `--` isn't mentioned in the mkdir manpage on my system, but it works. E.g. `mkdir -- -p` does what you'd want.

Strictly speaking you want `mkdir -p "./$1"`, although the failure modes of `--`-ing arguments aren't as immediately demonstratable as those of not deflagging them at all.

You definitely don't want to universally add the "./" prefix because it breaks on absolute paths.

The only solution is for users to add the "./" prefix themselves when the path begins with "-", because many BSD userspaces don't support "--" as a marker to stop option parsing. Maybe that doesn't matter for a document with Linux in the title, but given the popularity of macOS for doing Linux development, I would still err on the side of supporting the BSDs for such things. Never mind that support for "--" outside GNU is very spotty, even on Linux.

There is no point, in my opinion, in trying to be smart in small shell helper functions. It should just do a simple, relatively foolproof series of commands, and usually, bail early on error. But the intersection of `mkdir -p` failures and `cd` successes is tiny, so I didn't even bother muddying the waters by suggesting another alteration to use `&&`.

Re: Linux Terminal Tools [pdf]

#47
post #36

The secret that I never see brought up on any of the linux command line tools is "esc + ." - It's by far one of the most valuable tricks I've learned, it will insert the last thing from the last command ls /foo/bar/this_is_the_file.txt cat "esc + ." which expands to cat /foo/bar/this_is_the_file.txt

ok this is going to sound stupid, but I don't care. learning time, for me. do you type the literal characters "esc + ." or do you press CTRL+[ then period, or do you push the escape key, then period, or do you push escape and period at the same time? I'm not at a terminal to try any of this and find out for myself.

I press and hold escape first then period

Re: Linux Terminal Tools [pdf]

#48
post #36

The secret that I never see brought up on any of the linux command line tools is "esc + ." - It's by far one of the most valuable tricks I've learned, it will insert the last thing from the last command ls /foo/bar/this_is_the_file.txt cat "esc + ." which expands to cat /foo/bar/this_is_the_file.txt

I agree, and some days ago, in another thread, I got +10 on my comment detailing this shortcut.

Another no-brainer imho is editing you /etc/inputrc or your $HOME/.inputrc and bind keys (usually PgUp and PgDn) to history-search-backward and history-search-forward.

From there you can navigate your history like with the arrows, but it will only consider lines that starts with the string that is currently on the command line.

It is a MUST.

Re: Linux Terminal Tools [pdf]

#49
post #48
post #36

The secret that I never see brought up on any of the linux command line tools is "esc + ." - It's by far one of the most valuable tricks I've learned, it will insert the last thing from the last command ls /foo/bar/this_is_the_file.txt cat "esc + ." which expands to cat /foo/bar/this_is_the_file.txt

I agree, and some days ago, in another thread, I got +10 on my comment detailing this shortcut. Another no-brainer imho is editing you /etc/inputrc or your $HOME/.inputrc and bind keys (usually PgUp and PgDn) to history-search-backward and history-search-forward. From there you can navigate your history like with the arrows, but it will only consider lines that starts with the string that is currently on the command…

This is something that comes with oh-my-zsh, love that feature!

Re: Linux Terminal Tools [pdf]

#50
post #36

The secret that I never see brought up on any of the linux command line tools is "esc + ." - It's by far one of the most valuable tricks I've learned, it will insert the last thing from the last command ls /foo/bar/this_is_the_file.txt cat "esc + ." which expands to cat /foo/bar/this_is_the_file.txt

Alt + . does the same thing as well, with the added advantage that you can keep pressing Alt and then hit "." several times to go through all the "last arguments" in your history one by one.
Post reply on HN