News for hackers. Stuff that matters.
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by FranOntanaya on Friday October 30, 2015 @10:19AM (#10477936)
I'm afraid they'll manage to launch vim and will never be able to get out.
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by eloy on Friday October 30, 2015 @10:33AM (#10478012)
They should read the book "Popular Unix text editors and how to exit them"
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by scarmig on Friday October 30, 2015 @10:55AM (#10478164)

  quit
  ?
  exit
  ?
  end
  ?
  done
  ?
  bye
  ?
  quit!
  ?
  ^X  
  ?
  ^C
  ?
  ^C
  ?
  help
  ?
  ?
  ?
  ^Z
  $ killall ed
  $ vi
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by xnxn on Friday October 30, 2015 @04:50PM (#10480471)
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by Eupolemos on Friday October 30, 2015 @12:09PM (#10478648)
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by api on Friday October 30, 2015 @12:26PM (#10478768)
You mean that isn't how to exit 'ed'?
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by mcguire on Friday October 30, 2015 @12:53PM (#10478945)
Technically, the official method of exiting ed, if you're running as root, is:

    $ed a_file
    ... (normal usage)
    r /etc/motd
    w /boot/vmlinuz-3.19.0-16-generic (replace with specific kernel)
    !reboot
The alternative of "w /dev/sda1" is also acceptable.
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by mcguire on Friday October 30, 2015 @01:01PM (#10479007)
Note to those objecting to '$': I have PS1 set to '$' on every account. It just saves confusion.
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by iso8859-1 on Friday October 30, 2015 @02:02PM (#10479411)
Don't you think it is prettier with the space?
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by mcguire on Friday October 30, 2015 @02:24PM (#10479564)
Nah, just adds clutter.

[Fixed in the great-grandparent.]

Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by ChrisArgyle on Friday October 30, 2015 @03:55PM (#10480148)
^D^D should do it
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by Roodgorf on Friday October 30, 2015 @11:17AM (#10478327)
I was much too easily convinced that this could be a real book.
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by Keyframe on Friday October 30, 2015 @03:55PM (#10480150)
Accompanied by coffe table book 'Greatest screenshots of ruby in Sublime with dark themes'
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by Natanael_L on Friday October 30, 2015 @03:22PM (#10479941)
We can make it one! Who'll launch the kickstarter?
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by Roodgorf on Friday October 30, 2015 @04:08PM (#10480237)
Top contributor decides which editor we write it in.
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by dllthomas on Saturday October 31, 2015 @03:13AM (#10482070)
Can it be proprietary?

... can it cost more than my contribution?

Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by fisherjeff on Friday October 30, 2015 @10:47AM (#10478105)
Thank you both for inciting a fascinating combination of uncontrollable laughter and existential dread
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by DonHopkins on Friday October 30, 2015 @03:42PM (#10480076)
Not to be confused with the book "Popular Unix text editors and how to nest them".
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by techdragon on Friday October 30, 2015 @04:37PM (#10480395)
Which is a book inside a smaller book which is inside a smaller book ...
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by gknoy on Friday October 30, 2015 @07:19PM (#10481133)
... published as a Jupyter notebook of a LaTeX document of a markdown file containing Perl POD comments. ;)
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by eru on Friday October 30, 2015 @10:56AM (#10478171)
Ctrl-z works universally, doesn't it?
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by emergie on Friday October 30, 2015 @11:03AM (#10478228)
it doesn't, ctrl-z only suspends process and switches to backgroud - the thing is still alive try ctrl-z and then type bg command - you will see a list, you can resume with fg [number]
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by jokr004 on Friday October 30, 2015 @04:02PM (#10480200)
Ctrl-z by itself doesn't actually switch the process to run in the background, it stops the process. Running 'bg' is what starts the process back up running in the background, 'fg', like you said, resumes the process in the foreground and 'jobs' is the command you can run to see a list of processes that are running.
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by waterhouse on Saturday October 31, 2015 @05:44AM (#10482248)
Since the question was "Ctrl-z works universally", I feel obliged to point out that ctrl-z sends SIGTSTP, which can be blocked--not to be confused with SIGSTOP, which cannot be blocked. I don't know of any program that does intercept SIGTSTP (except a test program I wrote that tries to print the name of any signal it receives), and I suspect that "polite" interception would be to release a few resources and then accept being paused--but, in theory, a program could ignore it.
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by FreeFull on Saturday October 31, 2015 @09:18AM (#10482554)
Many curses programs (for example vim) intercept ^Z to set the terminal back into a more normal mode and then pause.
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by Touche on Saturday October 31, 2015 @12:47PM (#10483197)
This is probably a stupid question, didn't know about bg and fg before. But after playing around with it, it feels pretty amazing, why even use screen/tmux when you have these?
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by wutbrodo on Saturday October 31, 2015 @02:37PM (#10483605)
Screen has aaugh easier interface for multitasking, including things like stderr not bleeding out from whatever background tasks you're running. Not to mention that switching back and forth between screens is what it's designed for and thus a lot easier than switching between job numbers. Also the ability to detach your screen and its running processes from being coupled to a specific login session, which is probably the main reason I started using screen instead of multiple terminals in the first place.
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by dllthomas on Saturday October 31, 2015 @03:15AM (#10482075)
With bg, it is likely to suspend itself again by attempting to read from the terminal (which a text editor is likely to do basically all the time).
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by Anderkent on Friday October 30, 2015 @11:33AM (#10478422)
Well, it might still run but it lets you out of the editor, which is the goal here. You can just kill -9 it afterwards.
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by mcguire on Friday October 30, 2015 @12:57PM (#10478975)
If you have good reflexes, you can type "^Z" right after "kill -9", before the syscall to send the signal is executed.

Legend has it that, if you do, you bring on the Singularity immediately.

Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by dllthomas on Saturday October 31, 2015 @03:17AM (#10482079)
There is no reason for -9 here - all the major unix editors happily exit on SIGTERM.
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by ciupicri on Friday October 30, 2015 @11:03AM (#10478223)
Not really. Some programs disable it including vim (at least on some setups).
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by api_or_ipa on Friday October 30, 2015 @04:45PM (#10480429)
Every vim I've ever played on has respected `ctrl-z`. In fact, I use `ctrl-z` to jump out of my vim (to restart a server, ls the local dir, etc).
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by ciupicri on Friday October 30, 2015 @07:19PM (#10481130)
My vimrc has

    source $VIMRUNTIME/mswin.vim
    behave mswin
which maps Ctrl-z to undo.
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by skinnyfoetusboy on Saturday October 31, 2015 @06:42AM (#10482323)
You monster.
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by tomcam on Saturday October 31, 2015 @02:28PM (#10483578)
Well I'll be damned. Never thought of trying it. Thank you.
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by jlhim on Friday October 30, 2015 @11:04AM (#10478235)
this has got to be trolling. right? right?! i'm so confused.
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by schwap on Friday October 30, 2015 @11:41AM (#10478472)
Back when I first started my CompSci degree, a friend of mine always "quit" emacs with ctrl-z. Or, at least he did until he managed to fill his entire home directory quota with emacs backup files that were never cleaned up...
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by __david__ on Friday October 30, 2015 @02:26PM (#10479577)
Ha, I still do that!

    $ jobs
    [4]   Stopped                 emacsclient -a '' -nw [redacted]  (wd: [redacted])
    [5]   Stopped                 emacsclient -a '' -nw [redacted]  (wd: [redacted])
    [6]   Stopped                 emacsclient -a '' -nw [redacted]  (wd: [redacted])
    [7]   Stopped                 emacsclient -a '' -nw [redacted]  (wd: [redacted])
    [8]   Stopped                 emacsclient -a '' -nw [redacted]  (wd: [redacted])
    [9]   Stopped                 emacsclient -a '' -nw [redacted]  (wd: [redacted])
    [10]   Stopped                 emacsclient -a '' -nw [redacted]  (wd: [redacted])
    [11]   Stopped                 emacsclient -a '' -nw [redacted]  (wd: [redacted])
    [12]-  Stopped                 emacsclient -a '' -nw [redacted]  (wd: [redacted])
    [13]+  Stopped                 emacsclient -a '' -nw [redacted]
But since they're all emacsclients it doesn't really matter.
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by jnpatel on Friday October 30, 2015 @05:01PM (#10480520)
Don't you frequently deal with:

  /private/tmp/foo.txt locked by jnpatel@mac... (pid 14836): (s, q, p, ?)?
because of the lock files?
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by __david__ on Friday October 30, 2015 @05:25PM (#10480630)
Nope, because emacsclient ends up opening them all in the same process (that's the beauty/entire point): Fork off an emacs in the background:

  emacs --daemon
Then run emacsclient to connect to it (open a new buffer in the daemon and switch to it):

  emacsclient -nw some_file
When you "quit" (with C-x C-c), it really just quits that client, but the main emacs is left running.

This has a number of benefits: 1) no locks like you mention, 2) access to all open buffers (even unsaved) from every emacsclient that's currently running (since they're really all just opening buffers in a single instance), 3) blazing startup speed (emacs is already running, you're just connecting to it and splatting a new buffer to the terminal).

Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by krylon on Friday October 30, 2015 @08:26PM (#10481320)
I still remember how happy I was when I found out about that. On all servers I use (at home and at work), starting an emacs daemon is usually among the first things I do after rebooting.
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by rcthompson on Friday October 30, 2015 @05:34PM (#10480675)
Do you know about the "--no-wait" option for emacsclient?
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by __david__ on Friday October 30, 2015 @06:20PM (#10480883)
Yes. But it doesn't play well with "-nw".
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by rcthompson on Friday October 30, 2015 @08:03PM (#10481266)
Ah yes, good point. In that case, the solution is `C-x #` to finish an emacsclient session without causing the server to quit.
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by __david__ on Friday October 30, 2015 @08:20PM (#10481305)
Luckily C-x C-c also does that now.
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by api_or_ipa on Friday October 30, 2015 @04:45PM (#10480442)
`fg` is your friend
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by PhasmaFelis on Friday October 30, 2015 @05:55PM (#10480760)
My "favorite" thing is when you hit Ctrl-C, and Vim says "Type :quit<Enter> to exit Vim". Vim isn't dumb. It knows what Ctrl-C means, it knows what you wanted to happen. But it's gonna make you do it its way anyway, because fuck you.
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by pizzeys on Friday October 30, 2015 @06:39PM (#10480984)
Actually, that's a feature... Ctrl-C exits insert mode. If it quit vim when in Normal mode, you'd accidentally quit Vim all the time. Less annoying to just show a helpful message in case you actually meant quit, than dump everyone who knows what Ctrl-C does back to a shell.
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by dllthomas on Saturday October 31, 2015 @03:28AM (#10482100)
I think more important than exiting insert mode is (as I described in a peer comment, hopefully clearly) killing foreground processes you've spawned out of vim. 1) With exiting insert mode there's the option of using escape instead (or capslock or jk or whatever people bind it to), and 2), I think most importantly, with killing processes there's an actual race condition: if the command finishes after I decide to kill it and before vim registers my Ctrl-c, exiting is totally the wrong thing to do.
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by koide on Friday October 30, 2015 @06:35PM (#10480958)
I would think that it's because ViM wants you to learn something about how the it works.

If it just exited with Ctrl-C, you'd never get to know about the : magic.

Not to mention Ctrl-C is ambiguous. What to do: Exit and save? Exit without saving? What if it's a new file? And probably others I'm not thinking about right now.

Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by pnathan on Friday October 30, 2015 @06:06PM (#10480807)
Much like Python

    Python 2.7.9 (default, Mar  1 2015, 12:57:24) 
    [GCC 4.9.2] on linux2
    Type "help", "copyright", "credits" or "license" for  more information.
    >>> quit
    Use quit() or Ctrl-D (i.e. EOF) to exit
    >>>
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by retbull on Friday October 30, 2015 @06:36PM (#10480966)
thats because you don't want to be using a variable quit and have it suddenly exit.
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by dllthomas on Saturday October 31, 2015 @03:24AM (#10482090)
Definitely a feature not a bug.

    :'a,'b!longrunningcommand
oh, wait, that was not the right thing...

    C-<longrunningcommand finishes>c
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by creshal on Friday October 30, 2015 @10:31AM (#10478006)
Or emacs.

Or vim inside emacs' terminal emulator.

Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by LukeShu on Friday October 30, 2015 @02:02PM (#10479408)
Unfortunately, Vi is on the Arch install disc, but Emacs isn't (unless it's changed very recently). Though they of course could install it.
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by FreeFull on Saturday October 31, 2015 @09:20AM (#10482559)
The arch install disk also has vim. The base install of arch doesn't include vim, but does include vi.
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by oneeyedpigeon on Friday October 30, 2015 @11:23AM (#10478362)
Orders of magnitude more likely that vi will get launched than emacs :-)
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by krylon on Friday October 30, 2015 @08:28PM (#10481328)
> Or vim inside emacs' terminal emulator.

I've been there, by accident, two or three times.

The first time was really scary, since I did not know vi, yet, and did not know how to exit it or what in the world was going on...

Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by tlrobinson on Friday October 30, 2015 @04:01PM (#10480197)
Pretty sure it will be "rm -rf /"'d by trolls before that.
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by mgr86 on Friday October 30, 2015 @10:42AM (#10478076)
It's been awhile since a fresh install but is it ViM. is Vi still around? I just seem to recall some things not working right. Such as not being able to ZZ or ZQ out of a file.
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by aidenn0 on Friday October 30, 2015 @12:13PM (#10478686)
vim defaults to 100% backwards compatible with vi. It has an option "nocompat" that enables some non-backwards compatible improvements.

ZZ definitely still works regardless of nocompat though.

Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by TranquilMarmot on Friday October 30, 2015 @11:34AM (#10478427)
ZZ and ZQ work, at least on every instance of vim I've ever used
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by Gonzih on Friday October 30, 2015 @10:45AM (#10478099)
vi is built-in in arch installation. so...
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by valarauca1 on Friday October 30, 2015 @11:28AM (#10478398)
Vi is everywhere. Its part of the POSIX standard and comes out of the box (in one flavor or another) with every Linux Distro, OSX, HP-UX, AIX, Solaris, Darwin, FreeBSD, OpenBSD, and DragonFlyBSD.

ViM is just Vi iMproved. They share most their keybinds but VIM has the whole plugin architecture thing.

This is a big sticking point for a lot of VIM users [1]. If you ever end up on a Unix box that doesn't have VIM, you can always fall back on Vi.

[1]: /users/religious fanatics/

Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by zck on Friday October 30, 2015 @11:59AM (#10478586)
At least on Ubuntu, vi is really VIM:

    zck@zck-desktop:~$ vi --version
    VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jan  2 2014 19:39:32)
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by LukeShu on Friday October 30, 2015 @01:57PM (#10479371)
On Arch, vi is the original Bill Joy vi.

    $ vi --version
    vi: illegal option -- -
    Usage: vi [- | -s] [-l] [-L] [-R] [-r [file]] [-t tag]
           [-v] [-V] [-w size] [+cmd | -c cmd] file...
    $ pacman -Qi vi
    Name           : vi
    Version        : 1:070224-2
    Description    : The original ex/vi text editor
    Architecture   : x86_64
    URL            : http://ex-vi.sourceforge.net/
    Licenses       : custom:ex
    Groups         : base
    Provides       : None
    Depends On     : ncurses
    Optional Deps  : s-nail: used by the preserve command for notification [installed]
    Required By    : None
    Optional For   : None
    Conflicts With : None
    Replaces       : None
    Installed Size : 290.00 KiB
    Packager       : Evangelos Foutras <[email protected]>
    Build Date     : Sun 06 Sep 2015 03:34:15 PM EDT
    Install Date   : Fri 18 Sep 2015 10:33:33 PM EDT
    Install Reason : Explicitly installed
    Install Script : No
    Validated By   : Signature
(ok, I'm not actually on Arch, but I'm downstream of Arch, and that package is directly from Arch)
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by RexRollman on Friday October 30, 2015 @06:16PM (#10480861)
Re:Show HN: Twitch Installs Arch Linux – A cooperative text-... by xiaodown on Friday October 30, 2015 @12:55PM (#10478955)
Eh, yeah, but it usually links to the "basic" version (which, I assume, is compatibility mode for old school vi).

    root@dicks:~# which vi
    /usr/bin/vi
    root@dicks:~# file /usr/bin/vi
    /usr/bin/vi: symbolic link to `/etc/alternatives/vi'
    root@dicks:~# file /etc/alternatives/vi
    /etc/alternatives/vi: symbolic link to    `/usr/bin/vim.basic'
    root@dicks:~# file /usr/bin/vim.basic
    /usr/bin/vim.basic: ELF 64-bit LSB  executable, x86-64, (snip)
    root@dicks:~# vi --version
    VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jan  2 2014 19:39:32)