dot

packages and services management
Log | Files | Refs | README

commit beef581ed3e5a6bccd48d51975339c0331ab823f
parent 41148895af7f439de38101492ca16ff1d4b30542
Author: Josuah Demangeon <mail@josuah.net>
Date:   Thu, 25 Oct 2018 00:57:43 +0200

go crazy about command line interaction

Diffstat:
Dbin/80 | 15---------------
Rbin/bitreich-blog -> bin/bitreich/bitreich-blog | 0
Rbin/bitreich-export-git -> bin/bitreich/bitreich-export-git | 0
Rbin/bitreich-paste -> bin/bitreich/bitreich-paste | 0
Dbin/blih | 286-------------------------------------------------------------------------------
Dbin/clip | 17-----------------
Abin/clip/copy | 8++++++++
Abin/clip/paste | 8++++++++
Rbin/ff2touch -> bin/conv/ff2touch | 0
Rbin/txt2ics -> bin/conv/txt2ics | 0
Dbin/doc | 3---
Dbin/echo | 4----
Rbin/fun-psyche -> bin/fun/fun-psyche | 0
Rbin/fun-troll -> bin/fun/fun-troll | 0
Rbin/piano -> bin/fun/piano | 0
Rbin/git-all -> bin/git/git-all | 0
Rbin/git-count -> bin/git/git-count | 0
Rbin/git-dog -> bin/git/git-dog | 0
Rbin/git-s -> bin/git/git-s | 0
Rbin/git-stat -> bin/git/git-stat | 0
Rbin/git-update -> bin/git/git-update | 0
Dbin/header | 18------------------
Rbin/http-0x0.st -> bin/http/0x0.st | 0
Rbin/http-icanhazip.com -> bin/http/icanhazip.com | 0
Rbin/http-wttr.in -> bin/http/wttr.in | 0
Dbin/io-uri | 3---
Dbin/ll | 2--
Rbin/m -> bin/mblaze/m | 0
Rbin/m-filter -> bin/mblaze/mfilter | 0
Rbin/mread -> bin/mblaze/mread | 0
Rbin/msearch -> bin/mblaze/msearch | 0
Abin/menu/menu-find | 6++++++
Rbin/io-session -> bin/menu/menu-session | 0
Abin/menu/menu-uri | 3+++
Abin/menu/menu-xdg-open | 30++++++++++++++++++++++++++++++
Rbin/agent -> bin/misc/agent | 0
Rbin/fig -> bin/misc/fig | 0
Rbin/flac-split -> bin/misc/flac-split | 0
Rbin/hgrep -> bin/misc/hgrep | 0
Rbin/ics2txt -> bin/misc/ics2txt | 0
Rbin/ii-client -> bin/misc/ii-client | 0
Rbin/include -> bin/misc/include | 0
Abin/misc/lc | 2++
Rbin/lines -> bin/misc/lines | 0
Abin/misc/ll | 2++
Rbin/mdoc -> bin/misc/mdoc | 0
Rbin/mount-key -> bin/misc/mount-key | 0
Rbin/mv-sane -> bin/misc/mv-sane | 0
Rbin/play -> bin/misc/play | 0
Rbin/put -> bin/misc/put | 0
Rbin/rfc -> bin/misc/rfc | 0
Rbin/ssh-paste -> bin/misc/ssh-paste | 0
Rbin/tmp -> bin/misc/tmp | 0
Dbin/mv-flac | 40----------------------------------------
Dbin/mv-groupdir | 21---------------------
Dbin/nft-nat | 26--------------------------
Dbin/o | 2--
Dbin/pass | 15---------------
Abin/remap/o | 2++
Abin/remap/xdg-open | 2++
Dbin/s6-rc-join | 14--------------
Dbin/s6-rc-load | 7-------
Rbin/edit -> bin/std/edit | 0
Rbin/light -> bin/std/light | 0
Abin/std/menu | 3+++
Rbin/xdg-open -> bin/std/open | 0
Abin/std/pass | 9+++++++++
Rbin/plumb -> bin/std/plumb | 0
Rbin/session -> bin/std/session | 0
Rbin/shell -> bin/std/shell | 0
Abin/std/shortcut | 7+++++++
Rbin/sound -> bin/std/sound | 0
Rbin/web -> bin/std/web | 0
Abin/std/window | 3+++
Rbin/suckless-patch-mail -> bin/suckless/suckless-patch-mail | 0
Rbin/term-black -> bin/term/black | 0
Rbin/term-clear -> bin/term/clear | 0
Rbin/term-white -> bin/term/white | 0
Dbin/tls-dh | 3---
Dbin/tls-pem-key | 16----------------
Rbin/ltree -> bin/tree/ltree | 0
Rbin/ptree -> bin/tree/ptree | 0
Rbin/tty-video -> bin/tty/fbvideo | 0
Rbin/tty-theme -> bin/tty/tty-theme | 0
Dbin/update-agenda | 10----------
Dbin/update-sfeed | 36------------------------------------
Aconf-bin | 4++++
Aconf-gpg | 6++++++
Ddot/gnupg/pubring.gpg | 2--
Ddot/gnupg/secring.gpg | 2--
Mdot/profile | 3++-
Aopen/extension/0 | 2++
Aopen/extension/0p | 2++
Aopen/extension/1 | 2++
Aopen/extension/1p | 2++
Aopen/extension/2 | 2++
Aopen/extension/2p | 2++
Aopen/extension/3 | 2++
Aopen/extension/3p | 2++
Aopen/extension/4 | 2++
Aopen/extension/4p | 2++
Aopen/extension/5 | 2++
Aopen/extension/5p | 2++
Aopen/extension/6 | 2++
Aopen/extension/6p | 2++
Aopen/extension/7 | 2++
Aopen/extension/7p | 2++
Aopen/extension/7z | 2++
Aopen/extension/8 | 2++
Aopen/extension/8p | 2++
Aopen/extension/9 | 2++
Aopen/extension/9p | 2++
Aopen/extension/a | 2++
Aopen/extension/avi | 2++
Aopen/extension/bz2 | 3+++
Aopen/extension/deb | 2++
Aopen/extension/flac | 2++
Aopen/extension/gif | 2++
Aopen/extension/gz | 3+++
Aopen/extension/html | 2++
Aopen/extension/ics | 2++
Aopen/extension/iso | 2++
Aopen/extension/jpeg | 2++
Aopen/extension/jpg | 2++
Aopen/extension/lz | 3+++
Aopen/extension/mkv | 2++
Aopen/extension/mp3 | 2++
Aopen/extension/mp4 | 2++
Aopen/extension/o | 2++
Aopen/extension/ogg | 2++
Aopen/extension/ogv | 2++
Aopen/extension/opus | 2++
Aopen/extension/pdf | 2++
Aopen/extension/png | 2++
Aopen/extension/ps | 2++
Aopen/extension/rar | 2++
Aopen/extension/tar | 2++
Aopen/extension/tbz | 3+++
Aopen/extension/tgz | 3+++
Aopen/extension/tlz | 3+++
Aopen/extension/txz | 3+++
Aopen/extension/vorbis | 2++
Aopen/extension/wav | 2++
Aopen/extension/webm | 2++
Aopen/extension/xz | 3+++
Aopen/extension/zip | 2++
Aopen/protocol/9p | 5+++++
Aopen/protocol/ftp | 2++
Aopen/protocol/git | 8++++++++
Aopen/protocol/http | 2++
Aopen/protocol/https | 2++
Aopen/protocol/news | 2++
Aopen/protocol/sacc | 2++
Aopen/protocol/sftp | 2++
Aopen/protocol/ssh | 4++++
Aopen/protocol/telnet | 2++
Aopen/protocol/vnc | 2++
157 files changed, 248 insertions(+), 543 deletions(-)

