fix(shell): disable init logging by default
This commit is contained in:
parent
2f8f5e340b
commit
e4fcf78b09
1 changed files with 17 additions and 2 deletions
|
|
@ -1,7 +1,22 @@
|
|||
# ---- logging ---------------------------------------------------------------
|
||||
|
||||
log_shell_init() {
|
||||
printf '%s\n' "shell-init: $*" >>/tmp/shell-init.log 2>/dev/null || true
|
||||
# Disabled by default to avoid noisy permission errors in login shells.
|
||||
# Enable with:
|
||||
# export NANUQSAURUS_SHELL_INIT_LOG=1
|
||||
# Optionally override the file path:
|
||||
# export NANUQSAURUS_SHELL_INIT_LOG_FILE="$HOME/.local/state/shell-init.log"
|
||||
[[ -n "${NANUQSAURUS_SHELL_INIT_LOG:-}" ]] || return 0
|
||||
|
||||
local uid="${UID:-}"
|
||||
[[ -n "$uid" ]] || uid="$(id -u 2>/dev/null || echo unknown)"
|
||||
|
||||
local log_file="${NANUQSAURUS_SHELL_INIT_LOG_FILE:-${XDG_STATE_HOME:-$HOME/.local/state}/nanuqsaurus/shell-init-${uid}.log}"
|
||||
local log_dir="${log_file%/*}"
|
||||
|
||||
mkdir -p "$log_dir" 2>/dev/null || return 0
|
||||
# Redirect stderr first so a failing stdout redirection stays silent.
|
||||
printf '%s\n' "shell-init: $*" 2>/dev/null >>"$log_file" || true
|
||||
}
|
||||
|
||||
# ---- helpers ---------------------------------------------------------------
|
||||
|
|
@ -126,4 +141,4 @@ fi
|
|||
|
||||
if have bat; then
|
||||
alias cat='bat --style=plain --pager=never' 2>/dev/null
|
||||
fi
|
||||
fi
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue