Live data from Hacker News

Little known features of iTerm2

banga.github.io

141–150 of 156 posts

Re: Little known features of iTerm2

#141

Earlier quoted context omitted.

Can it extract the correct line number from tracebacks, compiler / linter output etc? I wrote this tool, but I know George Nachman has added some features since I wtote it: https://github.com/dandavison/iterm2-dwim

It should, I originally built it for rspec output but it should work with most common formats that put the line number attached to the path with a colon.

OK, but beyond path:line_column there are other common formats in which paths and line numbers are dumped to the terminal, e.g. stack traces. The original idea behind iterm2-dwim was to house a useful collection of regular expressions for capturing these, outside iTerm2, but maybe it would make sense to extend the functionality inside iTerm2? So far iterm2-dwim only implements a handful that I personally needed:

Compiler/Linter etc output, e.g.

  a/b/c.py:18:1:
Git diff output (note the initial meaningless "a" or "b"), e.g.

  a/a/b/c.py
Python stack trace, e.g.

  /a/b/c.py, line 2, in some_function
Pdb stack trace, e.g.

  /a/b/c.py (336)some_function()

Re: Little known features of iTerm2

#142
post #123

Earlier quoted context omitted.

I use iTerm2 with tmux every day (but I don’t ssh into machines often nowadays) and I feel oppositely — I don’t get the attraction of the tmux integration. But maybe I still haven’t understood it, so please feel free to tell me what I’m missing. For me, the purpose of using tmux on my laptop is session, window, and pane management. (Perhaps my favorite tmux feature is zoom-pane.) So I find that the iTerm2 tmux integr…

Out of curiosity, why do you use iTerm2? As a heavy tmux user, I made the switch back to Terminal recently and never looked back.

- visor mode: I always have a fullscreen terminal one keypress away

- genuine fullscreen mode, not the crazy Apple thing where you try to fullscreen an app and it creates another "workspace" or "desktop" or something and you can no longer switch efficiently between fullscreened and non-fullscreened apps without seeing some sliding animation.

