Hacker News new | past | comments | ask | show | jobs | submit login
Little known features of iTerm2 (banga.github.io)
329 points by milkbikis on March 2, 2020 | hide | past | favorite | 154 comments

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, try running `tmux -CC` on the server. It'll pop up a new window that looks and feels just like it's running natively (complete with tab support), except it's all tunneled over SSH.

And if you disconnect, you can just reconnect later and your windows will all come back in the same state as when you left them.

I use this one-liner to SSH into a server and reconnect (or start) a tmux session:

    ssh -XY -F user@hostname -Ct \
     'sh -l -c "exec tmux -CC -u new-session -AD -s remote"'
iTerm2's tmux integration makes SSH access to remote machines feel almost as native as using your machine locally. It's really a killer feature, and it made iTerm2 worth a donation for me.

I haven’t really figured out Tmux, and I’m a little ashamed to admit it. I usually reach for screen when needed, and disconnect/reconnect/kill are the only commands of screen I know.

I’ll give the tmux -CC a go when I’m back at my machine, but what else does the integration do? I’m a heavy pane user - does the default split pane in tmux mode use tmux splitting for example?

Yes, splitting panes in iTerm will crate tmux panes on the remote. It's a pretty neat feature.

I mean, it uses it, but it no longer feels like tmux, and you don’t have nice tmux features like zoom-pane, right? iTerm2 is absolutely fantastic and I would miss it if I moved to a linux laptop, but I still haven’t seen the attraction of the tmux integration yet!

Very true that you don't really have access to zoom-pane type features. But they're also not really applicable. The integration is more about giving you a native "tabs and GUI windows" kind of feel, so that you can have multiple terminals open without needing to mess around with panes, tmux windows, etc. And of course, that gets provided in a persistent way (so that you can disconnect and reconnect at will) just like a normal tmux experience.

iTerm2 panes can be zoomed in.

As in maximise to take up the entire window? cmd+shift+enter to toggle, I love this feature.

Even better, it also maintains multiple windows!

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 integration takes away everything I liked about tmux, and makes using tmux feel like using iTerm2 without tmux!

I love tmux just for letting me run long running sessions on remote machines. I don't like tmux's window management, I want to use my terminal, scroll back with mouse, that kind of thing. Tmux integration is therefore for those of us who love their GUI terminal :)

You can always `set -g mouse on` in your `tmux.conf`. But that has the nasty downside of stopping you from being able to right-click and copy text to your OS clipboard. It does let you pane select and scroll with a mouse though.

For someone that doesn't like or understand working with tmux windows and panes, it brings the benefit of running sessions in remote servers, being able to disconnect while still using their GUI.

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?)

> 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)

