- Notifications
You must be signed in to change notification settings - Fork 73
add cached eval #56
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
add cached eval #56
Conversation
| Sorry, I have very few times to work on my open source projects. I'll try to review your work tomorrow. |
ctjhoa left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 comment.
It looks good to me otherwise
may fix cygwin/osx
| local key="$1" | ||
| local val="${@:2}" | ||
| local tmpdir="$(get_tmp_dir)" | ||
| [ ! -d "$tmpdir" ] && mkdir -p "$tmpdir" && chmod 0700 "$tmpdir" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chmod 0700 is not wanted on global system tmp directory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's never global. get_tmp_dir always returns an EUID-specific subdir.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one of the main reasons I looked at tmux-copycat's implementation for reference is because they would've fixed any problems with it by now if it was wrong.
| } | ||
| | ||
| get_tmp_dir() { | ||
| local tmpdir="${TMPDIR:-${TMP:-${TEMP:-/tmp}}}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From man tmux
tmux stores the server socket in a directory under TMUX_TMPDIR or /tmp if it is unset.
So either TMUX_TMPDIR or /tmp should exist
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe that's why tmux-copycat does that if inside tmux env TMUX_TMPDIR turn into TMPDIR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the back and forth
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe; though I don't really see much point in reverting - surely checking TMP & TEMP is fine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm ok with both solution
Attempts to cache runs of underlying commands so that e.g.
#{gpu_bg_color}#{gpu_percentage}only callsnvidia-smionce per update.Notes:
date +%sandbasename command, ignoring command arguments. This could be a problem if running the same command with different arguments (not currently a problem)details
While testing this, I think I've found an upstream problem (with
tmuxortpm). Basicallywill ignore
status-intervaland result in one update per second (!) which appears to be #15.status-intervalnot respected) looks like an upstream bugset -g status-right #(write_hello_to_debug_file) #(write_bye_to_debug_file)won't guaranteehellois written beforebye. This means that caching within an update may not work. Needs investigating... it's possible that some higher level code (outside this repo) handles caching of#(external commands)status-interval. This seems to fix (maybe) status-interval not respected #15 but no there's not clear reason why... I suspect some higher level logic may be doing something like:debugging
in
~/.tmux.conf:print to a debug file in
~/.tmux/plugins/tmux-cpu/debug.log:miss nvidia-smi4 times in quick succession each updatemiss nvidia-smionce, thenhit nvidia-smi3 timestail -f ~/.tmux/plugins/tmux-cpu/debug.log