Terminal Commands

If we’re going a bit off-piste, Julia Evans recently created a ‘Bite Size Command Line’ zine that’s hand-drawn and gives explanations of 20-30 different command line tools and some of their more useful arguments and combinations.

If you’re going to be spending a lot of time on the command line, it may also be advisable to spend some time customising your bash profile (provided you use bash). I found some great ideas for shortcuts in Nathaniel Landau’s .bash_profile that I rely on every time I’m in Terminal.

One clever tip from the Take Control Book for your .bash_profile:

Open a Man Page in Preview

psman() {
	man -t "${1}" | open -f -a /Applications/Preview.app/
}

and then to use it:

psman command

6 Likes

@nostodnayr This is brilliant!

1 Like

This isn’t exactly a terminal command, but it make working with shell scripts a whole lot easier across multiple computers. Dr Drang talks about creating a ~/bin folder in Dropbox.

http://leancrew.com/all-this/2013/05/dropbox-bin/

I love the command bro which presents brief user supplied examples such as the ones above directly in the terminal. Think of it as a man that only shows concrete examples.

Installation instructions and online access to the examples: http://bropages.org

1 Like

I’ve never used bro but I use tldr and occasionally cht.sh which are essentially the same.

I admire your contribution but here’s a little suggestion:

Always Provide undo method and/or anatomical explanation when sharing command line-based tricks.

It will be a disaster for starter users to binge copy, paste, and execute commands and end up with a dead-end mess.

@platyhsu
Hence the following clear warning at the top of the thread:

Sure, some beginners might burn their fingers at the first attempt, but that’s how we learn, right?

Besides, the listeners to this show should all have solid backup solutions by now.

fc01577

1 Like

It is a good starting point. It is non-destructive, so you can try it to see how well it works for you.

1 Like

I have tried diff. It is good when I want to see how code or some prose has changed. comm is better for my most of my needs with lists of items.

To quickly toggle hidden files in Finder, try Shift Command period. Pressing once will show hidden files and pressing it again will hide hidden files.

5 Likes

Holy shortcuts, Batman. I did not know that one. Very nice.

1 Like

Yes great app, but if you have keyboard maestro you can build macro to do this, or use the macro contributed by @JMichaelTX in the keyboard maestro forum.

long directory listing

A simple command that I use all the time. This produces a long listing of a directory’s contents with file permissions, owner, size, etc. In your .bash_profile add this:

alias ll="ls -l"

You can tailor the command to your liking by adding more options.

More options:
https://ss64.com/bash/ls.html

2 Likes