(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?


> What does Terminal.app give you over iTerm2?

Ease. I've been down many a custom-config-rabbit-hole but these days I find greater pleasure in paths of least resistance. I'll admit, however, that I love my hyper key and BetterTouchTool gestures.

I don't use tmux locally, but I find iTerm2+Tmux invaluable when it comes to managing my servers. for each of them I have an ssh command that automatically opens all the windows and panes for that particular server. It even persists colors I give various panes so I don't accidentally work in the wrong one.

Saves a bunch of time!

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

I really wish some Linux-based terminal emulator would copy this feature.

I'm not too sure if it has this built-in by default, but I've found kitty terminal to be the nearest thing to iterm for Linux. Lots of customizability and it has fairly good docs which is always a plus.

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 <user@host-redacted>: 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.

Remove the `-F` flag right in front of that, works for me after that.

Correction for those playing along at home: remove the -F from above. That was a cut/paste error on my part. Corrected version should be:

    ssh user@hostname -Ct 'sh -l -c "exec tmux -CC -u new-session -AD -s remote"'

More of a normal tmux question, but is there a way to input the window number, or is there a fast way to open up ssh to 4 servers numbered sequentially?

pane 1: ssh <server>-1

pane 2: ssh <server>-2

pane 3: ssh <server>-3

pane 4: ssh <server>-4

When I need to do cluster ssh with tmux I do this or a variant of it:

  function cluster_ssh() { 
    # Start a pane for every server
    for server in $*; do
      tmux split-window ssh $server

    # Same input to all panes
    tmux setw synchronize-panes on;

    # Init pane to background, tile layout
    tmux break-pane -s 0 -d
    tmux select-layout tiled

  bash# cluster_ssh server-{01..10}.example.com

EDIT: made it a bit more complete, but you only need split and sync panes IMHO.

So what exactly is the iTerm feature here? You are just describing regular tmux.

it pulls out windows into terminal tabs (in the UI), and handles panes like they were native iTerm panes (so same keybindings etc). Makes for a native-feeling experience while still getting the benefits of tmux.

So when Volkswagen releases a new car you say "what is new here? You are just describing regular Cugnot's steam wagon?"

iTerm2 will use tmux's scripting mode to give you a "tmux without tmux" kind of experience. Scrollback will work normally, and so will opening new terminal tabs and new windows.

It doesn't give you anything if you're already comfortable with tmux. But if you want your experience to "feel" more native, it's an awesome tool.

great tip thanks for sharing

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 obscure key combinations, which I then have vim interpret and pass along to whatever I want to bind over there. I had no idea the feature existed for years. And sure, I know you're all laughing, why would I even do such a thing... but vim is vim, and we all have our own weird version of it.

iTerm2 is amazing. I've been using it for years daily and it is 100% one of the best, most reliable pieces of software in my toolkit, right next to Alfred.

Show you love for George and contribute to his Patreon[0]. We always love to complain about how to make money with open source on HN. I'd love to see him making a lot more than he does, if for no other reason than we can get more people working full time on the project and provide some redundancy for a critical tool we all love. I wish I could pay for it, but I guess Patreon works.

[0]: https://www.patreon.com/gnachman

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 <D-j> <C-j>
    nmap <D-k> <C-k>
    nmap <D-h> <C-h>
    nmap <D-l> <C-l>
    nmap <C-[> <C-T>
    nmap <D-]> <C-]>
    nmap <D-[> <C-]>
    nmap <D-p> :CtrlP pwd<cr>
    nmap <D-r> :CtrlPBufTag<cr>
    nmap <D-e> :CtrlPMRUFiles<cr>
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 that cmd-p and cmd-l don't get incercepted: "Disable the print key for MacVim" if has("gui_macvim") macmenu &File.Print key=<nop> macmenu &Tools.List\ Errors key=<nop> "macmenu &MacVim.Hide\ MacVim key=<nop> set macligatures endif

If there's any possible way to accomplish the same with iTerm, I'd give it another try!

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 <F6> :w<CR> imap <F6> <Esc>:w<CR>

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.

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.

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:


I think you might want to re-read the commit message :D

Not a vim user but iTerm2 settings have a section for rebinding modifier keys, (plus you also have karabiner-elements)

I don't have karabiner-elements, but doesn't it basically just remap keys across your whole system (much like my mechanical keyboard can)?

I don't want change my cmd-keys into control keys system wide. I just want to be able to map my cmd-keys in vim (which to be honest is the lion's share of what I use any terminal for).

Karabiner-elements is good for mapping single keys to other keys. It doesn’t handle key combinations. (There is something called complex modifiers, but I can’t figure out how to edit them.)

BetterTouchTool is good for mapping key sequences. Further, it can do it selectively based on what application is active.

The complex modifiers are just a json file that’s fairly easy to edit. I have a file that has caps+hjkl to arrow keys. Caps by itself is Esc. caps with anything else is Cmd-shift-option-control+anything else. And finally right shift plus caps toggles caps lock.

Wow. That’s good know. I will poke around. Thank you.

I like KE and have contributed to the dev several times. In typical modest Japanese fashion, contributions are limited to $10 max. Mapping ‘Enter’ to ‘Caps’ and ‘right shift‘ to ‘right command‘ staved off RSI in my right pinky, so I’m happy to send him/her some cash.

https://pqrs.org/osx/karabiner/json.html if you want to know a bit more about them

Is it per program or global? If it's global, it fixes nothing for this specific issue.

BTT can do both. Karabiner Elements is global only.

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.

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.

Yeah - I use this workflow and love it. cmd + esp (with caps lock remapped to escape) to toggle a full screen terminal from any application. Means don't have to cmd + tab and hunt for it, it's always one shortcut away.

Agreed this is the most important feature for me. I use it in the same way.

I just discovered this last night! Such a cool feature.

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...

On imgcat, those extensions to the xterm protocol[0] seem really nice. I've long thought that there needs to be a simple escape sequence for a horizontal divider that doesn't break upon resizing, they should do that next!

Also check out tiv[1] which is an alternative that works with any unicode terminal.

[0]: https://www.iterm2.com/documentation-images.html


These iterm image extensions are almost there. It is unfortunate that it can only display files, and not image created on the fly (i.e., you dump all the pixel values into the terminal and it shows an image).

The actual extension does support images created on the fly. All that's missing is some commandline tool that'll translate from whichever format it's in to the format iterm expects. For e.g. a PNG image data you could probably get away with a single-line bash script: all it has to do is stick an escape sequence in front of the base64 encoded file contents.

that's great! I hope it will be implemented for xterm and becomes a sort of standard. Sometimes I use "sixels" but they are hopelessly slow and low-resolution.

Not much a fan of the base64 encoding here. I'd prefer if it was the pixel binary buffer data that you output directly, pinching a hole in the terminal protocol. The fact taht it is binary does not pose problems if the escape sequence contains the size of the image.

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

imgcat and image displaying is amazing; I use a matplotlib backend that renders plots inline in the terminal, makes remote working much nicer.

Along with imgcat there’s it2dl. Downloads a file from the remote system browser-style. It’s much more convenient than scp, especially when several sessions deep.

  -bash: imgcat: command not found
am I missing something?

GP is talking about the inline images protocol: https://www.iterm2.com/documentation-images.html

You probably need to download and put it in your path.


  $ curl https://www.iterm2.com/utilities/imgcat > /something/on/your/path/imgcat

I've found a lot of use from cmd-shift-e, which shows timestamps for each output line in the terminal. Great for figuring out how long a process ran for.

I've also used this for building outage timelines after the fact by noting the timestamps for my first time to touch and the timestamp of the repair.

Is there a way to make the timestamps permanent? Kinda sucks that they disappear when you close iTerm.

Would having them print directly in the shell prompt work? For bash, I combine PS0 support (in bash >=4.4) and PROMPT_COMMAND to do this.

My prompt command: https://github.com/paxswill/dotfiles/blob/c4c6d50123fc2535e2...

And PS0: https://github.com/paxswill/dotfiles/blob/c4c6d50123fc2535e2...

Basically the prompt command writes the current time stamp on the right edge of the window whenever the prompt is printed. Then PS0 overwrites that time stamp right before a command is executed.

If you want the time stamp on the left you can skip the prompt command and tput usage by using the \t escape code in PS1, but PS0 will need to be modified for the new location while still using tput.

Not natively:


However, you could probably hack together a fix pretty easily with this:


Make it press cmd-shift-e as a Profile command.

didn't know this, amazing :O

I usually have my PS1 show how long the previous command took

The cool thing about iterm's timestamp is that it even applies to SSH and other shells

Hi, author here. What a great way to wake up, an HN love fest :) Check our the Tip of the Day feature, which is meant to help you find stuff like this.

The github trick is pretty cool. I'm running into an issue though where it opens the link but in the wrong repo. Have you ever experienced that?

Any chance of a port to Linux/X (Ubuntu) and especially Windows? I recently needed a terminal emulator that supports Sixel.

Second this. ITerm2 is the only console emulator that I actually enjoy using. I've been flip-flopping on terminals on windows and linux constantly.

It’s a simple matter of funding me for the next 7 years :)

I suspect it's a simple matter of giving you a job where you are forced to use Windows for everything :)

Semantic History is pretty handy and not well-known. It lets you Command+Click on a path to open it in your editor (or associated application).

