From e85469a11bb0152d38b31cfb8667234e0f63a324 Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Wed, 26 Oct 2022 14:13:15 +0300 Subject: [PATCH] Fixes to precommit hook and reformat some zsh files --- .husky/pre-commit | 6 +++--- home/.config/zsh/01-tmux.zsh | 10 +++++----- home/.config/zsh/02-env.zsh | 10 +++++----- home/.config/zsh/08-pacman.zsh | 12 ++++++------ 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/.husky/pre-commit b/.husky/pre-commit index 7bcd182..79df10e 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -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 diff --git a/home/.config/zsh/01-tmux.zsh b/home/.config/zsh/01-tmux.zsh index f909bec..55d3f0c 100644 --- a/home/.config/zsh/01-tmux.zsh +++ b/home/.config/zsh/01-tmux.zsh @@ -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 diff --git a/home/.config/zsh/02-env.zsh b/home/.config/zsh/02-env.zsh index 55c4f7c..fda7c3a 100644 --- a/home/.config/zsh/02-env.zsh +++ b/home/.config/zsh/02-env.zsh @@ -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" @@%} diff --git a/home/.config/zsh/08-pacman.zsh b/home/.config/zsh/08-pacman.zsh index d0e2370..72077ed 100644 --- a/home/.config/zsh/08-pacman.zsh +++ b/home/.config/zsh/08-pacman.zsh @@ -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