8f5e5233fb781c1442960f4ed50fea1a78cde147

Author
Jake Stanley <madstanners@users.noreply.github.com>
Committer
Robby Russell <robby@planetargon.com>
Date

Message

added stn create_project function for stubbing sublime-project files (#6515)

Diff

This diff is truncated to protect this page.

 1diff --git a/plugins/sublime/README.md b/plugins/sublime/README.md
 2index 7b02d8428efec81f02775cf042365a2cd8d93d25..5379891ad0dfa8302760456f80299a579cb88b4e 100644
 3--- a/plugins/sublime/README.md
 4+++ b/plugins/sublime/README.md
 5@@ -19,3 +19,7 @@ Plugin for Sublime Text, a cross platform text and code editor, available for Li
 6  * If `sst` command is called, it is like `sudo st`, opening the file or folder in Sublime Text. Useful for editing system protected files.
 7 
 8diff --git a/plugins/sublime/sublime.plugin.zsh b/plugins/sublime/sublime.plugin.zsh
 9index f84b7032af775d08437f45f994cde5c7f169d441..22cf98227c7630d51c123d19c109e9057145522a 100644
10--- a/plugins/sublime/sublime.plugin.zsh
11+++ b/plugins/sublime/sublime.plugin.zsh
12@@ -84,4 +84,35 @@ find_project()
13     st $FINAL_DEST
14 }
15 
16+function create_project() {
17+
18+    local _target=$1
19+
20+    if [[ "${_target}" == "" ]]; then
21+        _target=$(pwd);
22+    elif [[ ! -d ${_target} ]]; then
23+        echo "${_target} is not a valid directory"
24+        return 1
25+    fi
26+
27+    local _sublime_project_file=$_target/$(basename $_target).sublime-project
28+
29+    if [[ ! -f $_sublime_project_file ]]; then
30+        
31+        touch $_sublime_project_file
32+
33+        echo -e "{"                         >> $_sublime_project_file
34+        echo -e "\t\"folders\":"            >> $_sublime_project_file
35+        echo -e "\t\t[{"                    >> $_sublime_project_file
36+        echo -e "\t\t\t\"path\": \".\","    >> $_sublime_project_file
37+        echo -e "\t\t\t\"file_exclude_patterns\": []" >> $_sublime_project_file
38+        echo -e "\t\t}]"                    >> $_sublime_project_file
39+        echo -e "}"                         >> $_sublime_project_file
40+
41+        echo -e "New Sublime Text project created:\n\t${_sublime_project_file}"
42+
43+    fi
44+}
45+
46 alias stp=find_project
47+alias stn=create_project