Live data from Hacker News

The Art of Command Line

github.com

101–110 of 134 posts

Re: The Art of Command Line

#101
post #78

Earlier quoted context omitted.

I have the following set in my .cshrc: setenv LC_ALL en_US.UTF-8 setenv LC_COLLATE C # use the ASCII sort order What have I broken, and how badly?

This won't work because LC_ALL overrides LC_COLLATE (and all the LC_* variables actually). It's LANG that you want to use. LANG is overriden by LC_* which are in turn overriden by LC_ALL. Don't use LC_ALL in your config files, use it only for one shot command lines or in scripts that need to be sure of the environment they run in.

Thank you both for the clue. I used to have LANG set, but I'm just going to unset them all. I think I put them in originally to change how directory listings got sorted, but I'm not sure I care any more. :)

Re: The Art of Command Line

#103

Earlier quoted context omitted.

Can you share a little more info about this? I tried it but found it rather confusing. Also, for more readline maneuvers: http://unix.stackexchange.com/questions/21788/how-to-delete-...

`set -o vi` allows us to use `vi` bindings instead of the default `emacs` bindings. The way to think about it is that the prompt starts out in `vi insert mode` so whatever we type in will just be inserted at the prompt. However, we can hit the`Escape` key and move into `vi normal mode` where the keys are interpreted as normal `vi` commands. So, for example, once we hit `esc` we can navigate around the line using `h`…

Thanks for the brief explanation. I wish there was some indication of whether you're in insert mode or normal mode.

Re: The Art of Command Line

#104

One really useful shortcut I learned in bash is Ctrl-/ which is a sort of undo for bash when composing a command. Can't really explain how it works, you should try it out yourself. Also really handy is Ctrl-Y, which pastes the last cut characters by Ctrl-W, Ctrl-U or Ctrl-K.

C-/ and C-y are from readline which mimicked them (and many more) from Emacs.

Re: The Art of Command Line

#106

So this is tangentially related by why do people seem to push Vi? Nano is a perfectly serviceable editor. If I need to do extensive editing I always end up loading it into Atom, Sublime or some other editor anyway. I've never really had to use a console editor for more than 10s of lines.

Nano is not as ubiquitous as vi. Every single *nix box will have vi on it, so even if you prefer something else, it's still in your best interest to learn the basics of vi.

Re: The Art of Command Line

#107

So this is tangentially related by why do people seem to push Vi? Nano is a perfectly serviceable editor. If I need to do extensive editing I always end up loading it into Atom, Sublime or some other editor anyway. I've never really had to use a console editor for more than 10s of lines.

In modern Bourne shell derivatives (Bash, ksh, some POSIX shells), the command: set -o emacs Will give command line editing bindings compatible with Emacs (which is also the default editing keys in MS-Windows and many IDE's BTW). HTH

Emacs bindings are not at all compatible with MS Windows.

Re: The Art of Command Line

#109
post #99
post #77

Earlier quoted context omitted.

or if you learn emacs you have emacs shortcuts by default in shells. which goes against his childish comment on emacs: > Learn Vim (vi). There's really no competition for random Linux editing (even if you use Emacs, a big IDE, or a modern hipster editor most of the time).

At first I thought the same as you, but then I realised that he's not talking about your average editor, but about which editor to use if you SSH into a random web server etc. The thing you use in a foreign environment. That's what "random Linux editing" probably means.

This. On your home computer, use whatever you want. If you're using all sorts of foreign environments, you're going to want to use whatever is common to all of them so that you don't fumble around badly trying to do basic tasks. Learn vi. You don't have to like it, you don't have to use it on your home system, and you don't have to learn the eleventy-billion vim-efficiency-hacks floating around the Internet. But learn it well enough that if you have to ssh into some server that only has vi installed on it, you aren't rendered completely helpless. Even "Notepad Capability" is fine.

Re: The Art of Command Line

#110
post #98
post #84

Another one for obscure but useful: jot # print 10 values from 1 to 10, with leading zeros: for n in `jot -w "%04d" 10 1 10`; do echo $n; done

Just use Bash's builtin things: for n in {0001..0010}; do echo ${n}; done

Nice, but this needs an actual version of bash, with that oldie shipped with OSX Yosemite the result is not padded with zeros.
Post reply on HN