1~4:Terminal中输入命令subl打开Sublime Text
5:Sublime Text安装Swift包
6:配置Git的文本编辑为Sublime Text
1.下载Sublime
2.找到Sublime对应的路径
Sublime Text2:ls /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin
Sublime Text3:ls /Applications/Sublime\ Text\.app/Contents/SharedSupport/bin
如果出现No such file or directory就说明路径不对
3.在.bash_profile中添加Sublime的路径
-
$ cd
切换到当前用户的home目录 -
$ ls -a
查看所有文件 -
$ touch .bash_profile
如果home里面没有.bash_profile文件,那么创建一个 -
$ open .bash_-profile
打开.bash_profile文件
然后在文件的末尾添加以下内容,按下cmd + s保存
export PATH=$PATH:/Applications/Sublime\ Text\.app/Contents/SharedSupport/bin
4.重启Terminal,输入subl看是否能打开Sublime Text
$ subl
5.Sublime Text 安装Swift包(高亮+自动补全)
- 打开Sublime Text编辑器
-
shift + cmd + p打开Sublime 的包管理工具,输入install package
install package -
稍等一会就会出现下面这个窗口, 输入Swift,可以安装Swift, Swift AutoCompletion, Swift Completion等等
swift -
然后就可以选择Swift啦
PlainToSwift
6.配置Git的文本编辑为Sublime Text
Downloading necessary files
- Save this file in your home directory with the name
git-completion.bash. - Save this file in your home directory with the name
git-prompt.sh. - Download
bash_profile_coursehere. - If you already have a file in your home directory named
.bash_profile, copy the content frombash_profile_courseand paste it at the bottom of.bash_profile. Otherwise, movebash_profile_courseto your home directory and rename it to.bash_profile. If you use Linux, you may need to name this file.bashrcinstead of.bash_profile. (If you're curious to learn more about how bash prompts work, see this page.)
Make sure you can start your editor from the terminal(参考1~4)
Making Git configurations
Run the following Git configuration commands. The first one will need to be modified if you are using a text editor other than Sublime, or if Sublime is installed in another location for you. See this page for the correct command for a couple of other popular text editors. For any other editor, you'll need to enter the command you use to launch that editor from the terminal.
在Terminal中输入以下3行
git config --global core.editor "subl -n -w"
git config --global push.default upstream
git config --global merge.conflictstyle diff3
或者
git config --global core.editor "'/Applications/Sublime\ Text\.app/Contents/SharedSupport/bin/subl' -n -w"
git config --global push.default upstream
git config --global merge.conflictstyle diff3
(Instead of the first command, you may be able to use the simpler git config --global core.editor "subl -n -w" as shown in the video, but many students have found this does not work for them.)
Restart the terminal
You'll need to close and re-open the terminal before all your changes take effect.
Supporting Materials
参考链接:
https://www.udacity.com/wiki/ud775/sublime
https://classroom.udacity.com/courses/ud775/lessons/2980038599/concepts/33331589510923



