56 comments

[ 4.8 ms ] story [ 117 ms ] thread
Eep, people still use MacOS Terminal? Just get iTerm2, it's vastly better.
Recently discovered the wonders of zsh and oh my zsh. If you’re like me and never tried anything other than bash, you’re missing out.
Fish and oh-my-fish is also great. I like it more than oh-my-zsh because it requires less configuration
brew install bash-completion?
Oh-my-zsh + iterm2 is the best combination out there imho
Both are horribly slow, seriously, try iTerm2 for a week then try Terminal - you'll then notice how much latency iTerm2 adds to basic key presses.

oh-my-zsh is also horribly slow out of box, spend some time manually configuring zsh and observe your terminals open in fractional seconds instead of multiple seconds.

Personally, I haven't found keypress latency to be a particular issue.

I'm familiar enough with the terminal that I generally type by rote, I don't even need to look at the terminal while typing for most common tasks.

My terminals stay open inbetween computer re-boots, so not really a problem? I imagine most dev-types keep terminals open all the time on their local dev machines.
iTerm2 with the new metal renderer (only added to the stable releases recently) is as fast as Terminal. But if you want to see what a truly fast terminal can be, give Kitty a try: https://sw.kovidgoyal.net/kitty/

As for OMZ, yep, it includes a lot of functionality out of the box which makes it a little slow. I personally use prezto because it's quicker. Give that a try.

Kitty is OpenGL based. Apple is deprecating OpenGL in Mojave.
Yeah but it’s still gonna work. I mean they haven’t updated it in ages either.
Deprecated just means all the bugs have been found and you can use it without fear!
I find this religion quite amusing.
You should do, it was a joke.
I switched from iTerm+ohmyzsh to Terminal + fish.

It's basically exactly what I had before except I can't click on links in my terminal.

