Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can i rename project via bash? #89

Open
neins opened this issue Jul 13, 2019 · 4 comments
Open

Can i rename project via bash? #89

neins opened this issue Jul 13, 2019 · 4 comments

Comments

@neins
Copy link

neins commented Jul 13, 2019

Hello! I use bash script to generate new projects, i clone my template - just a git repository:

function new-gulp() {

    # Copy .git folder of my template to my remote disk
    cp -r ~/WEB/TEMPLATES/HTML\ template\ GULP/.git/ /d/WEB/$1.git

    # Alias 'cd' to my local project dir
    gulpdir

    # Clone to local
    git clone /d/WEB/$1.git
    cd $1

    # Ignore these files
    git update-index --assume-unchanged TEMPLATE.sublime-workspace
    git update-index --assume-unchanged TEMPLATE.sublime-project
    printf '\n*.sublime-*'>>.gitignore

    # Back to remote
    cd  /d/WEB/$1.git
    git init --bare

    # Back to project and initial commit for the project
    gulpdir
    cd $1
    git commit -am "Windows: project added"
    git push

    # Open the project in Sublime Text
    /c/PORTABLE/Sublime\ Text\ 3/sublime_text.exe /c/gulp/gulp-layout/$1 TEMPLATE.sublime-project

    return
    
}

But in this automated chain i have a few "roughness", when sublime text open brand-new TEMPLATE project i have to import and rename project manually, so my question is - can the ProjectManager somehow interact with $1 variable in order to rename project and then automatically add project to sublime? Any ideas to resolve this? I don't know which method ProjectManager uses to rename projects, but long time ago i tried manually rename .sublime-project/.sublime-worspace files and got errors in sublime.

Maybe it will be possible to create a feature like reading external .json file when it appears and name project as it describes in this file?
For example, i just generate ProjectManagerConf.json in root of project folder, which contains:

{
"auto_import": true,
"project_name": "My project"
}
@randy3k
Copy link
Owner

randy3k commented Aug 17, 2019

It is an interesting idea but I think it is out of the scope of Project Manager.

@neins
Copy link
Author

neins commented Sep 25, 2019

It is an interesting idea but I think it is out of the scope of Project Manager.

So, i have found list where ProjectManager store all projects, it is Packages\User\Projects\library.json. I may edit this list without any problem, but other problem is how to rename sublime files properly, maybe you coud tell me what is the right method to rename these files without getting any error?

@randy3k
Copy link
Owner

randy3k commented Sep 25, 2019

I guess you just need to add again the project with the new name and then remove the old project.

@neins
Copy link
Author

neins commented Sep 25, 2019

I guess you just need to add again the project with the new name and then remove the old project.

So, i found out how it works:

  • first it needs to rename TEMPLATE.sublime-project TEMPLATE.sublime-worspace to
    My great project.sublime-project My great project.sublime-worspace

  • second need add full path with My great project.sublime-project into Packages\User\Projects\library.json

  • and most important part, need to edit My great project.sublime-worspace and inside this file just replace "project": "TEMPLATE.sublime-project", to "project": "My great project.sublime-project", - this code line will be almost at end of the file.

Obviously, all actions must be completed before Sublime text will be started. So, i think it is time to write my own script to rename project in shell. When i done with my code i'll show my solution here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants