From 7438a8f2c7d3d68ee9f8bf55aad4cbfa5606c325 Mon Sep 17 00:00:00 2001
From: LangLangbart <92653266+LangLangBart@users.noreply.github.com>
Date: Sun, 12 May 2024 14:16:38 +0200
Subject: [PATCH] docs: Update environment variables and history section
---
.pre-commit-config.yaml | 6 ++---
gh-find-code | 21 ++++++++----------
readme.md | 49 ++++++++++++++++++++---------------------
3 files changed, 36 insertions(+), 40 deletions(-)
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index ec055f6..b0b59e8 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -13,12 +13,12 @@ repos:
pass_filenames: false
files: gh-find-code
- repo: https://github.com/pre-commit/pre-commit-hooks
- rev: v4.5.0
+ rev: v4.6.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/crate-ci/typos
- rev: v1.19.0
+ rev: v1.21.0
hooks:
- id: typos
args: [--format, brief, --write-changes]
@@ -59,7 +59,7 @@ repos:
name: markdown link check
args: [--quiet]
- repo: https://github.com/commitizen-tools/commitizen
- rev: v3.20.0
+ rev: v3.25.0
hooks:
- id: commitizen
stages: [commit-msg]
diff --git a/gh-find-code b/gh-find-code
index 5a408fe..8fc7aa3 100755
--- a/gh-find-code
+++ b/gh-find-code
@@ -18,9 +18,6 @@ if ((GHFC_DEBUG_MODE)); then
store_gh_search_debug="${debug_directory}/gh_search_debug"
store_grep_extended_debug="${debug_directory}/grep_extended_debug"
- # Redirect stdout and stderr to both the terminal and the debug file.
- exec &> >(command tee -a "$store_all_debug")
-
# 'GH_DEBUG' is useful for understanding the reasons behind failed GitHub API calls.
export GH_DEBUG=api
@@ -66,8 +63,8 @@ error_handler() {
--language bash \
--line-range $((lineno - 3)):+7 \
--style numbers \
- --terminal-width $((${COLUMNS:-$(tput cols)} - 4)) "${BASH_SOURCE[0]}" \
- --wrap never |
+ --terminal-width $((${COLUMNS:-$(tput cols)} - 4)) \
+ --wrap never -- "${BASH_SOURCE[0]}" |
command sed 's/^/ /;4s/ />>/'
} >&2
exit "$exit_code"
@@ -885,10 +882,10 @@ main() {
trap - ERR
# NOTE: The 'change-preview-window' action in 'transform' should precede 'change-preview'.
- # NOTE: In the transform action, placeholders and functions using placeholders as arguments must be
- # escaped, e.g. '\view_contents \{}', but not 'print_help_text'.
- # TODO: The hotkeys 'ctrl-t' and '?' may cause issues if used during certain operations; a solution
- # is needed to address this complexity.
+ # NOTE: In the transform action, placeholders and functions using placeholders as arguments must
+ # be escaped, e.g. '\view_contents \{}', but not 'print_help_text'.
+ # TODO: The hotkeys 'ctrl-t' and '?' may cause issues if used during certain operations; a
+ # solution is needed to address this complexity.
fzf_basic_style \
--bind "change:first+reload:command sleep 0.5; gh_query" \
--bind "resize:transform:preview_transformer" \
@@ -901,9 +898,9 @@ main() {
--bind 'ctrl-r:reload:gh_user_limit=100 gh_query' \
--bind 'ctrl-space:execute:view_history_commands' \
--bind "ctrl-t:transform:[[ ! \$FZF_PROMPT == \"$fzf_prompt_fuzzyAB\" ]] &&
- echo 'unbind(change)+change-prompt($fzf_prompt_fuzzyAB)+enable-search+transform-query:echo \{fzf:query} > $store_search_string; command cat $store_fuzzy_search_string' ||
- echo 'rebind(change)+change-prompt($default_fzf_prompt)+disable-search+transform-query:echo \{fzf:query} > $store_fuzzy_search_string; command cat $store_search_string'" \
- --bind 'ctrl-x:execute-silent:open_query_in_browser {fzf:query}' \
+ echo 'unbind(change)+change-prompt($fzf_prompt_fuzzyAB)+enable-search+transform-query:echo \{q} > $store_search_string; command cat $store_fuzzy_search_string' ||
+ echo 'rebind(change)+change-prompt($default_fzf_prompt)+disable-search+transform-query:echo \{q} > $store_fuzzy_search_string; command cat $store_search_string'" \
+ --bind 'ctrl-x:execute-silent:open_query_in_browser {q}' \
--bind $'enter:execute:[[ $FZF_MATCH_COUNT -ge 1 ]] && view_contents {}' \
--bind 'esc:become:' \
--bind "tab:change-prompt($default_fzf_prompt)+change-preview(view_contents {})+change-preview-window:hidden:hidden|+{1}+3/3" \
diff --git a/readme.md b/readme.md
index c6f270d..96c11af 100644
--- a/readme.md
+++ b/readme.md
@@ -84,6 +84,26 @@ gh ext remove LangLangBart/gh-find-code
---
+## 🌐 Environment Variables
+
+**Table 1: Environment Variables Utilized**
+
+| Variable | Purpose | Default |
+| ------------------ | -------------------------------------- | ------------------ |
+| `BAT_THEME` | Preview theme for syntax highlighting. | `Monokai Extended` |
+| `EDITOR` | Editor to open selected files. | System-specific |
+| `PAGER` | Pager for file viewing. | System-specific |
+
+**Table 2: Environment Variables Defined and Utilized**
+
+| Variable | Purpose | Default |
+| -------------------- | ----------------------------- | -------------------------------------------- |
+| `GHFC_DEBUG_MODE` | Enable debug mode | `0` (Disabled) |
+| `GHFC_HISTORY_FILE` | Custom location | `${BASH_SOURCE%/*}/gh_find_code_history.txt` |
+| `GHFC_HISTORY_LIMIT` | Max number of stored commands | `500` |
+
+---
+
## 💁 TIPS
### Alias
@@ -98,10 +118,7 @@ alias ghfc='BAT_THEME="Dracula" EDITOR="vim" gh find-code'
```
### Bat
-- The color scheme of the preview is determined by the `BAT_THEME` environment
- variable. If not explicitly set by the user, the theme defaults to `Monokai
- Extended`.
-
+- Set `BAT_THEME` to change the preview color scheme:
```sh
# To view all default themes
bat --list-themes --color=never
@@ -110,15 +127,6 @@ bat --list-themes --color=never
BAT_THEME="Dracula" gh find-code
```
-### Debugging
-- To activate debug mode, set `GHFC_DEBUG_MODE=1`. This enables `xtrace` and
- logs outputs to a file, with the file's location displayed after script
- execution.
-
-```bash
-GHFC_DEBUG_MODE=1 gh find-code
-```
-
### Editor
- The extension uses the `EDITOR` environment variable to determine in which
editor the selected file will be opened, works with `nano`, `nvim/vi/vim`,
@@ -147,21 +155,12 @@ export FZF_DEFAULT_OPTS="
- **NOTE:** [How to use ALT commands in a terminal on macOS?](https://superuser.com/questions/496090/how-to-use-alt-commands-in-a-terminal-on-os-x)
### History
-- Recent commands can be viewed with ⌃ Control + Space.
-- The history file stores successfully completed unique commands, one can
- specify a custom location using the `GHFC_HISTORY_FILE` environment variable.
+- The history file stores successfully completed unique commands.
+- Customize history file location and limit:
-```bash
-# Default location: ${BASH_SOURCE%/*}/gh_find_code_history.txt
+```sh
# Specify a custom location for the history file
GHFC_HISTORY_FILE="/custom/location/history.txt" gh find-code
-```
-
-- In case of duplicates, only the most recent entry is preserved. The default
- maximum number of command entries is **500**, but this can be adjusted by
- setting the `GHFC_HISTORY_LIMIT` variable.
-
-```bash
# Set the maximum number of stored commands to 1000
GHFC_HISTORY_LIMIT="1000" gh find-code
```