Compare commits

..

69 commits

Author SHA1 Message Date
vladislav doster 597d7c027c
Merge pull request #2 from zdharma-continuum/ci/gh-action-lint-workflow
feat: add lint gh action workflows
2023-04-15 23:46:16 -05:00
Vladislav Doster d151f1805e
feat: add lint gh action workflow 2023-04-14 17:11:08 -05:00
Philipp Schmitt 90e82e2022
Update zdharma and zinit refs 2021-11-12 18:57:51 +01:00
Philipp Schmitt 96189b47a7
Update repo url 2021-11-10 18:44:59 +01:00
Philipp Schmitt f95d026737
Update url 2021-11-10 18:27:41 +01:00
Aaron Lichtman f81880cda3
Merge pull request #1 from MenkeTechnologies/master 2021-11-08 04:13:21 -06:00
MenkeTechnologies 372f505f21 silence msg 2021-03-18 22:55:41 -04:00
Sebastian Gniazdowski 851dbd7f60 Add completions for the commands. Thanks @MenkeTechnologies! 2020-09-03 16:19:38 +02:00
Sebastian Gniazdowski 627e8aff06 plugin.zsh,myflock/c.h: Support Cygwin 2020-05-07 23:17:37 +02:00
Sebastian Gniazdowski 6df790888a plugin.zsh: Unbusy session 2020-04-19 03:58:18 +02:00
Sebastian Gniazdowski 95094ec162 plugin.zsh: Standard $0 handling and $fpath extending 2020-01-25 00:57:57 +01:00
Sebastian Gniazdowski f3e828fce4 plugin.zsh: Use 2 instead of INT 2019-11-01 14:38:56 +01:00
Sebastian Gniazdowski 232781ca82 feeder: Define the ioctl 2019-10-21 14:38:30 +02:00
Sebastian Gniazdowski 945086f062 Updated README.md 2019-09-03 18:26:20 +02:00
Sebastian Gniazdowski 5e548862fc plugin.zsh: *preexec_hook – store complete command making sesssion busy 2019-08-19 01:09:06 +02:00
Sebastian Gniazdowski 18103df319 plugin.zsh: Dequote received command/notification, usage settled this 2018-11-07 17:19:26 +01:00
Sebastian Gniazdowski 3aef21260c doc: Two asciicasts downloaded and added (Asciinema) 2018-10-24 14:56:08 +02:00
Matthew S. Dippel e93731fe59 Added .gitignore 2018-09-18 10:39:06 -04:00
Sebastian Gniazdowski d2d34f934c Ensure no error message is output when loading zsh/system module 2018-05-13 08:51:54 +02:00
Sebastian Gniazdowski 5b88a12a3a Correct reading of use_zsystem_flock boolean zstyle 2018-05-13 08:49:29 +02:00
Sebastian Gniazdowski d89c0bbbf4 plugin.zsh: Don't rely on *_ID being integer (defensive, should work) 2018-02-26 09:59:07 +01:00
Sebastian Gniazdowski e615e5c600 plugin.zsh: Two places not resistant to setopt noclobber 2018-02-23 18:05:07 +01:00
Sebastian Gniazdowski 9b439e6e50 plugin.zsh: Notifications are being stacked 2018-02-02 11:00:17 +01:00
Sebastian Gniazdowski 3f3ed54d23 plugin.zsh: Not needed hide flag (-h) for global parameters 2018-02-02 10:59:08 +01:00
Sebastian Gniazdowski 9921e56efe Updated README.md 2018-01-13 18:40:13 +01:00
Sebastian Gniazdowski d78f8efbe0 Updated README.md 2018-01-12 16:55:40 +01:00
Sebastian Gniazdowski 04a3b9ab8b Updated README.md 2018-01-12 16:44:31 +01:00
Sebastian Gniazdowski c5f3099cbb notify: A wrapper for marzocchi/zsh-notify plugin 2018-01-12 15:58:37 +01:00
Sebastian Gniazdowski 2f02abe09f notify: Don't quote arguments 2018-01-12 15:56:45 +01:00
Sebastian Gniazdowski 54fceaec7a plugin.zsh: Add support for the new zc-bg-notify *script* 2018-01-12 15:36:23 +01:00
Sebastian Gniazdowski adc7cb5447 cmds/zc-bg-notify 2018-01-12 15:35:46 +01:00
Sebastian Gniazdowski 1206924775 zc: Adapt redirections to noclobber option 2018-01-12 15:11:08 +01:00
Sebastian Gniazdowski ce475add09 plugin.zsh: Export *{REPO,CONFIG}_DIR, respect XDG_CONFIG_HOME 2018-01-12 13:37:04 +01:00
Sebastian Gniazdowski 4b4139fd48 plugin.zsh: No bold colors in *pinfo functions 2018-01-12 12:57:21 +01:00
Sebastian Gniazdowski 337d264b94 plugin.zsh: Mute fd close in zshexit hook 2018-01-06 12:57:32 +01:00
Sebastian Gniazdowski 4483a1edc8 *period_passed saves and restores $? 2017-12-22 08:18:50 +01:00
Sebastian Gniazdowski 0808de2992 Full namespace add to simple functions 2017-09-21 13:14:58 +02:00
Sebastian Gniazdowski 1aa961317c plugin.zsh: Switch to [[ 2017-08-29 10:22:09 +02:00
Sebastian Gniazdowski dc11081777 Add namespace to simple functions (pinfo*) 2017-08-27 11:10:45 +02:00
Sebastian Gniazdowski 545bb652a0 plugin.zsh: Lock LICENSE instead of flock.c, because of Linux 2017-06-15 15:08:37 +02:00
Sebastian Gniazdowski cede1db45d Updated README.md (PayPal button) 2017-05-23 18:52:49 +02:00
Sebastian Gniazdowski 79393c8116 zc-all,plugin.zsh: Fix two parameter leaks (name, res) 2017-05-13 08:34:04 +02:00
Sebastian Gniazdowski 8971b19a3c Use text greeting by default 2017-04-18 13:48:09 +02:00
Sebastian Gniazdowski 7ade1d9ce0 Updated README.md 2017-03-21 16:39:22 +01:00
Sebastian Gniazdowski 1e242be9d5 plugin.zsh: Use zsystem flock for compilation 2017-03-20 10:49:32 +01:00
Sebastian Gniazdowski c7e244e342 plugin.zsh: *is_session_active correctly handles current session. Uplift 2017-03-06 10:43:43 +01:00
Sebastian Gniazdowski 3e7fe023d8 *.plugin.zsh: Further fix zsystem / flock usage (activated Zsh >= 5.3) 2017-03-01 11:44:33 +01:00
Sebastian Gniazdowski e039c0e252 Fix zsystem / flock usage for Zsh >= 5.3 2017-02-06 13:36:48 +01:00
Sebastian Gniazdowski f5485d3571 *.plugin.zsh: The zsh_nrN files now contain $$ 2016-10-01 11:24:38 +02:00
Sebastian Gniazdowski fc5fb116f5 zc-all: Better coloring when informing about send to busy session 2016-10-01 00:00:25 +02:00
Sebastian Gniazdowski 06ddbefd3c zc: Better coloring of -v status messages about sending to sessions 2016-09-29 17:41:30 +02:00
Sebastian Gniazdowski 9598182e64 zc-all: Missing help message on -f/--force options 2016-09-28 16:11:00 +02:00
Sebastian Gniazdowski c5059afbc7 Updated README.md 2016-09-26 22:29:27 +02:00
Sebastian Gniazdowski fb5e8d8141 zc-all 2016-09-26 22:26:33 +02:00
Sebastian Gniazdowski d6946c7a93 zc: Show session name in the "Zconvey successfully ..." message 2016-09-26 22:20:34 +02:00
Sebastian Gniazdowski 355e454565 Make __zconvey_get_name_of_id testable 2016-09-26 22:18:46 +02:00
Sebastian Gniazdowski 3f960f2775 zc: Inform about timeout when sending to busy sessions 2016-09-26 22:15:50 +02:00
Sebastian Gniazdowski a0a8401ce0 zc: -r/--raw - raw input mode (quoted string), for use with scripts 2016-09-26 22:08:11 +02:00
Sebastian Gniazdowski d680baffb1 zc: Superfluous variable "zshselect" 2016-09-26 22:00:02 +02:00
Sebastian Gniazdowski eeb6fe41c8 __zconvey_on_period_passed: return "0" when fast-track shows no data 2016-09-17 23:49:19 +02:00
Sebastian Gniazdowski c74ab8e815 Currently choose to return specific error codes for no-lock situations 2016-09-17 23:48:51 +02:00
Sebastian Gniazdowski 58dedeb7d1 Include information that FreeBSD was tested 2016-09-17 23:47:26 +02:00
Sebastian Gniazdowski d00272e34f Update README.md 2016-09-15 11:20:13 +02:00
Sebastian Gniazdowski 961386ff9d Updated README.md, ZSTYLES.md 2016-09-15 10:30:06 +02:00
Sebastian Gniazdowski 1a27047b5d zc detects whether target session is absent and issues a warning message 2016-09-14 16:11:06 +02:00
Sebastian Gniazdowski ba3ec69bf5 Updated README.md 2016-09-14 08:33:27 +02:00
Sebastian Gniazdowski 76425b385e zc: Dequote "|" when sending command 2016-09-14 08:11:36 +02:00
Sebastian Gniazdowski 6bd2f681fa Extract last large function zc-logo-all into autoloaded function 2016-09-14 08:03:01 +02:00
Sebastian Gniazdowski 31986a91c9 Update environment variable of zsh-select to match changes done in it 2016-09-14 07:49:46 +02:00
21 changed files with 3193 additions and 200 deletions

15
.github/workflows/lint.yml vendored Normal file
View file

@ -0,0 +1,15 @@
name: Lint
on:
pull_request:
branches: [main, master]
push:
branches: [main, master]
tags: ["v*.*.*"]
workflow_dispatch:
jobs:
commit:
uses: zdharma-continuum/.github/.github/workflows/commit-job.yml@main
lint:
uses: zdharma-continuum/.github/.github/workflows/lint-job.yml@main

4
.gitignore vendored Normal file
View file

@ -0,0 +1,4 @@
feeder/**/*
myflock/**/*
feeder/
myflock/

136
README.md
View file

@ -1,34 +1,74 @@
## Introduction
[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=D6XDCHDSBDSDG)
Zconvey integrates multiple Zsh sessions. They are given an ID, optionally a NAME (both unique),
and can send commands to each other.
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
Video  view on [asciinema](https://asciinema.org/a/85646). You can resize the video by pressing `Ctrl-+` or `Cmd-+`.
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
[![asciicast](https://asciinema.org/a/85646.png)](https://asciinema.org/a/85646)
**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
## Zstyles
- [Introduction](#introduction)
- [Zstyles](#zstyles)
- [Installation](#installation)
- [Zinit](#zinit)
- [Antigen](#antigen)
- [Oh-My-Zsh](#oh-my-zsh)
- [Zgen](#zgen)
- [Information](#information)
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
# Introduction
Zconvey integrates multiple Zsh sessions. They are given an ID, optionally a NAME (both unique), and can send commands
to each other. Use this to switch all your Zshells to given directory, via `zc-all cd $PWD`! Also, there's
`zc-bg-notify` **script** (not a function), that will show notification under prompt of every active Zsh session. You
can call this script from any program, Bash or GUI.
Video  view on [asciinema](https://asciinema.org/a/156726). You can resize the video by pressing `Ctrl-+` or `Cmd-+`.
[![asciicast](https://asciinema.org/a/156726.png)](https://asciinema.org/a/156726)
# Zstyles
The values being set are the defaults. They must be set before loading the plugin.
```zsh
zstyle ":plugin:zconvey" check_interval "2" # How often to check if there are new commands (in seconds)
zstyle ":plugin:zconvey" expire_seconds "22" # If shell is busy for 22 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" output_method "feeder" # To put commands on command line, Zconvey can use small program "feeder". Or "zsh"
# method, which currently doesn't automatically run the command  to use when e.g.
# feeder doesn't build (unlikely) or when occurring any problems with it
zstyle ":plugin:zconvey" timestamp_from "datetime" # Use zsh/datetime module for obtaining timestamp. "date" use date command (fork)
# How often to check if there are new commands (in seconds)
zstyle ":plugin:zconvey" check_interval "2"
# If shell is busy for 22 seconds, the received command will expire and not run
zstyle ":plugin:zconvey" expire_seconds "22"
# Display logo at Zsh start ("text" display text, "none" no greeting)
zstyle ":plugin:zconvey" greeting "logo"
# zc won't ask for missing data ("1" has the same effect as always using -a
# option)
zstyle ":plugin:zconvey" ask "0"
# Don't execute zc-ls after doing rename (with zc-rename or zc-take)
zstyle ":plugin:zconvey" ls_after_rename "0"
# Should use faster zsystem's flock when it's possible?
# (default true on Zsh >= 5.3, will revert to mixed zsystem/flock on older
# Zshells)
zstyle ":plugin:zconvey" use_zsystem_flock "1"
# To put commands on command line, Zconvey can use small program "feeder". Or
# "zsh" method, which currently doesn't automatically run the command  to use
# when e.g. feeder doesn't build (unlikely) or when occurring any problems
# with it
zstyle ":plugin:zconvey" output_method "feeder"
# Use zsh/datetime module for obtaining timestamp. "date" use date command
# (fork)
zstyle ":plugin:zconvey" timestamp_from "datetime"
```
## Installation
# Installation
**The plugin is "standalone"**, which means that only sourcing it is needed. So to
install, unpack `zconvey` somewhere and add
**The plugin is "standalone"**, which means that only sourcing it is needed. So to install, unpack `zconvey` somewhere
and add
```zsh
source {where-zconvey-is}/zconvey.plugin.zsh
@ -36,46 +76,58 @@ source {where-zconvey-is}/zconvey.plugin.zsh
to `zshrc`.
If using a plugin manager, then `Zplugin` is recommended, but you can use any
other too, and also install with `Oh My Zsh` (by copying directory to
`~/.oh-my-zsh/custom/plugins`).
If using a plugin manager, then `Zinit` is recommended, but you can use any other too, and also install with `Oh My Zsh`
(by copying directory to `~/.oh-my-zsh/custom/plugins`).
The plugin integrates with my other plugin [Zsh-Select](https://github.com/zdharma-continuum/zsh-select). Install it
with e.g. Zinit to be able to use `-a` option for `zc` command. It also integrates with
[marzocchi/zsh-notify](https://github.com/marzocchi/zsh-notify), via `cmds/plg-zsh-notify` script.
### [Zplugin](https://github.com/psprint/zplugin)
## [Zinit](https://github.com/zdharma-continuum/zinit)
Add `zplugin load psprint/zconvey` to your `.zshrc` file. Zplugin will handle
cloning the plugin for you automatically the next time you start zsh. To update
issue `zplugin update psprint/zconvey` (`update-all` can also be used).
Add `zinit load zdharma-continuum/zconvey` to your `.zshrc` file. Zinit will clone the plugin the next time you start
zsh. To update issue `zinit update zdharma-continuum/zconvey`.
### Antigen
Zinit can load in [turbo-mode](https://github.com/zdharma-continuum/zinit#turbo-mode-zsh--53), below is an example
configuration, together with adding `zc-bg-notify` to `$PATH`:
Add `antigen bundle psprint/zconvey` to your `.zshrc` file. Antigen will handle
cloning the plugin for you automatically the next time you start zsh.
```zsh
zinit ice wait"0"
zinit light zdharma-continuum/zconvey
zinit ice wait"0" as"command" pick"cmds/zc-bg-notify" silent
zinit light zdharma-continuum/zconvey
```
### Oh-My-Zsh
## Antigen
Add `antigen bundle zdharma-continuum/zconvey` to your `.zshrc` file. Antigen will handle cloning the plugin for you
automatically the next time you start zsh.
## Oh-My-Zsh
1. `cd ~/.oh-my-zsh/custom/plugins`
2. `git clone git@github.com:psprint/zconvey.git`
3. Add `zconvey` to your plugin list
1. `git clone git@github.com:zdharma-continuum/zconvey.git`
1. Add `zconvey` to your plugin list
### Zgen
## Zgen
Add `zgen load psprint/zconvey` to your .zshrc file in the same place you're doing
your other `zgen load` calls in.
Add `zgen load zdharma-continuum/zconvey` to your .zshrc file in the same place you're doing your other `zgen load`
calls in.
## Information
# Information
There are following commands:
- `zc` sends to other session; use "-a" option to be asked for target and a command to send
- `zc-all`  the same as `zc`, but targets are all other active sessions (with `-f` also busy sessions)
- `zc-rename`  assigns name to current or selected session; won't rename if there's a session with the same name
- `zc-take`  takes a name for current or selected sessions, schematically renames any conflicting sessions
- `zc-ls` lists all active and named sessions
- `zc-id`  shows ID and NAME of current session
- `zc-logo` the same as `zc-id`, but in a form of an on-screen logo; bound to Ctrl-O Ctrl-I
- `zc-bg-notify` in subdirectory `cmds`, link it to `/usr/local/bin`, etc. or load with e.g. Zinit
The main command is `zc`. It is used to execute commands on other sessions. `zc-ls` is the main tool
to obtain overall information on sessions. `zc-take` is a nice rename tool to quickly name a few
sessions. Keyboard shortcut Ctrl-O Ctrl-I will show current session's ID and NAME in form of an
on-screen logo.
The main command is `zc` (yet it is rather rarely used, I'm always sending to all sessions with `zc-all`). It is used to
execute commands on other sessions. `zc-ls` is the main tool to obtain overall information on sessions. `zc-take` is a
nice rename tool to quickly name a few sessions. Keyboard shortcut Ctrl-O Ctrl-I will show current session's ID and NAME
in form of an on-screen logo.

View file

@ -9,7 +9,7 @@ zstyle ":plugin:zconvey" greeting "logo" # Display logo at Zsh start
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)
# (default true on Zsh >= 5.3, will revert to mixed zsystem/flock on older Zshells)
zstyle ":plugin:zconvey" output_method "feeder" # To put commands on command line, Zconvey can use small program "feeder". Or "zsh"
# method, which currently doesn't automatically run the command  to use when e.g.
# feeder doesn't build (unlikely) or when occurring any problems with it

16
_zc Normal file
View file

@ -0,0 +1,16 @@
#compdef zc
local arguments
arguments=(
{-h,--help}'[this message]'
{-i,--id}'[ID (number) of Zsh session]:ID'
{-n,--name}'[NAME of Zsh session]:NAME'
{-q,--quiet}'[dont output status messages]'
{-v,--verbose}'[output more status messages]'
{-a,--ask}'[ask for command (if not provided) and session (etc.)]'
{-r,--raw}'[raw input (for scripts) - a quoted string, e.g. ls a dir]'
'*:filename:_files'
)
_arguments -s $arguments

14
_zc-all Normal file
View file

@ -0,0 +1,14 @@
#compdef zc-all
local arguments
arguments=(
{-h,--help}'[this message]'
{-q,--quiet}'[dont output status messages]'
{-v,--verbose}'[output more status messages]'
{-a,--ask}'[ask for command (if not provided)]'
{-f,--force}'[send also to busy sessions; command can time out]'
'*:filename:_files'
)
_arguments -s $arguments

14
_zc-bg-notify Normal file
View file

@ -0,0 +1,14 @@
#compdef zc-bg-notify
local arguments
arguments=(
{-h,--help}'[this message]'
{-q,--quiet}'[dont output status messages about target sessions]'
{-v,--verbose}'[output more status messages]'
{-a,--ask}'[ask for notification text (if not provided)]'
{-f,--force}'[send also to busy sessions; notification can time-out]'
'*:filename:_files'
)
_arguments -s $arguments

13
_zc-rename Normal file
View file

@ -0,0 +1,13 @@
#compdef zc-rename
local arguments
arguments=(
{-h,--help}'[this message]'
{-i,--id}'[(number) of Zsh session]:ID'
{-n,--name}'[NAME of Zsh session]:NAME'
{-q,--quiet}'[dont output status messages]'
'*:filename:_files'
)
_arguments -s $arguments

13
_zc-take Normal file
View file

@ -0,0 +1,13 @@
#compdef zc-take
local arguments
arguments=(
{-h,--help}'[this message]'
{-i,--id}'[(number) of Zsh session]:ID'
{-n,--name}'[NAME of Zsh session]:NAME'
{-q,--quiet}'[dont output status messages]'
'*:filename:_files'
)
_arguments -s $arguments

11
cmds/plg-zsh-notify Executable file
View file

@ -0,0 +1,11 @@
#!/usr/bin/env zsh
# For use with marzocchi/zsh-notify, by setting following zstyle in zshrc:
# zstyle ':notify:*' notifier /path/to/zconvey/cmds/plg-zsh-notify
typeset -g BINDIR=${0:h}
local tpe="$1"
read -t1 -r msg
$BINDIR/zc-bg-notify -q "$tpe - $msg"

304
cmds/zc-bg-notify Executable file
View file

@ -0,0 +1,304 @@
#!/usr/bin/env zsh
setopt localoptions extendedglob clobber
integer idx is_locked counter=0
local name busyfile busywith
#
# Helper functions
#
# FUNCTION: __zconvey_pinfo {{{
function __zconvey_pinfo() {
print -- "\033[0;32m$*\033[0m";
}
# }}}
# FUNCTION: __zconvey_pinfo2 {{{
function __zconvey_pinfo2() {
print -- "\033[0;33m$*\033[0m";
}
# }}}
# FUNCTION: __zconvey_get_name_of_id {{{
function __zconvey_get_name_of_id() {
local id="$1"
REPLY=""
local f="$ZCONVEY_NAMES_DIR/${id}.name"
if [[ -e "$f" ]]; then
REPLY=${(f)"$(<$f)"}
REPLY="${REPLY#:}"
REPLY="${REPLY%:}"
return 0
fi
return 1
}
# }}}
# FUNCTION: __zconvey_is_session_active {{{
function __zconvey_is_session_active() {
setopt localoptions extendedglob
local res idx="$1"
if [[ "$idx" != <-> || "$idx" = "0" || "$idx" -gt "100" ]]; then
__zconvey_pinfo "Incorrect sesion ID occured: $idx"
return 2
fi
if [[ "$idx" = "$ZCONVEY_ID" ]]; then
# Return true - current session is active
return 0;
fi
integer is_locked=0
local idfile="$ZCONVEY_LOCKS_DIR/zsh_nr${idx}" tmpfd
if [[ -e "$idfile" ]]; then
# Use zsystem only if non-blocking call is available (Zsh >= 5.3)
if [[ "${ZCONVEY_CONFIG[use_zsystem_flock]}" = "1" ]]; then
zsystem 2>/dev/null flock -t 0 -f tmpfd "$idfile"
res="$?"
else
exec {tmpfd}>"$idfile"
"${ZCONVEY_REPO_DIR}/myflock/flock" -nx "$tmpfd"
res="$?"
# Close the fd immediately - unlocking if gained lock
exec {tmpfd}>&-
fi
if [[ "$res" = "101" || "$res" = "1" || "$res" = "2" ]]; then
is_locked=1
elif [[ "${ZCONVEY_CONFIG[use_zsystem_flock]}" = "1" ]]; then
# Close the lock immediately
zsystem flock -u "$tmpfd"
fi
fi
return $(( 1-is_locked ))
}
# }}}
# FUNCTION: __zconvey_usage_zc-bg-notify {{{
__zconvey_usage_zc-bg-notify() {
__zconvey_pinfo2 "Sends notification to all unbusy sessions (also busy when -f passed)"
__zconvey_pinfo "Usage: zc-bg-notify [-h|--help] [-f|--force] [-a|--ask] [-q|--quiet] [-v|--verbose] {notification-text}"
print -- "-h/--help - this message"
print -- "-q/--quiet - don't output status messages about target sessions"
print -- "-v/--verbose - output more status messages"
print -- "-a/--ask - ask for notification text (if not provided)"
print -- "-f/--force - send also to busy sessions; notification can time-out"
}
# }}}
#
# Send function
#
# FUNCTION __zconvey_zc {{{
function __zconvey_zc() {
local id="$1" ntext="$2" ts
# Obtain current time stamp
[[ "${+modules}" = 1 && "${modules[zsh/datetime]}" != "loaded" && "${modules[zsh/datetime]}" != "autoloaded" ]] && zmodload zsh/datetime 2>/dev/null
(( ${+modules} == 0 )) && zmodload zsh/datetime 2>/dev/null
(( ${+EPOCHSECONDS} )) && ts="$EPOCHSECONDS" || ts="$(date +%s )"
local fd datafile="${ZCONVEY_IO_DIR}/${id}.io"
local lockfile="${datafile}.lock"
{ echo "PID $$ is sending command" >! "$lockfile"; } 2>/dev/null
# 1. Zsystem lock with timeout (2 seconds)
if (( ${ZCONVEY_CONFIG[use_zsystem_flock]} > 0 )); then
(( ${verbose} )) && print "Will use zsystem flock..."
if ! zsystem flock -t 2 -f fd "$lockfile"; then
__zconvey_pinfo2 "Communication channel of session $id is busy, could not send"
exit 1
fi
# 2. Provided flock binary (two calls)
else
(( ${verbose} )) && print "Will use provided flock..."
exec {fd}>"$lockfile"
"${ZCONVEY_REPO_DIR}/myflock/flock" -nx "$fd"
if [ "$?" = "101" ]; then
(( ${verbose} )) && print "First attempt failed, will retry..."
LANG=C sleep 1
"${ZCONVEY_REPO_DIR}/myflock/flock" -nx "$fd"
if [ "$?" = "101" ]; then
__zconvey_pinfo2 "Communication channel of session $id is busy, could not send"
exit 1
fi
fi
fi
# >> - multiple messages can be accumulated
print -r -- "n$ts $ntext" >> "$datafile"
# Release the lock by closing the lock file
exec {fd}>&-
if (( ${quiet} == 0 )); then
__zconvey_get_name_of_id "$id"
if [[ -n "$REPLY" ]]; then
print "Notification sent to session $id (name: $REPLY)"
else
print "Notification sent to session $id"
fi
integer is_locked
__zconvey_is_session_active "$id" && is_locked=1 || is_locked=0
(( is_locked == 0 )) && print "The session is ABSENT, the message will time out"
fi
}
# }}}
#
# Options
#
# {{{
local -A opthash
zmodload zsh/zutil
zparseopts -D -A opthash h -help q -quiet v -verbose f -force a -ask || { __zconvey_usage_zc-bg-notify; return 1; }
integer verbose=0 quiet=0 force=0 ask=0
# Help
(( ${+opthash[-h]} + ${+opthash[--help]} )) && { __zconvey_usage_zc-bg-notify; return 0; }
# ASK (requests command and/or ID)
(( ask = ${+opthash[-a]} + ${+opthash[--ask]} ))
if [ "$ask" = "0" ]; then
local ask_setting
zstyle -b ":plugin:zconvey" ask ask_setting || ask_setting="no"
[ "$ask_setting" = "yes" ] && ask=1 || ask=0
fi
# VERBOSE, QUIET, FORCE
(( verbose = ${+opthash[-v]} + ${+opthash[--verbose]} ))
(( quiet = ${+opthash[-q]} + ${+opthash[--quiet]} ))
(( force = ${+opthash[-f]} + ${+opthash[--force]} ))
# }}}
#
# Configuration
#
# {{{
zmodload zsh/system || typeset -g no_zsystem=1
zsystem supports flock || typeset -g no_zsystem=1
typeset -g ZCONVEY_REPO_DIR ZCONVEY_CONFIG_DIR ZCONVEY_IO_DIR ZCONVEY_LOCKS_DIR ZCONVEY_NAMES_DIR ZCONVEY_OTHER_DIR
typeset -gA ZCONVEY_CONFIG
: ${ZCONVEY_REPO_DIR:=$HOME/.zinit/plugins/zdharma---zconvey} # TODO: add configuration file
: ${ZCONVEY_CONFIG_DIR:=${XDG_CONFIG_HOME:-$HOME/.config}/zconvey}
: ${ZCONVEY_IO_DIR:=${ZCONVEY_CONFIG_DIR}/io}
: ${ZCONVEY_LOCKS_DIR:=${ZCONVEY_CONFIG_DIR}/locks}
: ${ZCONVEY_NAMES_DIR:=${ZCONVEY_CONFIG_DIR}/names}
: ${ZCONVEY_OTHER_DIR:=${ZCONVEY_CONFIG_DIR}/other}
autoload is-at-least
if [[ "$no_zsystem" != 1 ]]; then
if ! is-at-least 5.3; then
if [[ -e ${ZCONVEY_REPO_DIR}/myflock/flock ]]; then
# Use, but not for acquire
ZCONVEY_CONFIG[use_zsystem_flock]="2"
else
print "Couldn't find ${ZCONVEY_REPO_DIR}/myflock/flock, and Zsh is older than 5.3, cannot notify"
exit 1
fi
else
# Use for all operations
ZCONVEY_CONFIG[use_zsystem_flock]="1"
fi
else
if [[ -e ${ZCONVEY_REPO_DIR}/myflock/flock ]]; then
# Use flock for all operations
ZCONVEY_CONFIG[use_zsystem_flock]="0"
else
print "Couldn't find ${ZCONVEY_REPO_DIR}/myflock/flock, and Zsh doesn't have \`zsystem flock', cannot notify"
exit 1
fi
fi
# }}}
#
# Input establishing
#
# {{{
local -a args
args=( "$@" )
local ntext="${args[*]}"
# Resupply missing input if requested
if (( $ask )); then
# Supply command?
if [[ -z "$ntext" ]]; then
vared -cp "Enter notification-text to send: " ntext
ntext="${ntext##[[:space:]]#}"
ntext="${ntext%%[[:space:]]#}"
if [ -z "$ntext" ]; then
__zconvey_pinfo "No command enterred, exiting"
return 0
fi
fi
fi
if [ -z "$ntext" ]; then
__zconvey_pinfo "No command provided, aborting"
return 1
fi
# }}}
#
# Business logic
#
# {{{
for (( idx = 1; idx <= 100; idx ++ )); do
name=""
busywith=""
is_locked=0
__zconvey_is_session_active "$idx" && is_locked=1 || is_locked=0
if (( is_locked )); then
busyfile="$ZCONVEY_OTHER_DIR/${idx}.busy"
if [[ -e "$busyfile" && "$idx" != "$ZCONVEY_ID" ]]; then
busywith="\033[1;33m$(<$busyfile)\033[0m"
__zconvey_get_name_of_id "$idx"
if (( force )); then
counter+=1
(( quiet )) || print "\033[1;35mSending to busy\033[0m session $idx (name: $REPLY, busy with: $busywith)"
__zconvey_zc "$idx" "$ntext"
else
(( quiet )) || print "Session $idx (name: $REPLY) busy ($busywith)"
fi
elif [[ "$idx" != "$ZCONVEY_ID" ]]; then
counter+=1
if (( verbose )); then
__zconvey_zc "$idx" "$ntext"
else
__zconvey_zc "$idx" "$ntext"
fi
fi
fi
done
(( quiet )) || __zconvey_pinfo "Sent command to $counter other sessions"
# }}}
return 0
# vim:ft=zsh

858
doc/asciicasts/156726.json Normal file
View file

@ -0,0 +1,858 @@
{
"version": 1,
"width": 115,
"height": 27,
"duration": 50.461882,
"command": "zsh-5.4.2-dev-0",
"title": "Notifications for Zshell, no dbus, etc., batteries included",
"env": {
"TERM": "xterm-256color",
"SHELL": "/bin/bash"
},
"stdout": [
[
0.626098,
"\u001b[0m\u001b[27m\u001b[24m\u001b[JREADY > \u001b[K\u001b[?2004h"
],
[
1.168809,
"\r\r\n"
],
[
0.000101,
"Loaded OMZ::lib/git.zsh\r\u001b[A\u001b[0m\u001b[27m\u001b[24m\r\u001b[8C\u001b[K"
],
[
0.024683,
"\r\r\n\u001b[J"
],
[
6.6e-05,
"Loaded OMZ::plugins/git\r\u001b[A\u001b[0m\u001b[27m\u001b[24m\r\u001b[8C\u001b[K"
],
[
0.042287,
"\r\r\n\u001b[J"
],
[
6.3e-05,
"Loaded psprint/zsh-editing-workbench\r\u001b[A\u001b[0m\u001b[27m\u001b[24m\r\u001b[8C\u001b[K"
],
[
0.028482,
"\r\r\n\u001b[J"
],
[
4.7e-05,
"Loaded psprint/zsh-navigation-tools\r\u001b[A\u001b[0m\u001b[27m\u001b[24m\r\u001b[8C\u001b[K"
],
[
0.078599,
"\r\r\n\u001b[J"
],
[
4.4e-05,
"Loaded zdharma/zconvey\r\u001b[A\u001b[0m\u001b[27m\u001b[24m\r\u001b[8C\u001b[K"
],
[
0.001554,
"\r\r\n\u001b[J"
],
[
6.1e-05,
"Loaded zdharma/zconvey\r\u001b[A\u001b[0m\u001b[27m\u001b[24m\r\u001b[8C\u001b[K"
],
[
0.003916,
"\r\r\n\u001b[J"
],
[
0.000375,
"Loaded zservices/redis\r\u001b[A\u001b[0m\u001b[27m\u001b[24m\r\u001b[8C\u001b[K"
],
[
0.005001,
"\r\r\n\u001b[J"
],
[
0.000244,
"Loaded zservices/py3http\r\u001b[A\u001b[0m\u001b[27m\u001b[24m\r\u001b[8C\u001b[K"
],
[
0.020314,
"\r\r\n\u001b[J"
],
[
6e-05,
"Loaded psprint/history-search-multi-word\r\u001b[A\u001b[0m\u001b[27m\u001b[24m\r\u001b[8C\u001b[K"
],
[
0.035898,
"\r\r\n\u001b[J"
],
[
5.2e-05,
"Loaded zdharma/zui\r\u001b[A\u001b[0m\u001b[27m\u001b[24m\r\u001b[8C\u001b[K"
],
[
0.497341,
"t"
],
[
0.089076,
"\r\r\n\u001b[J"
],
[
4.2e-05,
"Loaded b4b4r07/zsh-vimode-visual\r\u001b[A\u001b[0m\u001b[27m\u001b[24m\r\u001b[8Ct\u001b[K"
],
[
0.121734,
"\r\r\n\u001b[J"
],
[
4.4e-05,
"Loaded zsh-users/zsh-autosuggestions\r\u001b[A\u001b[0m\u001b[27m\u001b[24m\r\u001b[8Ct\u001b[K"
],
[
0.084719,
"\r\r\n\u001b[J"
],
[
5.3e-05,
"Loaded zdharma/fast-syntax-highlighting\r\u001b[A\u001b[0m\u001b[27m\u001b[24m\r\u001b[8Ct\u001b[K"
],
[
0.058183,
"\b\u001b[1m\u001b[31mt\u001b[1m\u001b[31mm\u001b[0m\u001b[39m\u001b[90mux\u001b[39m\b\b"
],
[
0.216846,
"\b\b\u001b[1m\u001b[31mt\u001b[1m\u001b[31mm\u001b[1m\u001b[31mu\u001b[0m\u001b[39m"
],
[
0.327563,
"\b\b\b\u001b[0m\u001b[32mt\u001b[0m\u001b[32mm\u001b[0m\u001b[32mu\u001b[32mx\u001b[39m"
],
[
0.384346,
"\u001b[?2004l\r\r\n\u001b[J"
],
[
0.101625,
"\u001b[?1049h\u001b[?1h\u001b=\u001b[H\u001b[2J\u001b[?12l\u001b[?25h\u001b[?1000l\u001b[?1002l\u001b[?1006l\u001b[?1005l\u001b[c\u001b(B\u001b[m\u001b[?12;25h\u001b[?12l\u001b[?25h\u001b[?1003l\u001b[?1006l\u001b[?2004l\u001b[1;1H\u001b[1;27r\u001b]112\u0007\u001b[1;1H"
],
[
0.001411,
"\u001b]0;0:1:zsh-5.4.2-dev-0 - \"MacMini.local\" \u0007\u001b[?25l\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[37m\u001b[40m \u001b[42m\u001b[1m1:zsh-5.4.2-dev-0*\u001b(B\u001b[m\u001b[37m\u001b[40m 04:49P | sty. 12\u001b(B\u001b[m\u001b[1;1H\u001b[?12l\u001b[?25h"
],
[
0.307662,
"\u001b[1;26r\u001b[1;1H\u001b[K\r\n\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[HREADY > \u001b[K\u001b[1;27r\u001b[1;9H\u001b[?2004h"
],
[
1.019891,
"\r\n"
],
[
6.1e-05,
"Loaded OMZ::lib/git.zsh\u001b[1;9H"
],
[
0.007303,
"\u001b[1;26r\u001b[2;1H\u001b[K\r\n\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1;27r\u001b[2;1HLoaded OMZ::plugins/git\u001b[1;9H"
],
[
0.00478,
"\u001b[1;26r\u001b[2;1H\u001b[K\r\n\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1;27r\u001b[2;1HLoaded psprint/zsh-editing-workbench\u001b[1;9H"
],
[
0.00702,
"\u001b[1;26r\u001b[2;1H\u001b[K\r\n\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1;27r\u001b[2;1HLoaded psprint/zsh-navigation-tools\u001b[1;9H"
],
[
0.02073,
"\u001b[1;26r\u001b[2;1H\u001b[K\r\n\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1;27r\u001b[2;1HLoaded zdharma/zconvey\u001b[1;9H"
],
[
0.001025,
"\u001b[1;26r\u001b[2;1H\u001b[K\r\n\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1;27r\u001b[2;1H"
],
[
4.6e-05,
"Loaded zdharma/zconvey\u001b[1;9H"
],
[
0.002882,
"\u001b[1;26r\u001b[2;1H\u001b[K\r\n\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1;27r\u001b[2;1H"
],
[
4.7e-05,
"Loaded zservices/redis\u001b[1;9H"
],
[
0.003902,
"\u001b[1;26r\u001b[2;1H\u001b[K\r\n\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1;27r\u001b[2;1HLoaded zservices/py3http"
],
[
5.2e-05,
"\u001b[1;9H"
],
[
0.0043,
"\u001b[1;26r\u001b[2;1H\u001b[K\r\n\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1;27r\u001b[2;1HLoaded psprint/history-search-multi-word\u001b[1;9H"
],
[
0.00786,
"\u001b[1;26r\u001b[2;1H\u001b[K\r\n\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1;27r\u001b[2;1H"
],
[
4.9e-05,
"Loaded zdharma/zui\u001b[1;9H"
],
[
0.589243,
"\u001b[?25l\u001b[14;1H──────────────────────────────────────────────────────────\u001b[32m─────────────────────────────────────────────────────────\u001b[1;1H\u001b(B\u001b[mREADY > \u001b[K\r\nLoaded zdharma/zui \u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\u001b[2B\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[37m\u001b[40m \u001b[42m\u001b[1m1:zsh-5.4.2-dev-0*\u001b(B\u001b[m\u001b[37m\u001b[40m 04:49P | sty. 12\u001b(B\u001b[m\u001b[15;1H\u001b[?12l\u001b[?25h\u001b[?2004l"
],
[
0.000269,
"\u001b[1;13r\u001b[1;1H\u001b[K\r\n\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[HREADY > \u001b[1;27r\u001b[15;1H"
],
[
0.303573,
"\u001b[15;26r\u001b[15;1H\u001b[K\r\n\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[15dREADY > \u001b[K\u001b[1;27r\u001b[15;9H\u001b[?2004h"
],
[
0.764524,
"\u001b[2;1HLoaded b4b4r07/zsh-vimode-visual\u001b[1;9H\u001b[K\u001b[15d"
],
[
0.051627,
"\u001b[?25l\u001b[14;1H─────────────────────────────────────────────────────────\u001b[32m┬─────────────────────────────────────────────────────────\u001b[15;58H│\u001b[16;58H│\u001b[17;58H│\u001b[18;58H│\u001b[19;58H│\u001b[20;58H│\u001b[21;58H│\u001b[22;58H│\u001b[23;58H│\u001b[24;58H│\u001b[25;58H│\u001b[26;58H│\u001b[H\u001b(B\u001b[mREADY > \u001b[K\r\nLoaded b4b4r07/zsh-vimode-visual \u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\u001b[15;57H\u001b[1K\rREADY > \u001b[16;57H\u001b[1K\n\u001b[1K\n\u001b[1K\n\u001b[1K\n\u001b[1K\n\u001b[1K\n\u001b[1K\n\u001b[1K\n\u001b[1K\n\u001b[1K\n\u001b[1K\u001b[15;59H\u001b[K\n\u001b[K\n\u001b[K\n\u001b[K\n\u001b[K\n\u001b[K\n\u001b[K\n\u001b[K\n\u001b[K\n\u001b[K\n\u001b[K\n\u001b[K\r\n\u001b[37m\u001b[40m \u001b[42m\u001b[1m1:zsh-5.4.2-dev-0*\u001b(B\u001b[m\u001b[37m\u001b[40m 04:49P | sty. 12\u001b(B\u001b[m\u001b[15;59H\u001b[?12l\u001b[?25h\u001b[?2004l"
],
[
0.001719,
"\u001b]0;0:1:tmux - \"MacMini.local\" \u0007\u001b[?25l\u001b[27;1H\u001b[37m\u001b[40m \u001b[42m\u001b[1m1:tmux*\u001b(B\u001b[m\u001b[37m\u001b[40m 04:49P | sty. 12\u001b(B\u001b[m\u001b[15;59H\u001b[?12l\u001b[?25h\u001b[15;26r\u001b[15;1H \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \u001b[15;1HREADY > "
],
[
5.8e-05,
"\u001b[1;27r\u001b[15;59H"
],
[
0.051877,
"\u001b[1;13r\u001b[2;1H\u001b[K\r\n\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1;27r\u001b[15;59H"
],
[
5e-05,
"\u001b[2;1HLoaded zsh-users/zsh-autosuggestions\u001b[15;59H"
],
[
0.050697,
"\u001b[1;13r\u001b[2;1H\u001b[K\r\n\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1;27r\u001b[15;59H"
],
[
4.7e-05,
"\u001b[2;1HLoaded zdharma/fast-syntax-highlighting\u001b[15;59H"
],
[
0.23615,
"\u001b[15;26r\u001b[15;59H \u001b[16;59H \u001b[17;59H \u001b[18;59H \u001b[19;59H \u001b[20;59H \u001b[21;59H \u001b[22;59H \u001b[23;59H \u001b[24;59H \u001b[25;59H \u001b[26;59H \u001b[15;59HREADY > \u001b[15;1H\u001b[1;27r\u001b[15;67H"
],
[
4.6e-05,
"\u001b[?2004h"
],
[
0.659458,
"\u001b]0;0:1:zsh-5.4.2-dev-0 - \"MacMini.local\" \u0007\u001b[?25l\u001b[27;1H\u001b[37m\u001b[40m \u001b[42m\u001b[1m1:zsh-5.4.2-dev-0*\u001b(B\u001b[m\u001b[37m\u001b[40m 04:49P | sty. 12\u001b(B\u001b[m\u001b[15;67H\u001b[?12l\u001b[?25h"
],
[
0.019563,
"\r\nLoaded OMZ::lib/git.zsh\u001b[15;9H \u001b[9C"
],
[
0.005679,
"\u001b[15;26r\u001b[16;1H \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \u001b[1;27r\u001b[15;67H"
],
[
4.8e-05,
"\r\nLoaded OMZ::plugins/git\u001b[15;67H"
],
[
0.004594,
"\u001b[15;26r\u001b[16;1H \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \u001b[1;27r\u001b[15;67H"
],
[
4.3e-05,
"\r\nLoaded psprint/zsh-editing-workbench\u001b[15;67H"
],
[
0.004885,
"\u001b[15;26r\u001b[16;1H \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \u001b[1;27r\u001b[15;67H\r\nLoaded psprint/zsh-navigation-tools"
],
[
3.9e-05,
"\u001b[15;67H"
],
[
0.02325,
"\u001b[15;26r\u001b[16;1H \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \u001b[1;27r\u001b[15;67H"
],
[
6e-05,
"\r\nLoaded zdharma/zconvey\u001b[15;67H"
],
[
0.001326,
"\u001b[15;26r\u001b[16;1H \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \u001b[1;27r\u001b[15;67H\r\nLoaded zdharma/zconvey"
],
[
4.6e-05,
"\u001b[15;67H"
],
[
0.003777,
"\u001b[15;26r\u001b[16;1H \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \u001b[1;27r\u001b[15;67H\r\nLoaded zservices/redis"
],
[
0.00036,
"\u001b[15;67H"
],
[
0.003691,
"\u001b[15;26r\u001b[16;1H \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \u001b[1;27r\u001b[15;67H"
],
[
0.000229,
"\r\nLoaded zservices/py3http\u001b[15;67H"
],
[
0.003908,
"\u001b[15;26r\u001b[16;1H \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \u001b[1;27r\u001b[15;67H\r\nLoaded psprint/history-search-multi-word"
],
[
4.3e-05,
"\u001b[15;67H"
],
[
0.010095,
"\u001b[15;26r\u001b[16;1H \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \u001b[1;27r\u001b[15;67H"
],
[
4.7e-05,
"\r\nLoaded zdharma/zui\u001b[15;67H"
],
[
0.254767,
"\u001b[?25l\u001b[32m\u001b[14;1H─────────────────────────────────────────────────────────┬─────────────────────────────────────────────────────────\u001b[39m\u001b[15;58H│\u001b[16;58H│\u001b[17;58H│\u001b[18;58H│\u001b[19;58H│\u001b[20;58H│\u001b[21;58H│\u001b[22;58H│\u001b[23;58H│\u001b[24;58H│\u001b[25;58H│\u001b[26;58H│\u001b(B\u001b[m\u001b[1;9H\u001b[?12l\u001b[?25h"
],
[
0.02438,
"\u001b[16;59HLoaded OMZ::lib/git.zsh\u001b[1;9H"
],
[
0.005976,
"\u001b[15;26r\u001b[16;59H \u001b[17;59H \u001b[18;59H \u001b[19;59H \u001b[20;59H \u001b[21;59H \u001b[22;59H \u001b[23;59H \u001b[24;59H \u001b[25;59H \u001b[26;59H \u001b[26;1H\u001b[1;27r\u001b[1;9H"
],
[
4.9e-05,
"\u001b[16;59HLoaded OMZ::plugins/git\u001b[1;9H"
],
[
0.004685,
"\u001b[15;26r\u001b[16;59H \u001b[17;59H \u001b[18;59H \u001b[19;59H \u001b[20;59H \u001b[21;59H \u001b[22;59H \u001b[23;59H \u001b[24;59H \u001b[25;59H \u001b[26;59H \u001b[26;1H\u001b[1;27r\u001b[1;9H"
],
[
4.5e-05,
"\u001b[16;59HLoaded psprint/zsh-editing-workbench\u001b[1;9H"
],
[
0.007131,
"\u001b[15;26r\u001b[16;59H \u001b[17;59H \u001b[18;59H \u001b[19;59H \u001b[20;59H \u001b[21;59H \u001b[22;59H \u001b[23;59H \u001b[24;59H \u001b[25;59H \u001b[26;59H \u001b[26;1H\u001b[1;27r\u001b[1;9H"
],
[
6.1e-05,
"\u001b[16;59HLoaded psprint/zsh-navigation-tools\u001b[1;9H"
],
[
0.025176,
"\u001b[15;26r\u001b[16;59H \u001b[17;59H \u001b[18;59H \u001b[19;59H \u001b[20;59H \u001b[21;59H \u001b[22;59H \u001b[23;59H \u001b[24;59H \u001b[25;59H \u001b[26;59H \u001b[26;1H\u001b[1;27r\u001b[1;9H"
],
[
5.3e-05,
"\u001b[16;59HLoaded zdharma/zconvey\u001b[1;9H"
],
[
0.000946,
"\u001b[15;26r\u001b[16;59H \u001b[17;59H \u001b[18;59H \u001b[19;59H \u001b[20;59H \u001b[21;59H \u001b[22;59H \u001b[23;59H \u001b[24;59H \u001b[25;59H \u001b[26;59H \u001b[26;1H\u001b[1;27r\u001b[1;9H"
],
[
4.8e-05,
"\u001b[16;59HLoaded zdharma/zconvey\u001b[1;9H"
],
[
0.003046,
"\u001b[15;26r\u001b[16;59H \u001b[17;59H \u001b[18;59H \u001b[19;59H \u001b[20;59H \u001b[21;59H \u001b[22;59H \u001b[23;59H \u001b[24;59H \u001b[25;59H \u001b[26;59H \u001b[26;1H\u001b[1;27r\u001b[1;9H\u001b[16;59HLoaded zservices/redis"
],
[
0.000118,
"\u001b[1;9H"
],
[
0.003187,
"\u001b[15;26r\u001b[16;59H \u001b[17;59H \u001b[18;59H \u001b[19;59H \u001b[20;59H \u001b[21;59H \u001b[22;59H \u001b[23;59H \u001b[24;59H \u001b[25;59H \u001b[26;59H \u001b[26;1H\u001b[1;27r\u001b[1;9H"
],
[
5.1e-05,
"\u001b[16;59HLoaded zservices/py3http\u001b[1;9H"
],
[
0.003496,
"\u001b[15;26r\u001b[16;59H \u001b[17;59H \u001b[18;59H \u001b[19;59H \u001b[20;59H \u001b[21;59H \u001b[22;59H \u001b[23;59H \u001b[24;59H \u001b[25;59H \u001b[26;59H \u001b[26;1H\u001b[1;27r\u001b[1;9H\u001b[16;59HLoaded psprint/history-search-multi-word"
],
[
5e-05,
"\u001b[1;9H"
],
[
0.00757,
"\u001b[15;26r\u001b[16;59H \u001b[17;59H \u001b[18;59H \u001b[19;59H \u001b[20;59H \u001b[21;59H \u001b[22;59H \u001b[23;59H \u001b[24;59H \u001b[25;59H \u001b[26;59H \u001b[26;1H\u001b[1;27r\u001b[1;9H"
],
[
4.9e-05,
"\u001b[16;59HLoaded zdharma/zui\u001b[1;9H"
],
[
0.727548,
"\u001b[15;26r\u001b[16;1H \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \u001b[1;27r\u001b[1;9H"
],
[
4.8e-05,
"\u001b[16;1HLoaded b4b4r07/zsh-vimode-visual\u001b[1;9H"
],
[
0.094027,
"\u001b[15;26r\u001b[16;1H \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \u001b[1;27r\u001b[1;9H\u001b[16;1HLoaded zsh-users/zsh-autosuggestions"
],
[
7.2e-05,
"\u001b[1;9H"
],
[
0.046145,
"\u001b[15;26r\u001b[16;1H \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \u001b[1;27r\u001b[1;9H"
],
[
5e-05,
"\u001b[16;1HLoaded zdharma/fast-syntax-highlighting\u001b[1;9H"
],
[
0.227412,
"\u001b[15;26r\u001b[16;59H \u001b[17;59H \u001b[18;59H \u001b[19;59H \u001b[20;59H \u001b[21;59H \u001b[22;59H \u001b[23;59H \u001b[24;59H \u001b[25;59H \u001b[26;59H \u001b[26;1H\u001b[1;27r\u001b[1;9H"
],
[
5.2e-05,
"\u001b[16;59HLoaded b4b4r07/zsh-vimode-visual\u001b[1;9H"
],
[
0.099524,
"\u001b[15;26r\u001b[16;59H \u001b[17;59H \u001b[18;59H \u001b[19;59H \u001b[20;59H \u001b[21;59H \u001b[22;59H \u001b[23;59H \u001b[24;59H \u001b[25;59H \u001b[26;59H \u001b[26;1H\u001b[1;27r\u001b[1;9H"
],
[
5.8e-05,
"\u001b[16;59HLoaded zsh-users/zsh-autosuggestions\u001b[1;9H"
],
[
0.047877,
"\u001b[15;26r\u001b[16;59H \u001b[17;59H \u001b[18;59H \u001b[19;59H \u001b[20;59H \u001b[21;59H \u001b[22;59H \u001b[23;59H \u001b[24;59H \u001b[25;59H \u001b[26;59H \u001b[26;1H\u001b[1;27r\u001b[1;9H"
],
[
6.6e-05,
"\u001b[16;59HLoaded zdharma/fast-syntax-highlighting\u001b[1;9H"
],
[
0.336777,
"\u001b[31m\u001b[1mz\u001b(B\u001b[m\u001b[90mplg load marzocchi/zsh-notify\u001b[10G\u001b(B\u001b[m"
],
[
0.353158,
"\b\u001b[32mzc\u001b[90m-bg-notify -q Hello, this is a notification \":)\"\u001b[11G\u001b(B\u001b[m"
],
[
0.171715,
"\b\b\u001b[31m\u001b[1mzc-\u001b(B\u001b[m"
],
[
0.392888,
"\b\u001b[31m\u001b[1m-a\u001b(B\u001b[m\u001b[90mll -q MYPROMPT=1; MYPROMPT=1\u001b[39m \u001b[13G"
],
[
0.447268,
"\b\u001b[31m\u001b[1mal\u001b(B\u001b[m"
],
[
0.176337,
"\u001b[5D\u001b[32mzc-all\u001b(B\u001b[m"
],
[
0.513202,
" \u001b[36m-q\u001b[39m MYPROMPT=1; MYPROMPT=1"
],
[
2.001485,
"\u001b[1;13r\u001b[2;1H\u001b[K\r\n\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1;27r\u001b[2;1H\u001b[?2004l"
],
[
0.329241,
"\u001b[1;13r\u001b[2;1H\u001b[K\r\n\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[2d\u001b[33m\u001b[1m16:50\u001b[31m[\u001b(B\u001b[m\u001b[36m/Users/sgniazdowski\u001b[31m\u001b[1m]\u001b[33m2\u001b[32m >: \u001b(B\u001b[m\u001b[K\u001b[1;27r\u001b[2;32H\u001b[?2004h"
],
[
0.34192,
"\u001b[15;67HM\u001b[2;32H"
],
[
0.001778,
"\u001b[15;67HMY\u001b[2;32H"
],
[
0.001328,
"\u001b[15;69HP\u001b[2;32H"
],
[
0.001243,
"\u001b[15;70HR\u001b[2;32H"
],
[
0.001068,
"\u001b[15;71HO\u001b[2;32H"
],
[
0.000939,
"\u001b[15;72HM\u001b[2;32H"
],
[
0.000888,
"\u001b[15;73HP\u001b[2;32H"
],
[
0.001175,
"\u001b[15;74HT\u001b[2;32H"
],
[
0.001819,
"\u001b[15;75H=\u001b[2;32H"
],
[
0.000907,
"\u001b[15;76H1\u001b[2;32H"
],
[
0.001442,
"\u001b[15;77H \u001b[2;32H"
],
[
0.001262,
"\u001b[15;78H#\u001b[2;32H"
],
[
0.001232,
"\u001b[15;79H#\u001b[2;32H"
],
[
0.005286,
"\u001b[15;78H\u001b[30m\u001b[1m##\u001b[2;32H\u001b(B\u001b[m"
],
[
0.001708,
"\u001b[15;26r\u001b[16;59H \u001b[17;59H \u001b[18;59H \u001b[19;59H \u001b[20;59H \u001b[21;59H \u001b[22;59H \u001b[23;59H \u001b[24;59H \u001b[25;59H \u001b[26;59H \u001b[26;1H\u001b[1;27r\u001b[2;32H"
],
[
0.098855,
"\u001b[15;26r\u001b[16;59H \u001b[17;59H \u001b[18;59H \u001b[19;59H \u001b[20;59H \u001b[21;59H \u001b[22;59H \u001b[23;59H \u001b[24;59H \u001b[25;59H \u001b[26;59H \u001b[16;59HREADY > \u001b[16;1H\u001b[1;27r\u001b[2;32H"
],
[
0.497609,
"\u001b[15;9HM\u001b[2;32H"
],
[
0.000927,
"\u001b[15;9HMY\u001b[2;32H"
],
[
0.000844,
"\u001b[15;11HP\u001b[2;32H"
],
[
0.000851,
"\u001b[15;12HR\u001b[2;32H"
],
[
0.000916,
"\u001b[15;13HO\u001b[2;32H"
],
[
0.00082,
"\u001b[15;14HM\u001b[2;32H"
],
[
0.000888,
"\u001b[15;15HP\u001b[2;32H"
],
[
0.000815,
"\u001b[15;16HT\u001b[2;32H"
],
[
0.001318,
"\u001b[15;17H=\u001b[2;32H"
],
[
0.000922,
"\u001b[15;18H1\u001b[2;32H"
],
[
0.001276,
"\u001b[15;19H \u001b[2;32H"
],
[
0.001444,
"\u001b[15;20H#\u001b[2;32H"
],
[
0.001247,
"\u001b[15;21H#\u001b[2;32H"
],
[
0.005696,
"\u001b[15;20H\u001b[30m\u001b[1m##\u001b[2;32H\u001b(B\u001b[m"
],
[
0.001201,
"\u001b[15;26r\u001b[16;1H \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \u001b[1;27r\u001b[2;32H"
],
[
0.089655,
"\u001b[15;26r\u001b[16;1H \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \u001b[16;1HREADY > \u001b[1;27r\u001b[2;32H"
],
[
0.409803,
"\u001b[17;59HLoaded psprint/zprompts\u001b[2;32H"
],
[
0.001048,
"\u001b[15;26r\u001b[16;59H \u001b[17;59H \u001b[18;59H \u001b[19;59H \u001b[20;59H \u001b[21;59H \u001b[22;59H \u001b[23;59H \u001b[24;59H \u001b[25;59H \u001b[26;59H \u001b[16;59H\u001b[33m\u001b[1m16:50\u001b[31m[\u001b(B\u001b[m\u001b[36m/Users/sgniazdowski\u001b[31m\u001b[1m]\u001b[33m30\u001b[32m >: \u001b(B\u001b[m \u001b[16;1H\u001b[1;27r\u001b[2;32H"
],
[
0.608715,
"\u001b[17;1HLoaded psprint/zprompts\u001b[2;32H"
],
[
0.001406,
"\u001b[15;26r\u001b[16;1H \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \u001b[16;1H\u001b[33m\u001b[1m16:50\u001b[31m[\u001b(B\u001b[m\u001b[36m/Users/sgniazdowski\u001b[31m\u001b[1m]\u001b[33m30\u001b[32m >: \u001b(B\u001b[m \u001b[1;27r\u001b[2;32H"
],
[
1.946601,
"\u001b[31m\u001b[1mz\u001b(B\u001b[m\u001b[90mc-all -q MYPROMPT=1; MYPROMPT=1\u001b[31D\u001b(B\u001b[m"
],
[
0.252061,
"\b\u001b[32mzc\u001b(B\u001b[m"
],
[
0.168607,
"\b\b\u001b[31m\u001b[1mzc-\u001b(B\u001b[m"
],
[
0.222523,
"\b\u001b[31m\u001b[1m-b\u001b(B\u001b[m\u001b[90mg-notify -q Hello, this is a notification \":)\"\u001b[36G\u001b(B\u001b[m"
],
[
0.231058,
"\b\u001b[31m\u001b[1mbg\u001b(B\u001b[m"
],
[
1.07916,
"\u001b[5D\u001b[32mzc-bg-notify\u001b[39m \u001b[36m-q\u001b[39m Hello, this is \u001b[35ma\u001b[39m notification \u001b[33m\":)\"\u001b(B\u001b[m"
],
[
2.104492,
"\r\n\u001b[?2004l"
],
[
0.432261,
"\u001b[17;59HNotification: Hello, this is a notification :)\u001b[3;1H"
],
[
0.043479,
"\u001b[1;13r\u001b[3;1H\u001b[K\r\n\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[3d\u001b[33m\u001b[1m16:50\u001b[31m[\u001b(B\u001b[m\u001b[36m/Users/sgniazdowski\u001b[31m\u001b[1m]\u001b[33m3\u001b[32m >: \u001b(B\u001b[m\u001b[K\u001b[1;27r\u001b[3;32H\u001b[?2004h"
],
[
0.572582,
"\u001b[17;1HNotification: Hello, this is a notification :)\u001b[3;32H"
],
[
3.212131,
"\u001b[31m\u001b[1mz\u001b(B\u001b[m\u001b[90mc-bg-notify -q Hello, this is a notification \":)\"\u001b[33G\u001b(B\u001b[m"
],
[
0.24654,
"\b\u001b[31m\u001b[1mzp\u001b(B\u001b[m\u001b[90mlg load marzocchi/zsh-notify\u001b[39m \u001b[34G"
],
[
0.091053,
"\b\b\u001b[32mzpl\u001b(B\u001b[m"
],
[
0.225038,
"\b\u001b[32mlg\u001b(B\u001b[m"
],
[
0.205787,
" "
],
[
0.198544,
"l"
],
[
0.176307,
"o"
],
[
0.128904,
"a"
],
[
0.921396,
"d marzocchi/zsh-notify"
],
[
1.416939,
"\r\n\u001b[?2004l"
],
[
0.206711,
"\u001b[1;13r\u001b[4;1H\u001b[K\r\n\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[4d\u001b[33m\u001b[1m16:50\u001b[31m[\u001b(B\u001b[m\u001b[36m/Users/sgniazdowski\u001b[31m\u001b[1m]\u001b[33m4\u001b[32m >: \u001b(B\u001b[m\u001b[K\u001b[1;27r\u001b[4;32H\u001b[?2004h"
],
[
1.813306,
"\u001b[31m\u001b[1ms\u001b(B\u001b[m\u001b[90mleep 4\u001b[6D\u001b(B\u001b[m"
],
[
0.160502,
"\b\u001b[31m\u001b[1msl\u001b(B\u001b[m"
],
[
0.141742,
"\b\b\u001b[31m\u001b[1msle\u001b(B\u001b[m"
],
[
0.163424,
"\b\u001b[31m\u001b[1mee\u001b(B\u001b[m"
],
[
0.110292,
"\u001b[4D\u001b[32msleep\u001b(B\u001b[m"
],
[
0.666823,
" 4"
],
[
1.410221,
"\r\n\u001b[?2004l"
],
[
0.738788,
"\u001b[?25l\u001b[27d\u001b[37m\u001b[40m \u001b[42m\u001b[1m1:zsh-5.4.2-dev-0*\u001b(B\u001b[m\u001b[37m\u001b[40m 04:50P | sty. 12\u001b(B\u001b[m\u001b[5;1H\u001b[?12l\u001b[?25h"
],
[
0.337715,
"\u001b[?25l\u001b[9B─────────────────────────────────────────────────────────\u001b[32m┬─────────────────────────────────────────────────────────\u001b[15;58H│\u001b[16;58H│\u001b[17;58H│\u001b[18;58H│\u001b[19;58H│\u001b[20;58H│\u001b[21;58H│\u001b[22;58H│\u001b[23;58H│\u001b[24;58H│\u001b[25;58H│\u001b[26;58H│\u001b(B\u001b[m\u001b[16;91H\u001b[?12l\u001b[?25h\u001b[?2004h"
],
[
3.081547,
"\u001b[1;13r\u001b[5;1H\u001b[K\r\n\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[5d\u001b[33m\u001b[1m16:50\u001b[31m[\u001b(B\u001b[m\u001b[36m/Users/sgniazdowski\u001b[31m\u001b[1m]\u001b[33m5\u001b[32m >: \u001b(B\u001b[m\u001b[K\u001b[1;27r\u001b[16;91H"
],
[
1.894473,
"\u001b[15;26r\u001b[17;59H \u001b[18;59H \u001b[19;59H \u001b[20;59H \u001b[21;59H \u001b[22;59H \u001b[23;59H \u001b[24;59H \u001b[25;59H \u001b[26;59H \u001b[26;1H\u001b[1;27r\u001b[17;59H"
],
[
5.3e-05,
"Notification: success - sleep 4\u001b[16;91H"
],
[
0.574054,
"\u001b[15;26r\u001b[17;1H \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \u001b[1;27r\u001b[16;91H"
],
[
0.000113,
"\r\nNotification: success - sleep 4\u001b[16;91H"
],
[
3.057596,
"\u001b[?25l\u001b[32m\u001b[14;1H─────────────────────────────────────────────────────────┬─────────────────────────────────────────────────────────\u001b[39m\u001b[15;58H│\u001b[16;58H│\u001b[17;58H│\u001b[18;58H│\u001b[19;58H│\u001b[20;58H│\u001b[21;58H│\u001b[22;58H│\u001b[23;58H│\u001b[24;58H│\u001b[25;58H│\u001b[26;58H│\u001b(B\u001b[m\u001b[5;32H\u001b[?12l\u001b[?25h"
],
[
0.855259,
"\r\n\u001b[?2004l"
],
[
0.796476,
"\u001b[?25l\u001b[1;58H│\u001b[2;58H│\u001b[3;58H│\u001b[4;58H│\u001b[5;58H│\u001b[6;58H│\u001b[7;58H│\u001b[8;58H│\u001b[9;58H│\u001b[10;58H│\u001b[11;58H│\u001b[12;58H│\u001b[13;58H│\u001b[14;58H│\u001b[32m\u001b[15;58H│\u001b[16;58H│\u001b[17;58H│\u001b[18;58H│\u001b[19;58H│\u001b[20;58H│\u001b[21;58H│\u001b[22;58H│\u001b[23;58H│\u001b[24;58H│\u001b[25;58H│\u001b[26;58H│\u001b(B\u001b[m\u001b[1;57H\u001b[1K\u001b[HREADY > MYPROMPT=1 \u001b[30m\u001b[1m##\u001b(B\u001b[m \u001b[2;57H\u001b[1K\r\u001b[33m\u001b[1m16:50\u001b[31m[\u001b(B\u001b[m\u001b[36m/Users/sgniazdowski\u001b[31m\u001b[1m]\u001b[33m30\u001b[32m >: \r\n\u001b(B\u001b[mNotification: success - sleep 4 \u001b[4;57H\u001b[1K\n\u001b[1K\n\u001b[1K\n\u001b[1K\n\u001b[1K\n\u001b[1K\n\u001b[1K\n\u001b[1K\n\u001b[1K\n\u001b[1K\n\u001b[1K\n\u001b[1K\n\u001b[1K\n\u001b[1K\n\u001b[1K\n\u001b[1K\n\u001b[1K\n\u001b[1K\n\u001b[1K\n\u001b[1K\n\u001b[1K\n\u001b[1K\n\u001b[1K\u001b[1;59HREADY > MYPROMPT=1 \u001b[30m\u001b[1m##\u001b(B\u001b[m \u001b[K\u001b[2;59H\u001b[33m\u001b[1m16:50\u001b[31m[\u001b(B\u001b[m\u001b[36m/Users/sgniazdowski\u001b[31m\u001b[1m]\u001b[33m30\u001b[32m >: \u001b(B\u001b[m\u001b[K\u001b[3;59HNotification: success - sleep 4 \u001b[3;115H\u001b[4;59H\u001b[K\n\u001b[K\n\u001b[K\n\u001b[K\n\u001b[K\n\u001b[K\n\u001b[K\n\u001b[K\n\u001b[K\n\u001b[K\n\u001b[K\n\u001b[K\n\u001b[K\n\u001b[K\n\u001b[K\n\u001b[K\n\u001b[K\n\u001b[K\n\u001b[K\n\u001b[K\n\u001b[K\n\u001b[K\n\u001b[K\r\n\u001b[37m\u001b[40m "
],
[
0.000151,
" \u001b[42m\u001b[1m1:zsh-5.4.2-dev-0*\u001b(B\u001b[m\u001b[37m\u001b[40m 04:50P | sty. 12\u001b(B\u001b[m\u001b[2;91H\u001b[?12l\u001b[?25h\u001b[?2004h"
],
[
0.000322,
"\u001b[1;26r\u001b[2;1H \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n "
],
[
0.000142,
" \r\n \r\n \r\n \r\n \r\n \r\n \r\n \u001b[2;1H\u001b[33m\u001b[1m16:50\u001b[31m[\u001b(B\u001b[m\u001b[36m/Users/sgniazdowski\u001b[31m\u001b[1m]\u001b[33m2\u001b[32m >: \u001b(B\u001b[m\u001b[27C \u001b[3;59H \u001b[4;59H \u001b[5;59H \u001b[6;59H \u001b[7;59H \u001b[8;59H \u001b[9;59H "
],
[
0.000136,
" \u001b[10;59H \u001b[11;59H \u001b[12;59H \u001b[13;59H \u001b[14;59H \u001b[15;59H \u001b[16;59H \u001b[17;59H \u001b[18;59H \u001b[19;59H \u001b[20;59H \u001b[21;59H \u001b[22;59H \u001b[23;59H \u001b[24;59H \u001b[25;59H "
],
[
4.6e-05,
" \u001b[26;59H \u001b[2;59H\u001b[33m\u001b[1m16:50\u001b[31m[\u001b(B\u001b[m\u001b[36m/Users/sgniazdowski\u001b[31m\u001b[1m]\u001b[33m2\u001b[32m >: \u001b[1;27r\u001b[2;90H\u001b(B\u001b[m"
],
[
0.450586,
"\u001b[3;59H\u001b[?2004l"
],
[
0.777972,
"\u001b[?25l\u001b[HREADY > MYPROMPT=1 \u001b[30m\u001b[1m##\u001b(B\u001b[m \u001b[K\r\n\u001b[33m\u001b[1m16:50\u001b[31m[\u001b(B\u001b[m\u001b[36m/Users/sgniazdowski\u001b[31m\u001b[1m]\u001b[33m2\u001b[32m >: \u001b(B\u001b[m \u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[K\r\n\u001b[37m\u001b[40m \u001b[42m\u001b[1m1:zsh-5.4.2-dev-0*\u001b(B\u001b[m\u001b[37m\u001b[40m 04:50P | sty. 12\u001b(B\u001b[m\u001b[2;32H\u001b[?12l\u001b[?25h\u001b[?2004h"
],
[
0.00025,
"\u001b[1;26r\u001b[2;1H\u001b[K\r\n\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[1B\u001b[K\u001b[2d\u001b[33m\u001b[1m16:50\u001b[31m[\u001b(B\u001b[m\u001b[36m/Users/sgniazdowski\u001b[31m\u001b[1m]\u001b[33m2\u001b[32m >: \u001b[1;27r\u001b[2;32H\u001b(B\u001b[m"
],
[
0.373956,
"\r\n\u001b[?2004l"
],
[
0.782026,
"\u001b[1;27r\u001b(B\u001b[m\u001b[?1l\u001b>\u001b[H\u001b[2J\u001b]112\u0007\u001b[?12l\u001b[?25h\u001b[?1000l\u001b[?1002l\u001b[?1006l\u001b[?1005l\u001b[?1049l"
],
[
0.000196,
"[exited]\r\n"
],
[
0.084071,
"\u001b[0m\u001b[27m\u001b[24m\u001b[JREADY > \u001b[K\u001b[?2004h"
],
[
0.836974,
"\u001b[?2004l\r\r\n"
]
]
}

1502
doc/asciicasts/208206.cast Normal file

File diff suppressed because it is too large Load diff

View file

@ -5,7 +5,7 @@
#include <sys/ioctl.h>
#include <sys/types.h>
#ifdef __CYGWIN__
#ifndef TIOCSTI
#define TIOCSTI 0x5412
#endif

View file

@ -210,8 +210,10 @@ static inline __attribute__((const)) int is_power_of_2(unsigned long num)
}
#ifndef HAVE_LOFF_T
#ifndef __CYGWIN__
typedef int64_t loff_t;
#endif
#endif
#if !defined(HAVE_DIRFD) && (!defined(HAVE_DECL_DIRFD) || HAVE_DECL_DIRFD == 0) && defined(HAVE_DIR_DD_FD)
#include <sys/types.h>

73
zc
View file

@ -1,20 +1,21 @@
setopt localoptions extendedglob clobber
function __zconvey_usage_zc() {
pinfo2 "Sends specified commands to given (via ID or NAME) Zsh session"
pinfo "Usage: zc {-i ID}|{-n NAME} [-q|--quiet] [-v|--verbose] [-h|--help] [-a|--ask] COMMAND ARGUMENT ..."
__zconvey_pinfo2 "Sends specified commands to given (via ID or NAME) Zsh session"
__zconvey_pinfo "Usage: zc {-i ID}|{-n NAME} [-q|--quiet] [-v|--verbose] [-h|--help] [-a|--ask] [-r|--raw] COMMAND ARGUMENT ..."
print -- "-h/--help - this message"
print -- "-i ID / --id ID - ID (number) of Zsh session"
print -- "-n NAME / --name NAME - NAME of Zsh session"
print -- "-q/--quiet - don't output status messages"
print -- "-v/--verbose - output more status messages"
print -- "-a/--ask - ask for command (if not provided) and session (etc.)"
print -r -- "-r/--raw - raw input (for scripts) - a quoted string, e.g. ls \\'a\\ dir\\'"
}
local -A opthash
zparseopts -D -A opthash h -help q -quiet v -verbose i: -id: n: -name: a -ask || { __zconvey_usage_zc; return 1; }
zparseopts -D -A opthash h -help q -quiet v -verbose i: -id: n: -name: a -ask r -raw || { __zconvey_usage_zc; return 1; }
integer have_id=0 have_name=0 verbose=0 quiet=0 zshselect=0 ask=0
integer have_id=0 have_name=0 verbose=0 quiet=0 ask=0 raw=0
local id name
# Help
@ -38,28 +39,35 @@ if [ "$ask" = "0" ]; then
[ "$ask_setting" = "yes" ] && ask=1 || ask=0
fi
# VERBOSE, QUIET
# VERBOSE, QUIET, RAW
(( verbose = ${+opthash[-v]} + ${+opthash[--verbose]} ))
(( quiet = ${+opthash[-q]} + ${+opthash[--quiet]} ))
(( raw = ${+opthash[-r]} + ${+opthash[--raw]} ))
if [[ "$have_id" != "0" && "$have_name" != "0" ]]; then
pinfo "Please supply only one of ID (-i) and NAME (-n)"
__zconvey_pinfo "Please supply only one of ID (-i) and NAME (-n)"
return 1
fi
if [[ "$have_id" != "0" && "$id" != <-> ]]; then
pinfo "ID must be numeric, 1..100"
__zconvey_pinfo "ID must be numeric, 1..100"
return 1
fi
local -a args
args=( "${(q)@}" )
local cmd
if (( raw )); then
cmd="${*}"
else
local -a args
args=( "${(q)@}" )
local cmd="${args[*]}"
cmd="${cmd//\\;/;}"
cmd="${cmd//\\&/&}"
cmd="${cmd##[[:space:]]#}"
cmd="${cmd%%[[:space:]]#}"
cmd="${args[*]}"
cmd="${cmd//\\;/;}"
cmd="${cmd//\\|/|}"
cmd="${cmd//\\&/&}"
cmd="${cmd##[[:space:]]#}"
cmd="${cmd%%[[:space:]]#}"
fi
if [[ -z "$cmd" && "$ask" = "0" ]]; then
__zconvey_usage_zc
@ -67,7 +75,7 @@ if [[ -z "$cmd" && "$ask" = "0" ]]; then
fi
if [[ "$have_id" = "0" && "$have_name" = "0" && "$ask" = "0" ]]; then
pinfo "Either supply target ID/NAME or request Zsh-Select (-a/--ask)"
__zconvey_pinfo "Either supply target ID/NAME or request Zsh-Select (-a/--ask)"
return 1
fi
@ -93,7 +101,7 @@ if (( $ask )); then
cmd="${cmd##[[:space:]]#}"
cmd="${cmd%%[[:space:]]#}"
if [ -z "$cmd" ]; then
pinfo "No command enterred, exiting"
__zconvey_pinfo "No command enterred, exiting"
return 0
fi
fi
@ -101,14 +109,14 @@ if (( $ask )); then
# Supply session?
if [[ "$have_id" = "0" && "$have_name" = "0" ]]; then
if ! type zsh-select 2>/dev/null 1>&2; then
pinfo "Zsh-Select not installed, please install it before using -a/--ask, aborting"
pinfo "Example installation: zplugin load psprint/zsh-select"
__zconvey_pinfo "Zsh-Select not installed, please install it before using -a/--ask, aborting"
__zconvey_pinfo "Example installation: zinit load psprint/zsh-select"
return 1
else
export ZSELECT_START_IN_SEARCH_MODE=0
export ZSHSELECT_START_IN_SEARCH_MODE=0
id=`zc-ls | zsh-select`
if [ -z "$id" ]; then
pinfo "No selection, exiting"
__zconvey_pinfo "No selection, exiting"
return 0
else
id="${id//(#b)*ID: ([[:digit:]]#)[^[:digit:]]#*(#e)/$match[1]}"
@ -118,12 +126,12 @@ if (( $ask )); then
fi
if [ -z "$cmd" ]; then
pinfo "No command provided, aborting"
__zconvey_pinfo "No command provided, aborting"
return 1
fi
if [[ "$id" != <-> || "$id" = "0" || "$id" -gt "100" ]]; then
pinfo "Incorrect sesion ID occured: \`$idx'. ID should be in range 1..100"
__zconvey_pinfo "Incorrect sesion ID occured: \`$idx'. ID should be in range 1..100"
return 1
fi
@ -141,13 +149,13 @@ fi
local fd datafile="${ZCONVEY_IO_DIR}/${id}.io"
local lockfile="${datafile}.lock"
echo "PID $$ ID $ZCONVEY_ID is sending command" > "$lockfile"
{ echo "PID $$ ID $ZCONVEY_ID is sending command" >! "$lockfile"; } 2>/dev/null
# 1. Zsh lock with timeout (2 seconds)
if (( ${ZCONVEY_CONFIG[use_zsystem_flock]} > 0 )); then
(( ${verbose} )) && print "Will use zsystem flock..."
if ! zsystem flock -t 2 -f fd "$lockfile"; then
pinfo2 "Communication channel of session $id is busy, could not send"
__zconvey_pinfo2 "Communication channel of session $id is busy, could not send"
return 1
fi
# 2. Provided flock binary (two calls)
@ -160,22 +168,31 @@ else
LANG=C sleep 1
"${ZCONVEY_REPO_DIR}/myflock/flock" -nx "$fd"
if [ "$?" = "101" ]; then
pinfo2 "Communication channel of session $id is busy, could not send"
__zconvey_pinfo2 "Communication channel of session $id is busy, could not send"
return 1
fi
fi
fi
# >> - multiple commands can be accumulated
print -r -- "$ts $cmd" >> "$datafile"
print -r -- "$ts $cmd" >>! "$datafile"
# Release the lock by closing the lock file
exec {fd}>&-
if (( ${quiet} == 0 )); then
pinfo2 "Zconvey successfully sent command to session $id"
__zconvey_get_name_of_id "$id"
if [[ -n "$REPLY" ]]; then
print "Zconvey successfully sent command to \033[1;32msession $id\033[0m (name: \033[1;32m$REPLY\033[0m)"
else
print "Zconvey successfully sent command to \033[1;32msession $id\033[0m"
fi
local busyfile="$ZCONVEY_OTHER_DIR/${id}.busy"
[ -e "$busyfile" ] && print "The session is busy \033[1;33m($(<$busyfile))\033[0m"
[ -e "$busyfile" ] && print "The session is busy \033[1;33m($(<$busyfile))\033[0m (command will time out after ${ZCONVEY_CONFIG[expire_seconds]}s)"
integer is_locked
__zconvey_is_session_active "$id" && is_locked=1 || is_locked=0
(( is_locked == 0 )) && print "The session is ABSENT, the command will probably time out (after ${ZCONVEY_CONFIG[expire_seconds]}s)"
fi
# vim:ft=zsh

100
zc-all Normal file
View file

@ -0,0 +1,100 @@
setopt localoptions extendedglob clobber
integer idx is_locked counter=0
local name busyfile busywith
__zconvey_usage_zc-all() {
__zconvey_pinfo2 "Sends command to all unbusy sessions (also busy when -f passed)"
__zconvey_pinfo "Usage: zc-all [-h|--help] [-f|--force] [-a|--ask] [-q|--quiet] [-v|--verbose] COMMAND ARGUMENT ..."
print -- "-h/--help - this message"
print -- "-q/--quiet - don't output status messages"
print -- "-v/--verbose - output more status messages"
print -- "-a/--ask - ask for command (if not provided)"
print -- "-f/--force - send also to busy sessions; command can time out"
}
local -A opthash
zparseopts -D -A opthash h -help q -quiet v -verbose f -force a -ask || { __zconvey_usage_zc-all; return 1; }
integer verbose=0 quiet=0 force=0 ask=0
# Help
(( ${+opthash[-h]} + ${+opthash[--help]} )) && { __zconvey_usage_zc-all; return 0; }
# ASK (requests command and/or ID)
(( ask = ${+opthash[-a]} + ${+opthash[--ask]} ))
if [ "$ask" = "0" ]; then
local ask_setting
zstyle -b ":plugin:zconvey" ask ask_setting || ask_setting="no"
[ "$ask_setting" = "yes" ] && ask=1 || ask=0
fi
# VERBOSE, QUIET, FORCE
(( verbose = ${+opthash[-v]} + ${+opthash[--verbose]} ))
(( quiet = ${+opthash[-q]} + ${+opthash[--quiet]} ))
(( force = ${+opthash[-f]} + ${+opthash[--force]} ))
local -a args
args=( "${(q)@}" )
local cmd="${args[*]}"
cmd="${cmd//\\;/;}"
cmd="${cmd//\\|/|}"
cmd="${cmd//\\&/&}"
cmd="${cmd##[[:space:]]#}"
cmd="${cmd%%[[:space:]]#}"
# Resupply missing input if requested
if (( $ask )); then
# Supply command?
if [[ -z "$cmd" ]]; then
vared -cp "Enter command to send: " cmd
cmd="${cmd##[[:space:]]#}"
cmd="${cmd%%[[:space:]]#}"
if [ -z "$cmd" ]; then
__zconvey_pinfo "No command enterred, exiting"
return 0
fi
fi
fi
if [ -z "$cmd" ]; then
__zconvey_pinfo "No command provided, aborting"
return 1
fi
for (( idx = 1; idx <= 100; idx ++ )); do
name=""
busywith=""
is_locked=0
__zconvey_is_session_active "$idx" && is_locked=1 || is_locked=0
if (( is_locked )); then
busyfile="$ZCONVEY_OTHER_DIR/${idx}.busy"
if [[ -e "$busyfile" && "$idx" != "$ZCONVEY_ID" ]]; then
busywith="\033[1;33m$(<$busyfile)\033[0m"
__zconvey_get_name_of_id "$idx"
if (( force )); then
counter+=1
(( quiet )) || print "\033[1;35mSending to busy\033[0m session $idx (name: $REPLY, busy with: $busywith)"
zc -qi "$idx" -r "${cmd[@]}"
else
(( quiet )) || print "Session $idx (name: $REPLY) busy ($busywith)"
fi
elif [[ "$idx" != "$ZCONVEY_ID" ]]; then
counter+=1
if (( verbose )); then
zc -i "$idx" -r "${cmd[@]}"
else
zc -qi "$idx" -r "${cmd[@]}"
fi
fi
fi
done
(( quiet )) || __zconvey_pinfo "Sent command to $counter other sessions"
return 0
# vim:ft=zsh

35
zc-logo-all Normal file
View file

@ -0,0 +1,35 @@
setopt localoptions extendedglob clobber
integer idx is_locked counter=0
local busyfile busywith
if [[ "$1" = "-h" || "$1" = "--help" ]]; then
__zconvey_pinfo "Sends zc-logo or zc-id to all terminals (the latter when argument \"text\" is passed)"
return 0
fi
for (( idx = 1; idx <= 100; idx ++ )); do
name=""
busywith=""
is_locked=0
__zconvey_is_session_active "$idx" && is_locked=1 || is_locked=0
if (( is_locked )); then
busyfile="$ZCONVEY_OTHER_DIR/${idx}.busy"
if [[ -e "$busyfile" && "$idx" != "$ZCONVEY_ID" ]]; then
busywith="\033[1;33m$(<$busyfile)\033[0m"
__zconvey_get_name_of_id "$idx"
print "Session $idx (name: $REPLY) busy ($busywith), no logo request for it"
else
counter+=1
[ "$1" = "text" ] && zc -qi "$idx" zc-id || zc -qi "$idx" zc-logo \&\& sleep 18
fi
fi
done
__zconvey_pinfo "Sent logo request to $counter sessions, including this one"
return 0
# vim:ft=zsh

View file

@ -1,8 +1,8 @@
setopt localoptions extendedglob clobber
function __zconvey_usage_zc-rename() {
pinfo2 "Renames current Zsh session, or one given via ID or (old) NAME"
pinfo "Usage: zc-rename [-i ID|-n NAME] [-q|--quiet] [-h|--help] NEW_NAME"
__zconvey_pinfo2 "Renames current Zsh session, or one given via ID or (old) NAME"
__zconvey_pinfo "Usage: zc-rename [-i ID|-n NAME] [-q|--quiet] [-h|--help] NEW_NAME"
print -- "-h/--help - this message"
print -- "-i ID / --id ID - ID (number) of Zsh session"
print -- "-n NAME / --name NAME - NAME of Zsh session"
@ -33,12 +33,12 @@ have_name=$(( ${+opthash[-n]} + ${+opthash[--name]} ))
(( quiet = ${+opthash[-q]} + ${+opthash[--quiet]} ))
if [[ "$have_id" != "0" && "$have_name" != "0" ]]; then
pinfo "Please supply only one of ID (-i) and NAME (-n)"
__zconvey_pinfo "Please supply only one of ID (-i) and NAME (-n)"
return 1
fi
if [[ "$have_id" != "0" && ( "$id" != <-> || "$id" = "0" ) ]]; then
pinfo "ID must be numeric, 1..100"
__zconvey_pinfo "ID must be numeric, 1..100"
return 1
fi
@ -47,7 +47,7 @@ if (( $have_name )); then
__zconvey_resolve_name_to_id "$name"
local resolved="$REPLY"
if [ -z "$resolved" ]; then
pinfo "Could not find session named: \`$name'"
__zconvey_pinfo "Could not find session named: \`$name'"
return 1
fi
@ -60,24 +60,24 @@ fi
__zconvey_resolve_name_to_id "$new_name"
if [ -n "$REPLY" ]; then
pinfo "A session already has target name: \`$new_name' (its ID: $REPLY)"
__zconvey_pinfo "A session already has target name: \`$new_name' (its ID: $REPLY)"
return 1
fi
if [[ "$id" != <-> || "$id" = "0" ]]; then
pinfo "Bad ID ($id), aborting"
__zconvey_pinfo "Bad ID ($id), aborting"
return 1
fi
if [[ "$id" -gt "100" ]]; then
pinfo "Maximum nr of sessions is 100, aborting"
__zconvey_pinfo "Maximum nr of sessions is 100, aborting"
return 1
fi
print ":$new_name:" > "$ZCONVEY_NAMES_DIR"/"$id".name
if (( ${quiet} == 0 )); then
pinfo2 "Renamed session $id to: $new_name"
__zconvey_pinfo2 "Renamed session $id to: $new_name"
fi
local ls_after_rename

18
zc-take
View file

@ -1,9 +1,9 @@
setopt localoptions extendedglob clobber
function __zconvey_usage_zc-take() {
pinfo2 "Takes a name for current Zsh session, i.e. takes it away from any other session if needed"
pinfo2 "You can take a name for other session (not the current one) if -i or -n is provided"
pinfo "Usage: zc-take [-i ID|-n NAME] [-q|--quiet] [-h|--help] NEW_NAME"
__zconvey_pinfo2 "Takes a name for current Zsh session, i.e. takes it away from any other session if needed"
__zconvey_pinfo2 "You can take a name for other session (not the current one) if -i or -n is provided"
__zconvey_pinfo "Usage: zc-take [-i ID|-n NAME] [-q|--quiet] [-h|--help] NEW_NAME"
print -- "-h/--help - this message"
print -- "-i ID / --id ID - ID (number) of Zsh session"
print -- "-n NAME / --name NAME - NAME of Zsh session"
@ -34,12 +34,12 @@ have_name=$(( ${+opthash[-n]} + ${+opthash[--name]} ))
(( quiet = ${+opthash[-q]} + ${+opthash[--quiet]} ))
if [[ "$have_id" != "0" && "$have_name" != "0" ]]; then
pinfo "Please supply only one of ID (-i) and NAME (-n)"
__zconvey_pinfo "Please supply only one of ID (-i) and NAME (-n)"
return 1
fi
if [[ "$have_id" != "0" && ( "$id" != <-> || "$id" = "0" ) ]]; then
pinfo "ID must be numeric, 1..100"
__zconvey_pinfo "ID must be numeric, 1..100"
return 1
fi
@ -60,12 +60,12 @@ elif (( $have_id == 0 )); then
fi
if [[ "$id" != <-> || "$id" = "0" ]]; then
pinfo "Bad ID ($id), aborting"
__zconvey_pinfo "Bad ID ($id), aborting"
return 1
fi
if [[ "$id" -gt "100" ]]; then
pinfo "Maximum nr of sessions is 100, aborting"
__zconvey_pinfo "Maximum nr of sessions is 100, aborting"
return 1
fi
@ -87,7 +87,7 @@ if [ -n "$other_id" ]; then
# it to the initial conflicting session $new_name
print ":$subst_name:" > "$ZCONVEY_NAMES_DIR"/"$other_id".name
(( ${quiet} == 0 )) && pinfo "Pre-rename: $new_name -> $subst_name"
(( ${quiet} == 0 )) && __zconvey_pinfo "Pre-rename: $new_name -> $subst_name"
break
fi
@ -97,7 +97,7 @@ fi
print ":$new_name:" > "$ZCONVEY_NAMES_DIR"/"$id".name
if (( ${quiet} == 0 )); then
pinfo2 "Renamed session $id to: $new_name"
__zconvey_pinfo2 "Renamed session $id to: $new_name"
fi
local ls_after_rename

View file

@ -5,49 +5,54 @@
# to ~/.zshrc.
#
0="${(%):-%N}" # this gives immunity to functionargzero being unset
ZCONVEY_REPO_DIR="${0%/*}"
ZCONVEY_CONFIG_DIR="$HOME/.config/zconvey"
# According to the standard:
# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
0="${${(M)0:#/*}:-$PWD/$0}"
typeset -gx ZCONVEY_REPO_DIR="${0:h}"
typeset -gx ZCONVEY_CONFIG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/zconvey"
#
# Update FPATH if:
# 1. Not loading with Zplugin
# 2. Not having fpath already updated (that would equal: using other plugin manager)
# 1. Not loading with a plugin manager
# 2. Not having fpath already updated
#
if [[ -z "$ZPLG_CUR_PLUGIN" && "${fpath[(r)$ZCONVEY_REPO_DIR]}" != $ZCONVEY_REPO_DIR ]]; then
fpath+=( "$ZCONVEY_REPO_DIR" )
if [[ ${zsh_loaded_plugins[-1]} != */zconvey && -z ${fpath[(r)${0:h}]} ]]
then
fpath+=( "${0:h}" )
fi
#
# Autoloads
#
autoload zc zc-rename zc-take zc-ls zc-logo
autoload zc zc-rename zc-take zc-ls zc-logo zc-logo-all zc-all
#
# Global variables
#
typeset -gi ZCONVEY_ID
typeset -ghH ZCONVEY_FD
typeset -ghH ZCONVEY_IO_DIR="${ZCONVEY_CONFIG_DIR}/io"
typeset -ghH ZCONVEY_LOCKS_DIR="${ZCONVEY_CONFIG_DIR}/locks"
typeset -ghH ZCONVEY_NAMES_DIR="${ZCONVEY_CONFIG_DIR}/names"
typeset -ghH ZCONVEY_OTHER_DIR="${ZCONVEY_CONFIG_DIR}/other"
typeset -ghH ZCONVEY_RUN_SECONDS=$(( SECONDS + 4 ))
typeset -ghH ZCONVEY_SCHEDULE_ORIGIN
typeset -gH ZCONVEY_FD
typeset -gxH ZCONVEY_IO_DIR="${ZCONVEY_CONFIG_DIR}/io"
typeset -gxH ZCONVEY_LOCKS_DIR="${ZCONVEY_CONFIG_DIR}/locks"
typeset -gxH ZCONVEY_NAMES_DIR="${ZCONVEY_CONFIG_DIR}/names"
typeset -gxH ZCONVEY_OTHER_DIR="${ZCONVEY_CONFIG_DIR}/other"
typeset -gH ZCONVEY_RUN_SECONDS=$(( SECONDS + 4 ))
typeset -gH ZCONVEY_SCHEDULE_ORIGIN
typeset -gHa ZCONVEY_NNS
command mkdir -p "$ZCONVEY_IO_DIR" "$ZCONVEY_LOCKS_DIR" "$ZCONVEY_NAMES_DIR" "$ZCONVEY_OTHER_DIR"
#
# Helper functions
#
function pinfo() {
print -- "\033[1;32m$*\033[0m";
function __zconvey_pinfo() {
print -- "\033[0;32m$*\033[0m";
}
function pinfo2() {
print -- "\033[1;33m$*\033[0m";
function __zconvey_pinfo2() {
print -- "\033[0;33m$*\033[0m";
}
function __zconvey_resolve_name_to_id() {
@ -59,7 +64,7 @@ function __zconvey_resolve_name_to_id() {
for f in "$ZCONVEY_NAMES_DIR"/*.name(N); do
arr=( ${(@f)"$(<$f)"} )
arr=( "${(@M)arr:#:$name:}" )
if [ "${#arr}" != "0" ]; then
if [[ "${#arr}" != "0" ]]; then
REPLY="${${f:t}%.name}"
fi
done
@ -70,42 +75,53 @@ function __zconvey_get_name_of_id() {
REPLY=""
local f="$ZCONVEY_NAMES_DIR/${id}.name"
if [ -e "$f" ]; then
if [[ -e "$f" ]]; then
REPLY=${(f)"$(<$f)"}
REPLY="${REPLY#:}"
REPLY="${REPLY%:}"
return 0
fi
return 1
}
function __zconvey_is_session_active() {
setopt localoptions extendedglob
local idx="$1"
local res idx="$1"
if [[ "$idx" != <-> || "$idx" = "0" || "$idx" -gt "100" ]]; then
pinfo "Incorrect sesion ID occured: $idx"
__zconvey_pinfo "Incorrect sesion ID occured: $idx"
return 2
fi
if [[ "$idx" = "$ZCONVEY_ID" ]]; then
# Return true - current session is active
return 0;
fi
integer is_locked=0
local idfile="$ZCONVEY_LOCKS_DIR/zsh_nr${idx}" tmpfd
if [ -e "$idfile" ]; then
if [[ -e "$idfile" ]]; then
# Use zsystem only if non-blocking call is available (Zsh >= 5.3)
if [ "${ZCONVEY_CONFIG[use_zsystem_flock]}" = "1" ]; then
zsystem flock -t 0 -f tmpfd "$idfile"
if [[ "${ZCONVEY_CONFIG[use_zsystem_flock]}" = "1" ]]; then
zsystem 2>/dev/null flock -t 0 -f tmpfd "$idfile"
res="$?"
else
exec {tmpfd}>"$idfile"
"${ZCONVEY_REPO_DIR}/myflock/flock" -nx "$tmpfd"
res="$?"
# Close the fd immediately - unlocking if gained lock
exec {tmpfd}>&-
fi
if [[ "$res" = "101" || "$res" = "1" || "$res" = "2" ]]; then
is_locked=1
elif [[ "${ZCONVEY_CONFIG[use_zsystem_flock]}" = "1" ]]; then
# Close the lock immediately
zsystem flock -u "$tmpfd"
fi
# Close the lock immediately
[ "${ZCONVEY_CONFIG[use_zsystem_flock]}" = "1" ] && zsystem flock -u "$tmpfd" || exec {tmpfd}>&-
fi
return $(( 1-is_locked ))
@ -117,49 +133,13 @@ function __zconvey_is_session_active() {
function zc-id() {
__zconvey_get_name_of_id "$ZCONVEY_ID"
if [ -z "$REPLY" ]; then
if [[ -z "$REPLY" ]]; then
print "This Zshell's ID: \033[1;33m<${ZCONVEY_ID}>\033[0m (no name assigned)";
else
print "This Zshell's ID: \033[1;33m<${ZCONVEY_ID}>\033[0m, name: \033[1;33m${REPLY}\033[0m";
fi
}
function zc-logo-all() {
setopt localoptions extendedglob clobber
integer idx is_locked counter=0
local busyfile busywith
if [[ "$1" = "-h" || "$1" = "--help" ]]; then
pinfo "Sends zc-logo or zc-id to all terminals (the latter when argument \"text\" is passed)"
return 0
fi
for (( idx = 1; idx <= 100; idx ++ )); do
name=""
busywith=""
is_locked=0
__zconvey_is_session_active "$idx" && is_locked=1 || is_locked=0
if (( is_locked )); then
busyfile="$ZCONVEY_OTHER_DIR/${idx}.busy"
if [[ -e "$busyfile" && "$idx" != "$ZCONVEY_ID" ]]; then
busywith="\033[1;33m$(<$busyfile)\033[0m"
__zconvey_get_name_of_id "$idx"
print "Session $idx (name: $REPLY) busy ($busywith), no logo request for it"
else
counter+=1
[ "$1" = "text" ] && zc -qi "$idx" zc-id || zc -qi "$idx" zc-logo \&\& sleep 18
fi
fi
done
pinfo "Sent logo request to $counter sessions, including this one"
return 0
}
#
# Load configuration
#
@ -174,12 +154,12 @@ function zc-logo-all() {
ZCONVEY_CONFIG[check_interval]="$check_interval"
local use_zsystem_flock
zstyle -b ":plugin:zconvey" use_zsystem_flock use_zsystem_flock || use_zsystem_flock="yes"
[ "$use_zsystem_flock" = "yes" ] && use_zsystem_flock="1" || use_zsystem_flock="0"
zstyle -T ":plugin:zuid" use_zsystem_flock && use_zsystem_flock="yes"
[[ "$use_zsystem_flock" = "yes" ]] && use_zsystem_flock="1" || use_zsystem_flock="0"
ZCONVEY_CONFIG[use_zsystem_flock]="$use_zsystem_flock"
local greeting
zstyle -s ":plugin:zconvey" greeting greeting || greeting="logo"
zstyle -s ":plugin:zconvey" greeting greeting || greeting="text"
[[ "$greeting" != "none" && "$greeting" != "text" && "$greeting" != "logo" ]] && greeting="logo"
ZCONVEY_CONFIG[greeting]="$greeting"
@ -206,23 +186,44 @@ function zc-logo-all() {
# Binary flock command that supports 0 second timeout (zsystem's
# flock in Zsh ver. < 5.3 doesn't) - util-linux/flock stripped
# of some things, compiles hopefully everywhere (tested on OS X,
# Linux).
if [ ! -e "${ZCONVEY_REPO_DIR}/myflock/flock" ]; then
echo "\033[1;35m""psprint\033[0m/\033[1;33m""zconvey\033[0m is building small locking command for you..."
make -C "${ZCONVEY_REPO_DIR}/myflock"
# Linux, FreeBSD).
if [[ ! -e "${ZCONVEY_REPO_DIR}/myflock/flock" && ! -e "${ZCONVEY_REPO_DIR}/myflock/flock.exe" ]]; then
(
if zmodload zsh/system 2>/dev/null; then
if zsystem flock -t 1 "${ZCONVEY_REPO_DIR}/myflock/LICENSE"; then
{
echo "\033[1;35m""zdharma\033[0m/\033[1;33m""zconvey\033[0m is building small locking command for you..."
make -C "${ZCONVEY_REPO_DIR}/myflock"
} &>/dev/null
fi
else
make -C "${ZCONVEY_REPO_DIR}/myflock"
fi
)
fi
# A command that feeds data to command line, via TIOCSTI ioctl
if [ ! -e "${ZCONVEY_REPO_DIR}/feeder/feeder" ]; then
echo "\033[1;35m""psprint\033[0m/\033[1;33m""zconvey\033[0m is building small command line feeder for you..."
make -C "${ZCONVEY_REPO_DIR}/feeder"
if [[ ! -e "${ZCONVEY_REPO_DIR}/feeder/feeder" ]]; then
(
if zmodload zsh/system 2>/dev/null; then
if zsystem flock -t 1 "${ZCONVEY_REPO_DIR}/myflock/LICENSE"; then
{
echo "\033[1;35m""zdharma\033[0m/\033[1;33m""zconvey\033[0m is building small command line feeder for you..."
make -C "${ZCONVEY_REPO_DIR}/feeder"
} &>/dev/null
fi
else
make -C "${ZCONVEY_REPO_DIR}/feeder"
fi
)
fi
#
# Acquire ID
#
if [ "${ZCONVEY_CONFIG[use_zsystem_flock]}" = "1" ]; then
if [[ "${ZCONVEY_CONFIG[use_zsystem_flock]}" = "1" ]]; then
autoload is-at-least
if ! is-at-least 5.3; then
# Use, but not for acquire
@ -268,12 +269,12 @@ fi
[[ "$try_id" = "0" ]] && continue
lockfile="${ZCONVEY_LOCKS_DIR}/zsh_nr${try_id}"
echo "Lock done by Zsh (PID $$)" > "$lockfile"
[[ ! -f "$lockfile" ]] && echo "(created)" >! "$lockfile"
# Use zsystem only if non-blocking call is available (Zsh >= 5.3)
# -e: preserve file descriptor on exec
if [ "${ZCONVEY_CONFIG[use_zsystem_flock]}" = "1" ]; then
zsystem flock -t 0 -f ZCONVEY_FD -e "$lockfile"
if [[ "${ZCONVEY_CONFIG[use_zsystem_flock]}" = "1" ]]; then
zsystem 2>/dev/null flock -t 0 -f ZCONVEY_FD -e "$lockfile"
res="$?"
else
exec {ZCONVEY_FD}>"$lockfile"
@ -282,7 +283,7 @@ fi
fi
if [[ "$res" = "101" || "$res" = "1" || "$res" = "2" ]]; then
[ "${ZCONVEY_CONFIG[use_zsystem_flock]}" != "1" ] && exec {ZCONVEY_FD}>&-
[[ "${ZCONVEY_CONFIG[use_zsystem_flock]}" != "1" ]] && exec {ZCONVEY_FD}>&-
# Is this the special case, i.e. inherition of ZCONVEY_ID?
# In this case being unable to lock means: we already have
@ -305,7 +306,7 @@ fi
# We will not be able to quick-close FD on zshexit
ZCONVEY_FD=0
else
ZCONVEY_ID=try_id
ZCONVEY_ID=$try_id
# ID and FD will be inherited by subshells and exec zsh calls
export ZCONVEY_ID
export ZCONVEY_FD
@ -314,9 +315,16 @@ fi
fi
done
# Output PID to the locked file. The problem is
# with Zsh 5.3, 5.3.1 - zsystem's obtained file
# descriptors cannot be written to
[[ "$ZCONVEY_FD" -ne "0" ]] && { echo "$$" >&${ZCONVEY_FD} } 2>/dev/null
command rm -f "$ZCONVEY_OTHER_DIR/${ZCONVEY_ID}.busy"
# Show what is resolved (ID and possibly a NAME)
[ "$ZCONVEY_CONFIG[greeting]" = "logo" ] && zc-logo echo
[ "$ZCONVEY_CONFIG[greeting]" = "text" ] && zc-id
[[ "$ZCONVEY_CONFIG[greeting]" = "logo" ]] && zc-logo echo
[[ "$ZCONVEY_CONFIG[greeting]" = "text" ]] && zc-id
}
#
@ -337,6 +345,7 @@ zle -N __zconvey_zle_paster
#
function __zconvey_on_period_passed() {
integer __ret=$?
# Reschedule as quickly as possible - user might
# press Ctrl-C when function is executing
#
@ -346,7 +355,7 @@ function __zconvey_on_period_passed() {
# ..and block Ctrl-C, this function will not
# stall, no reason for someone to use Ctrl-C
setopt localtraps; trap '' INT
setopt localtraps; trap '' 2
setopt localoptions extendedglob clobber
# Remember when the command was run to detect a possible
@ -357,13 +366,13 @@ function __zconvey_on_period_passed() {
local lockfile="${datafile}.lock"
# Quick return when no data
[ ! -e "$datafile" ] && return 1
[[ ! -e "$datafile" ]] && return $__ret
# Prepare the lock file, follows locking it
echo "PID $$ ID $ZCONVEY_ID is reading commands" > "$lockfile"
echo "PID $$ ID $ZCONVEY_ID is reading commands" >! "$lockfile"
# 1. Zsh 5.3 flock that supports timeout 0 (i.e. can be non-blocking)
if [ "${ZCONVEY_CONFIG[use_zsystem_flock]}" = "1" ]; then
if [[ "${ZCONVEY_CONFIG[use_zsystem_flock]}" = "1" ]]; then
if ! zsystem flock -t 0 -f fd "$lockfile"; then
LANG=C sleep 0.11
if ! zsystem flock -t 0 -f fd "$lockfile"; then
@ -373,34 +382,34 @@ function __zconvey_on_period_passed() {
# Waited too long, lock must be broken, remove it
command rm -f "$lockfile"
# Will handle this input at next call
return 1
return $__ret
fi
fi
fi
# 2. Zsh < 5.3 flock that isn't non-blocking
elif [ "${ZCONVEY_CONFIG[use_zsystem_flock]}" = "2" ]; then
elif [[ "${ZCONVEY_CONFIG[use_zsystem_flock]}" = "2" ]]; then
if ! zsystem flock -t 1 -f fd "$lockfile"; then
# Waited too long, lock must be broken, remove it
command rm -f "$lockfile"
# Will handle this input at next call
return 1
return $__ret
fi
# 3. Provided flock binary
else
exec {fd}>"$lockfile"
"${ZCONVEY_REPO_DIR}/myflock/flock" -nx "$fd"
if [ "$?" = "101" ]; then
if [[ "$?" = "101" ]]; then
LANG=C sleep 0.11
"${ZCONVEY_REPO_DIR}/myflock/flock" -nx "$fd"
if [ "$?" = "101" ]; then
if [[ "$?" = "101" ]]; then
# Examine the situation by waiting long
sleep 1
"${ZCONVEY_REPO_DIR}/myflock/flock" -nx "$fd"
if [ "$?" = "101" ]; then
if [[ "$?" = "101" ]]; then
# Waited too long, lock must be broken, remove it
command rm -f "$lockfile"
# Will handle this input at next call
return 1
return $__ret
fi
fi
fi
@ -413,9 +422,9 @@ function __zconvey_on_period_passed() {
# Obtain current time stamp
local ts
if [ "$ZCONVEY_CONFIG[timestamp_from]" = "datetime" ]; then
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
[[ "${+modules}" = 0 ]] && zmodload zsh/datetime
ts="$EPOCHSECONDS"
fi
# Also a fallback
@ -428,29 +437,40 @@ function __zconvey_on_period_passed() {
local line cmdts concat_command=""
for line in "${commands[@]}"; do
cmdts="${line%% *}"
concat_command+="; ${line#* }"
concat_command+="; ${(Q)line#* }"
done
concat_command="${concat_command#; }"
[[ -o interactive_comments ]] && concat_command+=" ##"
integer notify=0
if [[ "$cmdts" = n* ]]; then
notify=1
cmdts="${cmdts#n}"
fi
# TODO: a message that command expired
if (( ts - cmdts <= ZCONVEY_CONFIG[expire_seconds] )); then
# Two available methods of outputting the command
if [ "${ZCONVEY_CONFIG[output_method]}" = "zsh" ]; then
if zle; then
zle __zconvey_zle_paster "$concat_command"
else
print -zr "$concat_command"
fi
if (( notify )); then
ZCONVEY_NNS[1,0]="Notification: $concat_command"
zle && { zle -M "${(pj:\n:)ZCONVEY_NNS}"; }
else
"${ZCONVEY_REPO_DIR}/feeder/feeder" "$concat_command"
[[ -o interactive_comments ]] && concat_command+=" ##"
# Two available methods of outputting the command
if [[ "${ZCONVEY_CONFIG[output_method]}" = "zsh" ]]; then
if zle; then
zle __zconvey_zle_paster "$concat_command"
else
print -zr "$concat_command"
fi
else
"${ZCONVEY_REPO_DIR}/feeder/feeder" "$concat_command"
fi
fi
fi
# Tried: zle .kill-word, .backward-kill-line, .backward-kill-word,
# .kill-line, .vi-kill-line, .kill-buffer, .kill-whole-line
return 0
return $__ret
}
#
@ -471,15 +491,18 @@ __zconvey_preexec_hook() {
# scheduling sequence will be quickly eradicated
ZCONVEY_SCHEDULE_ORIGIN="$SECONDS"
sched +"${ZCONVEY_CONFIG[check_interval]}" __zconvey_on_period_passed "$ZCONVEY_SCHEDULE_ORIGIN"
#__zconvey_pinfo "Failure in reschedule detected ${zsh_scheduled_events[*]}"
fi
# Mark that the shell is busy
print -r -- "${1[(w)1]}" >! "$ZCONVEY_OTHER_DIR/${ZCONVEY_ID}.busy"
print -r -- "$1" >! "$ZCONVEY_OTHER_DIR/${ZCONVEY_ID}.busy"
}
# A hook marking the shell as not busy
__zconvey_precmd_hook() {
command rm -f "$ZCONVEY_OTHER_DIR/${ZCONVEY_ID}.busy"
ZCONVEY_NNS=()
}
#
@ -489,7 +512,7 @@ __zconvey_precmd_hook() {
# Not called ideally at say SIGTERM, but
# at least when "exit" is enterred
function __zconvey_zshexit() {
[[ "$ZCONVEY_FD" != "0" && "$SHLVL" = "1" ]] && exec {ZCONVEY_FD}>&-
[[ "$ZCONVEY_FD" != "0" && "$SHLVL" = "1" ]] && { exec {ZCONVEY_FD}>&- ; } 2>/dev/null
}
if ! type sched 2>/dev/null 1>&2; then