From 07fd6f26d7c59ba728064da7d10c0addf61cfff5 Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Sun, 12 Mar 2023 20:56:01 +0300 Subject: [PATCH] Quick file download --- cmd/{download => dl} | 6 ++++-- cmd/dlpane | 14 ++++++++++++++ cmd/start | 5 ++++- cmd/tmux.conf | 4 ++++ doc/arch.texi | 11 ++++++----- doc/index.texi | 2 ++ doc/usage.texi | 8 ++++++-- 7 files changed, 40 insertions(+), 10 deletions(-) rename cmd/{download => dl} (79%) create mode 100755 cmd/dlpane diff --git a/cmd/download b/cmd/dl similarity index 79% rename from cmd/download rename to cmd/dl index b704d20..dd9c029 100755 --- a/cmd/download +++ b/cmd/dl @@ -9,6 +9,8 @@ trap "rm -f $tmp" HUP PIPE INT QUIT TERM EXIT echo $2 > "$1"/file/get & cat "$1"/file/out > $tmp mv $tmp $2.tar -echo $2.tar -tar tvf $2.tar +tar tvf $2.tar >&2 +realpath $2.tar +echo -n "x it?" +read foo tar xf $2.tar diff --git a/cmd/dlpane b/cmd/dlpane new file mode 100755 index 0000000..cadbf4f --- /dev/null +++ b/cmd/dlpane @@ -0,0 +1,14 @@ +#!/bin/sh -e + +fileId=$(tmux show-buffer | + sed -n 's/^.*\[FILE\] \(.*\) (\(.*\))$/\1 \2/p' | + fzf | + cut -d" " -f1) +[ -n "$fileId" ] +tmux delete-buffer +cmd="$(dirname "$(realpath -- "$0")")" +state="$PWD" +cd /tmp +$cmd/dl "$state" $fileId +echo extracted +read foo diff --git a/cmd/start b/cmd/start index b5e33f9..caae3fa 100755 --- a/cmd/start +++ b/cmd/start @@ -7,7 +7,10 @@ $TMUX has-session -t mmc 2>/dev/null && exit mkdir -p users rm -f debug users/status mkfifo debug users/status -[ -s tmux.conf ] || sed "s#NEWWIN#$cmd/newwin# ; s#CATFILE#$cmd/catfile#" < "$cmd"/tmux.conf > tmux.conf +[ -s tmux.conf ] || sed \ + -e "s#NEWWIN#$cmd/newwin#" \ + -e "s#CATFILE#$cmd/catfile#" \ + -e "s#DLPANE#$cmd/dlpane#" < "$cmd"/tmux.conf > tmux.conf $TMUX -f tmux.conf new-session -d -n ROOT -s mmc "cat debug | tai64n | tai64nlocal" $TMUX split-window -h 'while : ; do cat users/status | spc -e grn,"^O:.*" -e cya,"^A:.*" ; sleep 5 ; clear ; done' $TMUX split-window -v "$cmd/mmc/mmc -debug debug -user-status users/status -newwin $cmd/newwin -notify $cmd/notify | tai64n | tai64nlocal" diff --git a/cmd/tmux.conf b/cmd/tmux.conf index fc5face..2a19c28 100644 --- a/cmd/tmux.conf +++ b/cmd/tmux.conf @@ -21,6 +21,10 @@ bind-key Q kill-session bind-key c new-window NEWWIN bind-key d kill-window bind-key S new-window CATFILE +bind-key D { + capture-pane -t 0 + new-window DLPANE +} bind-key -n C-PgUp previous-window bind-key -n C-PgDn next-window diff --git a/doc/arch.texi b/doc/arch.texi index 15f5cd4..15bb7e5 100644 --- a/doc/arch.texi +++ b/doc/arch.texi @@ -11,9 +11,6 @@ cmd/start R tmux -f tmux.conf R tail -f debug | tai64n R for { cat users/status ; sleep 5 } - R fzf **(/) | cmd/newwin - R cmd/catfile - R fzf **(.) | fmt R cmd/mmc | tai64n F users/status F users/.../{id,email,name,|in,out.rec,|status,last} @@ -26,8 +23,12 @@ cmd/start R cmd/rd < .../out.rec | spc R cmd/wr R for { rlwrap cat > .../in } + R fzf **(/) | cmd/newwin + R tmux capture-pane | fzf | cmd/dl + R cmd/catfile + R fzf **(.) | fmt -cmd/download +cmd/dl R echo ... > file/get R tar xf < file/out @@ -145,7 +146,7 @@ it sets an alert for window in @command{tmux}. @end itemize -Outside that running @command{tmux} user can use @command{cmd/download} +Outside that running @command{tmux} user can use @command{cmd/dl} utility to download specified file's identifier. It sends it identifier to @file{file/get} and reads the archive with that file from @file{file/out}. File is sent inside diff --git a/doc/index.texi b/doc/index.texi index 38e7a66..dd88245 100644 --- a/doc/index.texi +++ b/doc/index.texi @@ -22,6 +22,8 @@ based frontend with colourized output. threading meta information in both human and machine friendly format. @item Ability to send and retrieve files. Multiline messages support. @item All channels refreshing after the login. +@item Keybindings for quick channel opening, window selection, +information viewing and file downloading. @end itemize @command{mmc} is diff --git a/doc/usage.texi b/doc/usage.texi index 870fae1..ea0833d 100644 --- a/doc/usage.texi +++ b/doc/usage.texi @@ -42,6 +42,10 @@ prefix is prepended. If message contains appended files, then @item By pressing @code{Prefix+S}, list of available files is shown inside @command{fzf}, just to quickly display it. +@item By pressing @code{Prefix+D}, list of available file links in +current window is shown. Choose the desired one and it will be saved in +@file{/tmp} directory. + @item Status change and typing notifications are shown as a short-lived message at the bottom of the screen. @@ -49,8 +53,8 @@ message at the bottom of the screen. @code{/FILE /path/to/file} message. @item If you want to download some file, then you can invoke -@command{cmd/download FILEID} utility, that will save the file to -@file{FILEID.tar} archive in current directory. +@command{cmd/dl path/to/state FILEID} utility, that will save the file +to @file{FILEID.tar} archive in current directory and extract it. @item After you just logged in, @command{cmd/mmc} checks for new messages since you were offline, if any messages were in the state's -- 2.44.0