Compare commits

..

91 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
Sebastian Gniazdowski 211c5153ed Updated README.md 2016-09-14 07:24:02 +02:00
Sebastian Gniazdowski 0326d30cf1 Increase distance between id-logo-all busy time and expire_seconds 2016-09-14 07:04:54 +02:00
Sebastian Gniazdowski 9981906c22 investig.txt: no change to myflock has been done, reformulate sentences 2016-09-14 07:02:29 +02:00
Sebastian Gniazdowski c78adec4ed Vim modeline for the plugin.zsh file 2016-09-13 22:12:19 +02:00
Sebastian Gniazdowski 3b46453d48 Extract zc-logo into autoloaded function 2016-09-13 22:11:50 +02:00
Sebastian Gniazdowski 4a17b6d4bc Extract zc-ls into autoloaded function 2016-09-13 22:09:30 +02:00
Sebastian Gniazdowski cae26c16a6 Extract zc-take into autoloaded function 2016-09-13 20:00:14 +02:00
Sebastian Gniazdowski 75da44bdb4 Extract zc-rename into autoloaded function 2016-09-13 19:55:38 +02:00
Sebastian Gniazdowski bfca5b534a Use syntax acceptable by Zsh 5.0.2 (in general grepping with M flag) 2016-09-13 19:49:23 +02:00
Sebastian Gniazdowski ff0874fd35 Extract zc into autoloaded function 2016-09-13 19:44:29 +02:00
Sebastian Gniazdowski e73b6b7205 Updated README.md (language) 2016-09-13 18:54:18 +02:00
Sebastian Gniazdowski f210caccb7 Updated README.md (quoting of command names) 2016-09-13 18:52:41 +02:00
Sebastian Gniazdowski 65e0951f8d Updated README.md 2016-09-13 18:51:53 +02:00
Sebastian Gniazdowski 45c430b523 Updated README.md 2016-09-13 18:39:53 +02:00
Sebastian Gniazdowski 8f54a5100e Properly send zc-logo \&\& sleep 20 in zc-logo-all 2016-09-13 18:32:34 +02:00
Sebastian Gniazdowski d48f3bad63 Don't quote & characters in command 2016-09-13 18:25:32 +02:00
Sebastian Gniazdowski 6f27c2df13 First attempt of correctly quoting command before send 2016-09-13 18:20:44 +02:00
Sebastian Gniazdowski 70c6de63fe __convey* -> __zconvey* 2016-09-13 18:13:01 +02:00
Sebastian Gniazdowski 6690f1d9d4 Updated README.md 2016-09-13 18:02:47 +02:00
Sebastian Gniazdowski 176688197f Updated README.md – installation instructions 2016-09-13 18:01:08 +02:00
Sebastian Gniazdowski 844a43f3a6 Other method "zsh" of command output. "feeder" is the default. Zstyle 2016-09-13 17:44:26 +02:00
Sebastian Gniazdowski 6f577abbca More panic-like rescheduling, run timestamp updated after disabling INT
This way it's more likely that one presses Ctrl-C after rescheduling,
and before timestamp update, and preexec rescheduling protection will
be activated. But let it be that way, we choose to strive for command
execution in doubtful situations.
2016-09-13 17:12:27 +02:00
24 changed files with 3685 additions and 591 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/

140
README.md
View file