I've tried fish for a year or two but in the end I went back to zsh. I found that the differences in scripting languages were just not worth it.
My scripts are still bash scripts, I just run them with `bash somescript.sh`.
You can cmd-double click. (I don't use fish, though. But I don't think there's a way for fish to turn it off.)
Neat! It's exactly what I had before then.
Afaik Terminal.app still doesn’t support true color, let alone such things as ligatures.
I don’t know about color (never needed anything fancy that way) but Terminal has supported ligatures for at least the past macOS release or two. I use Fira Code with mine and it works exactly as expected.

iTerm2 is nice but for my usage it does too much. If there were a lite version that cut a lot of the more niche features and focused solely on speed and responsiveness I might consider it.

I use iTerm2 all the term and I can honestly say I've never given a second thought to responsiveness. What are you noticing specifically? Are you typing super fast?
I cannot understand how my colleagues get any command line work done with the default macOS terminal.
To each his own: I find Terminal.app to be one of the best terminal out there, all platforms combined. Speed and latency are awesome, colors are exact. Line marks (both manual and with automatic prompt detection) navigated with cmd+up/down is a godsend. Escape sequences to update tab and window titles with directory and document paths are great too. The only thing I miss is having different settings for alt and meta on the left and right alt keys. The days of Terminal.app being crap (up till Leopard) are long gone since Snow Leopard where it had a major update, and was constantly improved upon on each subsequent release.
What’s wrong with it? I spend most of my day using it.
I can highly recommend Zplug instead of oh-my-zsh, I find it much faster. https://github.com/zplug/zplug

I also like FZF a lot for fast history search: https://github.com/junegunn/fzf

I know this is territory that gets rehashed every time someone says "hey, I like tool X..." but I still get a kick out of browsing these threads to see what tools people are using.

On that front, I've been using ZIM: https://github.com/zimfw/zimfw

I also recently added sandboxd so certain things are not run during shell init (rbenv/pyenv/asdf/etc): https://github.com/benvan/sandboxd

Haven't tried oh-my-zsh, but iterm2 is my favorite terminal.

I have a keybinding set to CTRL+CMD+SPACEBAR for show/hiding item2. This is fairly close to activating the spotlight shortcut (CMD+SPACEBAR)

This makes it easy for me to seamlessly swap between my IDE and 2-3 terminals. Without having to use desktop swapping, etc.

How exactly did you set up that keybinding? Are you using Automator or something like Hammerspoon, etc?
If you want one persistent window to always popup with a hotkey:

Preferences => Profiles => (Choose or make from scratch[1]) => Keys => Configure Hotkey Window

I think that works with the Control-Command-Space binding mentioned above. I use caps lock to toggle my terminal, which required some remapping via Karabiner[2]

[1] I have a profile called "Hotkey Profile" I don't remember if I set this up myself or if iTerm did it for me. I have it configured to appear on whichever monitor my mouse is on when I open it, and to have its window fill the bottom 1/3 or so of my screen

[2] https://pqrs.org/osx/karabiner/

Thanks for this. Never knew that feature existed and now I've got it set up -- it's super convenient.
inputrc has nothing to do with Mac Terminal. It’s the configuration file for GNU readline.
Exactly! The title is inaccurate and misleading. Readline works across all terminal emulators and is supported by a lot of applications, Bash being just one of them.
from a comment from tfa: 'Now if you’re really tired of seventies tech you should try fish.' Really, that's pretty much it.
The problem with fish is that it's not POSIX-compliant, and it doesn't try to be (it's a design non-goal), and it's not backwards-compatible with the literally billions of POSIX-compliant scripts and tools already out there.

It doesn't even support `!!` since the maintainers don't seem to like it[0].

    [0] https://github.com/fish-shell/fish-shell/issues/288
I've been using fish as my daily driver for a few months now, and I don't really miss zsh or bash.

I get the occasional hiccup, but most scripts have a proper shebang line, so they work with fish anyway.

The literally billions of POSIX-compliant scripts and tools already out there will run just fine under fish with a hashbang/shebang (a first line that defines what the file executed should be opened with, e.g. `/usr/bin/env sh`) :) . And it's not as if adding a hashbang was painful, not having one is super bad anyway as it leads to uncertainty of whether the script is bash / sh / etc, and can lead to tricky corner cases.

I was a wary zsh user too, until I moved my zsh aliases to scripts with a proper hashbang, then migration to fish was painless, and the benefits are real: I get all the features I expected from my long-tuned zsh, with none of the maintenance/performance pains.

Actually, even for one-time personal scripts I still default to writing (ba)sh, because 1. habit/competence, 2. shellcheck, 3. what you say: examples and resources are everywhere.

Tangentially, upcoming fish will support POSIX && and || (in addition to maybe-even-weirder `; and` / `; or`), and already does if you build from sources now.

So long as you don't need to "source" any of these POSIX-compliant scripts into your environment... A shebang'd script cannot affect the environment of the parent process
Indeed, thanks for the precision. Never ran into that, though; config.fish is the only thing touching my environment.
Lucky for you. I have really come to love zsh's sh and ksh emulation features for this very reason. I have worked in various work environments where setting up a build environment or a testing environment required sourcing ksh scripts that sourced even more ksh scripts. The majority of the engineers on these teams would "deal with" ksh for this reason but a few of the "geekier" engineers would set up zsh with ksh emulation in order to work in a more usable shell.
A shebang is good practice, but the state of the industry is such that many scripts don't use them (unfortunately).

I'm still of the opinion that fish is little more than a novelty and won't see widespread adoption in the long run.

`bash script.sh` works fine. The source issue mentioned above is more of an issue.
what i have yet to figure out is how i can make the commands that i build work with auto-completion. i have never been able to find a good guide. anyone have a good resource/library (in Go) that can help me with this?
It is actually done with bash or zsh extensions that you'll need to make for that to happen.
My approach is to copy, paste, & tailor the programmable completion for a command that has similar interface to my mine. Can try browsing /usr/local/share/bash-completions/completions or `set` & search for _FOO. Hopefully the special variables like COMPREPLY will be self-explanatory. Also `help compgen`. I'm assuming bash, by the way.
Add an environment variable for `GOBIN`, like this in `~/.bashrc`

export GOBIN=$GOPATH/bin

export PATH=$PATH:$GOBIN

Now, whenever you run `go install filename.go`, you'll automatically be able to run it anywhere on your machine.

Are you familiar with https://github.com/spf13/cobra? It's used by a few heavy hitters (kubernetes's kubectl) and it provides you a bit of help with bash completion: https://github.com/spf13/cobra/blob/master/bash_completions....

I just added bash completion to a few internal tools that work with kafka, basically just autocompleting topics. It was a little harder than I would have liked (who wants to write all that bash), and I had to fix a bug in Cobra, but overall it wasn't that bad.

I'm actually at Gophercon right now, if anyone wants to hack on Cobra at the community day on Thursday to make this easier, shoot me an email (@gmail).

But if you don't do this, you can still use <tab> - and if there are more than one option it'll list the possibilities. With this you just have to tab through all the options to see what is there.
So basically it switches the behaviour to what CMD does on Windows. IMO this is extremely annoying and I wish I could disable it on Windows.

If you have 3 options starting with the same prefix, it's fine, but if there's hundreds (e.g. a directory with a lot of libraries starting with lib<something>), it becomes highly annoying and it's better to just give the list so I can type the next letter

For PowerShell, there is PSReadLine, and that has an option to make completion more bash-like in that it completes common prefixes, then lists all options afterwards.

(Say you have a directory with two subdirectories "fooabc" and "foo123". You are in the directory and you type "cd f" and then hit tab. This will complete to "cd foo", and if you hit tab again, then it will show the two options, and then you have to enter "a" or "1" to disambiguate.)

Yes, I'm very confused -- I don't have to do anything to "turn on" autocomplete, it's already turned on! The things they talk about change the behavior.
If you use '~/.ssh/config' with SSH, add this to your '~/.bash_profile' file to add autocompletion for all your servers:

complete -f -d -W "$(grep '[Hh]ost ' ~/.ssh/config | grep -v '*' | awk '{print $2}')" ssh scp

If you don't use '~/.ssh/config' but have a '~/.ssh/known_hosts' file, add this instead:

complete -f -d -W "$(cut -d',' -f1 ~/.ssh/known_hosts | awk '{print $1}')" ssh scp

Similarly, you can use the 'complete' command in '~/.bash_profile' to tweak everything. Some other ways I use it are:

1. Make 'cd' and 'ls' only autocomplete for directories: complete -d cd ls

2. Make 'foo' autocomplete with 'bar0' and 'bar1': complete -W 'bar0 bar1' foo

If any of you find Oh-My-ZSH bloated and slow and ZPrezto being abandonware then check out ZIM framework that's ZPrezto fork with goal of being maintained, workable and making ZSH great again ;)
What's the terminal boot time like using Zim?

I got omz + zgen down to sub 60ms but I had to trade some functionality to get there.

I tried zplug but my pruned omz worked out slower than zgen.

The bash that comes with macOS is very old due to Apple sticking to GPLv2 I believe. So I did "brew install bash" and switched my login shell from /bin/bash to /usr/local/bin/bash and now I can use new bash things.

Just a thought.