Topic: https://brettterpstra.com/2013/03/14/more-command-line-handiness/
hide preview

What's next? verify your email address for reply notifications!

Lauri Ranta 12y, 5d ago

lsz and chgext don't work with filenames that have spaces. And chgext doesn't work if the filenames contain characters interpreted by sed, but you could use "${file%.$1}.$2".

ps -c only prints command names, so you could use `ps -Aco pid,comm | sed 's/^ *//'`. pgrep has also been installed by default since 10.8. -l (long) prints process names, and -a includes ancestors like iTerm:

$ pgrep -ila ite
32894 WriteRoom
8591 iTerm

remark link
hide preview

What's next? verify your email address for reply notifications!

ttscoff 12y, 5d ago

I beg to differ. lsz and chgext both work fine on filenames with spaces. And granted sed-interpreted filenames would throw it off, but who would use regex symbols in a filename? I do like the mangling plan better than sed, though… I wrote that function before I had a grasp on variable mangling. Excuses.

You're right on psgrep. I had pgrep homebrewed but never noticed the -l option, and didn't look too hard because I've had this function running since long before I knew of it.

remark link parent
hide preview

What's next? verify your email address for reply notifications!

Lauri Ranta 12y, 5d ago

I see you edited chgext already, but lsz still doesn't work for me:

$ lsz a\ b.tgz
-bash: [: a: binary operator expected
'a b.tgz' is not a valid file

tar tvf (without a dash) doesn't seem to work either.

remark link parent
hide preview

What's next? verify your email address for reply notifications!

ttscoff 12y, 5d ago

Are you in bash? All of the above work for me. I've updated the gists nonetheless, they'll post here as soon as I clear the cache and regenerate.

remark link parent

load more (1 remarks)
hide preview

What's next? verify your email address for reply notifications!

Lauri Ranta 12y, 5d ago

Yeah, I tried it with both Bash 4.2 and 3.2. The old test expands unquoted variables:

$ x='a b'
$ [ -s $x ]
bash: [: a: binary operator expected
$ [[ -s $x ]]
$ [ -s "$x" ]
$

It also has (or had) `tar tvf $1`.

But you're right, tar tvf should work without the dash. It didn't work for me because I had aliased tar to "COPYFILE_DISABLE=1 tar --exclude .DS_Store".

hide preview

What's next? verify your email address for reply notifications!

PaulCapestany 12y, 6d ago

"Someday I’ll actually get my entire dotfile setup onto GitHub.." 

...I've been telling myself I should do the same (↑) thing for a while as well. While I've got clones of my entire system, I really wish I could *track* all the crazy tweaks I do (from dotfiles to plists, and everything in-between) in case I ever wanted to roll something back. 

Have you seen/played with http://boxen.github.com/ at all? 

Boxen seems like it could be the perfect solution to manage all of this kind of stuff, but it could also be a deep pit of fiddliness...

hide preview

What's next? verify your email address for reply notifications!