Macos 如何设置.bash_配置文件(如果它还不存在)。我想在Mac中从命令行启动升华

Macos 如何设置.bash_配置文件(如果它还不存在)。我想在Mac中从命令行启动升华,macos,Macos,我想在Mac中使用subl filename从命令行启动升华。它似乎涉及处理.bash\u profile。但我没有找到文件。要采取什么步骤?典型的OS X安装不会为您创建.bash\u配置文件。当您想从命令行运行函数时,这是必须具备的 启动终端 键入cd~/转到主文件夹 键入touch.bash\u profile创建新文件 使用您喜爱的编辑器编辑.bash\u profile(或者您可以键入打开-e.bash\u profile以在文本编辑中打开它) 键入.bash\u profile以重新

我想在Mac中使用
subl filename
从命令行启动升华。它似乎涉及处理
.bash\u profile
。但我没有找到文件。要采取什么步骤?

典型的OS X安装不会为您创建
.bash\u配置文件。当您想从命令行运行函数时,这是必须具备的

  • 启动终端
  • 键入
    cd~/
    转到主文件夹
  • 键入
    touch.bash\u profile
    创建新文件
  • 使用您喜爱的编辑器编辑
    .bash\u profile
    (或者您可以键入
    打开-e.bash\u profile
    以在文本编辑中打开它)
  • 键入
    .bash\u profile
    以重新加载
    .bash\u profile
    并更新您添加的任何函数。请注意两点之间的空格
  • 更新 我在Mac OS Mojave上

    打开
    Terminal.app
    并粘贴下面的行,

    (1) touch .bash_profile
    (2) open -a TextEdit.app .bash_profile
    
    这将在
    TextEdit.app
    中打开一个空白页,从这里您可以
    添加、更新、删除
    代码


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

    只需创建一个新文件-它不是您计算机的默认文件。所有文件都位于您的用户目录下-ex./Users/username

    touch .bash_profile
    ~/.bash_profile
    

    Q1.如何检查我的mac电脑中是否存在
    .bash\u配置文件

    解决方案:如果您使用的是macOS 10.14(Mojave)或更低版本。请打开Terminal.app。运行以下命令检查您的mac中是否存在
    .bash\u配置文件

    if [ -r ~/.bash_profile ];
        then
            echo "Yes, file exists"
        else
            echo "No, file does not exists"
    fi
    
    运行上述命令后,如果您在Terminal.app中打印以下行-“是,文件存在”。这意味着该文件存在于mac中

    if [ -r ~/.bash_profile ];
        then
            echo "Yes, file exists"
        else
            echo "No, file does not exists"
    fi
    
    如果您在Terminal.app中打印了以下行-“否,文件不存在”。这意味着该文件在您的mac中不存在

    if [ -r ~/.bash_profile ];
        then
            echo "Yes, file exists"
        else
            echo "No, file does not exists"
    fi
    
    要在mac中创建
    .bash\u profile
    文件,请运行以下命令

    touch ~/.bash_profile
    
    chmod 700 ~/.bash_profile
    
    要限制对
    .bash\u配置文件的访问,请运行以下命令

    touch ~/.bash_profile
    
    chmod 700 ~/.bash_profile
    
    Q2.我想从Mac中的命令行启动sublime?

    解决方案:要从mac启动升华。您可以创建指向
    subl
    的符号链接。假设您已将升华文本放置在应用程序文件夹中,并且路径中有一个
    ~/bin
    目录,则可以运行以下命令:

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

    有关更多详细信息

    我在莫哈韦,这不起作用。你能更新你的答案吗?它在莫哈韦起作用,你能解释一下哪一步对你不起作用吗?@Vats