Visual Studio Code Mac OS (苹果电脑) 下命令行 ( shell ) 打开

yufei       5 年 前       1982

我是属于那种 使用命令行 ( shell ) 打开项目的人,也一直不习惯先打开 Visual Studio Code 然后再把文件夹拖进去。

所以,能够再命令行 ( shell ) 打开 Visual Studio Code 则成了一种需求,刚性需求。

好在 Visual Studio Code 的文档够齐全,相关的设置都给了说明,Visual Studio Code on macOS

参考文档中的 Launching from the command line 章节,有两种方式设置 shell

  1. 在 VS Code 中设置

    1. 打开 Visual Studio Code

    2. 打开 命令行面板 (快捷键 ⇧⌘P ),然后输入 shell command 找到 Shell 命令 Install 'code' command in PATH command

    3. 选中 Install 'code' command in PATH command 后按下 回车键

    4. 关闭 VS Code

    5. 然后我们就可以在任意目录中输入 code . 来打开当前目录了

  2. 修改 ~/.bash_profile 文件

    第二种方法就是直接修改 shell 启动的配置脚本,比如 bash~/.bash_profile 或者 zsh~/.zshrc 文件

    方法很简单,打开相应的配置文件,然后在末尾追加以下代码

    export PATH="\$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
    

    然后重开一个 shell ,你就能发现可以使用 code . 来打开任意目录了

目前尚无回复
简单教程 = 简单教程,简单编程
简单教程 是一个关于技术和学习的地方
现在注册
已注册用户请 登入
关于   |   FAQ   |   我们的愿景   |   广告投放   |  博客

  简单教程,简单编程 - IT 入门首选站

Copyright © 2013-2022 简单教程 twle.cn All Rights Reserved.