Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

iterm

iterm2

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.

like image 639
Aero Wang Avatar asked Sep 12 '25 17:09

Aero Wang


1 Answers

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

like image 55
Peter Olu Avatar answered Sep 15 '25 10:09

Peter Olu