26

I'm using VS Code on Mac. I frequently use integrated terminal in VS Code for performing command line operations relevant to my workspace/project [instead of using Terminal or iTerm].

I am able to use autocomplete for basic shell commands via Integrated terminal in VS Code. For example doing cd followed by a Tab automatically suggests possible directory options for me [just like Terminal or iTerm would].

However, this automatic suggestion doesn't work for git commands. For example, doing git br followed by a Tab should complete to git branch but that's not working.

I looked at User Settings in VS Code [by invoking Cmd + Shift + P -> User Settings -> User -> Extensions -> Git I verified my default terminal for Mac is "Terminal". But however, it's not picking Git commands for autocomplete.

What's missing?

Related issue: https://github.com/Microsoft/vscode/issues/17748

Chaitanya Bapat
  • 3,381
  • 6
  • 34
  • 59
  • 1
    For Bash, see https://stackoverflow.com/questions/12399002/how-to-configure-git-bash-command-line-completion – phil294 Jul 13 '21 at 00:40

6 Answers6

9

If you're using zsh shell, there is a good and quick solution for it right in this discussion. Git tab completion not working in zsh on mac

Then in VSCode, choose zsh as your default terminal.

Manu
  • 183
  • 2
  • 11
2

Add this to your .zshrc: autoload -Uz compinit && compinit

eboakyegyau
  • 225
  • 1
  • 13
2

Enter the following commands:

// switch to root folder
cd ~

// check for .bashrc file, it is most likely a hidden file
ls -A -l

// enable git auto-complete by uncommenting the lines that enable it.
// At the time of writing, these are the last 3 lines in the file.
// The lines look like this after uncommenting.

if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
    . /etc/bash_completion
fi

This solved the problem for me. Hope it helps.

Cacious
  • 137
  • 1
  • 14
0

I had same issues with VSCode and Windows 10. The default terminal was set to Powershell. After i installed poshgit https://github.com/dahlbyk/posh-git autocompletion works fine.

0

If you're using zsh, you can configure vscode terminal by default with zsh terminal. Go to preferences -> Settings and click on the top right icon to open the json view. Then add the following settings

"terminal.integrated.shell.osx": "/bin/zsh"

This assumes you already have git autocomplete in your zsh terminal but not within vscode. If you don't have git autocomplete in your terminal, I'd suggest using Oh my zsh which already has nice plugins for git and more.

Peter T.
  • 8,757
  • 3
  • 34
  • 32
0

If you're using MacOS,you could use Fig. I use it myself and it has great autocomplete, in VSCode's integrated terminal as well!

fig.io