It also lets you Command+Drag a path to get a usable file-handle to drop into other apps that handle file-related dropzones.

Demo video I made when I added the feature: https://vimeo.com/21872771

Use it with care, though: it's not shy about creating invalid file references when it doesn't know what it's talking about :)

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:


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.

Git diff output (note the initial meaningless "a" or "b"), e.g.

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()

Hey! Glad to see you’re still around. Hope you’re doing well :)

Oh hey! Still kicking about but haven't really done Mac dev for a couple of years. Hope you're doing well too and keep up the great work with iTerm2!

Wow, thanks for creating it!

This feels like a dumb question, but is the text rendering really dark for others in iTerm2? It seems like on a black background I cannot get pure white text. It’s always a middle shade of gray for me - before and after getting a Retina display.

I have messed with the colors and text rendering for literal hours over the last ten years and I genuinely cannot get it as clear and readable as Terminal.app which is a big part of the reason I always end up falling back to Terminal

iTerm -> Preferences -> Profiles tab -> Colors subtab.

You'll see two columns of options. The left column is titled "Basic Colors", the right is titled "ANSI Colors".

Under Basic Colors, click the color next to Foreground, and a color picker appears. Slide it to the lower-left: bright white.

Now it should be fixed. But if it didn't, repeat the same procedure for the White that's at the bottom of the column ANSI Colors.

There's also a setting that controls the thickness of font strokes, independent of color. I forget exactly how it's labeled (not at my Mac right now), but I remember it's a dropdown with combinations of options for using thin strokes on dark backgrounds and/or Retina displays. I believe it defaults to using thin strokes on Retina displays. I believe turning this off will make font rendering identical to Terminal. Either way, I think it looks better turned off, even on a Retina display.

iTerm2 has so many features [1] I don’t think I have enough space here to promote them all.

Please consider setting up recurrent donations to George Nachman [2] to support his work.

[1] https://www.iterm2.com/documentation-one-page.html

[2] https://www.iterm2.com/donate.html

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.


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. So, compiler/linter output, tracebacks, git output, etc.

Currently Emacs, PyCharm and Sublime are supported.

I _love_ this. Thank you.

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

For me, the killer feature is supporting inline plots in a shell, in a terminal-based Emacs session, etc. I have a short section in my latest book on setting it up, which you can read free online: https://leanpub.com/hy-lisp-python/read#leanpub-auto-bonus-p...

I’ve said it before: iterm2 is one of the two reasons I feel so much more productive on mac compared to Windows or Ubuntu

The other one being quicklook (space preview of files)

I installed it on Mac to attempt to come close to using Tilix on Ubuntu but I think I prefer Tilix overall. It comes default with Ubuntu Budgie. Tilix isnt perfect and has its weirdness but its really awesome to use.

Weird thing to say, considering both Windows and Linux-based systems are way more developer-friendly.

(Windows due to VS and the rest of MS resources/docs/tools, Linux due to its package management systems natively supporting just about anything you could ever need for development. For macOS to compete, you need a plethora of best-effort or paid tools that don’t come from Apple).

Also a weird thing to say. VS is on Mac, and not everyone uses VS to develop. Mac also has brew, which is a great package manager that can replace apt and the like.

Sounds like you have a specific use case that requires you to use Windows and are projecting that on every other use case. There is a reason why Macs are used in a lot of development shops.

What's your iTerm2 replacement on Windows? I use Hyper right now but the clear command doesn't even work correctly.

Have you given Windows Terminal a try? It's in the store. https://github.com/microsoft/terminal

iTerm2 is fantastic! It can be a bit CPU hungry but you get a stack of mod cons out of the bargain.

There are tons of proprietary escape codes, not least of all the incredibly useful one for "fireworks"! [1]

[1]: https://iterm2.com/documentation-escape-codes.html

To save people needing to lookup how to use that:

    perl -e 'print "\e]1337;RequestAttention=fireworks\007\n"'


   echo -e "\x1B]1337;RequestAttention=fireworks\007"

