Skip to content

Instantly share code, notes, and snippets.

@zeffii
Last active April 15, 2022 08:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeffii/5df38f00e76156a119864110f12d82b7 to your computer and use it in GitHub Desktop.
Save zeffii/5df38f00e76156a119864110f12d82b7 to your computer and use it in GitHub Desktop.
xnew git alias explained `.bashrc` ,located in `C:\user\.bashrc`

i'm pretty lazy so this is what i use

my_alternate_git_func() {
    git checkout -b $1
    git push --set-upstream origin $1
}

alias xnew=my_alternate_git_func

in git shell i can type in xnew somenewbranch and it switches.

grown out to

my_alternate_git_func() {
    git checkout -b $1
    git push --set-upstream origin $1
}

my_alternate_gitmaster() {
    git checkout master
}

my_alternate_pull() {
    git pull
}

my_alternate_push() {
    git push
}

my_alternate_commentcommit() {
    git commit -am "$1"
}

alias xnew=my_alternate_git_func
alias gm=my_alternate_gitmaster
alias pull=my_alternate_pull
alias push=my_alternate_push
alias cm=my_alternate_commentcommit


@zeffii
Copy link
Author

zeffii commented Dec 4, 2020

make_new_empty_template() {
    python C:\\Users\\zeffi\\Desktop\\GITHUB\\start_new_cpp_project.py $1
}

alias cpp=make_new_empty_template

and

import sys
import shutil
import os
from distutils.dir_util import copy_tree



def make_new_project(new_project_name):
    """
    start new empty C++ folder + structure
    """
    if not new_project_name:
        print('no project name suggested')
        return

    template_folder = r"C:\2020\empty_project_template"
    main_dir = os.path.dirname(template_folder)
    destination_folder = os.path.join(main_dir, new_project_name)
    os.mkdir(destination_folder)

    copy_tree(template_folder, destination_folder)
    empty = "empty_project_template"
    empty_project_file = f"{empty}.sublime-project"
    empty_workspace_file = f"{empty}.sublime-workspace"
    new_project_file = f"{new_project_name}.sublime-project"
    new_workspace_file = f"{new_project_name}.sublime-workspace"

    file_path = lambda a: os.path.join(destination_folder, a)
    os.rename(file_path(empty_project_file), file_path(new_project_file))
    os.rename(file_path(empty_workspace_file), file_path(new_workspace_file))



if __name__ == "__main__":
   make_new_project(sys.argv[1])

@zeffii
Copy link
Author

zeffii commented Apr 6, 2022

now github changes master to main it looks like

my_alternate_git_func() {
    git checkout -b $1
    git push --set-upstream origin $1
}

my_alternate_gitmaster() {
    git checkout master
}

my_alternate_gitmain() {
    git checkout main
}


my_alternate_pull() {
    git pull
}

my_alternate_push() {
    git push
}

my_alternate_commentcommit() {
    git commit -am "$1"
}

alias xnew=my_alternate_git_func
alias gm=my_alternate_gitmaster
alias gm2=my_alternate_gitmain
alias pull=my_alternate_pull
alias push=my_alternate_push
alias cm=my_alternate_commentcommit

@zeffii
Copy link
Author

zeffii commented Apr 15, 2022

now with an easy way to make symlinks in windows and git bash

my_alternate_git_func() {
    git checkout -b $1
    git push --set-upstream origin $1
}

my_alternate_gitmaster() {
    git checkout master
}

my_alternate_gitmain() {
    git checkout main
}


my_alternate_pull() {
    git pull
}

my_alternate_push() {
    git push
}

my_alternate_commentcommit() {
    git commit -am "$1"
}

my_mklink() {
	cmd <<< "mklink /D \"C:\Users\zeffi\Desktop\scripts\addons_contrib\\$1\" \"C:\Users\zeffi\Desktop\GITHUB\\$1\""
}

alias xnew=my_alternate_git_func
alias gm=my_alternate_gitmaster
alias gm2=my_alternate_gitmain
alias pull=my_alternate_pull
alias push=my_alternate_push
alias cm=my_alternate_commentcommit
alias lnr=my_mklink

type

lnr <the name of the module>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment