12 ms·
How to Enable Autocomplete in Mac Terminal
- stevage 8y agoEep, people still use MacOS Terminal? Just get iTerm2, it's vastly better.
- aiyodev 8y agoRecently 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.
- alx_hghs 8y agoFish and oh-my-fish is also great. I like it more than oh-my-zsh because it requires less configuration
- megido 8y agobrew install bash-completion?
- TimLeland 8y agoThanks I’ll check that out
- hrcxxx 8y agoOh-my-zsh + iterm2 is the best combination out there imho
- AdamGibbins 8y agoBoth 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.
- toomanybeersies 8y agoPersonally, 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.
- taude 8y agoMy 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.
- fredoliveira 8y agoiTerm2 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/ 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.
- nsnick 8y agoKitty is OpenGL based. Apple is deprecating OpenGL in Mojave.
- Synaesthesia 8y agoYeah but it’s still gonna work. I mean they haven’t updated it in ages either.
- jrockway 8y agoDeprecated just means all the bugs have been found and you can use it without fear!
- beschicker 8y agoI find this religion quite amusing.
- toomanybeersies 8y agoI cannot understand how my colleagues get any command line work done with the default macOS terminal.
- lloeki 8y agoTo 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.
- gumby 8y agoWhat’s wrong with it? I spend most of my day using it.
- weeha 8y agoI can highly recommend Zplug instead of oh-my-zsh, I find it much faster. https://github.com/zplug/zplug https://github.com/zplug/zplug I also like FZF a lot for fast history search: https://github.com/junegunn/fzf https://github.com/junegunn/fzf
- tvon 8y agoI 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 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 https://github.com/benvan/sandboxd
- Kagerjay 8y agoHaven'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.
- luckman212 8y agoHow exactly did you set up that keybinding? Are you using Automator or something like Hammerspoon, etc?
- Rebelgecko 8y agoIf 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/ https://pqrs.org/osx/karabiner/
- luckman212 8y agoThanks for this. Never knew that feature existed and now I've got it set up -- it's super convenient.
- massysett 8y agoinputrc has nothing to do with Mac Terminal. It’s the configuration file for GNU readline.
- mrzool 8y agoExactly! 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.
- agiamas 8y agofrom a comment from tfa: 'Now if you’re really tired of seventies tech you should try fish.' Really, that's pretty much it.
- _verandaguy 8y agoThe 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
- eat_veggies 8y agoI'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.
- ronjouch 8y agoThe 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.
- prg318 8y agoSo 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
- nkcmr 8y agowhat 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?
- fouc 8y agoIt is actually done with bash or zsh extensions that you'll need to make for that to happen.
- jorge-fundido 8y agoMy 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.
- TheAndruu 8y agoAdd 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.
- pgwhalen 8y agoAre you familiar with https://github.com/spf13/cobra 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.md 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).
- webdevetc 8y agoBut 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.
- Aaargh20318 8y agoSo 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
- hibbelig 8y agoFor 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.)
- hibbelig 8y agoYes, 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.
- TmpAccToSayThis 8y agoIf 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
- tachion 8y agoIf 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 ;)
- lugg 8y agoWhat'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.
- hibbelig 8y agoThe 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.