Skip to content

Commit

Permalink
fix: enhance PS4 prompt for millisecond precision
Browse files Browse the repository at this point in the history
  • Loading branch information
LangLangBart committed May 16, 2024
1 parent f2731ed commit 8872abd
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions gh-find-code
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ if ((GHFC_DEBUG_MODE)); then
exec 6>>"$store_all_debug"
BASH_XTRACEFD=6
# Use a more detailed execution trace prompt.
PS4='+ $(date +%Y-%m-%d:%H:%M:%S) [${BASH_SOURCE[0]:+${BASH_SOURCE[0]##*/}}:${FUNCNAME[0]:+${FUNCNAME[0]}():}${LINENO}]: '
# Check if the date command supports milliseconds; macOS native 'date' doesn't support '%3N'
PS4='+ $(date +%H:%M:%S:%3N) [${BASH_SOURCE[0]:+${BASH_SOURCE[0]##*/}}:${FUNCNAME[0]:+${FUNCNAME[0]}():}${LINENO}]: '
# Fall back to zsh for displaying milliseconds with prompt sequences
if command -v zsh &>/dev/null && [[ "$(date +%3N 2>/dev/null)" == "3N" ]]; then
PS4='+ $(zsh -c "print -Pr -- %D{%T:%3.}") [${BASH_SOURCE[0]:+${BASH_SOURCE[0]##*/}}:${FUNCNAME[0]:+${FUNCNAME[0]}():}${LINENO}]: '
fi
set -o xtrace

# Ensure xtrace is enabled in all child processes started by 'fzf'; 'errexit' is too strict
Expand Down Expand Up @@ -637,7 +642,7 @@ gh_query() {
# for now, I'm opting to use grep.
done < <(command grep --color=never --line-number --text \
--extended-regexp --regexp="$sanitized_patterns" -- \
"${store_file_contents}_${index}_fetched" 2>"${redirect_location}" | cut -d: -f1)
"${store_file_contents}_${index}_fetched" 2>"${redirect_location}" | command cut -d: -f1)
# Save additional information only if an error is encountered by grep
if ((GHFC_DEBUG_MODE)) && [[ -s ${store_grep_extended_debug}_${index} ]]; then
{
Expand Down

0 comments on commit 8872abd

Please sign in to comment.