Skip to content

Commit

Permalink
feat(installation): including shebang if creating file
Browse files Browse the repository at this point in the history
  • Loading branch information
olets committed Nov 26, 2024
1 parent ac79e43 commit 3816858
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions git-activity
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,13 @@ __git_activity_install() {
fi

for hook in "${!hook_cmds[@]}"; do
'command' 'touch' "${hooks_dir}/$hook"
'command' 'chmod' +x "${hooks_dir}/$hook"
'builtin' 'echo' "${hook_cmds[$hook]}" >> "${hooks_dir}/$hook"
if [[ -f "${hooks_dir}/$hook" ]]; then
'builtin' 'printf' "%s\\n" "${hook_cmds[$hook]}" >> "${hooks_dir}/$hook"
else
'command' 'touch' "${hooks_dir}/$hook"
'command' 'chmod' +x "${hooks_dir}/$hook"
'builtin' 'printf' "#!/usr/bin/env bash\\n\\n%s\\n" "${hook_cmds[$hook]}" >> "${hooks_dir}/$hook"
fi
done

'builtin' 'printf' "Added hooks in %s\\n" "$hooks_dir"
Expand Down

0 comments on commit 3816858

Please sign in to comment.