073ea01ccec5dc70bb2e998372d69d893509f2d0
- Author
- Peter Han <han.peter.621@gmail.com>
- Committer
- Robby Russell <robby@planetargon.com>
- Date
Message
Diff
This diff is truncated to protect this page.
1diff --git a/plugins/sublime/README.md b/plugins/sublime/README.md
2index e1e666f05413c483d80959ea7fa208f8577a4793..7b02d8428efec81f02775cf042365a2cd8d93d25 100644
3--- a/plugins/sublime/README.md
4+++ b/plugins/sublime/README.md
5@@ -15,5 +15,7 @@ Plugin for Sublime Text, a cross platform text and code editor, available for Li
6 * If `st` is passed a file, open it in Sublime Text
7
8 * If `stt` command is called, it is equivalent to `st .`, opening the current folder in Sublime Text
9-
10- * If `sst` command is called, it is like `sudo st`, opening the file or folder in Sublime Text. Useful for editing system protected files.
11+
12+ * If `sst` command is called, it is like `sudo st`, opening the file or folder in Sublime Text. Useful for editing system protected files.
13+
14diff --git a/plugins/sublime/sublime.plugin.zsh b/plugins/sublime/sublime.plugin.zsh
15index a5d63cde6cffe77a95086f2ecebe8648fd3a2ade..75a39eab137cd7154df92979611bb05e5c6dcef1 100644
16--- a/plugins/sublime/sublime.plugin.zsh
17+++ b/plugins/sublime/sublime.plugin.zsh
18@@ -56,3 +56,32 @@ elif [[ "$OSTYPE" = 'cygwin' ]]; then
19 fi
20
21 alias stt='st .'
22+
23+find_project()
24+{
25+ local PROJECT_ROOT="${PWD}"
26+ local FINAL_DEST="."
27+
28+ while [[ $PROJECT_ROOT != "/" && ! -d "$PROJECT_ROOT/.git" ]]; do
29+ PROJECT_ROOT=$(dirname $PROJECT_ROOT)
30+ done
31+
32+ if [[ $PROJECT_ROOT != "/" ]]; then
33+ local PROJECT_NAME="${PROJECT_ROOT##*/}"
34+
35+ local SUBL_DIR=$PROJECT_ROOT
36+ while [[ $SUBL_DIR != "/" && ! -f "$SUBL_DIR/$PROJECT_NAME.sublime-project" ]]; do
37+ SUBL_DIR=$(dirname $SUBL_DIR)
38+ done
39+
40+ if [[ $SUBL_DIR != "/" ]]; then
41+ FINAL_DEST="$SUBL_DIR/$PROJECT_NAME.sublime-project"
42+ else
43+ FINAL_DEST=$PROJECT_ROOT
44+ fi
45+ fi
46+
47+ st $FINAL_DEST
48+}
49+
50+alias stp=find_project