diff --git a/scripts/start_logging.sh b/scripts/start_logging.sh index 3841b3c..57c1290 100755 --- a/scripts/start_logging.sh +++ b/scripts/start_logging.sh @@ -2,6 +2,8 @@ # path to log file - global variable FILE="$1" +# LOG FILTER +LOGGING_FILTER="$2" ansifilter_installed() { type ansifilter >/dev/null 2>&1 || return 1 @@ -27,15 +29,34 @@ pipe_pane_sed() { tmux pipe-pane "exec cat - | sed -r 's/$ansi_codes//g' >> $FILE" } +pipe_pane_no_filter() { + tmux pipe-pane "exec cat >> $FILE" +} + start_pipe_pane() { - if ansifilter_installed; then - pipe_pane_ansifilter - elif system_osx; then - # OSX uses sed '-E' flag and a slightly different regex - pipe_pane_sed_osx - else - pipe_pane_sed - fi + case "$LOGGING_FILTER" in + auto) + if ansifilter_installed; then + pipe_pane_ansifilter + elif system_osx; then + # OSX uses sed '-E' flag and a slightly different regex + pipe_pane_sed_osx + else + pipe_pane_sed + fi + ;; + ansifilter) + pipe_pane_ansifilter + ;; + sed_osx) + pipe_pane_sed_osx + ;; + sed) + pipe_pane_sed + ;; + *) + pipe_pane_no_filter + esac } main() { diff --git a/scripts/toggle_logging.sh b/scripts/toggle_logging.sh index e240d8c..0735b58 100755 --- a/scripts/toggle_logging.sh +++ b/scripts/toggle_logging.sh @@ -8,7 +8,7 @@ source "$CURRENT_DIR/shared.sh" start_pipe_pane() { local file=$(expand_tmux_format_path "${logging_full_filename}") - "$CURRENT_DIR/start_logging.sh" "${file}" + "$CURRENT_DIR/start_logging.sh" "${file}" "${logging_filter}" display_message "Started logging to ${logging_full_filename}" } diff --git a/scripts/variables.sh b/scripts/variables.sh old mode 100644 new mode 100755 index a27c24f..fcc90b0 --- a/scripts/variables.sh +++ b/scripts/variables.sh @@ -53,3 +53,7 @@ save_complete_history_filename=$(tmux show-option -gqv "@save-complete-history-f save_complete_history_filename=${save_complete_history_filename:-$default_save_complete_history_filename} save_complete_history_full_filename="${save_complete_history_path}/${save_complete_history_filename}" + +default_logging_filter="auto" +logging_filter=$(tmux show-option -gqv "@logging_filter") +logging_filter=${logging_filter:-$default_logging_filter}