diff --git a/bin/80 b/bin/80 @@ -1,15 +0,0 @@ -#!/usr/bin/awk -f - -BEGIN { - ARGC = 1 -} - -{ - sub(" *\\" ARGV[2] "*$", " ", $0); - line = $0; - for (i = 80 - length($0); i > 0; i--) - line = line ARGV[2]; - sub("^ ", ARGV[2], line); - - print line; -} diff --git a/bin/bitreich-blog b/bin/bitreich/bitreich-blog diff --git a/bin/bitreich-export-git b/bin/bitreich/bitreich-export-git diff --git a/bin/bitreich-paste b/bin/bitreich/bitreich-paste diff --git a/bin/blih b/bin/blih @@ -1,286 +0,0 @@ -#!/usr/bin/env python3.6 - -import os -import sys -import getopt -import hmac -import hashlib -import urllib.request -import urllib.parse -import json -import getpass - -version = 1.7 - -# https://blih.epitech.eu/ - -class blih: - def __init__(self, baseurl='127.0.0.1', user=None, token=None, verbose=False, user_agent='blih-' + str(version)): - self._baseurl = baseurl - if token: - self._token = token - else: - self.token_calc() - if user == None: - self._user = getpass.getuser() - else: - self._user = user - self._verbose = verbose - self._useragent = user_agent - - def token_get(self): - return self._token - - def token_set(self, token): - self._token = token - - token = property(token_get, token_set) - - def token_calc(self): - self._token = bytes(hashlib.sha512(bytes(getpass.getpass(), 'utf8')).hexdigest(), 'utf8') - - def sign_data(self, data=None): - signature = hmac.new(self._token, msg=bytes(self._user, 'utf8'), digestmod=hashlib.sha512) - if data: - signature.update(bytes(json.dumps(data, sort_keys=True, indent=4, separators=(',', ': ')), 'utf8')) - - signed_data = {'user' : self._user, 'signature' : signature.hexdigest()} - if data != None: - signed_data['data'] = data - - return signed_data - - def request(self, resource, method='GET', content_type='application/json', data=None, url=None): - signed_data = self.sign_data(data) - - if url: - req = urllib.request.Request(url=url, method=method, data=bytes(json.dumps(signed_data), 'utf8')) - else: - req = urllib.request.Request(url=self._baseurl + resource, method=method, data=bytes(json.dumps(signed_data), 'utf8')) - req.add_header('Content-Type', content_type) - req.add_header('User-Agent', self._useragent) - - try: - f = urllib.request.urlopen(req) - except urllib.error.HTTPError as e: - print ('HTTP Error ' + str(e.code)) - data = json.loads(e.read().decode('utf8')) - print ("Error message : '" + data['error'] + "'") - sys.exit(1) - - if f.status == 200: - try: - data = json.loads(f.read().decode('utf8')) - except: - print ("Can't decode data, aborting") - sys.exit(1) - return (f.status, f.reason, f.info(), data) - - print ('Unknown error') - sys.exit(1) - - def repo_create(self, name, type='git', description=None): - data = {'name' : name, 'type' : type} - if description: - data['description'] = description - status, reason, headers, data = self.request('/repositories', method='POST', data=data) - print (data['message']) - - def repo_list(self): - status, reason, headers, data = self.request('/repositories', method='GET') - for i in data['repositories']: - print (i) - - def repo_delete(self, name): - status, reason, headers, data = self.request('/repository/' + name, method='DELETE') - print (data['message']) - - def repo_info(self, name): - status, reason, headers, data = self.request('/repository/' + name, method='GET') - print (data['message']) - - def repo_setacl(self, name, acluser, acl): - data = {'user' : acluser, 'acl' : acl} - status, reason, headers, data = self.request('/repository/' + name + '/acls', method='POST', data=data) - print (data['message']) - - def repo_getacl(self, name): - status, reason, headers, data = self.request('/repository/' + name + '/acls', method='GET') - for i in data.keys(): - print (i + ':' + data[i]) - - def sshkey_upload(self, keyfile): - try: - f = open(keyfile, 'r') - except (PermissionError, FileNotFoundError): - print ("Can't open file : " + keyfile) - return - key = urllib.parse.quote(f.read().strip('\n')) - f.close() - data = {'sshkey' : key} - status, reason, headers, data = self.request('/sshkeys', method='POST', data=data) - print (data['message']) - - def sshkey_delete(self, sshkey): - status, reason, headers, data = self.request('/sshkey/' + sshkey, method='DELETE') - print (data['message']) - - def sshkey_list(self): - status, reason, headers, data = self.request('/sshkeys', method='GET') - for i in data.keys(): - print (data[i] + ' ' + i) - - def whoami(self): - status, reason, headers, data = self.request('/whoami', method='GET') - print (data['message']) - -def usage_repository(): - print ('Usage: ' + sys.argv[0] + ' [options] repository command ...') - print () - print ('Commands :') - print ('\tcreate repo\t\t\t-- Create a repository named "repo"') - print ('\tinfo repo\t\t\t-- Get the repository metadata') - print ('\tgetacl repo\t\t\t-- Get the acls set for the repository') - print ('\tlist\t\t\t\t-- List the repositories created') - print ('\tsetacl repo user [acl]\t\t-- Set (or remove) an acl for "user" on "repo"') - print ('\t\t\t\t\tACL format:') - print ('\t\t\t\t\tr for read') - print ('\t\t\t\t\tw for write') - print ('\t\t\t\t\ta for admin') - sys.exit(1) - -def repository(args, baseurl, user, token, verbose, user_agent): - if len(args) == 0: - usage_repository() - if args[0] == 'create': - if len(args) != 2: - usage_repository() - handle = blih(baseurl=baseurl, user=user, token=token, verbose=verbose, user_agent=user_agent) - handle.repo_create(args[1]) - elif args[0] == 'list': - if len(args) != 1: - usage_repository() - handle = blih(baseurl=baseurl, user=user, token=token, verbose=verbose, user_agent=user_agent) - handle.repo_list() - elif args[0] == 'info': - if len(args) != 2: - usage_repository() - handle = blih(baseurl=baseurl, user=user, token=token, verbose=verbose, user_agent=user_agent) - handle.repo_info(args[1]) - elif args[0] == 'delete': - if len(args) != 2: - usage_repository() - handle = blih(baseurl=baseurl, user=user, token=token, verbose=verbose, user_agent=user_agent) - handle.repo_delete(args[1]) - elif args[0] == 'setacl': - if len(args) != 4 and len(args) != 3: - usage_repository() - if len(args) == 3: - acl = '' - else: - acl = args[3] - handle = blih(baseurl=baseurl, user=user, token=token, verbose=verbose, user_agent=user_agent) - handle.repo_setacl(args[1], args[2], acl) - elif args[0] == 'getacl': - if len(args) != 2: - usage_repository() - handle = blih(baseurl=baseurl, user=user, token=token, verbose=verbose, user_agent=user_agent) - handle.repo_getacl(args[1]) - else: - usage_repository() - -def usage_sshkey(): - print ('Usage: ' + sys.argv[0] + ' [options] sshkey command ...') - print () - print ('Commands :') - print ('\tupload [file]\t\t\t-- Upload a new ssh-key') - print ('\tlist\t\t\t\t-- List the ssh-keys') - print ('\tdelete <sshkey>\t\t\t-- Delete the sshkey with comment <sshkey>') - sys.exit(1) - -def sshkey(args, baseurl, user, token, verbose, user_agent): - if len(args) == 0: - usage_sshkey() - if args[0] == 'list': - handle = blih(baseurl=baseurl, user=user, token=token, verbose=verbose, user_agent=user_agent) - handle.sshkey_list() - elif args[0] == 'upload': - key = None - if len(args) == 1: - key = os.getenv('HOME') + '/.ssh/id_rsa.pub' - elif len(args) == 2: - key = args[1] - else: - usage_sshkey() - handle = blih(baseurl=baseurl, user=user, token=token, verbose=verbose, user_agent=user_agent) - handle.sshkey_upload(key) - elif args[0] == 'delete': - if len(args) != 2: - usage_sshkey() - handle = blih(baseurl=baseurl, user=user, token=token, verbose=verbose, user_agent=user_agent) - handle.sshkey_delete(args[1]) - else: - usage_sshkey() - -def whoami(args, baseurl, user, token, verbose, user_agent): - handle = blih(baseurl=baseurl, user=user, token=token, verbose=verbose, user_agent=user_agent) - handle.whoami() - -def usage(): - print ('Usage: ' + sys.argv[0] + ' [options] command ...') - print () - print ('Global Options :') - print ('\t-u user | --user=user\t\t-- Run as user') - print ('\t-v | --verbose\t\t\t-- Verbose') - print ('\t-b url | --baseurl=url\t\t-- Base URL for BLIH') - print ('\t-t | --token\t\t\t-- Specify token in the cmdline') - print () - print ('Commands :') - print ('\trepository\t\t\t-- Repository management') - print ('\tsshkey\t\t\t\t-- SSH-KEYS management') - print ('\twhoami\t\t\t\t-- Print who you are') - sys.exit(1) - -if __name__ == "__main__": - try: - opts, args = getopt.getopt(sys.argv[1:], 'hvu:b:t:VU:', ['help', 'verbose', 'user=', 'baseurl=', 'token=', 'version', 'useragent=']) - except getopt.GetoptError as e: - print (e) - usage() - - verbose = False - user = None - baseurl = 'https://blih.epitech.eu/' - token = None - user_agent = 'blih-' + str(version) - - for o, a in opts: - if o in ('-h', '--help'): - usage() - elif o in ('-v', '--verbose'): - verbose = True - elif o in ('-u', '--user'): - user = a - elif o in ('-b', '--baseurl'): - baseurl = a - elif o in ('-t', '--token'): - token = bytes(a, 'utf8') - elif o in ('-V', '--version'): - print ('blih version ' + str(version)) - sys.exit(0) - elif o in ('-U', '--useragent'): - user_agent = a - else: - usage() - - if len(args) == 0: - usage() - - if args[0] == 'repository': - repository(args[1:], baseurl, user, token, verbose, user_agent) - elif args[0] == 'sshkey': - sshkey(args[1:], baseurl, user, token, verbose, user_agent) - elif args[0] == 'whoami': - whoami(args[1:], baseurl, user, token, verbose, user_agent) - else: - usage() diff --git a/bin/clip b/bin/clip @@ -1,17 +0,0 @@ -#!/bin/sh -e -# stdin/stdout-based clipboard - -CLIP=${CLIP:-$HOME/.cache/clip} - -mkdir -p "$(dirname "$CLIP")" -touch "$CLIP" -chmod 600 "$CLIP" - -case $1 in -(i) cat >$CLIP - ;; -(o) cat <$CLIP - ;; -(*) echo 'usage: clip {i,o}' - ;; -esac diff --git a/bin/clip/copy b/bin/clip/copy @@ -0,0 +1,8 @@ +#!/bin/sh -e + +CLIP=${CLIP:-$HOME/.cache/clip} + +mkdir -p "$(dirname "$CLIP")" +touch "$CLIP" +chmod 600 "$CLIP" +cat >$CLIP diff --git a/bin/clip/paste b/bin/clip/paste @@ -0,0 +1,8 @@ +#!/bin/sh -e + +CLIP=${CLIP:-$HOME/.cache/clip} + +mkdir -p "$(dirname "$CLIP")" +touch "$CLIP" +chmod 600 "$CLIP" +cat >$CLIP diff --git a/bin/ff2touch b/bin/conv/ff2touch diff --git a/bin/txt2ics b/bin/conv/txt2ics diff --git a/bin/doc b/bin/doc @@ -1,3 +0,0 @@ -#!/bin/sh -e - -ls "$DOCPATH" diff --git a/bin/echo b/bin/echo @@ -1,4 +0,0 @@ -#!/bin/sh -e -# print the arguments separated by one space and then a newline. - -printf '%s\n' "$*" diff --git a/bin/fun-psyche b/bin/fun/fun-psyche diff --git a/bin/fun-troll b/bin/fun/fun-troll diff --git a/bin/piano b/bin/fun/piano diff --git a/bin/git-all b/bin/git/git-all diff --git a/bin/git-count b/bin/git/git-count diff --git a/bin/git-dog b/bin/git/git-dog diff --git a/bin/git-s b/bin/git/git-s diff --git a/bin/git-stat b/bin/git/git-stat diff --git a/bin/git-update b/bin/git/git-update diff --git a/bin/header b/bin/header @@ -1,18 +0,0 @@ -#!/bin/sh -e -# print a header for a C file - -test git rev-parse 2>/dev/null && cd "$(dirname "$(git rev-parse --git-dir)")" - -printf '/* -** EPITECH PROJECT, 2018 -** %s -** File description: -** Copyright (c) %d to Josuah Demangeon. All rights reserved. -*/ -' "$(basename "$(pwd)")" "$(date +%Y)" - -test $# = 0 || printf '\n' - -for header in "$@" -do printf '#include <%s.h>\n' "$header" -done diff --git a/bin/http-0x0.st b/bin/http/0x0.st diff --git a/bin/http-icanhazip.com b/bin/http/icanhazip.com diff --git a/bin/http-wttr.in b/bin/http/wttr.in diff --git a/bin/io-uri b/bin/io-uri @@ -1,3 +0,0 @@ -#!/bin/sh -e - -exec xdg-open "$(iomenu <"$HOME/.config/uri")" diff --git a/bin/ll b/bin/ll @@ -1,2 +0,0 @@ -#!/bin/sh -e -exec lr -l1GG "$@" diff --git a/bin/m b/bin/mblaze/m diff --git a/bin/m-filter b/bin/mblaze/mfilter diff --git a/bin/mread b/bin/mblaze/mread diff --git a/bin/msearch b/bin/mblaze/msearch diff --git a/bin/menu/menu-find b/bin/menu/menu-find @@ -0,0 +1,6 @@ +#!/bin/sh -e +# find a file from current directory with menu + +test $# = 0 && set -- . + +find "$@" '(' -name .git -o -name CVS ')' -prune -o -print | sort | menu diff --git a/bin/io-session b/bin/menu/menu-session diff --git a/bin/menu/menu-uri b/bin/menu/menu-uri @@ -0,0 +1,3 @@ +#!/bin/sh -e + +exec xdg-open "$(menu <"$HOME/.config/uri")" diff --git a/bin/menu/menu-xdg-open b/bin/menu/menu-xdg-open @@ -0,0 +1,30 @@ +#!/bin/sh -e +# pick a file to open with xdg-open with iomenu with caching +# +# The cache is updated when a directory is selected. + +LC_COLLATE=C + +if test -f "$HOME/.cache/find" && test $# = 0 +then exec "$0" "$HOME" +elif test $# = 0 +then exec xdg-open "$(iomenu <$HOME/.cache/find)" +fi + +mkdir -p "$HOME/.cache" +{ + find "$1" '(' -name .git -o -name CVS ')' -prune -o \ + -type d -exec printf '%s/\n' '{}' + -o \ + -type f -exec printf '%s\n' '{}' + | tee "$HOME/.cache/$$" + grep -vF "$1" $HOME/.cache/find +} | sort -o "$HOME/.cache/find" + +s=$(iomenu <$HOME/.cache/$$) + +rm "$HOME/.cache/$$" + +case $s in +('') exit 1 ;; +(*/) exec "$0" "$(cd "$s" && pwd)" ;; +(*) exec xdg-open "$s" ;; +esac diff --git a/bin/agent b/bin/misc/agent diff --git a/bin/fig b/bin/misc/fig diff --git a/bin/flac-split b/bin/misc/flac-split diff --git a/bin/hgrep b/bin/misc/hgrep diff --git a/bin/ics2txt b/bin/misc/ics2txt diff --git a/bin/ii-client b/bin/misc/ii-client diff --git a/bin/include b/bin/misc/include diff --git a/bin/misc/lc b/bin/misc/lc @@ -0,0 +1,2 @@ +#!/bin/sh -e +exec ls -AF "$@" | exec cols diff --git a/bin/lines b/bin/misc/lines diff --git a/bin/misc/ll b/bin/misc/ll @@ -0,0 +1,2 @@ +#!/bin/sh -e +exec lr -Al1GG "$@" diff --git a/bin/mdoc b/bin/misc/mdoc diff --git a/bin/mount-key b/bin/misc/mount-key diff --git a/bin/mv-sane b/bin/misc/mv-sane diff --git a/bin/play b/bin/misc/play diff --git a/bin/put b/bin/misc/put diff --git a/bin/rfc b/bin/misc/rfc diff --git a/bin/ssh-paste b/bin/misc/ssh-paste diff --git a/bin/tmp b/bin/misc/tmp diff --git a/bin/mv-flac b/bin/mv-flac @@ -1,40 +0,0 @@ -#!/9/bin/rc -e -# rename a file according to its tags, extracted - -# The naming scheme is: -# "artist/year-album/[disc_nb-]track_nb-title.flac" - -if (! ~ $#* 1) - exec echo 'usage: mv-flac <file>' - -# Grab the year out of some string -fn y - sed -r 's/.*([0-9]{4}).*/\1/' - -# Grab the value out of a key=value pair -fn v - sed 's/^[^=]*=//' - -# Sanitize a string for use in a file name -fn s - tr -s ' \n\t$&*()[]<>\\/|";?'\' - | sed 's/^-//; s/-$//' - -# Grab the number 'n' out of a "n/m" format -fn n - sed -r 's/^[^0-9]*0*([0-9]+).*/\1/' - -ar=`{metaflac --show-tag'='ARTIST $1 | v | s} -da=`{metaflac --show-tag'='DATE $1 | y} -al=`{metaflac --show-tag'='ALBUM $1 | v | s} -dt=`{metaflac --show-tag'='DISCTOTAL $1 | v | n} -dn=`{metaflac --show-tag'='DISCNUMBER $1 | v | n} -tn=`{metaflac --show-tag'='TRACKNUMBER $1 | v | n} -ti=`{metaflac --show-tag'='TITLE $1 | v | s} - -if (test $dn = $dt) - dn='' -if not - dn=$dn- - -mkdir -p $ar/$da-$al -ln $1 $ar/$da-$al/$dn^`{printf %02d $tn}^-$ti.flac diff --git a/bin/mv-groupdir b/bin/mv-groupdir @@ -1,21 +0,0 @@ -#!/9/bin/rc -e -# Group all common sub-subdirectories - -# This changes all subdirectories into "d". It is useful to group -# multi-artist albums together: -# ./artis1/album1/* -> d/album1/* -# ./artis2/album1/* -> d/album1/* -# ./artis3/album1/* -> d/album1/* -# ./artis4/album2/* -> d/album2/* -# ./artis5/album2/* -> d/album2/* - -if (! ~ $#* 0) - exec echo 'usage: mv-groupdir' - -mkdir d - -for (dir in */*) { - new=`{echo $dir | sed 's,[^/]*/,,'} - mkdir -p d/$new - ln $dir/* d/$new -} diff --git a/bin/nft-nat b/bin/nft-nat @@ -1,26 +0,0 @@ -#!/9/bin/rc -e -# NAT rules for already NAT-ed local home network -# The hypervisor is 192.168.0.11, this VM is 192.168.0.10 - - -nft flush ruleset - - -nft add table nat - - -nft add chain nat prerouting \ - '{' type nat hook prerouting priority 0 ';' '}' - -nft add chain nat postrouting \ - '{' type nat hook postrouting priority 100 ';' '}' - - -nft add rule nat postrouting \ - iif ens3 snat to 192.168.0.10 - -nft add rule nat prerouting \ - oif ens3 dnat to 192.168.1.1 - -nft add rule nat postrouting \ - oif ens3 masquerade diff --git a/bin/o b/bin/o @@ -1 +0,0 @@ -xdg-open- \ No newline at end of file diff --git a/bin/pass b/bin/pass @@ -1,15 +0,0 @@ -#!/bin/sh -e - -case $1 in -(set) - dd if=/dev/random bs=48 count=1 | base64>"/mnt/key/pass/$2" - ;; -(get) - cat "/mnt/key/pass/$2" - ;; -(*) - echo 'usage: pass {set,get}' - echo - ls /mnt/key/pass/ - ;; -esac diff --git a/bin/remap/o b/bin/remap/o @@ -0,0 +1,2 @@ +#!/bin/sh -ex +exec open "$@" diff --git a/bin/remap/xdg-open b/bin/remap/xdg-open @@ -0,0 +1,2 @@ +#!/bin/sh -ex +exec open "$@" diff --git a/bin/s6-rc-join b/bin/s6-rc-join @@ -1,14 +0,0 @@ -#!/usr/bin/env execlineb - -multisubstitute { - importas 1 1 - importas 2 2 - backtick -n n1 { basename $1 } - backtick -n n2 { basename $2 } - importas n1 n1 - importas n2 n2 -} -if { redirfd -a 1 ${1}/producer-for echo $n2 } -if { redirfd -a 1 ${2}/consumer-for echo $n1 } -if { sort -u ${1}/producer-for -o ${1}/producer-for } -if { sort -u ${2}/consumer-for -o ${2}/consumer-for } diff --git a/bin/s6-rc-load b/bin/s6-rc-load @@ -1,7 +0,0 @@ -#!/usr/bin/env execlineb - -backtick t { s6-clock } importas t t -if { s6-rc-compile "/var/s6/compiled$t" /etc/s6 } -if { s6-rc-update -l /var/s6/live "/var/s6/compiled$t" } -if { s6-ln -nsf "/var/s6/compiled$t" /var/s6/compiled } -if { s6-rc -l /var/s6/live -u change ok-all } diff --git a/bin/edit b/bin/std/edit diff --git a/bin/light b/bin/std/light diff --git a/bin/std/menu b/bin/std/menu @@ -0,0 +1,3 @@ +#!/bin/sh -e + +test "$DISPLAY" && exec dmenu -l 40 || exec iomenu diff --git a/bin/xdg-open b/bin/std/open diff --git a/bin/std/pass b/bin/std/pass @@ -0,0 +1,9 @@ +#!/bin/sh -e + + dd if=/dev/random bs=48 count=1 | base64>"/mnt/key/pass/$2" + +PASS=/mnt/key/pass/ + +test $# = 0 && + exec ls "$PASS" || + exec cat "$PASS/$1" diff --git a/bin/plumb b/bin/std/plumb diff --git a/bin/session b/bin/std/session diff --git a/bin/shell b/bin/std/shell diff --git a/bin/std/shortcut b/bin/std/shortcut @@ -0,0 +1,7 @@ +#!/bin/sh -ex + +case "$1" in +(u) exec menu-uri ;; +(s) exec menu-session ;; +(m) exec menu-mblaze ;; +esac diff --git a/bin/sound b/bin/std/sound diff --git a/bin/web b/bin/std/web diff --git a/bin/std/window b/bin/std/window @@ -0,0 +1,3 @@ +#!/bin/sh -ex + +test "$DISPLAY" && exec st -e "$@" || exec "$@" diff --git a/bin/suckless-patch-mail b/bin/suckless/suckless-patch-mail diff --git a/bin/term-black b/bin/term/black diff --git a/bin/term-clear b/bin/term/clear diff --git a/bin/term-white b/bin/term/white diff --git a/bin/tls-dh b/bin/tls-dh @@ -1,3 +0,0 @@ -#!/usr/bin/env execlineb - -openssl dhparam -out dhparam.pem 4096 diff --git a/bin/tls-pem-key b/bin/tls-pem-key @@ -1,16 +0,0 @@ -#!/usr/bin/env execlineb - -importas domain 1 -if { test "${domain}" } -if { - openssl req - -new - -newkey rsa - -days 365 - -nodes - -x509 - -subj /CN=${domain} - -keyout "${domain}.key" - -out "${domain}.pem" -} -#if { chmod 400 data } diff --git a/bin/ltree b/bin/tree/ltree diff --git a/bin/ptree b/bin/tree/ptree diff --git a/bin/tty-video b/bin/tty/fbvideo diff --git a/bin/tty-theme b/bin/tty/tty-theme diff --git a/bin/update-agenda b/bin/update-agenda @@ -1,10 +0,0 @@ -#!/9/bin/rc -# download agendas in ics format - -d=$home/conf/ics - -wget -q -O $d/epitech.ics \ -'https://intra.epitech.eu/auth-251e3d0bfcea8ed69a5581361a6a5b8b7ac3cfd5/planning/load?format=ical&location=FR/REN&onlymypromo=true&onlymymodule=true&semester=0,1,10,2,3,4,5,6,7,8,9' - -#wget -q -O $d/bsdcan-2018.ics \ -#https://www.bsdcan.org/2018/schedule/schedule.en.ics diff --git a/bin/update-sfeed b/bin/update-sfeed @@ -1,36 +0,0 @@ -#!/9/bin/rc -# update feeds, merge with old feeds. - -mkdir -p $home/var/sfeed -cd $home/var/sfeed - -fn f { - printf '%-30s %s\n' $1 $2 - touch $1 - mkdir -p $home/var/mail/sfeed--$1/new \ - $home/var/mail/sfeed--$1/cur \ - $home/var/mail/sfeed--$1/tmp - - # fetch then sort and merge by id, link, title - curl -'#LH' User-Agent: $2 | - sfeed | - sort -t ' ' -u -k6,6 -k3,3 -k2,2 $1 - | - sort -t ' ' -k1rn,1 -o $1 - - # deliver using mblaze(7) - sfeed_mbox $1 | mdeliver -M $home/var/mail/sfeed--$1 -} - -f dragonflydigest.com https://www.dragonflydigest.com/feed -f codemadness.nl http://www.codemadness.nl/rss.xml -f kernel.org http://kernel.org/kdist/rss.xml -f xkcd.com http://xkcd.com/atom.xml -f research.googleblog.com http://feeds.feedburner.com/blogspot/gJZg -f bitreich.org gopher://bitreich.org/0/news.atom.xml -f swordarmor.fr https://www.swordarmor.fr/feeds/all.rss.xml -f r-datahoarder https://www.reddit.com/r/datahoarder/.rss -f r-homelab https://www.reddit.com/r/homelab/.rss -f r-unixporn https://www.reddit.com/r/unixporn/.rss -f r-stallmanwasright https://www.reddit.com/r/StallmanWasRight/.rss -f biochimej.univ-angers.fr http://biochimej.univ-angers.fr/FluxRss.xml -f status.gandi.net http://status.gandi.net/rss/ diff --git a/conf-bin b/conf-bin @@ -0,0 +1,4 @@ +#!/bin/sh -ex + +mkdir -p "$HOME/.local/bin" +cp "$(dirname "$0")/bin/"*"/"* "$HOME/.local/bin" diff --git a/conf-gpg b/conf-gpg @@ -0,0 +1,6 @@ +#!/bin/sh -ex + +mkdir -p "$HOME/.gnupg" +cp -f /mnt/key/gpg/pubring.gpg "$HOME/.gnupg/pubring.gpg" +cp -f /mnt/key/gpg/secring.gpg "$HOME/.gnupg/secring.gpg" +cp -f /mnt/key/gpg/trustdb.gpg "$HOME/.gnupg/trustdb.gpg" diff --git a/dot/gnupg/pubring.gpg b/dot/gnupg/pubring.gpg @@ -1 +0,0 @@ -/mnt/key/pgp/pubring.gpg- \ No newline at end of file diff --git a/dot/gnupg/secring.gpg b/dot/gnupg/secring.gpg @@ -1 +0,0 @@ -/mnt/key/pgp/secring.gpg- \ No newline at end of file diff --git a/dot/profile b/dot/profile @@ -23,7 +23,7 @@ export PXPATH=/var/px export GOPATH=$HOME/go export MANPATH=/usr/man:/usr/share/man:/usr/local/man:/usr/local/share/man export MANPATH=$PXPATH/man:$MANPATH -export PATH=$HOME/dot/bin:$GOPATH/bin:$PXPATH/bin:$PATH +export PATH=$HOME/.local/bin:$GOPATH/bin:$PXPATH/bin:$PATH ## programs ## @@ -31,3 +31,4 @@ export CVSROOT=anoncvs@anoncvs.fr.openbsd.org:/cvs export SSH_AUTH_SOCK=$HOME/.ssh/agent export ENV=$HOME/.bashrc export LESS=-SR +export OPEN="$HOME/dot/open" diff --git a/open/extension/0 b/open/extension/0 @@ -0,0 +1,2 @@ +#!/usr/bin/env execlineb +importas 1 1 mandoc -a -T utf8 $1 diff --git a/open/extension/0p b/open/extension/0p @@ -0,0 +1,2 @@ +#!/usr/bin/env execlineb +importas 1 1 mandoc -a -T utf8 $1 diff --git a/open/extension/1 b/open/extension/1 @@ -0,0 +1,2 @@ +#!/usr/bin/env execlineb +importas 1 1 mandoc -a -T utf8 $1 diff --git a/open/extension/1p b/open/extension/1p @@ -0,0 +1,2 @@ +#!/usr/bin/env execlineb +importas 1 1 mandoc -a -T utf8 $1 diff --git a/open/extension/2 b/open/extension/2 @@ -0,0 +1,2 @@ +#!/usr/bin/env execlineb +importas 1 1 mandoc -a -T utf8 $1 diff --git a/open/extension/2p b/open/extension/2p @@ -0,0 +1,2 @@ +#!/usr/bin/env execlineb +importas 1 1 mandoc -a -T utf8 $1 diff --git a/open/extension/3 b/open/extension/3 @@ -0,0 +1,2 @@ +#!/usr/bin/env execlineb +importas 1 1 mandoc -a -T utf8 $1 diff --git a/open/extension/3p b/open/extension/3p @@ -0,0 +1,2 @@ +#!/usr/bin/env execlineb +importas 1 1 mandoc -a -T utf8 $1 diff --git a/open/extension/4 b/open/extension/4 @@ -0,0 +1,2 @@ +#!/usr/bin/env execlineb +importas 1 1 mandoc -a -T utf8 $1 diff --git a/open/extension/4p b/open/extension/4p @@ -0,0 +1,2 @@ +#!/usr/bin/env execlineb +importas 1 1 mandoc -a -T utf8 $1 diff --git a/open/extension/5 b/open/extension/5 @@ -0,0 +1,2 @@ +#!/usr/bin/env execlineb +importas 1 1 mandoc -a -T utf8 $1 diff --git a/open/extension/5p b/open/extension/5p @@ -0,0 +1,2 @@ +#!/usr/bin/env execlineb +importas 1 1 mandoc -a -T utf8 $1 diff --git a/open/extension/6 b/open/extension/6 @@ -0,0 +1,2 @@ +#!/usr/bin/env execlineb +importas 1 1 mandoc -a -T utf8 $1 diff --git a/open/extension/6p b/open/extension/6p @@ -0,0 +1,2 @@ +#!/usr/bin/env execlineb +importas 1 1 mandoc -a -T utf8 $1 diff --git a/open/extension/7 b/open/extension/7 @@ -0,0 +1,2 @@ +#!/usr/bin/env execlineb +importas 1 1 mandoc -a -T utf8 $1 diff --git a/open/extension/7p b/open/extension/7p @@ -0,0 +1,2 @@ +#!/usr/bin/env execlineb +importas 1 1 mandoc -a -T utf8 $1 diff --git a/open/extension/7z b/open/extension/7z @@ -0,0 +1,2 @@ +#!/usr/bin/env execlineb +importas 1 1 7z x $1 diff --git a/open/extension/8 b/open/extension/8 @@ -0,0 +1,2 @@ +#!/usr/bin/env execlineb +importas 1 1 mandoc -a -T utf8 $1 diff --git a/open/extension/8p b/open/extension/8p @@ -0,0 +1,2 @@ +#!/usr/bin/env execlineb +importas 1 1 mandoc -a -T utf8 $1 diff --git a/open/extension/9 b/open/extension/9 @@ -0,0 +1,2 @@ +#!/usr/bin/env execlineb +importas 1 1 mandoc -a -T utf8 $1 diff --git a/open/extension/9p b/open/extension/9p @@ -0,0 +1,2 @@ +#!/usr/bin/env execlineb +importas 1 1 mandoc -a -T utf8 $1 diff --git a/open/extension/a b/open/extension/a @@ -0,0 +1,2 @@ +#!/usr/bin/env execlineb +pipeline { importas 1 1 nm $1 } less diff --git a/open/extension/avi b/open/extension/avi @@ -0,0 +1,2 @@ +#!/usr/bin/env execlineb +importas 1 1 play $1 diff --git a/open/extension/bz2 b/open/extension/bz2 @@ -0,0 +1,3 @@ +#!/usr/bin/env execlineb +importas 1 1 backtick f { pipeline { echo $1 } sed "s/.bz2$//" } +importas f f if { mv $1 $f } open $f diff --git a/open/extension/deb b/open/extension/deb @@ -0,0 +1,2 @@ +#!/usr/bin/env execlineb +importas 1 1 ar vx $1 diff --git a/open/extension/flac b/open/extension/flac @@ -0,0 +1,2 @@ +#!/usr/bin/env execlineb +importas 1 1 play $1 diff --git a/open/extension/gif b/open/extension/gif @@ -0,0 +1,2 @@ +#!/usr/bin/env execlineb +importas 1 1 ffplay -loop 0 $1 diff --git a/open/extension/gz b/open/extension/gz @@ -0,0 +1,3 @@ +#!/usr/bin/env execlineb +importas 1 1 backtick f { pipeline { echo $1 } sed "s/.gz$//" } +importas f f if { mv $1 $f } open $f diff --git a/open/extension/html b/open/extension/html @@ -0,0 +1,2 @@ +#!/usr/bin/env execlineb +importas 1 1 links "$1" diff --git a/open/extension/ics b/open/extension/ics @@ -0,0 +1,2 @@ +#!/usr/bin/env execlineb +pipeline { importas 1 1 ics2txt txt $1 } less diff --git a/open/extension/iso b/open/extension/iso @@ -0,0 +1,2 @@ +#!/bin/sh -e +importas 1 1 qemu-system-x86_64 -m 333M $1 diff --git a/open/extension/jpeg b/open/extension/jpeg @@ -0,0 +1,2 @@ +#!/usr/bin/env execlineb +background { pipeline { importas 1 1 redirfd -r 0 $1 jpg2ff } lel } diff --git a/open/extension/jpg b/open/extension/jpg @@ -0,0 +1,2 @@ +#!/usr/bin/env execlineb +background { pipeline { importas 1 1 redirfd -r 0 $1 jpg2ff } lel } diff --git a/open/extension/lz b/open/extension/lz @@ -0,0 +1,3 @@ +#!/usr/bin/env execlineb +importas 1 1 backtick f { pipeline { echo $1 } sed "s/.lz$//" } +importas f f if { mv $1 $f } open $f diff --git a/open/extension/mkv b/open/extension/mkv @@ -0,0 +1,2 @@ +#!/usr/bin/env execlineb +importas 1 1 play $1 diff --git a/open/extension/mp3 b/open/extension/mp3 @@ -0,0 +1,2 @@ +#!/usr/bin/env execlineb +importas 1 1 play $1 diff --git a/open/extension/mp4 b/open/extension/mp4 @@ -0,0 +1,2 @@ +#!/usr/bin/env execlineb +importas 1 1 play $1 diff --git a/open/extension/o b/open/extension/o @@ -0,0 +1,2 @@ +#!/usr/bin/env execlineb +pipeline { importas 1 1 objdump -D $1 } less diff --git a/open/extension/ogg b/open/extension/ogg @@ -0,0 +1,2 @@ +#!/usr/bin/env execlineb +importas 1 1 play $1 diff --git a/open/extension/ogv b/open/extension/ogv @@ -0,0 +1,2 @@ +#!/usr/bin/env execlineb +importas 1 1 play $1 diff --git a/open/extension/opus b/open/extension/opus @@ -0,0 +1,2 @@ +#!/usr/bin/env execlineb +importas 1 1 play $1 diff --git a/open/extension/pdf b/open/extension/pdf @@ -0,0 +1,2 @@ +#!/usr/bin/env execlineb +importas 1 1 background { mupdf "$1" } diff --git a/open/extension/png b/open/extension/png @@ -0,0 +1,2 @@ +#!/usr/bin/env execlineb +background { pipeline { importas 1 1 redirfd 1 $1 png2ff } lel } diff --git a/open/extension/ps b/open/extension/ps @@ -0,0 +1,2 @@ +#!/usr/bin/env execlineb +background { importas 1 1 gs $1 } diff --git a/open/extension/rar b/open/extension/rar @@ -0,0 +1,2 @@ +#!/usr/bin/env execlineb +importas 1 1 unrar x $1 diff --git a/open/extension/tar b/open/extension/tar @@ -0,0 +1,2 @@ +#!/usr/bin/env execlineb +importas 1 1 tar -xf $1 diff --git a/open/extension/tbz b/open/extension/tbz @@ -0,0 +1,3 @@ +#!/usr/bin/env execlineb +importas 1 1 backtick f { pipeline { echo $1 } sed "s/.tbz$/.tar.bz2/" } +importas f f if { mv $1 $f } open $f diff --git a/open/extension/tgz b/open/extension/tgz @@ -0,0 +1,3 @@ +#!/usr/bin/env execlineb +importas 1 1 backtick f { pipeline { echo $1 } sed "s/.tgz$/.tar.gz/" } +importas f f if { mv $1 $f } open $f diff --git a/open/extension/tlz b/open/extension/tlz @@ -0,0 +1,3 @@ +#!/usr/bin/env execlineb +importas 1 1 backtick f { pipeline { echo $1 } sed "s/.tlz$/.tar.lz/" } +importas f f if { mv $1 $f } open $f diff --git a/open/extension/txz b/open/extension/txz @@ -0,0 +1,3 @@ +#!/usr/bin/env execlineb +importas 1 1 backtick f { pipeline { echo $1 } sed "s/.txz$/.tar.xz/" } +importas f f if { mv $1 $f } open $f diff --git a/open/extension/vorbis b/open/extension/vorbis @@ -0,0 +1,2 @@ +#!/usr/bin/env execlineb +importas 1 1 play $1 diff --git a/open/extension/wav b/open/extension/wav @@ -0,0 +1,2 @@ +#!/usr/bin/env execlineb +importas 1 1 play $1 diff --git a/open/extension/webm b/open/extension/webm @@ -0,0 +1,2 @@ +#!/usr/bin/env execlineb +importas 1 1 play $1 diff --git a/open/extension/xz b/open/extension/xz @@ -0,0 +1,3 @@ +#!/usr/bin/env execlineb +importas 1 1 backtick f { pipeline { echo $1 } sed "s/.xz$//" } +importas f f if { mv $1 $f } open $f diff --git a/open/extension/zip b/open/extension/zip @@ -0,0 +1,2 @@ +#!/usr/bin/env execlineb +importas 1 1 unzip $1 diff --git a/open/protocol/9p b/open/protocol/9p @@ -0,0 +1,5 @@ +#!/bin/sh -e + +dir=/mnt/9p/$host +mkdir -p "$dir" +exec 9pfs "$host" "$dir" diff --git a/open/protocol/ftp b/open/protocol/ftp @@ -0,0 +1,2 @@ +#!/bin/sh -e +exec ftp "$1" diff --git a/open/protocol/git b/open/protocol/git @@ -0,0 +1,8 @@ +#!/bin/sh -e +dir=$HOME/git/$host +case $1 in (*github.com*|*bitbucket.com*) + dir=$dir/$(dirname "$file") +esac +mkdir -p "$dir" +cd $dir +exec git clone "$1" diff --git a/open/protocol/http b/open/protocol/http @@ -0,0 +1,2 @@ +#!/bin/sh -ex +exec web "$1" diff --git a/open/protocol/https b/open/protocol/https @@ -0,0 +1,2 @@ +#!/bin/sh -ex +exec web "$1" diff --git a/open/protocol/news b/open/protocol/news @@ -0,0 +1,2 @@ +#!/bin/sh -ex +exec links "$1" diff --git a/open/protocol/sacc b/open/protocol/sacc @@ -0,0 +1,2 @@ +#!/bin/sh -e +exec sacc "$1" diff --git a/open/protocol/sftp b/open/protocol/sftp @@ -0,0 +1,2 @@ +test -z "$port" && port='22' +exec sftp -P $port $host diff --git a/open/protocol/ssh b/open/protocol/ssh @@ -0,0 +1,4 @@ +#!/bin/sh -e +test "$user" && host=$user@$host +test "$port" && port=-p' '$port +exec ssh $port "$host" diff --git a/open/protocol/telnet b/open/protocol/telnet @@ -0,0 +1,2 @@ +#!/bin/sh -e +exec telnet "$port" "$host" diff --git a/open/protocol/vnc b/open/protocol/vnc @@ -0,0 +1,2 @@ +#!/bin/sh -e +exec vncviewer -use8 "$(echo "$1" | sed 's,vnc://,,')"