@ -1,21 +1,133 @@
## 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 -->
[![asciicast](https://asciinema.org/a/ayklrum7g4ut2hpt7mg6j0nzj.png)](https://asciinema.org/a/ayklrum7g4ut2hpt7mg6j0nzj)
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
## Zstyles
**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
The values being set are the defaults.
- [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 "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" 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
**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
```
to `zshrc`.
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.
## [Zinit](https://github.com/zdharma-continuum/zinit)
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`.
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`:
```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
```
## 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`
1. `git clone git@github.com:zdharma-continuum/zconvey.git`
1. Add `zconvey` to your plugin list
## Zgen
Add `zgen load zdharma-continuum/zconvey` to your .zshrc file in the same place you're doing your other `zgen load`
calls in.
# 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` (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

@ -4,11 +4,14 @@ 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" 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)
# (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
zstyle ":plugin:zconvey" timestamp_from "datetime" # Use zsh/datetime module for obtaining timestamp. "date" use date command (fork)
```

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>

View file

@ -2,7 +2,7 @@
=== THE SAME SHELL - THE SAME BEHAVIOR ===
==========================================
Original flock had behavior:~
Flock has behavior:~
% exec {MY}<test.txt
% ~/github/zconvey.git/myflock/flock -nx "${MY}" ; echo $?
@ -21,7 +21,7 @@ Zsh has behavior:~
=== NEW SUBSHELL - THE SAME BEHAVIOR ===
========================================
Original flock had behavior:~
Flock has behavior:~
% exec {MY}<test.txt
% ~/github/zconvey.git/myflock/flock -nx "${MY}" ; echo $?
@ -43,7 +43,7 @@ Zsh has behavior:~
=== EXEC ZSH - DIFFERENT BEHAVIOR ===
=====================================
Original flock had behavior:
Flock has behavior:
% exec {MY}<test.txt
% ~/github/zconvey.git/myflock/flock -nx "${MY}" ; echo $?

198
zc Normal file
View file

@ -0,0 +1,198 @@
setopt localoptions extendedglob clobber
function __zconvey_usage_zc() {
__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 r -raw || { __zconvey_usage_zc; return 1; }
integer have_id=0 have_name=0 verbose=0 quiet=0 ask=0 raw=0
local id name
# Help
(( ${+opthash[-h]} + ${+opthash[--help]} )) && { __zconvey_usage_zc; return 0; }
# ID
have_id=$(( ${+opthash[-i]} + ${+opthash[--id]} ))
(( ${+opthash[-i]} )) && id="${opthash[-i]}"
(( ${+opthash[--id]} )) && id="${opthash[--id]}"
# NAME
have_name=$(( ${+opthash[-n]} + ${+opthash[--name]} ))
(( ${+opthash[-n]} )) && name="${opthash[-n]}"
(( ${+opthash[--name]} )) && name="${opthash[--name]}"
# 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, RAW
(( verbose = ${+opthash[-v]} + ${+opthash[--verbose]} ))
(( quiet = ${+opthash[-q]} + ${+opthash[--quiet]} ))
(( raw = ${+opthash[-r]} + ${+opthash[--raw]} ))
if [[ "$have_id" != "0" && "$have_name" != "0" ]]; then
__zconvey_pinfo "Please supply only one of ID (-i) and NAME (-n)"
return 1
fi
if [[ "$have_id" != "0" && "$id" != <-> ]]; then
__zconvey_pinfo "ID must be numeric, 1..100"
return 1
fi
local cmd
if (( raw )); then
cmd="${*}"
else
local -a args
args=( "${(q)@}" )
cmd="${args[*]}"
cmd="${cmd//\\;/;}"
cmd="${cmd//\\|/|}"
cmd="${cmd//\\&/&}"
cmd="${cmd##[[:space:]]#}"
cmd="${cmd%%[[:space:]]#}"
fi
if [[ -z "$cmd" && "$ask" = "0" ]]; then
__zconvey_usage_zc
return 1
fi
if [[ "$have_id" = "0" && "$have_name" = "0" && "$ask" = "0" ]]; then
__zconvey_pinfo "Either supply target ID/NAME or request Zsh-Select (-a/--ask)"
return 1
fi
# Resolve name
if (( $have_name )); then
__zconvey_resolve_name_to_id "$name"
local resolved="$REPLY"
if [ -z "$resolved" ]; then
echo "Could not find session named: \`$name'"
return 1
fi
# Store the resolved ID and continue normally,
# with ID as the main specifier of session
id="$resolved"
fi
# 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
# Supply session?
if [[ "$have_id" = "0" && "$have_name" = "0" ]]; then
if ! type zsh-select 2>/dev/null 1>&2; then
__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 ZSHSELECT_START_IN_SEARCH_MODE=0
id=`zc-ls | zsh-select`
if [ -z "$id" ]; then
__zconvey_pinfo "No selection, exiting"
return 0
else
id="${id//(#b)*ID: ([[:digit:]]#)[^[:digit:]]#*(#e)/$match[1]}"
fi
fi
fi
fi
if [ -z "$cmd" ]; then
__zconvey_pinfo "No command provided, aborting"
return 1
fi
if [[ "$id" != <-> || "$id" = "0" || "$id" -gt "100" ]]; then
__zconvey_pinfo "Incorrect sesion ID occured: \`$idx'. ID should be in range 1..100"
return 1
fi
# 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
local fd datafile="${ZCONVEY_IO_DIR}/${id}.io"
local lockfile="${datafile}.lock"
{ 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
__zconvey_pinfo2 "Communication channel of session $id is busy, could not send"
return 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"
return 1
fi
fi
fi
# >> - multiple commands can be accumulated
print -r -- "$ts $cmd" >>! "$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 "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 (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

36
zc-logo Normal file
View file

@ -0,0 +1,36 @@
# Prints a graphical "logo" with ID and NAME
setopt localoptions extendedglob
integer halfl=$(( LINES / 2 )) halfc=$(( COLUMNS / 2 ))
integer hlen tlen
local text headerline=" Zconvey" headerline2=""
__zconvey_get_name_of_id "$ZCONVEY_ID"
if [ -z "$REPLY" ]; then
text="ID: <$ZCONVEY_ID> NAME: (no name assigned)"
else
text="ID: <$ZCONVEY_ID> NAME: $REPLY"
fi
tlen="${#text}"
hlen=tlen+4
headerline="${(r:hlen:: :)headerline}"
headerline="${headerline/Zconvey/\033[1;34mZconvey\033[0m\033[1;44m}"
headerline2="${(r:hlen:: :)headerline2}"
text="${text/(#b)(<[[:digit:]]#>)/\033[1;32m${match[1]}\033[1;33m}"
text="${text/(#b)NAME: (?#)/NAME: \033[1;32m${match[1]}\033[0m}"
[ "$1" != "echo" ] && {
echotc sc
echotc cm $(( halfl - 3 )) $(( halfc - hlen/2 ))
print -n "\033[1;44m$headerline\033[0m"
echotc cm $(( halfl - 2 )) $(( halfc - hlen/2 ))
print -n "\033[1;44m \033[0m \033[1;33m$text\033[0m \033[1;44m \033[0m"
echotc cm $(( halfl - 1 )) $(( halfc - hlen/2 ))
print -n "\033[1;44m$headerline2\033[0m"
echotc rc
} || {
print "\033[1;44m$headerline\033[0m\n\033[1;44m \033[0m \033[1;33m$text\033[0m \033[1;44m \033[0m\n\033[1;44m$headerline2\033[0m"
}
# 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

38
zc-ls Normal file
View file

@ -0,0 +1,38 @@
setopt localoptions extendedglob clobber
integer idx is_locked
local name busyfile busywith
for (( idx = 1; idx <= 100; idx ++ )); do
name=""
busywith=""
__zconvey_is_session_active "$idx" && is_locked=1 || is_locked=0
__zconvey_get_name_of_id "$idx"
name="$REPLY"
busyfile="$ZCONVEY_OTHER_DIR/${idx}.busy"
[[ -e "$busyfile" && "$idx" != "$ZCONVEY_ID" ]] && busywith=" \033[1;33m(BUSY: $(<$busyfile))\033[0m"
if [[ "$is_locked" = "0" && -n "$name" ]]; then
print "\033[1;31m(ABSENT)\033[0m ID: $idx, NAME: $name"
elif [[ "$is_locked" = "0" && -z "$name" ]]; then
# Don't inform about absent, nameless sessions
:
elif [[ "$is_locked" = "1" && -z "$name" ]]; then
if [ "$idx" = "$ZCONVEY_ID" ]; then
print "\033[1;32m\033[4m(CURRENT) ID: $idx\033[0m$busywith"
else
print "\033[1;33m(ON-LINE)\033[0m ID: $idx$busywith"
fi
elif [[ "$is_locked" = "1" && -n "$name" ]]; then
if [ "$idx" = "$ZCONVEY_ID" ]; then
print "\033[1;32m\033[4m(CURRENT) ID: $idx, NAME: $name\033[0m$busywith"
else
print "\033[1;33m(ON-LINE)\033[0m ID: $idx, NAME: $name$busywith"
fi
fi
done
# vim:ft=zsh

87
zc-rename Normal file
View file

@ -0,0 +1,87 @@
setopt localoptions extendedglob clobber
function __zconvey_usage_zc-rename() {
__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"
print -- "-q/--quiet - don't output status messages"
}
local -A opthash
zparseopts -E -D -A opthash h -help q -quiet i: -id: n: -name: || { __zconvey_usage_zc-rename; return 1; }
integer have_id=0 have_name=0 quiet=0
local id name new_name="$1"
# Help
(( ${+opthash[-h]} + ${+opthash[--help]} )) && { __zconvey_usage_zc-rename; return 0; }
[ -z "$new_name" ] && { echo "No new name given"; __zconvey_usage_zc-rename; return 1; }
# ID
have_id=$(( ${+opthash[-i]} + ${+opthash[--id]} ))
(( ${+opthash[-i]} )) && id="${opthash[-i]}"
(( ${+opthash[--id]} )) && id="${opthash[--id]}"
# NAME
have_name=$(( ${+opthash[-n]} + ${+opthash[--name]} ))
(( ${+opthash[-n]} )) && name="${opthash[-n]}"
(( ${+opthash[--name]} )) && name="${opthash[--name]}"
# QUIET
(( quiet = ${+opthash[-q]} + ${+opthash[--quiet]} ))
if [[ "$have_id" != "0" && "$have_name" != "0" ]]; then
__zconvey_pinfo "Please supply only one of ID (-i) and NAME (-n)"
return 1
fi
if [[ "$have_id" != "0" && ( "$id" != <-> || "$id" = "0" ) ]]; then
__zconvey_pinfo "ID must be numeric, 1..100"
return 1
fi
# Rename via NAME?
if (( $have_name )); then
__zconvey_resolve_name_to_id "$name"
local resolved="$REPLY"
if [ -z "$resolved" ]; then
__zconvey_pinfo "Could not find session named: \`$name'"
return 1
fi
# Store the resolved ID and continue normally,
# with ID as the main specifier of session
id="$resolved"
elif (( $have_id == 0 )); then
id="$ZCONVEY_ID"
fi
__zconvey_resolve_name_to_id "$new_name"
if [ -n "$REPLY" ]; then
__zconvey_pinfo "A session already has target name: \`$new_name' (its ID: $REPLY)"
return 1
fi
if [[ "$id" != <-> || "$id" = "0" ]]; then
__zconvey_pinfo "Bad ID ($id), aborting"
return 1
fi
if [[ "$id" -gt "100" ]]; then
__zconvey_pinfo "Maximum nr of sessions is 100, aborting"
return 1
fi
print ":$new_name:" > "$ZCONVEY_NAMES_DIR"/"$id".name
if (( ${quiet} == 0 )); then
__zconvey_pinfo2 "Renamed session $id to: $new_name"
fi
local ls_after_rename
zstyle -b ":plugin:zconvey" ls_after_rename ls_after_rename || ls_after_rename="no"
[ "$ls_after_rename" = "yes" ] && print && zc-ls
# vim:ft=zsh

107
zc-take Normal file
View file

@ -0,0 +1,107 @@
setopt localoptions extendedglob clobber
function __zconvey_usage_zc-take() {
__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"
print -- "-q/--quiet - don't output status messages"
}
local -A opthash
zparseopts -E -D -A opthash h -help q -quiet i: -id: n: -name: || { __zconvey_usage_zc-rename; return 1; }
integer have_id=0 have_name=0 quiet=0
local id name new_name="$1"
# Help
(( ${+opthash[-h]} + ${+opthash[--help]} )) && { __zconvey_usage_zc-take; return 0; }
[ -z "$new_name" ] && { echo "No new name given"; __zconvey_usage_zc-take; return 1; }
# ID
have_id=$(( ${+opthash[-i]} + ${+opthash[--id]} ))
(( ${+opthash[-i]} )) && id="${opthash[-i]}"
(( ${+opthash[--id]} )) && id="${opthash[--id]}"
# NAME
have_name=$(( ${+opthash[-n]} + ${+opthash[--name]} ))
(( ${+opthash[-n]} )) && name="${opthash[-n]}"
(( ${+opthash[--name]} )) && name="${opthash[--name]}"
# QUIET
(( quiet = ${+opthash[-q]} + ${+opthash[--quiet]} ))
if [[ "$have_id" != "0" && "$have_name" != "0" ]]; then
__zconvey_pinfo "Please supply only one of ID (-i) and NAME (-n)"
return 1
fi
if [[ "$have_id" != "0" && ( "$id" != <-> || "$id" = "0" ) ]]; then
__zconvey_pinfo "ID must be numeric, 1..100"
return 1
fi
# Rename via NAME?
if (( $have_name )); then
__zconvey_resolve_name_to_id "$name"
local resolved="$REPLY"
if [ -z "$resolved" ]; then
echo "Could not find session named: \`$name'"
return 1
fi
# Store the resolved ID and continue normally,
# with ID as the main specifier of session
id="$resolved"
elif (( $have_id == 0 )); then
id="$ZCONVEY_ID"
fi
if [[ "$id" != <-> || "$id" = "0" ]]; then
__zconvey_pinfo "Bad ID ($id), aborting"
return 1
fi
if [[ "$id" -gt "100" ]]; then
__zconvey_pinfo "Maximum nr of sessions is 100, aborting"
return 1
fi
__zconvey_resolve_name_to_id "$new_name"
local other_id="$REPLY"
if [ -n "$other_id" ]; then
# The new name exist in system - find an
# altered name that doesn't exist in system
# and rename conflicting session, so that
# $new_name is free
integer counter=1
local subst_name
while (( 1 )); do
counter+=1
subst_name="${new_name%%_[[:digit:]]#}_${counter}"
__zconvey_resolve_name_to_id "$subst_name"
if [ -z "$REPLY" ]; then
# Found a name that doesn't exist in system, assign
# it to the initial conflicting session $new_name
print ":$subst_name:" > "$ZCONVEY_NAMES_DIR"/"$other_id".name
(( ${quiet} == 0 )) && __zconvey_pinfo "Pre-rename: $new_name -> $subst_name"
break
fi
done
fi
print ":$new_name:" > "$ZCONVEY_NAMES_DIR"/"$id".name
if (( ${quiet} == 0 )); then
__zconvey_pinfo2 "Renamed session $id to: $new_name"
fi
local ls_after_rename
zstyle -b ":plugin:zconvey" ls_after_rename ls_after_rename || ls_after_rename="no"
[ "$ls_after_rename" = "yes" ] && print && zc-ls
# vim:ft=zsh

File diff suppressed because it is too large Load diff