Skip to content

Commit

Permalink
add unload method so that creating aliases from typos doesn't pollute…
Browse files Browse the repository at this point in the history
… the outer scope
  • Loading branch information
jakebman committed Sep 25, 2024
1 parent 06538b1 commit 6b87e2d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
15 changes: 9 additions & 6 deletions completion/available/complete-typo.completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@ function _use_complete_typo {
_log_error "Please enable the typos plugin to use this completion"
return 1
fi
complete -F _complete_typo "${!_BASH_IT_TYPOS[@]}"
complete -F _complete_alias_for_typos "${!_BASH_IT_TYPOS[@]}"
}

function _complete_typo {
(
_typos-load
_complete_alias
)

# Named to be compatible with _complete_alias checking https://github.com/cykerway/complete-alias/blob/7f2555c2fe7a1f248ed2d4301e46c8eebcbbc4e2/complete_alias#L806
function _complete_alias_for_typos {
_typos-load
_complete_alias
local ret=$?
_typos-unload
return $ret
}


Expand Down
4 changes: 4 additions & 0 deletions plugins/available/jake-typos.plugin.bash
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ function _typos-load {
done
}

function _typos-unload {
unalias "${!_BASH_IT_TYPOS[@]}"
}

function typos {
(
unalias -a
Expand Down

0 comments on commit 6b87e2d

Please sign in to comment.