I thought I was being fancy when I figured out I could use CMD+shift+c to get vim-style visual selection to yank some terminal output in a pinch.

iTerm2 is going to be the killer app that keeps me on macOS for a long time. Is there anything remotely as good for Linux systems?

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 use the badges functionality to let me know when I was in the production environment vs. say, the development environment. This seems pretty simple but I haven't been able to get it to work.

[0] https://iterm2.com/documentation-badges.html

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.


iTerm2 is what made me finally use Emacs in the terminal, completely replacing vim for me.

You can configure Emacs when running from the terminal to respond to mouse input or to integrate with the system's clipboard. You make it run in server mode, via a Launchd config and you get instant startup times too.

iTerm2 also has built-in powerline glyphs. It was actually easier to configure Emacs's powerline package to work from the terminal than it was to work from the GUI version.

I also like iTerm2's tmux integration.

iTerm2 is one of the reasons why I won't abandon MacOS for my software development needs anytime soon.

Why using Emacs in terminal though? I find it much better to run in gui.

tmux -CC support is my favorite feature of iTerm2. It's amazing.

Can anyone ELI5 on Tmux? I want to know if I’m missing out on an awesome tool by not knowing about it by having heard the name it a lot.

Have you ever needed to run a long-running job over SSH? If your command is still running and SSH disconnects, your command gets terminated. You can work around this by using nohup like this: `nohup <command> &` to launch your program.

Tmux is kind of like nohup, but for the whole shell. If you SSH into a terminal and start tmux, it'll give you a shell that survives disconnect/reconnect.

Tmux can also act sort-of like a tiling window manager for your shells. So you could have a few shells open, and maybe split your screen 50/50 between two shells, or 50/25/25 or something.

It's a pretty useful program if you spend a lot of your day SSHed into external machines (or if you like to work locally in a full-screen terminal window). It's also got some esoteric keybindings and a steep learning curve and it messes around with your mouse, scrollback, and copy-paste.

iTerm2's tmux integration ignores the disconnect/reconnect stuff (although if you reconnect, your session will just "come back" in whatever state it was when you disconnected). The killer feature is that it takes tmux's window-manager functions and maps them onto tabs and windows in the GUI app. This basically makes it look and feel like you're running iTerm from whatever machine you're logged into over SSH, except that what actually happens under the hood is a bunch of tmux magic.

In short, it's a terminal multiplexer (hence the name, tmux) that allows you to run multiple terminals within one (as opposed to opening a new window for each interactive shell you want to use). I spend 90% of my time as a developer either inside tmux or a web browser, so it wouldn't be a stretch to say that I find it quite useful.

The functionality I use the most in tmux is:

- attaching and detaching from a tmux session (e.g., for running machine learning jobs over SSH)

- having multiple terminals open inside of one

- scripting the setup of windows, panes, etc. for different projects I'm working on

I basically use vim and tmux as an IDE: my usual setup consists of one large pane consisting of vim and code, while two other panes are available for running git commands, starting servers, etc. Within one tmux session I separate different projects (e.g., frontend and backend) into tmux windows, and it's very easy to switch between panes, windows and sessions using keyboard shortcuts.

If you didn't miss it until now, it's likely you won't need in much in the future, either. Three main features and their value as I judge them:

* Detach/reattach sessions. This is useful; I run a always connected IRC client on my home machine in a detached session, then reattach to it on the go or from work. Tip: http://enwp.org/Byobu_(software) / http://byobu.co has a vastly better out-of-the-box experience than plain tmux.

* Split screens. I never use it. My GUI terminal emulator software already can do that, but plain tabs or the window manager's features have always been sufficient.

* Connection multiplexing. SSH already does that for me, see `ControlMaster` and `ControlPath` in `man 5 ssh_config`.

Aside from that, I have no idea how to use tmux ;)

Anyone else have any problems getting the first one to work?

I could run /usr/local/bin/hub browse -- commit abc123 without issue, but iTerm wasn't even changing to cursor when hovering over a hash and holding cmd.

Nevermind. Think quitting iTerm was key.

