Skip to content

Commit

Permalink
Add convenience hash for log dir
Browse files Browse the repository at this point in the history
  • Loading branch information
marlonrichert committed May 21, 2023
1 parent c2e921f commit 4fbd121
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 13 deletions.
27 changes: 25 additions & 2 deletions .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: Bug report
about: Always include minimal, reproducible test case. If I cannot reproduce it, then I cannot fix it!
about: Always include a minimal, reproducible test case. If I cannot reproduce it, then I cannot fix it!
title: ''
labels: 'bug'
assignees: ''
Expand All @@ -15,7 +15,7 @@ Failure to do so can result in your issue being closed.
## Environment
```zsh
typeset -p1 VENDOR OSTYPE SHELL ZSH_ARGZERO ZSH_PATCHLEVEL _autocomplete__funcfiletrace
git -C ~zsh-autocomplete log --oneline -n1
git -C ~autocomplete log --oneline -n1
```

* Operating system: <!-- e.g. macOS, Ubuntu -->
Expand All @@ -38,3 +38,26 @@ env -i HOME=$PWD PATH=$PATH TERM=$TERM ${TERMINFO:+TERMINFO=$TERMINFO} zsh -d
- [ ] I have run the code block above to create a test environment.
- [ ] I have reproduced my problem in this environment in the most minimal way possible.
- [ ] I have copy-pasted my entire test session into the same code block.
- [ ] I have copy-pasted the content of the log files found in the `~autocomplete-log` dir of the above session into
their respective sections below.

<details>
<summary><code>YYYY-MM-DD.log</code> (click to expand)</summary>
<pre>
<!-- Replace this line with the contents of the above log file. -->
</pre>
</details>

<details>
<summary><code>YYYY-MM-DD_async.log</code> (click to expand)</summary>
<pre>
<!-- Replace this line with the contents of the above log file. -->
</pre>
</details>

<details>
<summary><code>YYYY-MM-DD_pty.log</code> (click to expand)</summary>
<pre>
<!-- Replace this line with the contents of the above log file. -->
</pre>
</details>
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ To uninstall, remove `znap source marlonrichert/zsh-autocomplete` from your

To update, do:
```zsh
% git -C ~zsh-autocomplete pull
% git -C ~autocomplete pull
```

To uninstall, simply undo the installation steps above in reverse order:
Expand Down
19 changes: 11 additions & 8 deletions scripts/.autocomplete.__init__
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ if ! [[ -n $basedir && -d $basedir ]]; then
print -u2 -- 'autocomplete: Failed to find plugin dir. Aborting.'
return 66
fi
hash -d zsh-autocomplete=$basedir
typeset -gU FPATH fpath=( ~zsh-autocomplete/functions/completion $fpath[@] )
hash -d autocomplete=$basedir zsh-autocomplete=$basedir
typeset -gU FPATH fpath=( ~autocomplete/functions/completion $fpath[@] )

local -Pa funcs=(
~zsh-autocomplete/functions{,/widget}/.autocomplete.*~*.zwc(N-.:P)
~autocomplete/functions{,/widget}/.autocomplete.*~*.zwc(N-.:P)
)
if ! (( $#funcs )); then
print -u2 -- 'autocomplete: Failed to find function files. Aborting.'
Expand Down Expand Up @@ -93,13 +93,16 @@ for bug in ${logdir} ${logdir:h}; do
done

zf_mkdir -p -- $logdir
hash -d autocomplete-log=$logdir

local -Pa older_than_a_week=( $logdir/*(Nmd+7) )
(( $#older_than_a_week[@] )) &&
zf_rm -f -- $older_than_a_week[@]
local -P date=${(%):-%D{%F}}
typeset -g _autocomplete__log=$logdir/$date.log
typeset -g _autocomplete__log_async=$logdir/$date.async.log
typeset -g _autocomplete__log_pty=$logdir/$date.pty.log

local -P log= date=${(%):-%D{%F}}
for log in '' _async _pty; do
typeset -g _autocomplete__log${log}=${logdir}/${date}${log}.log
done

typeset -g _autocomplete__ps4=$'%D{%T.%.} %e:%N:%I\t%? %(1_,%_ ,)'

Expand All @@ -110,7 +113,7 @@ local -P zsh_cache_dir=${XDG_CACHE_HOME:-$HOME/.cache}/zsh
local -P mod=
for mod in compinit config widget key-binding recent-dirs async; do
if builtin zstyle -T ":autocomplete:$mod" enabled; then
builtin autoload +X -Uz ~zsh-autocomplete/scripts/.autocomplete.$mod
builtin autoload +X -Uz ~autocomplete/scripts/.autocomplete.$mod
{
.autocomplete.$mod "$@"
} always {
Expand Down
4 changes: 2 additions & 2 deletions scripts/.autocomplete.compinit
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ compdef() {
[[ -v ZSH_COMPDUMP && -r $ZSH_COMPDUMP ]] &&
omzdump=( ${(f)"$( < $ZSH_COMPDUMP )"} )

typeset -gU FPATH fpath=( ~zsh-autocomplete/functions/completion $fpath[@] )
typeset -gU FPATH fpath=( ~autocomplete/functions/completion $fpath[@] )
typeset -g \
_comp_dumpfile=${_comp_dumpfile:-${ZSH_COMPDUMP:-${XDG_CACHE_HOME:-$HOME/.cache}/zsh/compdump}}

if [[ -v _comps[-command-] && $_comps[-command-] != _autocomplete.command ]]; then
zf_rm -f $_comp_dumpfile
else
local -Pa compfuncfiles=( ~zsh-autocomplete/functions/completion/_autocomplete.*~*.zwc(N-.) )
local -Pa compfuncfiles=( ~autocomplete/functions/completion/_autocomplete.*~*.zwc(N-.) )

if ! (( $#compfuncfiles )); then
print -u2 -- 'autocomplete: Failed to find completion function files. Aborting.'
Expand Down

0 comments on commit 4fbd121

Please sign in to comment.