How to set .bash_profile, if it does not exist yet. I want to launch sublime from a command line in Mac

后端 未结 4 1389
伪装坚强ぢ
伪装坚强ぢ 2020-12-08 15:24

I want to launch sublime from a command line in Mac, using subl filename. It seems to involve dealing with .bash_profile. But I didn\'t locate the

4条回答
  •  难免孤独
    2020-12-08 15:57

    Q1. How to check if .bash_profile exists or not in my mac?

    Solution: If you're using macOS 10.14 (Mojave) or below. Then open the Terminal.app. Run the following command to check if the .bash_profile exists or not in your mac.

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

    After running the above command if you get the following line - "Yes, file exists" printed in your Terminal.app. That means the file exists in your mac.

    If you get the following line - "No, file does not exist" printed in your Terminal.app. That means the file does not exist in your mac.

    To create a .bash_profile file in your mac. Run the following command,

    touch ~/.bash_profile
    

    To restrict access to the .bash_profile. Run the following command,

    chmod 700 ~/.bash_profile
    

    Q2. I want to launch sublime from a command line in Mac?

    Solution: To launch sublime from mac. You can make a symlink to subl. Assuming you've placed Sublime Text in the Applications folder, and that you have a ~/bin directory in your path, you can run the following command:

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

    For more details visit the official sublime documentation

提交回复
热议问题