Off/on again.

Question. Do you know how to get iTerm2 to open on split into the same directory that it was in like in Terminator on Ubuntu? Currently it always open to home directory whether I do a vertical/horizontal split.

Go to Preferences->Profiles->Default and find the option over on the right for "Working Directory". Then set it to "Reuse previous session's directory".

Then for me Cmd+D and Cmd+Shift+D (split with current profile) gives the same current directory.

Depending on your workflow, you might even want the advanced configuration version of this.

I want new windows (which I rarely use) and new tabs to be my home directory, but split panes to be the directory I was in when I split. Works wonders.

Like @kevsim mentioned, you have to go advanced options etc, it’s hidden a bit, but it’s there.

I love iTerm!

I've wondered whether it's possible to setup profile-specific (or folder-specific) aliases? I understand it might be zsh feature that I'm really after, but perhaps iTerm can solve it too?

Profile-specific aliases are easy.

In your .zshrc (or .bashrc), just use the value of $ITERM_PROFILE to set (or source a file containing) the aliases you want:

[[ $ITERM_PROFILE == “AWS” ]] && source ~/.aliases.aws

I think you'll have to look into some scripting then; what you could do is create your aliases for each profile in a separate folder, then use the 'Send text at start' profile to just do a `source ~/profiles/1/aliases.sh` or something to that effect.

I'm a little jealous of iTerm, not going to lie. The UX is pretty nice from what I've seen, but I can't find a like for like replacement for either Windows or Linux.

Every time I've considered a full-on switch to Linux, the many little tools that I'd have to give up weigh heavily the cons column.

Which tools would you have to give up?

Some of the most obvious things I'd give up:

- ability to plug into any monitor at any resolution that monitor supports

- ability to copy and paste to/from my phone

- Transmit - I really haven't found many good s3 clients on Linux

- ScreenFlow

- Git Tower

Most of these have some sort of a work-around or close analog of course. (So I'd likely not be "giving anything up" as much as compromising or learning new techniques) However, I'm not sold on the benefits (other than ideological ones, the only thing that comes to mind is increased Docker performance) outweighing the costs. For someone with a different workflow and set of tools, a different conclusion may result.

> ability to plug into any monitor at any resolution that monitor supports

Doesn't xrandr do that?

Problem with xrandr is figuring out how and where to run it automatically.

Pushbullet (Chrome extension) might work for copy/paste to/from your phone.

Check out KDE Connect, it's a great piece of software for copy/paste, remote inputs and more. Will even wake your computers up when you walk in the door :)

Sublime Merge is a pretty good alternative to Git Tower.

Some applications I would miss: 1Password / Preview / Acorn / Evernote / Skitch / Pingplotter / djay

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

To each their own, but yes, personally I find the UX of Mac GUI applications to be generally a lot more appealing compared to the alternatives available on Linux.

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.


You list three proprietary tools.

It used to be that hackers put their efforts into developing/maintaining tools like this as open source software.

Urxvt is a great alternative for Linux!

DomTerm (https://domterm.org) has many similar features (https://domterm.org/Features.html) including programmable link handling (https://domterm.org/Tips.html). It has been tested on Linux, Windows (requires WSL, for now) and MacOS.

Tilix can be a decent alternative.

Looks great! Will install it on my Ubuntu VM, cheers :)

I use cmder on windows. It's pretty good you should check it out.

It is something I miss a great deal when on other OSes

iTerm2 has (had? I stopped using it a while ago) the tendency to drop data from a large paste. No problems with the built-in Terminal.app so I just went back to that.

Cool article, but here I am don't know how to jump between words on iterm2

You can set this up as a shortcut. I forget exactly how I did it, but here's what seems to be a similar guide on macos:


Something that I do:

`set -o vi` and then hit `<ESC>`. You now have vim motion-like controls to navigate on the command line:

- `b` goes back a word.

- `w` goes forward a word.

- `0` goes to the beginning of the line.

- `$` goes to the end of the line.


I put `set -o vi` in my rc file so I have it on by default.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact