Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-creating folders in logging path #2 #21

Merged
merged 2 commits into from
Mar 2, 2018
Merged

Auto-creating folders in logging path #2 #21

merged 2 commits into from
Mar 2, 2018

Conversation

selfuryon
Copy link
Contributor

Hello!
I created PR after some discussion on #20. The main changes are the way which variables work. Reduced the ambiguous path and filename with many get_tmux_option. So we don't need get_path like functions anymore

Based on this issue #19

@selfuryon
Copy link
Contributor Author

Hello @bruno- ! Can you review my commit?

logging.tmux Outdated
}

setup_clear_history_key_binding() {
local key="$(get_tmux_option "$clear_history_key_option" "$default_clear_history_key")"
tmux bind-key "$key" run-shell "$CURRENT_DIR/scripts/clear_history.sh"
tmux bind-key "$clear_history_key" run-shell "$CURRENT_DIR/scripts/clear_history.sh"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that all the above functions are just one-liners now, how do you feel about just having them in the main function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a good suggestion! I will make it in the second commit :)

local name_template=$(get_tmux_option "$name_option" "$default_name")
tmux display-message -p "$name_template"
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Big win!

"$CURRENT_DIR/start_logging.sh" "$filename"
display_message "Started logging to $filename"
local file=$(tmux display-message -p "$logging_full_filename")
local path=$(tmux display-message -p "$logging_path")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seing these 2 lines with tmux display-message -p again tripped me, despite getting your clarification in #20.
Chances are anyone else reading the source will be puzzled as well. How about extracting tmux display-message -p to a helper function? The purpose would be just to clarify intention. Example names: expand_value, expand_tmux_formats.. or something more fitting

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think about this part... Maybe you are right and extracting this code to external function will be a good decision

local history_limit="$(tmux display-message -p -F "#{history_limit}")"
tmux capture-pane -J -S "-${history_limit}" -p > "$file"
elif [[ $capture_scope == "Screen capture" ]]; then
local file=$(tmux display-message -p "$screen_capture_full_filename")
local path=$(tmux display-message -p "$screen_capture_path")
mkdir -p "$path"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After your refactoring it seems as this function is unnecessarily doing 2 things: capturing history and doing screen capture.

Would it make things simpler if this one was split into two functions? With that we could get rid of this whole file because the functions would be kept in files where they're used..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree it will be simpler than the current state. I will refactor this part

@bruno-
Copy link
Member

bruno- commented Mar 1, 2018

Good stuff! Thank you for your work on this 👍 I think this is ready to be merged.

I left some comments, but none are deal-breaking. Let me know your thoughts!

@selfuryon
Copy link
Contributor Author

I think I will refactor some part of code based on your comments and after make new PR for it :)

@selfuryon
Copy link
Contributor Author

Hello, @bruno- ! I made the second commit with some optimization. Check it, please!

@bruno- bruno- merged commit f79e5ed into tmux-plugins:master Mar 2, 2018
@bruno-
Copy link
Member

bruno- commented Mar 2, 2018

@selfuryon thank you for the good work and patience!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants