Fixes to precommit hook and reformat some zsh files

This commit is contained in:
Marko Korhonen 2022-10-26 14:13:15 +03:00
parent 3614b66354
commit e85469a11b
Signed by: FunctionalHacker
GPG Key ID: A7F78BCB859CD890
4 changed files with 19 additions and 19 deletions

View File

@ -17,7 +17,7 @@ if [ "$num_staged_toml" -gt 0 ]; then
printf '\nFormatting %s staged TOML files with taplo\n' "$num_staged_toml"
taplo format "$staged_toml"
printf "Re-staging\n"
git add "$staged_toml"
git add $staged_toml
fi
# Run lua-format on staged Lua files
@ -39,9 +39,9 @@ staged_sh=$(echo "$staged_files" | grep -E '(.sh$|pre-commit)' || true)
num_staged_sh=$(echo "$staged_sh" | grep -vce '^$' || true)
if [ "$num_staged_sh" -gt 0 ]; then
printf '\nFormatting %s staged shell scripts with shfmt\n' "$num_staged_sh"
shfmt -w "$staged_sh"
shfmt -w $staged_sh
printf "Re-staging\n\n"
git add "$staged_sh"
git add $staged_sh
fi
# Run prettier on all other staged files

View File

@ -1,8 +1,8 @@
# Launch tmux if logging in over ssh
if [[ -z "$TMUX" ]] && [[ -n "$SSH_CONNECTION" ]]; then
if tmux has-session -t ssh_tmux 2>/dev/null; then
exec tmux -2 attach-session -t ssh_tmux
else
exec tmux -2 new-session -s ssh_tmux
fi
if tmux has-session -t ssh_tmux 2>/dev/null; then
exec tmux -2 attach-session -t ssh_tmux
else
exec tmux -2 new-session -s ssh_tmux
fi
fi

View File

@ -46,12 +46,12 @@ export FZF_COMPLETION_TRIGGER='**'
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND --strip-cwd-prefix"
export FZF_CTRL_T_OPTS='--preview "bat --color=always --style=numbers --line-range=:500 {}"'
_fzf_compgen_path() {
resultcmd="$FZF_DEFAULT_COMMAND . $1"
eval ${resultcmd}
resultcmd="$FZF_DEFAULT_COMMAND . $1"
eval ${resultcmd}
}
_fzf_compgen_dir() {
resultcmd="$FZF_ALT_C_COMMAND . $1"
eval ${resultcmd}
resultcmd="$FZF_ALT_C_COMMAND . $1"
eval ${resultcmd}
}
# dotfile repository location
@ -72,7 +72,7 @@ export NEOVIDE_MULTIGRID=1
{%@@ if distro_id == "arch" or distro_id == "ubuntu" @@%}
if [ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]; then
export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"
export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"
fi
gpgconf --launch gpg-agent
{%@@ elif distro_id == "termux" @@%}

View File

@ -5,13 +5,13 @@ zshcache_time="$(date +%s%N)"
autoload -Uz add-zsh-hook
rehash_precmd() {
if [[ -e /var/cache/zsh/pacman ]]; then
local paccache_time="$(date -r /var/cache/zsh/pacman +%s%N)"
if ((zshcache_time < paccache_time)); then
rehash
zshcache_time="$paccache_time"
fi
if [[ -e /var/cache/zsh/pacman ]]; then
local paccache_time="$(date -r /var/cache/zsh/pacman +%s%N)"
if ((zshcache_time < paccache_time)); then
rehash
zshcache_time="$paccache_time"
fi
fi
}
add-zsh-hook -Uz precmd rehash_precmd