mirror of
https://github.com/m-housh/dotfiles.git
synced 2026-02-14 14:12:41 +00:00
feat: Updates logging paths, to all write to 'logs' directory in the tmp directory.
This commit is contained in:
13
env/.local/scripts/hypr/utils/logs/logs-picker
vendored
13
env/.local/scripts/hypr/utils/logs/logs-picker
vendored
@@ -8,7 +8,8 @@ SCRIPTS=${SCRIPTS:-$HOME/.local/scripts}
|
||||
THIS_FILE=${BASH_SOURCE[0]}
|
||||
LOG_LABEL=$(basename "$THIS_FILE")
|
||||
THIS=${THIS:-$LOG_LABEL}
|
||||
LOG_FILE=${LOG_FILE:-"/tmp/$LOG_LABEL.log"}
|
||||
LOG_DIR=${LOG_DIR:=""}
|
||||
LOG_FILE=${LOG_FILE:-"$LOG_LABEL.log"}
|
||||
FZF_DEFAULT_OPTS=${FZF_DEFAULT_OPTS:-""}
|
||||
|
||||
# Logging utility function, use in place of echo.
|
||||
@@ -34,18 +35,22 @@ EOF
|
||||
source "$SCRIPTS/hypr/logging"
|
||||
setup-logging "$LOG_FILE" "$LOG_LABEL"
|
||||
|
||||
if [[ -z $LOG_DIR ]]; then
|
||||
echo "Log directory not setup properly!" && exit 1
|
||||
fi
|
||||
|
||||
# Setup colors before calling fzf.
|
||||
[[ -z $FZF_DEFAULT_OPTS ]] &&
|
||||
[[ -f $SCRIPTS/catppuccin-colors ]] &&
|
||||
source $SCRIPTS/catppuccin-colors
|
||||
|
||||
sel=$(
|
||||
/bin/ls /tmp/*.log |
|
||||
/bin/ls $LOG_DIR/*.log |
|
||||
sed 's#.*/##; s/\..*$//' | # cleans to only show file name, excluding the path and '.log'
|
||||
fzf --style=full \
|
||||
--footer="$(footer)" \
|
||||
--preview-label='[ Logs ]' \
|
||||
--preview='echo ""; bat /tmp/{}.log' \
|
||||
--preview='echo ""; bat $LOG_DIR/{}.log' \
|
||||
--preview-window="down"
|
||||
)
|
||||
|
||||
@@ -53,4 +58,4 @@ if [[ -z $sel ]]; then
|
||||
log --error "No selection" && exit 1
|
||||
fi
|
||||
|
||||
bat /tmp/$sel.log
|
||||
bat $sel.log
|
||||
|
||||
Reference in New Issue
Block a user