如果它还不存在,如何设置.bash_profile。我想从Mac的命令行启动sublime

时间:2016-08-19 11:08:13

标签: macos

我想使用subl filename从Mac的命令行启动sublime。它似乎涉及处理.bash_profile。但我没有找到该文件。采取什么措施?

4 个答案:

答案 0 :(得分:19)

OS X的典型安装不会为您创建; Define count for number of loops, sum for pi estimate, and num/denom for calculating estimation in series (define count 1.0) (define sum 4.0) (define denomenator 3.0) (define numerator 4.0) ; make-pi gets accuracy needed as input ie (make-pi 0.001 => 3.1410926536210413 (define make-pi (lambda (accuracy) ; determine if next fraction will be + or - based on number of iterations thus far (if (zero? sign count) ; add fraction if odd, subtract otherwise (+ sum (/ numerator denomenator)) (- sum (/ numerator denomenator))) (define (check-accuracy sum) ; use check accuracy with current sum (if (zero? check-accuracy) ;return sum if within needed accuracy sum ; update count and new denom values if not accurate enough ; loop back if sum is not accurate enough (begin (+ count 1) (+ denomenator 2) (make-pi (sum))))))) ; if interation is even return 1 else 0 (define sign (lambda (count) (if (even? count)) 1 0)) ; if pi - sum is within desired accuracy, return 1 else 0 (define check-sum lambda (sum) (define check-accuracy lambda (accuracy) (if ((- 3.14159265358979 sum) < (abs(accuracy)))) 1 0)) 。当您想从命令行运行函数时,这是必须的。

  1. 启动终端
  2. 输入.bash_profile转到您的主文件夹
  3. 输入cd ~/以创建新文件。
  4. 使用您喜欢的编辑器修改touch .bash_profile(或者您只需键入.bash_profile即可在TextEdit中打开它。
  5. 键入open -e .bash_profile以重新加载. .bash_profile并更新您添加的所有功能。注意两个点之间的空间!

答案 1 :(得分:2)

更新 我在Mac OS Mojave上。

打开Terminal.app并粘贴波纹线,

(1) touch .bash_profile
(2) open -a TextEdit.app .bash_profile

这将在TextEdit.app中打开空白页,您可以在此处add,update,delete进行编码。

我希望这会对某人有所帮助。

答案 2 :(得分:1)

仅创建一个新文件-您的计算机没有默认文件。全部在您的用户目录下-例如。 / Users /用户名

touch .bash_profile
~/.bash_profile

答案 3 :(得分:0)

问题1。如何检查我的Mac中是否存在.bash_profile

解决方案:如果您使用的是macOS 10.14(Mojave)或更低版本。然后打开Terminal.app。运行以下命令,检查Mac中是否存在.bash_profile

if [ -r ~/.bash_profile ];
    then
        echo "Yes, file exists"
    else
        echo "No, file does not exists"
fi

运行上述命令后,如果出现以下行-Terminal.app中打印了“ 是,文件存在”。这意味着该文件存在于您的Mac中。

如果出现以下行-Terminal.app中打印了“否,文件不存在”。这意味着该文件在您的Mac中不存在。

要在Mac中创建.bash_profile文件。运行以下命令,

touch ~/.bash_profile

限制访问.bash_profile。运行以下命令,

chmod 700 ~/.bash_profile

第二季度。我想从Mac的命令行启动Sublime吗?

解决方案:要从Mac启动Sublime。您可以建立到subl的符号链接。假设已将 Sublime Text 放置在 Applications 文件夹中,并且路径中有~/bin目录,则可以运行以下命令:

ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" ~/bin/subl

有关更多详细信息,visit the official sublime documentation