Fixes
This commit is contained in:
@@ -402,6 +402,8 @@ else
|
||||
ensure_git_credential_helper 'cache --timeout=43200'
|
||||
fi
|
||||
|
||||
git config --global core.editor "code --wait"
|
||||
|
||||
# 6. Cleanup & Secrets
|
||||
rm -f "$HOME/.zshrc" "$HOME/.zsh_aliases"
|
||||
mkdir -p "$REPO_ROOT/Zsh"
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
git.sh show
|
||||
git.sh editor [code|nvim]
|
||||
EOF
|
||||
}
|
||||
|
||||
set_editor() {
|
||||
local editor_name="${1:-code}"
|
||||
|
||||
case "$editor_name" in
|
||||
code)
|
||||
git config --global core.editor "code --wait"
|
||||
printf 'Set git core.editor to: %s\n' 'code --wait'
|
||||
;;
|
||||
nvim)
|
||||
git config --global core.editor "nvim"
|
||||
printf 'Set git core.editor to: %s\n' 'nvim'
|
||||
;;
|
||||
*)
|
||||
printf 'Unknown editor: %s\n' "$editor_name" >&2
|
||||
usage >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
show_config() {
|
||||
local name email editor
|
||||
local helpers=()
|
||||
local helper
|
||||
|
||||
name="$(git config --global --get user.name || true)"
|
||||
email="$(git config --global --get user.email || true)"
|
||||
editor="$(git config --global --get core.editor || true)"
|
||||
|
||||
while IFS= read -r helper; do
|
||||
[ -n "$helper" ] && helpers+=("$helper")
|
||||
done < <(git config --global --get-all credential.helper || true)
|
||||
|
||||
printf 'Global git config\n'
|
||||
printf ' user.name %s\n' "${name:-<unset>}"
|
||||
printf ' user.email %s\n' "${email:-<unset>}"
|
||||
printf ' core.editor %s\n' "${editor:-<unset>}"
|
||||
|
||||
if [ "${#helpers[@]}" -eq 0 ]; then
|
||||
printf ' credential.helper %s\n' '<unset>'
|
||||
else
|
||||
printf ' credential.helper %s\n' "${helpers[0]}"
|
||||
if [ "${#helpers[@]}" -gt 1 ]; then
|
||||
local index
|
||||
for (( index=1; index<${#helpers[@]}; index++ )); do
|
||||
printf ' %s\n' "${helpers[$index]}"
|
||||
done
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
case "${1:-show}" in
|
||||
show)
|
||||
show_config
|
||||
;;
|
||||
editor)
|
||||
set_editor "${2:-code}"
|
||||
;;
|
||||
*)
|
||||
usage >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
Reference in New Issue
Block a user