Linux Terminal Tools [pdf]
ketancmaheshwari.github.io
ketancmaheshwari.github.io
> mcd() { mkdir -p $1; cd $1 }
It should be more like:
> mcd() { mkdir -p "$1"; cd "$1"; }
The trailing ";" is also required in bash for oneline blocks like this.
Same goes for most of the other functions on page 70. "$@", etc.
Just trying to make the learning experience less frustrating, not trying to tear down the effort :)
Surprisingly `--` isn't mentioned in the mkdir manpage on my system, but it works. E.g. `mkdir -- -p` does what you'd want.
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 `&&`.
Little things like this have made me prefer using zsh whenever feasible: and, in the age of dockerized everything, there’s few good reasons left to use bash.
function mkcd() {
mkdir -p "$@" && cd "$1";
}
supports multiple dirs and cd to the first one mkcd a b cbesides, what kind of savage wants a directory name with spaces?
But a beginner could still tab-complete file names and get them automatically backslashed.
[raises hand] This type of savage?
Table of Contents (for those who hate PDFs):
Part 1: Overview and Logistics
• Part 2: Basics
• Part 3: Streams, pipe and redirection
• Part 4: Classic Tools: find, grep, awk, sed
• Part 5: Session Management: tmux
• Part 6: ssh: config and tunneling
• Part 7: Secure Communication with GnuPG
• Part 8: Bash Tools
• Part 9: Program Development Tools
• Part 10: Miscellaneous Utilities
• Summary
• Practice and Exercises (if time permits else Offline)
ls /foo/bar/this_is_the_file.txt
cat "esc + ."
which expands to
cat /foo/bar/this_is_the_file.txt
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.
Try this: https://lorenzo.mile.si/macos-iterm2-use-linux-keyboard-shor...
edit: I'm dumb, that was for iTerm, I got it working!
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.
But pressing and releasing ESC and then pressing and releasing period works excellently. Thank you.
Would we name a map book "A Toyota Roadmap", as if we don't know that there are other cars, and that a map applies to cars, not just to Toyotas specifically? Sure, a map would be different for push scooters (Windows), but a map would be the same for cars and small trucks.
It seems petty, but it becomes difficult to make a distinction between what's generally Unix and what's actually specifically Linux when we just call everything Linux.
Is it though?
Disclaimer: I am an old Unix hand (a literal graybeard). I started using Unix back in the mid 1980s, when a dual VAX 11/780 was hot stuff. I've used most of the major Unix distributions that ever existed.
In terms of server market share [1], Unix these days is, like, 95% Linux in various distros, with Windows, Free/Open/NetBSD, Illuminos, and a few others rounding out the top 10.
We can and should honor the past, and the innovators that made today's compute environment possible. But in a sense, "Unix" is a historical legacy, and denying that isn't useful.
[1] Because outside of some hobbyists, who is running traditional Unix on the desktop these days? Desktop "Unix" is really OSX and Linux 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.
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.
Funny, I used to have ctrl-s muscle memory, then 10 years of primarily developing on mac got me used to cmd-s since mac keyboards are so annoying. now when i switch between mac/win/linux it's just a constant mess of pressing the wrong special key combos. Almost as bad switching between scripting languages and forgetting if a function starts with func, proc, sub, def, etc... (yes, I know you can swap special keys on mac: i tried it and it creates way more headaches than it solves.)
TIL
https://unix.stackexchange.com/questions/85390/what-is-meant...
I switched over to powershell and the quality of life improvements have been amazing.