News for hackers. Stuff that matters.
Re:Xi: an editor for the next 20 years [video] by postit on Tuesday January 30, 2018 @02:15PM (#16268057)
Xi creator did an amazing work implementing ropes (https://github.com/google/xi-editor/tree/master/rust/rope)

The design documents (https://github.com/google/xi-editor/tree/master/doc/rope_sci...) explaining the concepts and implementation details is a must for those who want to understand its core.

But I still have my regards regarding input latency being accredited only to the text editor. I recently switched back to Linux (nvim running on alacritty with tmux) and the latency issues magically disapeared. During my iterm2 (and even terminal) period on OSX I felt horrible lag during operations which I don't even have time to blink with my current setup.

The last straw was once I found out iterm2 consuming 10% of my CPU in idle, the issue only happened when any non builtin font (menlo, monaco or courier) was used.

Re:Xi: an editor for the next 20 years [video] by eeks on Tuesday January 30, 2018 @02:48PM (#16268350)
I must concur. With an equivalent vim setup and code files, nothing beats X11/suckless terminal on my OpenBSD machine. Comparing to that, even Alacritty looks like a slug.

I must say however that things are looking a bit better in iTerm2 when switching the Metal renderer on. It's just a shame that an Nvidia GPU on OSX is necessary to compete with my $1000 Lenovo with its crappy Intel chip on OpenBSD when it comes to text editing latency.

Re:Xi: an editor for the next 20 years [video] by gnachman on Tuesday January 30, 2018 @05:09PM (#16269552)
iTerm2's design is saddled by some history. At the time I took it over, everything was done in a single thread. By the time I realized I was going to stay with the project and how bad the design was, it was too late to change it. I've moved as much work as possible off the main thread (parsing the bytestream and now rendering). I think Terminal gets very nice performance without resorting to Metal by doing only UI work on the main thread. I think the Metal renderer will prove to be worthwhile, even though it was a lot of work to create that could've been avoided (kinda) if the design had been fixed 8 years ago.

As for using CPU when idle, there was a bug where a background thread was doing the equivalent of running `ps` over and over. That's been fixed in the last few versions, but please file issues for such things and I'll get to them as soon as I'm able.

Re:Xi: an editor for the next 20 years [video] by jarpineh on Tuesday January 30, 2018 @05:42PM (#16269779)
I'll add my thank you. I'm also backer at Patreon.

With tmux control mode it's already very good and now with faster rendering coming...

Re:Xi: an editor for the next 20 years [video] by acoard on Tuesday January 30, 2018 @07:00PM (#16270230)
I've got an unrelated question about tmux/iTerm2 - hope you don't mind me asking.

I'm a heavy iTerm2 user and always been curious about tmux. Is there any reason to try out tmux integration if I'm already comfortable with iTerm2's features and panelling? I kind of got the impression tmux integration was largely for people who love tmux and are migrating to iTerm2, so it just makes it more familiar. Or is it something I should take another look at?

Re:Xi: an editor for the next 20 years [video] by jarpineh on Tuesday January 30, 2018 @07:29PM (#16270354)
Not at all, if only to tell about virtues iTerm2 and tmux to wider audience!

Short version: iTerm with tmux control mode (tmux -CC flag) is still iTerm, only now with tmux benefits like persistent shell sessions. iTerm translates regular commands like new window and split pane into tmux commands and acts otherwise like regular iTerm. Mac might crash or SSH get disconnected and tmux stays running to save you from losing anything (well, if it's running on a server..).

In addition you tmux gives you shell sharing and allows using different devices alltogether. I sometimes use iPad or iPhone with Blink.app to connect to my always running sessions. You can connect to existing tmux session attaching with CC mode and iTerm will open windows and panes to accommodate.

One caveat if you require Mosh for network issues: it and tmux control mode aren't compatible. Also, I'd like to open tmux windows as tabs instead of separate iTerm windows, but that's a minor thing.

This page on iTerm's wiki explains things in detail: https://gitlab.com/gnachman/iterm2/wikis/TmuxIntegration

Re:Xi: an editor for the next 20 years [video] by wingspan on Tuesday January 30, 2018 @11:19PM (#16271257)
Regarding Mosh and control mode, Eternal Terminal https://mistertea.github.io/EternalTCP/ provides the same resumable session, and works flawlessly with tmux control mode.
Re:Xi: an editor for the next 20 years [video] by AlexCoventry on Wednesday January 31, 2018 @12:46AM (#16271745)
ET may be insecure. It was recently possible to segfault it with corrupted network inputs.

https://github.com/MisterTea/EternalTCP/issues/79

Re:Xi: an editor for the next 20 years [video] by AceJohnny2 on Tuesday January 30, 2018 @07:15PM (#16270290)
I use tmux with iTerm regularly, and it's my killer feature in iTerm.

I don't think there's much benefit to using tmux integration for a local shell, other than possibly long-lasting sessions that will survive iTerm itself crashing (and maybe you logging out? I'm not sure), which isn't enough of a problem for me to have to work around.

The awesome benefit for me is when using a remote tmux. Tmux integration works over SSH, so thanks to this I can have native-looking tabs and windows that are actually terminals on a remote machine. And if I get disconnected (frequent, with a laptop, as I'm moving around), I can reconnect and get all the remote windows just fine.

Gone are all the usual tmux C-b prefixes to managing windows, non-integrated scrolling, etc. Everything behaves like a normal iTerm window. I can even split/move panes like normal iTerm panes (though that crashed iTerm until about a year ago).

I have the following alias defined:

    ssh -t elf.example.com /opt/local/bin/tmux -u -CC attach
The -t is the SSH option to force pseudo-terminal allocation, which some versions of ssh fail to do when passing a command (in this case tmux) rather than starting a shell.

I'm specifying the /opt/local/bin version of tmux, because that's an updated one I've installed from MacPorts. Unfortunately Apple continues to bundle old versions of tmux in macOS, and last I checked the one that was bundled didn't actually support the Control Channel required by iTerm integration.

-u is a tmux option to force it in Unicode mode, required by iTerm's Tmux integration

-CC tells tmux to start a control channel and disable echo (required by iTerm's tmux integration)

`attach` attaches to the default session that I created prior.

Re:Xi: an editor for the next 20 years [video] by hultner on Tuesday January 30, 2018 @07:20PM (#16270307)
I’d say it’s the opposite as an die hard tmux-user. I don’t really use the integration since I’m more comfortable with my terminal in full screen and my own tmux config. The integration services seems more appropriate for someone who doesn’t already have their tmux-bindings and workflow stamped into muscle memory but rather just want the benefits of detaching their terminal sessions from their terminal application while retaining iterm native tabs, windows and panes.

I’ve tried out the integration mode a few times but it just doesn’t fit my workflow (often switching sessions, highly customized tmux configuration, etc).

Re:Xi: an editor for the next 20 years [video] by Myrmornis on Tuesday January 30, 2018 @10:17PM (#16271030)
Exactly. For people who already use tmux heavily, and use it on linux as well as macos, the iterm2 integration isn’t going to be an attractive direction. Partly because it will lose the uniform experience across OSs, and partly because they’re happy with session/window/pane management using tmux’s UI.
Re:Xi: an editor for the next 20 years [video] by kokey on Wednesday January 31, 2018 @02:14AM (#16272148)
I'm the same, but with screen. I usually have an iTerm2 tab for each screen session. I have a screen session on a work machine and one on a personal machine, each usually with close to 10 virtual terminals. I connect to both with mosh. I haven't seen a compelling reason for me to switch to tmux, yet.
Re:Xi: an editor for the next 20 years [video] by wll on Tuesday January 30, 2018 @05:31PM (#16269694)
Thank you for your work on iTerm2, George!
Re:Xi: an editor for the next 20 years [video] by bronxbomber92 on Tuesday January 30, 2018 @09:26PM (#16270844)
Did you hit any pain points using Metal?
Re:Xi: an editor for the next 20 years [video] by wincent on Tuesday January 30, 2018 @11:55PM (#16271442)
So looking forward to the Metal renderer. Any idea when it will makes into a release?
Re:Xi: an editor for the next 20 years [video] by Philipp__ on Tuesday January 30, 2018 @03:17PM (#16268618)
Wow, just gave iTerm2 Nightly with Metal renderer a spin! Holy shiet it's fast and smooth! FINALY! Opened 20k C file in Vim (stock vim 8 that comes with macOS High Sierra), pushed that scroll down and let it roll, it was soooo smooth! Amazing!
Re:Xi: an editor for the next 20 years [video] by bhoeting on Tuesday January 30, 2018 @08:49PM (#16270708)
I tried it after reading this comment. You weren't kidding. Unfortunately, my Vim isn't rendering properly. About 10 lines in the middle of the screen are blank for some reason. Both in and out of Tmux. Oh well. I'm just happy that I can look forward to Metal rendering being merged into stable.
Re:Xi: an editor for the next 20 years [video] by neoncontrails on Tuesday January 30, 2018 @10:32PM (#16271069)
Not sure if it's the same issue I had recently with iTerm2 periodically going black, but consider disabling the Core Text renderer with the following command:

$ defaults write org.vim.MacVim MMUseCGLayerAlways -bool YES

This was the developers' suggestion and it solved my issue. There's an informative discussion of the root causes here: https://github.com/macvim-dev/macvim/issues/557.

Re:Xi: an editor for the next 20 years [video] by bhoeting on Wednesday January 31, 2018 @02:30PM (#16276786)
Hmm, that didn't see to work for me. I think I have a different issue. Thanks, though!
Re:Xi: an editor for the next 20 years [video] by wyclif on Tuesday January 30, 2018 @08:36PM (#16270662)
Is there a way to install that with homebrew?
Re:Xi: an editor for the next 20 years [video] by bhoeting on Tuesday January 30, 2018 @08:40PM (#16270675)

    brew cask install iterm2-nightly
Re:Xi: an editor for the next 20 years [video] by myko on Tuesday January 30, 2018 @09:06PM (#16270762)
I had to:

    brew tap caskroom/versions
as well
Re:Xi: an editor for the next 20 years [video] by wyclif on Wednesday January 31, 2018 @01:13AM (#16271867)
Thanks guys, I was a bit embarrassed to ask that question but I suspected the answer wasn't quite intuitive.
Re:Xi: an editor for the next 20 years [video] by tomjakubowski on Tuesday January 30, 2018 @05:08PM (#16269541)
Have you tested iTerm2's Metal renderer performance with the integrated Intel GPU?
Re:Xi: an editor for the next 20 years [video] by eeks on Wednesday January 31, 2018 @09:08AM (#16273893)
Yes, however matter-of-factly while moving about the office. I did not perceive any difference between the Mac plugged in and on the go.
Re:Xi: an editor for the next 20 years [video] by bowmessage on Tuesday January 30, 2018 @06:52PM (#16270203)
Thank you so much for mentioning the new experimental metal renderer feature. This has dramatically improved my development setup.
Re:Xi: an editor for the next 20 years [video] by TheAceOfHearts on Wednesday January 31, 2018 @02:55AM (#16272258)
Have you tried Terminal.app recently? A lot of people seem to rush immediately to iTerm2... And I used to be one of those, a few years back. But eventually I gave the built-in Terminal.app a serious chance and found it met all my requirements. Although I also stopped customizing my theme, and I keep as many defaults as possible. SF Mono is a great font!
Re:Xi: an editor for the next 20 years [video] by MaxBarraclough on Wednesday January 31, 2018 @06:46AM (#16273147)
I did the same thing a few years ago. Terminal.app has had tab support for years now. What's the killer feature of iTerm these days?

I also recall finding Terminal.app to have lower CPU consumption, matching postit's experience.

Re:Xi: an editor for the next 20 years [video] by rdrey on Wednesday January 31, 2018 @10:28AM (#16274549)
The killer feature for me was setting an "alarm" on a currently running process and getting a notification when it finished. It's not something I've seen in any other terminal. (Using Ubuntu now and missing it.)
Re:Xi: an editor for the next 20 years [video] by arjunbajaj on Wednesday January 31, 2018 @11:38AM (#16275144)
I believe Elementary OS's terminal has this in-built.
Re:Xi: an editor for the next 20 years [video] by jhasse on Wednesday January 31, 2018 @06:58PM (#16278678)
Fedora has this, too.
Re:Xi: an editor for the next 20 years [video] by lambdadmitry on Wednesday January 31, 2018 @07:14AM (#16273252)
Quake-style console. I'm too addicted to it unfortunately.
Re:Xi: an editor for the next 20 years [video] by girvo on Friday February 02, 2018 @10:05AM (#16291030)
Literally the only reason why I use iTerm 2 over Terminal.app as well. Though I'm tempted to see if I can't replicate a similar "show over anything when a hotkey is pressed" in Terminal.app with some cute AppleScript...
Re:Xi: an editor for the next 20 years [video] by haskal on Wednesday January 31, 2018 @10:27PM (#16279460)
1. When you exit a terminal it dumps irrelevant stuff rather than just closing the tab.

    ~ % exit 
    
    [Process completed]
2. Cmd + Arrow doesn't doesn't move to the next or last tab. (Cmd + number does work however, but it doesn't show numbers on the tab list like iTerm)

3. Comes with terrible defaults like the screen color.

Re:Xi: an editor for the next 20 years [video] by Jakob on Thursday February 01, 2018 @05:20AM (#16280743)
There certainly are some advantages of iTerm2 but the ones you stated are very easily done in Terminal.app:

1. Settings > Profiles > Shell > When the shell exits: [Close the window|Close if the shell exited early|Don’t close the window]

2. macOS standard for all applications is the following.

  - next tab: ⌃⇥ or ⌘⇧]
  - previous tab: ⌃⇧⇥ or ⌘⇧[
If you really want to change that, you can do so in System Preferences

3. Settings > New window with profile: Pro

Re:Xi: an editor for the next 20 years [video] by latexr on Wednesday January 31, 2018 @08:06AM (#16273504)
Probably not a big feature for most, but I work with URLs in the terminal a lot and ⌘+click to immediately open them in the browser is convenient.

I prefer to open a new Terminal only when I need it instead of keeping one open all day (even if that sometimes happens) and I’ve never noticed an increase in CPU usage that’d made me want to check.

Re:Xi: an editor for the next 20 years [video] by bluerobotcat on Wednesday January 31, 2018 @08:50AM (#16273766)
Terminal.app does that too
Re:Xi: an editor for the next 20 years [video] by latexr on Friday February 02, 2018 @01:12PM (#16292690)
You have to double-click and pressing ⌘ gives no visual feedback. That explains why I didn’t find it before. Thank you for the tip.
Re:Xi: an editor for the next 20 years [video] by leshow on Wednesday January 31, 2018 @01:42PM (#16276332)
scoff how dare you use a mouse. In urxvt I have it mapped to ctrl+u
Re:Xi: an editor for the next 20 years [video] by stormking on Thursday February 01, 2018 @05:16AM (#16280728)
> What's the killer feature of iTerm these days?

Panes.

Re:Xi: an editor for the next 20 years [video] by dmytrish on Thursday February 01, 2018 @08:01AM (#16281536)
I don't use panes much, but Terminal.app seems to have panes too.
Re:Xi: an editor for the next 20 years [video] by eropple on Thursday February 01, 2018 @11:32AM (#16283154)
- Bafflingly, they split horizontally. I have a 4x4 pane setup, but my default is 2x1.

- Cmd-W closes the window, not the pane. (I get why they do this. I feel that it is wrong.)

- I can't send input to all panes, which is a pretty useful feature I probably use once a week.

- iTerm2 happily maps my panes to tmux. This is by itself perhaps a killer feature.

Re:Xi: an editor for the next 20 years [video] by dmytrish on Monday February 05, 2018 @12:01PM (#16310110)
Thanks! I feel the same about "tmux vs screen": tmux panes are just so much easier to use and more flexible than in screen, even though screen can split windows).
Re:Xi: an editor for the next 20 years [video] by brazzledazzle on Wednesday January 31, 2018 @09:38AM (#16274128)
I really like the tmux integration.
Re:Xi: an editor for the next 20 years [video] by coldtea on Wednesday January 31, 2018 @07:24AM (#16273314)
>found it met all my requirements. Although I also stopped customizing my theme, and I keep as many defaults as possible

Well, if your requirements are low and the defaults are OK, sure, Terminal.app can do it. But iTerm2 does so many more things it's not even funny.

Re:Xi: an editor for the next 20 years [video] by spinningarrow on Wednesday January 31, 2018 @06:37AM (#16273117)
I still can’t get 256 colours working properly in tmux in Terminal.app - any idea if that’s supported?
Re:Xi: an editor for the next 20 years [video] by fergie on Wednesday January 31, 2018 @10:04AM (#16274313)
Terminal with GNU Screen works really well for me.
Re:Xi: an editor for the next 20 years [video] by willtim on Tuesday January 30, 2018 @03:02PM (#16268487)
A more interesting approach would be to use persistent data structures. While possibly slower for some operations, undo is more efficient and there are really interesting opportunities for concurrency. See:

https://github.com/arximboldi/ewig/blob/master/README.md

Re:Xi: an editor for the next 20 years [video] by raphlinus on Tuesday January 30, 2018 @03:06PM (#16268521)
I believe xi-rope counts as a persistent data structure. We have plug-ins in separate processes now, for isolation, but might explore having them in-process but in separate threads. The underlying data structure should support that just fine. Is there something I'm missing?
Re:Xi: an editor for the next 20 years [video] by willtim on Tuesday January 30, 2018 @04:06PM (#16269021)
A rope data structure is very almost persistent. So perhaps I am splitting hairs! It could of course be made fully persistent if mutating operations are avoided. This would allow sharing them between threads.
Re:Xi: an editor for the next 20 years [video] by steveklabnik on Tuesday January 30, 2018 @04:16PM (#16269118)
> This would allow sharing them between threads.

This is an area where Rust ends up feeling different than many languages: xi's rope uses https://doc.rust-lang.org/stable/std/rc/struct.Rc.html#metho... like this: https://github.com/google/xi-editor/blob/422948d62688dcc2ee0... , which gives you both options. This code uses Rc, not Arc, so it's not currently sharable between threads, but Arc has the same API.

Rust cares about sharing more than immutability.

Re:Xi: an editor for the next 20 years [video] by raphlinus on Tuesday January 30, 2018 @04:52PM (#16269426)
Nope, it's Arc for exactly that reason, though we're not currently using it across threads right now. The fact that it can support immutable semantics safely is one of the really nice features of Rust.
Re:Xi: an editor for the next 20 years [video] by arximboldi on Wednesday January 31, 2018 @07:09AM (#16273227)
Thanks willtim, for mentioning Ewig/Immer :)

As Ralph and others have pointed out, their rope is fundamentally a persistent data structure.

I think that one of the fundamental differences between how Rust and C++ deal with value and reference semantics make the two approaches look more different than they are. The C++ API is allowed to look a bit more "immutable", where one can always use the same functional looking API even though sometimes the performance of an operation is gonna depend on the category of the reference you are operating on (l-value, r-value). Rust forces the user to be explicit about everything all the time, making it very explicit when intend to "branch" or "snapshot" the persistent data structure and where do we wanna allow "in place" updates.

I am still undecided about which approach I like most, and I do think that there merits to each approach. But maybe just because I never really wrote anything serious in Rust. The C++ approach has the problem that it becomes unsafe once you introduce `std::move` (but if the C++ type system was not a crazy evolutionary monster one could imagine a similar approach with moves being inserted automatically and safely by the compiler.)

Re:Xi: an editor for the next 20 years [video] by dikaiosune on Tuesday January 30, 2018 @09:53PM (#16270954)
The author of alacritty suggests that there's an IPC performance issue with tmux/nvim on macOS: https://github.com/jwilm/alacritty#faq
Re:Xi: an editor for the next 20 years [video] by jorvi on Tuesday January 30, 2018 @06:23PM (#16270046)
Alacritty is slower than Terminal.app..[1] perhaps placebo effects were/are in play?

[1]https://danluu.com/term-latency/

Re:Xi: an editor for the next 20 years [video] by jwilm on Tuesday January 30, 2018 @06:39PM (#16270138)
The article you linked is specifically about latency. There are other factors that contribute to overall terminal experience such as high frame rate and high throughput. Once latency reaches a "good enough" level, it becomes a non issue, and frame rate and throughput remain. Alacritty excels in those areas (there's even a table in that article demonstrating Alacritty's high throughput).

There is also a plan[1] for making Alacritty's latency best-in-class.

[1]: https://github.com/jwilm/alacritty/issues/673

Re:Xi: an editor for the next 20 years [video] by squeaky-clean on Tuesday January 30, 2018 @08:30PM (#16270644)
I haven't gone through the whole link yet, but the part where they make video game comparisons doesn't make sense. They say

> When people measure actual end-to-end latency for games on normal computer setups, they usually find latencies in the 100ms range.

And in that very sentence link to a latency test for a game that is notorious for being laggy, and even then it reaches 59.4ms latency. The same video they link, even says (at 1:32) that Overwatch has a button-to-pixel-change latency of about 15 ms! So where is this "usually 100ms" coming from?

Just because of this I don't really trust the rest of the article.

Re:Xi: an editor for the next 20 years [video] by XR0CSWV3h3kZWg on Tuesday January 30, 2018 @03:50PM (#16268898)
Yeah iterm2 is pretty unacceptable. For me alacritty is still missing some polish (i.e. text size keeps on changing when I attached/detach monitors), but it's really solid for using nvim.

I've actually been using nvim as my terminal multiplexer instead of using tmux.

Re:Xi: an editor for the next 20 years [video] by __jal on Tuesday January 30, 2018 @04:09PM (#16269046)
iTerm2 with the new renderer is awesome. Even without it on a slow old mac, you can tune it to behave normally. One thing I found in the past was that particular fonts would slow it down a lot - never bothered to hunt down what was going on, but I think the author was/is doing something a little odd there.
Re:Xi: an editor for the next 20 years [video] by evanrelf on Tuesday January 30, 2018 @02:18PM (#16268079)
Have you tried using Alacritty? https://github.com/jwilm/alacritty
Re:Xi: an editor for the next 20 years [video] by postit on Tuesday January 30, 2018 @02:59PM (#16268457)
Have your read my comment? :)
Re:Xi: an editor for the next 20 years [video] by evanrelf on Tuesday January 30, 2018 @04:00PM (#16268977)
Oops :)