- Powerful keybinding support for simple and sophisticated cases. E.g. I use the "send raw bytes" feature so that I can switch panes in tmux with a single keypress, without needing to explicitly send the tmux prefix key. And all that sort of configuration can be version controlled in JSON (you certainly wouldn't want to get something like that working and then commit it to an app config dialog for safe keeping)

- settings for everything

- "dynamic profiles" You can version control your config as JSON

- configurable click behavior ("smart selection"). See other subthreads in this discussion.

- color themes and convenient color switching

Probably others.

With respect, I believe you're making a mistake. Check out some of the things I mentioned. (What does Terminal.app give you over iTerm2?)

Re: Little known features of iTerm2

#143
post #123

Earlier quoted context omitted.

Out of curiosity, why do you use iTerm2? As a heavy tmux user, I made the switch back to Terminal recently and never looked back.

- visor mode: I always have a fullscreen terminal one keypress away - genuine fullscreen mode, not the crazy Apple thing where you try to fullscreen an app and it creates another "workspace" or "desktop" or something and you can no longer switch efficiently between fullscreened and non-fullscreened apps without seeing some sliding animation. - Powerful keybinding support for simple and sophisticated cases. E.g. I use…

> visor mode: I always have a fullscreen terminal one keypress away

Last time I tried this (which, admittedly was sometime back), I found that this was ugly as heck if one has multiple screens and them set to be above one another-ish (e.g. on laptop with desktop screen(s) offset above) - it turns out that iTerm was just sliding the window in from 'offscreen', which if one has windows as I do, means it appears on an upper window.

It's slick if your screens are in 'acceptable' positions for iTerm - otherwise it's an ugly mess. Which is a shame, because I quite like / want this feature.

(Not that Terminal offers this at all mind)

Re: Little known features of iTerm2

#144
post #123

Earlier quoted context omitted.

Out of curiosity, why do you use iTerm2? As a heavy tmux user, I made the switch back to Terminal recently and never looked back.

- visor mode: I always have a fullscreen terminal one keypress away - genuine fullscreen mode, not the crazy Apple thing where you try to fullscreen an app and it creates another "workspace" or "desktop" or something and you can no longer switch efficiently between fullscreened and non-fullscreened apps without seeing some sliding animation. - Powerful keybinding support for simple and sophisticated cases. E.g. I use…

(Replying to sibling due to HN constraints)

@jimsmart Yes I can believe that might take a bit of tweaking to get right. The author (George Nachman) is very responsive though, so I'm sure he'd appreciate the report. It might be reported/fixed/discussed already?

https://gitlab.com/gnachman/iterm2/issues/8536

Re: Little known features of iTerm2

#145

Earlier quoted context omitted.

https://keepassxc.org/ https://gitlab.gnome.org/GNOME/sushi/tree/master/ , https://en.wikipedia.org/wiki/GNOME_sushi https://krita.org/en/features/highlights/ https://github.com/klaussinani/tusk https://oss.oetiker.ch/smokeping/ , https://oss.oetiker.ch/smokeping-demo/?target=Customers.OP https://www.mixxx.org/features/

While these may do some or all of the apps OP mentioned, the UX of most of them, even from the screenshot seems horrid.

These projects were developed by volunteers and are distributed free of charge. No need to be a jerk. Plus if there's something you don't like you can always pull the code, modify what you need and submit a pull request.

I use Linux everyday and I prefer a slightly off UI once in a while than having to deal with the frustratingly sluggish performance of macOS.

Re: Little known features of iTerm2

#146
post #19

I was one of those vim users that was stuck on MacVim for years because my brain was too wired to hitting "cmd-s" for save and other dedicated app niceties. I mean, sure I can :w or bind it to another key, but there are a couple shared OS-level shortcuts like this I just like to retain. No worry, iTerm2 can capture ANYTHING, and rebind it as needed. This means I have a few remaps like "cmd-s" in iterm2 to map to obsc…

Really? I didn't think iTerm would pass along cmd keys, which is the primary reason I use MacVim instead. For example, I use these kinds of mappings: nmap nmap nmap nmap nmap nmap nmap nmap :CtrlP pwd nmap :CtrlPBufTag nmap :CtrlPMRUFiles This way, when on a Mac I can use cmd in place of ctrl for various commands I use all the time that are less convenient with ctrl. In my .gvimrc, I added the following to make sure…

Sorry for seeing this late. Basically, iTerm allows you to send Escape sequences and even Vim special characters.

Here's a screenshot http://snid.es/d156c6b7deea

In mine, under profiles/keys, I've set ⌘s to [17~

This is essentially F6, which I then bind in vim to

nnoremap :w imap :w

I do this with a lot of ⌘ or otherwise unbindable settings (again, this only effects iterm2). This is how you can get iterm2 to pick up any keybinding and send it to vim as something else.

Re: Little known features of iTerm2

#147
post #69

I love iTerm2 and have been using it for years. Thanks to this post I've even learned a couple of new things that make me love it even more. One thing I've been trying to get working in iTerm2 has been AWS profile badges. iTerm2 has the ability to use text "badges"[0] to give feedback about the current environment. I'm an AWS engineer and tend to switch between environments a lot, so I thought it would be great to us…

How does your shell know which environment you're in? Is it that you ssh into one environment or another one, and you want the badge to show which one you've connected to?

I cut and paste environment variables into the shell to authenticate to different accounts. Originally, I was trying to trigger an event by looking for specific words (ie. AWS_SECRET_ID) but that didn't seem to work reliably.

Re: Little known features of iTerm2

#148
post #146

Earlier quoted context omitted.

Really? I didn't think iTerm would pass along cmd keys, which is the primary reason I use MacVim instead. For example, I use these kinds of mappings: nmap nmap nmap nmap nmap nmap nmap nmap :CtrlP pwd nmap :CtrlPBufTag nmap :CtrlPMRUFiles This way, when on a Mac I can use cmd in place of ctrl for various commands I use all the time that are less convenient with ctrl. In my .gvimrc, I added the following to make sure…

Sorry for seeing this late. Basically, iTerm allows you to send Escape sequences and even Vim special characters. Here's a screenshot http://snid.es/d156c6b7deea In mine, under profiles/keys, I've set ⌘s to [17~ This is essentially F6, which I then bind in vim to nnoremap :w imap :w I do this with a lot of ⌘ or otherwise unbindable settings (again, this only effects iterm2). This is how you can get iterm2 to pick up…

I think this is a bit different than what I wrote above. I just want to send the command key as itself.

It looks like you're changing your .vimrc itself.

How would I get iTerm to just send cmd+p as cmd+p? I tried making a keymapping in that menu with "Key Combination": "cmd+p", "Action": "Do Not Remap Modifiers". Rather than sending it to VIM, it still brings up a print screen dialogue.

Similarly, I can't get cmd+[, cmd+], cmd+h (or j, k, l, etc) to send through to VIM.

With both VS Code and MacVim, that stuff is easily configurable. My failure (thus far) to figure out how to do the same with iTerm is why I don't really use it.

Re: Little known features of iTerm2

#149

Earlier quoted context omitted.

Really? I didn't think iTerm would pass along cmd keys, which is the primary reason I use MacVim instead. For example, I use these kinds of mappings: nmap nmap nmap nmap nmap nmap nmap nmap :CtrlP pwd nmap :CtrlPBufTag nmap :CtrlPMRUFiles This way, when on a Mac I can use cmd in place of ctrl for various commands I use all the time that are less convenient with ctrl. In my .gvimrc, I added the following to make sure…

AFAIK there is no way to tell vim about such a keystroke. If neovim adds something I’ll support it.

Sure there is! This has been in MacVim for many years and in NeoVim for four years and two days:

https://github.com/mgraczyk/neovim/commit/ac2b770c25c234ee3f...

Re: Little known features of iTerm2

#150

Earlier quoted context omitted.

How does your shell know which environment you're in? Is it that you ssh into one environment or another one, and you want the badge to show which one you've connected to?

I cut and paste environment variables into the shell to authenticate to different accounts. Originally, I was trying to trigger an event by looking for specific words (ie. AWS_SECRET_ID) but that didn't seem to work reliably.

If you're switching between envs with cut and paste, maybe you could do likewise with the badge?

   echo -e "\x1B]1337;SetBadgeFormat=$(echo "production" | base64)\007"

   echo -e "\x1B]1337;SetBadgeFormat=$(echo "development" | base64)\007"
Consider giving yourself some bash functions with appropriate names, which set the env vars and switch the badge too. Then instead of pasting each time, you'll just use the function name in the shell.

https://linuxize.com/post/bash-functions/

Post reply on HN