zsh: do not commit passwords to history

passwords are identified by their SHA256 hashes
This commit is contained in:
tea 2024-07-12 09:19:03 +02:00
parent 6aac7f16d8
commit a5ab7fcdbd
No known key found for this signature in database

View File

@ -55,6 +55,20 @@ function _my_filter_secrets_zshaddhistory() {
} }
add-zsh-hook zshaddhistory _my_filter_secrets_zshaddhistory add-zsh-hook zshaddhistory _my_filter_secrets_zshaddhistory
# compute hash from line until and excluding first newline
# reject if hash matches
function _my_filter_secrets_hash_zshaddhistory() {
local hash=$(sha256sum <<< ${1%%$'\n'*})
hash=${hash%% *}
case ${hash} in
2e324cea58462bb08bacb6e9bb44b1e972c02ad919d58ed61dd89b01ab480b11)
return 1 ;;
esac
return 0
}
add-zsh-hook zshaddhistory _my_filter_secrets_hash_zshaddhistory
############################## Plugins ######################################### ############################## Plugins #########################################
# https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters.md # https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters.md