Live data from Hacker News

Little known features of iTerm2

banga.github.io

101–110 of 156 posts

Re: Little known features of iTerm2

#102
post #34

Not sure whether or not this is a little-known feature. iTerm2 has _fantastic_ integration with tmux (software used for persisting a terminal session across multiple logins). Tmux can be a pretty complex piece of software, but iTerm can basically wrap it all up into a nice package. You don't need to know anything at all about tmux to use iTerm's tmux integration. If you're SSHed into a server that has tmux installed,…

I have a function that I've aliased `ssh` to that does a similar thing, so my default is to have tmux running on the remote.

It checks if the remote has tmux first though:

    function ssht() {
      /usr/bin/ssh -t "$@" "which tmux 2>&1 > /dev/null && tmux -u -CC new -A -s default"
    }
    alias ssh=ssht

Re: Little known features of iTerm2

#103
post #34

Not sure whether or not this is a little-known feature. iTerm2 has _fantastic_ integration with tmux (software used for persisting a terminal session across multiple logins). Tmux can be a pretty complex piece of software, but iTerm can basically wrap it all up into a nice package. You don't need to know anything at all about tmux to use iTerm's tmux integration. If you're SSHed into a server that has tmux installed,…

great tip thanks for sharing

Re: Little known features of iTerm2

#104

A couple more that I use often: * imgcat: you can view images without leaving your terminal. Somehow this works even across SSH connections… * Python scripting API: basically AppleScript for iTerm except it lets you touch pretty much everything and it's not soul-crushing to write. I have mine switch between themes based on the system appearance (which changes based on the time of day).

> Somehow this works even across SSH connections…

The source code[1] is quite simple to read (as long as you know Bash) but basically imgcat prints a special OSC[2] sequence (some bytes that tell the terminal to do something special) to stdout followed by the image data which iTerm then handles specially because of the OSC sequence, as far as SSH knows they're just some bytes that it needs to send (no different than running normal cat on a text file). You can kind of think of this as the opposite of what bracketed paste[3] does, in bracketed paste the terminal tells the program to treat some data specially but with imgcat the program tells the terminal to treat some data specially.

[1]: https://iterm2.com/utilities/imgcat

[2]: https://en.wikipedia.org/wiki/ANSI_escape_code#Escape_sequen...

[3]: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-B...

Re: Little known features of iTerm2

#105
post #36

I’m surprised to see that the iTerm2 dedicated hotkey window hasn’t been mentioned. It’s essentially a system-wide terminal window that you can open with a hotkey, similar to the old Visor app, and you can configure it as a floating window that appears over other apps' full screen windows. https://www.iterm2.com/documentation-hotkey.html

I always loved that feature -- you can map it to tilde (~) and set it to a full-width, top-docked window to emulate an old Quake-style terminal.

Re: Little known features of iTerm2

#106
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…

Other Vim user here. I was stuck on MacVim as well, but for mouse support. That's until I discovered that `set mouse=a` in Vim and using iTerm instead of the default Terminal essentially gave me the same thing.

Then I went into the tmux rabbit hole, but I never really liked iTerm's integration so I don't use it.

Re: Little known features of iTerm2

#108

A couple more that I use often: * imgcat: you can view images without leaving your terminal. Somehow this works even across SSH connections… * Python scripting API: basically AppleScript for iTerm except it lets you touch pretty much everything and it's not soul-crushing to write. I have mine switch between themes based on the system appearance (which changes based on the time of day).

Mintty/Cygwin has a similar utility[1] for images (I've not tested it over ssh. Should be the same idea though)

[1] https://github.com/mintty/utils/blob/master/showimg

Re: Little known features of iTerm2

#109
post #63

A little plug: iterm2-dwim is a click handler that makes use of the iTerm2 smart selection feature to open files in your editor at the correct line. https://github.com/dandavison/iterm2-dwim From the README: iterm2-dwim is a click handler for iTerm2. The aim is that you command-click on any file path, relative or absolute, and it opens the file in your editor. If there was a line number, your editor goes to that line…

I _love_ this. Thank you.

No problem! Don’t hesitate to get in touch on github if you have questions / issues.

Re: Little known features of iTerm2

#110
post #34

Not sure whether or not this is a little-known feature. iTerm2 has _fantastic_ integration with tmux (software used for persisting a terminal session across multiple logins). Tmux can be a pretty complex piece of software, but iTerm can basically wrap it all up into a nice package. You don't need to know anything at all about tmux to use iTerm's tmux integration. If you're SSHed into a server that has tmux installed,…

after years of seeing tmux fly by, and still not understanding its purpose I thought okay, lets give this one liner a try and see if I really don't need to know about tmux as you wrote. :) why do I get: Can't open user config file : No such file or directory

Sorry about that! Take off the -F.

I grabbed it out of a bigger script that also generates and uses an SSH config file. Looks like I pulled out the actual file from args, but not the -F.

Post reply on HN