From 7b47b8ca489b09edc36bac8056201917a832fac8 Mon Sep 17 00:00:00 2001 From: Alan Li <61896187+lebr0nli@users.noreply.github.com> Date: Wed, 29 Nov 2023 09:28:15 +0800 Subject: [PATCH] Enhance install script to avoid conflict when pulling new version (#26) * Move example configs to example/ to avoid conflict when pulling * Update README.md * Update example/gdbinit-gep --- .gitignore | 6 +++++- README.md | 2 ++ gdbinit-gep => example/gdbinit-gep | 2 +- geprc.py => example/geprc.py | 0 install.sh | 11 +++-------- lint.sh | 2 +- 6 files changed, 12 insertions(+), 11 deletions(-) rename gdbinit-gep => example/gdbinit-gep (82%) rename geprc.py => example/geprc.py (100%) diff --git a/.gitignore b/.gitignore index 7dce18c..03038ef 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ __pycache__/* .venv/* -.gdb_history \ No newline at end of file +.gdb_history +gdbinit-gep +geprc.py +!example/gdbinit-gep +!example/geprc.py \ No newline at end of file diff --git a/README.md b/README.md index 1ca3ebb..313bbeb 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,8 @@ You can modify the configuration for history, auto-completion, and other GEP con You can also add your custom key bindings by modifying `/path/to/GEP/geprc.py`. +> The `example` subdirectory houses samples and default configurations. + ## The trade-offs Since GDB doesn't have a good Python API to fully control and emulate its prompt, this plug-in has some side diff --git a/gdbinit-gep b/example/gdbinit-gep similarity index 82% rename from gdbinit-gep rename to example/gdbinit-gep index 4a667a5..6b76ee8 100644 --- a/gdbinit-gep +++ b/example/gdbinit-gep @@ -11,6 +11,6 @@ set history remove-duplicates unlimited # Note: Set it to unlimited is not a good idea for large projects # set max-completions unlimited -# Set whether to use single column for tab completion +# Set whether to use single column for tab completion (when fzf is not available) # defulat: on # set single-column-tab-complete off diff --git a/geprc.py b/example/geprc.py similarity index 100% rename from geprc.py rename to example/geprc.py diff --git a/install.sh b/install.sh index 82cbb2e..beb5c6c 100755 --- a/install.sh +++ b/install.sh @@ -31,16 +31,11 @@ PYTHON=$VENV_PATH/bin/python "$PYTHON" -m pip install -U pip "$VENV_PATH/bin/pip" install --no-cache-dir -U prompt_toolkit -if [ -f ~/.gdbinit ]; then - # backup gdbinit if exists - cp ~/.gdbinit ~/.gdbinit.old -else - # create gdbinit if not exists - touch ~/.gdbinit -fi +# copy example config to INSTALL_PATH if not exists +cp -n "$INSTALL_PATH"/example/* "$INSTALL_PATH" # append gep to gdbinit -if ! grep -q gep ~/.gdbinit; then +if ! grep -q '^[^#]*source.*/gdbinit-gep.py' ~/.gdbinit; then printf '\nsource%s\n' "$GDBINIT_GEP_PY" >> ~/.gdbinit fi diff --git a/lint.sh b/lint.sh index 93b3185..09483f7 100755 --- a/lint.sh +++ b/lint.sh @@ -31,7 +31,7 @@ set -o xtrace LINT_PYTHON_FILES=( "gdbinit-gep.py" - "geprc.py" + "example/geprc.py" ) LINT_SHELL_FILES=( "install.sh"