From f886614eb60965a24e11b0b35487ffae09d17b05 Mon Sep 17 00:00:00 2001 From: raven42 Date: Fri, 14 Jul 2023 10:09:02 -0500 Subject: [PATCH 1/6] Fix issues with GIT RC initialization --- .bashrc | 24 +++++++++++++++++++----- sbin/git-environment.bash | 3 +-- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/.bashrc b/.bashrc index d0f01f9..675a475 100644 --- a/.bashrc +++ b/.bashrc @@ -42,6 +42,7 @@ export UNIFIED_HISTORY=0 export USE_UNICODE=1 export VISUAL=vim export GITRC_ENVIRONMENT=1 +export GIT_PRIVATE_RC=$HOME/.private/repo_rc.sh # If not an interactive shell, don't proceed any further (ex. SCP commands) # need to do at least basic PATH setup and other common env vars @@ -82,6 +83,7 @@ function initialize_git_repository() { return fi GIT_RC_PATH=$1 + GIT_RC=$2 GIT_TAGS_PATH=$GIT_RC_PATH/tags NERDTREE_BOOKMARKS=$GIT_RC_PATH/NERDTreeBookmarks @@ -101,29 +103,41 @@ function initialize_git_repository() { $SOURCE_ECHO "init git .. [$GIT_REPO:$GIT_RC_PATH]" if [ ! -d $GIT_RC_PATH -a -w $GIT_ROOT ]; then - $ECHO "Creating repo rc directory at $GIT_RC_PATH..." + $ECHO -n "Creating repo rc directory at $GIT_RC_PATH .." mkdir $GIT_RC_PATH + $ECHO " done." fi if [ ! -d $GIT_TAGS_PATH -a -w $GIT_RC_PATH ]; then - $ECHO "Creating ctags output directory at $GIT_TAGS_PATH..." + $ECHO -n "Creating ctags output directory at $GIT_TAGS_PATH .." mkdir $GIT_TAGS_PATH + $ECHO " done." + fi + + # If needed, copy the GIT_RC from the .private location to the GIT_RC path + if [ ! -f ${GIT_RC} -a -w ${GIT_RC_PATH} -a -f ${GIT_PRIVATE_RC} ]; then + $ECHO -n "rc spec not found. Generating defaults at ${GIT_RC} from ${GIT_PRIVATE_RC} .." + cp ${GIT_PRIVATE_RC} ${GIT_RC} + $ECHO " done." fi # Look for REPO specific NERDTree File and if not exists, then generate it if [[ -f $NERDTREE_GEN_SCRIPT && -f $NERDTREE_DEF_BOOKMARKS ]]; then if [[ -f $NERDTREE_BOOKMARKS && $NERDTREE_DEF_BOOKMARKS -nt $NERDTREE_BOOKMARKS ]]; then - $ECHO "NERDTree Bookmarks out of date. Generating new file..." + $ECHO -n "NERDTree Bookmarks out of date. Generating new file .." $NERDTREE_GEN_SCRIPT -q -i $NERDTREE_DEF_BOOKMARKS -o $NERDTREE_BOOKMARKS + $ECHO " done." elif [[ ! -f $NERDTREE_BOOKMARKS ]]; then - $ECHO "Generating NERDTree Bookmarks file..." + $ECHO -n "Generating NERDTree Bookmarks file .." $NERDTREE_GEN_SCRIPT -q -i $NERDTREE_DEF_BOOKMARKS -o $NERDTREE_BOOKMARKS + $ECHO " done." fi fi # Look for TAG files and if none are found, generate new ones if [ ! "$(ls -A $GIT_TAGS_PATH)" ]; then - $ECHO " No TAGFILES found. Generating new tags in the background at $GIT_TAGS_PATH..." + $ECHO -n "No TAGFILES found. Generating new tags in the background at $GIT_TAGS_PATH .." nohup $RETAG_SCRIPT -a --dir $GIT_TAGS_PATH 2>&1 1> $HOME/var/log/retag_$GIT_REPO.log & + $ECHO " done." fi fi fi diff --git a/sbin/git-environment.bash b/sbin/git-environment.bash index 55ee7eb..50e46d2 100644 --- a/sbin/git-environment.bash +++ b/sbin/git-environment.bash @@ -195,10 +195,9 @@ function update_git_environment() { fi update_external_environment + [[ $(type -t initialize_git_repository) == function ]] && initialize_git_repository $GIT_RC_PATH $GIT_ROOT/.rc/rc souce_resouce_files - [[ $(type -t initialize_git_repository) == function ]] && initialize_git_repository $GIT_RC_PATH - _print_git_env "POST" } From 35440d2c9d311f776286d44734ed7a8696b260e2 Mon Sep 17 00:00:00 2001 From: raven42 Date: Fri, 14 Jul 2023 10:12:06 -0500 Subject: [PATCH 2/6] Update initialization message --- .bashrc | 1 + 1 file changed, 1 insertion(+) diff --git a/.bashrc b/.bashrc index 675a475..b0750bf 100644 --- a/.bashrc +++ b/.bashrc @@ -84,6 +84,7 @@ function initialize_git_repository() { fi GIT_RC_PATH=$1 GIT_RC=$2 + $ECHO "Initializing GIT RC environment .. [$GIT_RC_PATH] GIT_TAGS_PATH=$GIT_RC_PATH/tags NERDTREE_BOOKMARKS=$GIT_RC_PATH/NERDTreeBookmarks From d5e1e15ef954dab0c19cf9764bdf6bbb7bb5cee4 Mon Sep 17 00:00:00 2001 From: raven42 Date: Fri, 14 Jul 2023 10:18:45 -0500 Subject: [PATCH 3/6] Fix typo --- .bashrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.bashrc b/.bashrc index b0750bf..b976397 100644 --- a/.bashrc +++ b/.bashrc @@ -84,7 +84,7 @@ function initialize_git_repository() { fi GIT_RC_PATH=$1 GIT_RC=$2 - $ECHO "Initializing GIT RC environment .. [$GIT_RC_PATH] + $ECHO "Initializing GIT RC environment .. [$GIT_RC_PATH]" GIT_TAGS_PATH=$GIT_RC_PATH/tags NERDTREE_BOOKMARKS=$GIT_RC_PATH/NERDTreeBookmarks From 37e3c087c21a3f44693ba067d317d53f2af0cfe4 Mon Sep 17 00:00:00 2001 From: raven42 Date: Fri, 14 Jul 2023 10:33:38 -0500 Subject: [PATCH 4/6] Add vscode-server bin path to $PATH --- .bashrc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.bashrc b/.bashrc index b976397..c11c196 100644 --- a/.bashrc +++ b/.bashrc @@ -60,6 +60,13 @@ fi shopt -s checkwinsize +# vscode: +# This will ensure we have the `code` program in our PATH. This allows opening remote files with `code ` +if [[ -d "$HOME/.vscode-server" ]]; then + code_latest_version=$(ls -tral -1 --ignore=.* ~/.vscode-server/bin | sed -n '2p' | rev | cut -d' ' -f1 | rev) + export PATH=$HOME/.vscode-server/bin/${code_latest_version}bin/remote-cli:$PATH +fi + ############################## # initialize_git_repository() # From 0d7bce7e15c4940da30457cd861fe31b05cd49ae Mon Sep 17 00:00:00 2001 From: raven42 Date: Fri, 14 Jul 2023 11:12:01 -0500 Subject: [PATCH 5/6] Add prompt_command resource file sourcing --- .bashrc | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/.bashrc b/.bashrc index c11c196..1c8be4f 100644 --- a/.bashrc +++ b/.bashrc @@ -267,7 +267,7 @@ function format_prompt() { else TARGET_STRING="" fi - export PS1="${TARGET_STRING}$(git_prompt_format) ${PS_DIR}${PS_SYMB} " + export PS1="${PROMPT_PREFIX}${TARGET_STRING}$(git_prompt_format) ${PS_DIR}${PS_SYMB} " } function format_title() { @@ -283,17 +283,25 @@ function set_prompt() { history -r # read from history file into memory fi - if [ -f $BLD_TARGET_SCRIPT ]; then - # $ECHO "sourcing .. [$BLD_TARGET_SCRIPT]" - . $BLD_TARGET_SCRIPT - else - unset BLD_TARGET + if [ -d $PROMPT_COMMAND_PATH ]; then + for i in ${PROMPT_COMMAND_PATH}/*.sh; do + if [ -r "$i" ]; then + . $i + fi + done + unset i fi format_prompt format_title } +# The PROMPT_COMMAND_PATH directory is used to keep any files that should be +# sourced during the execution of PROMPT_COMAMND. This allows for updating env +# variables on each command if needed, or adjusting the information displayed +# in the prompt. To add a resource script to the prompt command path, just put +# the .sh script in this directory +export PROMPT_COMMAND_PATH=$PRIVATE_RC_PATH/prompt_command export PROMPT_COMMAND=set_prompt source $POST_RC From a68f89ac82f7fe35c4abbc8acbc8a1f7f9db95c7 Mon Sep 17 00:00:00 2001 From: raven42 Date: Fri, 14 Jul 2023 11:24:06 -0500 Subject: [PATCH 6/6] Update bld-target script location for integration with the bin/prompt_command path --- .bashrc | 2 +- sbin/bld-target | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.bashrc b/.bashrc index 1c8be4f..0054152 100644 --- a/.bashrc +++ b/.bashrc @@ -301,7 +301,7 @@ function set_prompt() { # variables on each command if needed, or adjusting the information displayed # in the prompt. To add a resource script to the prompt command path, just put # the .sh script in this directory -export PROMPT_COMMAND_PATH=$PRIVATE_RC_PATH/prompt_command +export PROMPT_COMMAND_PATH=$HOME/bin/prompt_command export PROMPT_COMMAND=set_prompt source $POST_RC diff --git a/sbin/bld-target b/sbin/bld-target index 4f588fe..821383e 100755 --- a/sbin/bld-target +++ b/sbin/bld-target @@ -19,7 +19,10 @@ bld_target= if [[ $GITRC_ENVIRONMENT == 1 && -n "$GIT_ROOT" ]]; then target_rc=${GIT_ROOT}/.rc/bld_target.sh else - target_rc=${HOME}/.private/bld_target.sh + if [[ ! -d $HOME/bin/prompt_command ]]; then + mkdir -p $HOME/bin/prompt_command + fi + target_rc=${HOME}/bin/prompt_command/bld_target.sh fi # Process the command line arguments