Aero Wang
Aero Wang

Reputation: 9227

How to open iTerm from the terminal in Visual Studio Code?

I tried the command iterm . but it says zsh: command not found: iterm.

How can I create a shortcut for iterm so I can open it from other terminal tools?

Pretty much I want open -a iTerm . to be shortern to iterm . but I don't want to use the alias because it seems too hacky.

Upvotes: 2

Views: 1669

Answers (2)

Peter Olu
Peter Olu

Reputation: 65

open the .zshrc file using Vim or Vs Code.

For Vs Code, use code ~/.zshrc

For Vim, use vim ~/.zshrc

inside the opened file, add this function to it probably anywhere before the end of the last line

iterm() {

    open -a iTerm "$*"

}

Refresh the terminal with this command source ~/.zshrc .

Now when you type iterm in your terminal, this will open the iTerm app

Note: the "$*" in the function above represents any argument of string you pass after typing iterm in your terminal.

By default, it points to the current folder VS Code is on, thus you can open iterm in another folder like taking your Desktop for an example.

Type iterm ~/Desktop , this will open the iTerm app and the Desktop folder will be its current working directory

Upvotes: 3

OziOcb
OziOcb

Reputation: 407

For people that want to use alias:

ZSH: alias iterm="open -a iTerm $*"

Upvotes: 2

Related Questions