5

I currently have iTerm version 3.4.12.

In my old work computer I had a different version that would autocomplete a partial command based on the previous commands I had typed when pressing the up key, for example if at some point I ran:

cd Desktop

And then I went back to the folder where I ran it and tried typing

cd De

Followed by pressing the up key it would autocomplete to cd Desktop

Now I'm on a different computer and pressing the up key simply goes through the history of commands I've ran regardless of the folder I'm in or what I've typed, how can I make it so it autocompletes paritially based on my history instead?

IvanHid
  • 669
  • 7
  • 25
  • Hi, this question is not really about programming so it belongs to SuperUser rather than here. Also it is not related to iTerm itself but shell you run in it (bash, zsh, fish…) as that is what runs commands and does autocompletion. – blami Nov 23 '21 at 15:35

1 Answers1

4

Brief

Hi, actually this is what are you looking for oh-my-zsh. It's a really complete framework for zsh that brings a lot of functionality and the capability to add external plugins.

Installation

  1. Execute the following in your terminal
$ sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
  1. it should updated your ~/.zshrc file with a bunch of stuff including some default useful plugin, you can restart your terminal or resource the configuration file just typing
$ zsh

Plugins

You can find other external plugin like zsh-autosuggestions, this actually brings you an autocomplete feature during the typing phase

like this

To Install this as other plugin you can follow this

  1. Open your .zshrc configuration file inside your terminal
$ vi ~/.zshrc 

Note

if vi does not work try to use nano or vim instead, if you don't have even nano you can just open the file via GUI using any text editor

  1. Inside the configuration file, find the plugin section, and inside the round brackets add zsh-autosuggestions

     # Which plugins would you like to load?
     # Standard plugins can be found in ~/.oh-my-zsh/plugins/*
     # Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
     # Example format: plugins=(rails git textmate ruby lighthouse)
     # Add wisely, as too many plugins slow down shell startup.
     plugins=(
     git
     bundler
     dotenv
     osx
     rake
     zsh-autosuggestions
     last-working-dir
     web-search
     brew
     extract
     history
     sudo
     yarn
     )
     
  2. Restart your terminal and you should be done! For more information you can find the github repo of oh-my-zsh

mikrowdev
  • 131
  • 8