mirror of
https://github.com/zdharma-continuum/zconvey.git
synced 2026-09-10 07:06:21 -04:00
Commands may expire (timestamps used), Zstyle for this (expire_seconds)
This commit is contained in:
parent
c2f003c1d5
commit
cde90cc9b4
|
|
@ -11,10 +11,11 @@ The values being set are the defaults.
|
|||
|
||||
```zsh
|
||||
zstyle ":plugin:zconvey" check_interval "2" # How often to check if there are new commands (in seconds)
|
||||
zstyle ":plugin:zconvey" expire_seconds "20" # If shell is busy for 20 seconds, the received command will expire and not run
|
||||
zstyle ":plugin:zconvey" greeting "logo" # Display logo at Zsh start ("text" – display text, "none" – no greeting)
|
||||
zstyle ":plugin:zconvey" ask "0" # zc won't ask for missing data ("1" has the same effect as always using -a option)
|
||||
zstyle ":plugin:zconvey" ls_after_rename "0" # Don't execute zc-ls after doing rename (with zc-rename or zc-take)
|
||||
zstyle ":plugin:zconvey" use_zsystem_flock "1" # Should use faster zsystem's flock when it's possible?
|
||||
# (default true on Zsh >= 5.3)
|
||||
zstyle ":plugin:zconvey" greeting "logo" # Display logo at Zsh start ("text" – display text, "none" – no greeting)
|
||||
zstyle ":plugin:zconvey" ls_after_rename "0" # Don't execute zc-ls after doing rename (with zc-rename or zc-take)
|
||||
zstyle ":plugin:zconvey" ask "0" # zc won't ask for missing data ("1" has the same effect as always using -a option)
|
||||
zstyle ":plugin:zconvey" timestamp_from "datetime" # Use zsh/datetime module for obtaining timestamp. "date" – use date command (fork)
|
||||
```
|
||||
|
|
|
|||
|
|
@ -4,10 +4,11 @@ The values being set are the defaults.
|
|||
|
||||
```zsh
|
||||
zstyle ":plugin:zconvey" check_interval "2" # How often to check if there are new commands (in seconds)
|
||||
zstyle ":plugin:zconvey" expire_seconds "20" # If shell is busy for 20 seconds, the received command will expire and not run
|
||||
zstyle ":plugin:zconvey" greeting "logo" # Display logo at Zsh start ("text" – display text, "none" – no greeting)
|
||||
zstyle ":plugin:zconvey" ask "0" # zc won't ask for missing data ("1" has the same effect as always using -a option)
|
||||
zstyle ":plugin:zconvey" ls_after_rename "0" # Don't execute zc-ls after doing rename (with zc-rename or zc-take)
|
||||
zstyle ":plugin:zconvey" use_zsystem_flock "1" # Should use faster zsystem's flock when it's possible?
|
||||
# (default true on Zsh >= 5.3)
|
||||
zstyle ":plugin:zconvey" greeting "logo" # Display logo at Zsh start ("text" – display text, "none" – no greeting)
|
||||
zstyle ":plugin:zconvey" ls_after_rename "0" # Don't execute zc-ls after doing rename (with zc-rename or zc-take)
|
||||
zstyle ":plugin:zconvey" ask "0" # zc won't ask for missing data ("1" has the same effect as always using -a option)
|
||||
zstyle ":plugin:zconvey" timestamp_from "datetime" # Use zsh/datetime module for obtaining timestamp. "date" – use date command (fork)
|
||||
```
|
||||
|
|
|
|||
|
|
@ -625,6 +625,11 @@ function zc-logo-all() {
|
|||
zstyle -s ":plugin:zconvey" timestamp_from timestamp_from || timestamp_from="datetime"
|
||||
[[ "$timestamp_from" != "date" && "$timestamp_from" != "datetime" ]] && timestamp_from="datetime"
|
||||
ZCONVEY_CONFIG[timestamp_from]="$timestamp_from"
|
||||
|
||||
local expire_seconds
|
||||
zstyle -s ":plugin:zconvey" expire_seconds expire_seconds || expire_seconds="20"
|
||||
[[ "$expire_seconds" != <-> ]] && expire_seconds="20"
|
||||
ZCONVEY_CONFIG[expire_seconds]="$expire_seconds"
|
||||
}
|
||||
|
||||
#
|
||||
|
|
@ -826,6 +831,18 @@ function __convey_on_period_passed() {
|
|||
command rm -f "$datafile"
|
||||
exec {fd}>&-
|
||||
|
||||
# Obtain current time stamp
|
||||
local ts
|
||||
if [ "$ZCONVEY_CONFIG[timestamp_from]" = "datetime" ]; then
|
||||
[[ "${+modules}" = 1 && "${modules[zsh/datetime]}" != "loaded" && "${modules[zsh/datetime]}" != "autoloaded" ]] && zmodload zsh/datetime
|
||||
[ "${+modules}" = 0 ] && zmodload zsh/datetime
|
||||
ts="$EPOCHSECONDS"
|
||||
fi
|
||||
# Also a fallback
|
||||
if [[ "$ZCONVEY_CONFIG[timestamp_from]" = "date" || -z "$ts" || "$ts" = "0" ]]; then
|
||||
ts="$( date +%s )"
|
||||
fi
|
||||
|
||||
# Get timestamp of each command, concatenate
|
||||
# remaining parts with "; " as separator
|
||||
local line cmdts concat_command=""
|
||||
|
|
@ -836,7 +853,10 @@ function __convey_on_period_passed() {
|
|||
concat_command="${concat_command#; }"
|
||||
[[ -o interactive_comments ]] && concat_command+=" ##"
|
||||
|
||||
"${ZCONVEY_REPO_DIR}/feeder/feeder" "$concat_command"
|
||||
# TODO: a message that command expired
|
||||
if (( ts - cmdts <= ZCONVEY_CONFIG[expire_seconds] )); then
|
||||
"${ZCONVEY_REPO_DIR}/feeder/feeder" "$concat_command"
|
||||
fi
|
||||
|
||||
# Tried: zle .kill-word, .backward-kill-line, .backward-kill-word,
|
||||
# .kill-line, .vi-kill-line, .kill-buffer, .kill-whole-line
|
||||
|
|
|
|||
Loading…
Reference in a new issue