@@ -57,22 +57,10 @@ gs_git_show_branch() {
5757PS1=" \e[7m\$ (gs_git_show_branch)\e[m\n$PS1 " # comment out to NOT show git branch!
5858PS1=' \$SHLVL' " :$SHLVL $PS1 " # comment out to NOT show shell level!
5959
60- # See which files have changed since some prior commit named `MY_FIRST_COMMIT`.
61- # Usage:
62- # gs_git_files_changed MY_FIRST_COMMIT~
63- # OR (same thing):
64- # gs_git_files_changed BASE_COMMIT
65- # Known limitations: works only on filenames which have no spaces or special bash chars. To make
66- # it handle these chars, it will require using `git diff --name-only -z`, with some more
67- # fancy bash trickery. See my ans:
68- # https://stackoverflow.com/questions/28109520/how-to-cope-with-spaces-in-file-names-when-iterating-results-from-git-diff-nam/62853776#62853776
69- gs_git_list_files_changed () {
70- files=" $( git diff --name-only " $1 " ) "
71- echo " These are the changed files:"
72- echo " $files "
73- # Now optionally create a new function from this and do something with these files here if you
74- # want!
75- }
60+ # Import this ".git_aliases" file, if it exists.
61+ if [ -f " $SCRIPT_DIRECTORY /.git_aliases" ]; then
62+ . " $SCRIPT_DIRECTORY /.git_aliases"
63+ fi
7664
7765# Find a file built by Bazel and therefor sitting in the "build/bin" dir.
7866alias gs_find_bazel_build_file=' find -L build/bin | grep'
@@ -83,67 +71,6 @@ alias gs_find_bazel_build_file_i='find -L build/bin | grep -i'
8371# See: https://askubuntu.com/questions/1792/how-can-i-suspend-hibernate-from-command-line/1795#1795
8472alias gs_suspend=' systemctl suspend'
8573
86- # ########### TODO: fix this up!
87- # 1. make it stand-alone
88- # 2. make it work as `git branch_hash_bak [optional message]`
89- # - let the optional message just be the remainder of the arguments, so it doesn't require a quote
90- # - however, force it to not contain spaces, so replace spaces with underscores
91- # - add the optional message into the filename itself at the end
92- # ###########
93- # GS: git branch backups: useful to back up git branch hashes before deleting branches, so you can
94- # always have their hashes to go back to to checkout rather than having to dig through your `git
95- # reflog` forever.
96- # - Note that this currently requires that the GIT_BRANCH_HASH_BAK_DIR directory already exists.
97- # - TODO: fail more gracefully: make it check to see if this dir exists & prompt the user for
98- # permission to auto-create it with `mkdir -p ${GIT_BRANCH_HASH_BAK_DIR}` if it does not.
99- #
100- # Syntax: `gs_git_branch_hash_bak [dir]` = back up to a backup file in directory "dir" if a dir is
101- # passed in.
102- GIT_BRANCH_HASH_BAK_DEFAULT_DIR=" ./git_branch_hash_backups"
103- gs_git_branch_hash_bak () {
104- CMD=" gs_git_branch_hash_bak"
105- GIT_BRANCH_HASH_BAK_DIR=" $GIT_BRANCH_HASH_BAK_DEFAULT_DIR "
106- EXIT_SUCCESS=0
107- EXIT_ERROR=1
108-
109- # Help menu
110- if [ " $1 " == " -h" ] || [ " $1 " == " -?" ]; then
111- echo " This is a bash function in \" ~/.bash_aliases\" which backs up git branch"
112- echo " names & short hashes to your local \" ${GIT_BRANCH_HASH_BAK_DEFAULT_DIR} \" (or other"
113- echo " specified) dir."
114- echo " "
115- echo " Usage: $CMD [dir]"
116- echo " Back up branch names and hashes to a backup file in directory \" dir\" ."
117- return $EXIT_SUCCESS
118- fi
119-
120- if [ -n " $1 " ]; then
121- # If an arg is passed in, then use it instead of the default directory!
122- GIT_BRANCH_HASH_BAK_DIR=" $1 "
123- fi
124-
125- DATE=` date +%Y%m%d-%H%Mhrs-%Ssec`
126- BRANCH=" $( gs_git_show_branch) "
127- DIR=$( pwd)
128- REPO=$( basename " $DIR " ) # repository name
129- # Replace any spaces in the repository name with underscores
130- # See: https://stackoverflow.com/questions/19661267/replace-spaces-with-underscores-via-bash/19661428#19661428
131- REPO=" ${REPO// / _} "
132- FILE=" ${GIT_BRANCH_HASH_BAK_DIR} /${REPO} _git_branch_bak--${DATE} .txt"
133-
134- echo " Backing up 'git branch -vv' info to \" $FILE \" ."
135- echo -e " date = \" $DATE \" " > $FILE
136- echo -e " repo (folder) name = \" $REPO \" " >> $FILE
137- echo -e " pwd = \" $DIR \" " >> $FILE
138- echo -e " current branch name = \" $BRANCH \" " >> $FILE
139- echo -e " \n=== \` git branch -vv\` ===\n" >> $FILE
140- git branch -vv >> $FILE
141- echo " Done!"
142- }
143- # Alias to do the git hash backups in a directory one higher so you don't have to add this backup
144- # dir to this git project's .gitignore file
145- alias gs_git_branch_hash_bak_up1=" gs_git_branch_hash_bak \" ../git_branch_hash_backups\" "
146-
14774# ssh into another computer. Override this ssh command by re-defining it in
14875# "~/.bash_aliases_private"! Make the username, domain_name, & options what they should be for you.
14976# Notes:
0 commit comments