Fix zsh config inclusion

This commit is contained in:
Tim
2020-03-09 15:32:52 +01:00
parent e6b0199bac
commit a69769e47f
871 changed files with 42 additions and 9 deletions

View File

@ -0,0 +1,13 @@
# torrent
This plugin creates a Torrent file based on a [MagnetURI](https://en.wikipedia.org/wiki/Magnet_URI_scheme).
To use it, add `torrent` to the plugins array in your zshrc file.
```zsh
plugins=(... torrent)
```
## Plugin commands
* `magnet_to_torrent <MagnetURI>`: creates Torrent file.

View File

@ -0,0 +1,17 @@
#
# Algorithm borrowed from http://wiki.rtorrent.org/MagnetUri and adapted to work with zsh.
#
function magnet_to_torrent() {
[[ "$1" =~ xt=urn:btih:([^\&/]+) ]] || return 1
hashh=${match[1]}
if [[ "$1" =~ dn=([^\&/]+) ]];then
filename=${match[1]}
else
filename=$hashh
fi
echo "d10:magnet-uri${#1}:${1}e" > "$filename.torrent"
}