-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5409146
commit 7c4afaf
Showing
4 changed files
with
485 additions
and
1 deletion.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
.config/zsh/zsh/user/functions/functions-available/wetty-download.zsh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# WeTTY supports file downloads by printing terminal escape sequences between a base64 encoded file. The name of the downloaded file can optionally be provided, also base64 encoded, before the encoded file contents with a : separating them. | ||
# | ||
# The terminal escape sequences used are ^[[5i and ^[[4i (VT100 for “enter auto print” and “exit auto print” respectively - https://vt100.net/docs/tp83/appendixc.html). | ||
# | ||
# To take advantage add the following bash function to your .bashrc | ||
# | ||
# Copy to clipboardErrorCopied | ||
# You are then able to download files via WeTTY! | ||
# | ||
# wetty-download my-pdf-file.pdf | ||
# Copy to clipboardErrorCopied | ||
# or you can still use the classic style: | ||
# | ||
# $ cat my-pdf-file.pdf | wetty-download | ||
# Copy to clipboardErrorCopied | ||
# WeTTY will then issue a popup like the following that links to a local file blob: Download ready: file-20191015233654.pdf | ||
|
||
function wetty-download() { | ||
file=${1:-/dev/stdin} | ||
|
||
nameprefix="" | ||
if [[ -f "$file" ]]; then | ||
nameprefix="$(basename "$file" | base64 -w 0):" | ||
fi | ||
|
||
|
||
if [[ -f "$file" || "$file" == "/dev/stdin" ]]; then | ||
printf "\033[5i"$nameprefix$(cat "$file" | base64 -w 0)"\033[4i" | ||
else | ||
echo "$file does not appear to be a file" | ||
fi | ||
} |
1 change: 1 addition & 0 deletions
1
.config/zsh/zsh/user/functions/functions-enabled/wetty-download.zsh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../functions-available/wetty-download.zsh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.