【问题标题】:How to cd into my local git repo from an AppleScript?如何从 AppleScript cd 进入我的本地 git 存储库?
【发布时间】:2016-08-08 06:53:51
【问题描述】:

我正在使用 OSX Yosemite v10.10.5 运行 Mac。

我想使用 AppleScript 将本地 git 存储库推送到远程。

所以 git 代码是:

贝壳
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/myusername/my-project.git
git push -u origin master

但是为了从终端运行它,首先我需要cd 进入我的本地目录。

cd my-directory

那么我将如何通过 AppleScript 完成所有这些工作?或者脚本编辑器中的 JavaScript 选项也会有所帮助。

【问题讨论】:

  • 将所有内容放入 bash 脚本中,然后从 AppleScript 运行该 bash 脚本?
  • @PaulR:这是个好主意!如果您能提示如何从 AppleScript 运行 bash 脚本,我会很乐意支持并接受您的回答。在这一点上,我只知道如何从 AppleScript 运行单个 shell 命令。
  • 你可以使用do shell script "my_script.sh"。我会写一个答案,但我现在在移动设备上 - 如果你愿意,请随时将其转换为答案,

标签: git macos shell github applescript


【解决方案1】:

使用“git -C dir 命令”形式明确告诉 git 在哪里工作。

【讨论】:

    【解决方案2】:

    来自 cmets 的总结(@PaulR):

    将所有内容放在 bash 脚本中,然后从 AppleScript 运行该 bash 脚本。

    myAppleScript.applescript
    do shell script "my_script.sh"
    

    【讨论】:

      猜你喜欢
      • 2018-06-26
      • 2020-04-27
      • 2023-03-20
      • 2018-04-30
      • 2017-01-23
      • 2011-01-08
      • 1970-01-01
      • 2011-07-28
      • 1970-01-01
      相关资源
      最近更新 更多