chezmoi init

This commit is contained in:
Cy Pokhrel 2024-10-22 11:11:45 -04:00
commit 530d6d7195
No known key found for this signature in database
GPG key ID: 1200FBE36C2ADE2E
1176 changed files with 111325 additions and 0 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"
}