dot

packages and services management
Log | Files | Refs | README

commit 5d424f9e1c95e3973778b11c8d6e4252b5630d24
parent 7bb8492d9887884eef5c6128226f8c953d96f3f2
Author: Josuah Demangeon <mail@josuah.net>
Date:   Tue,  3 Jul 2018 23:38:47 +0200

add the scripts in here

Diffstat:
Abin/80 | 15+++++++++++++++
Abin/agent | 7+++++++
Abin/bitreich-blog | 414+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Abin/bitreich-export-git | 76++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Abin/bitreich-paste | 13+++++++++++++
Abin/blih | 286+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Abin/clip | 18++++++++++++++++++
Abin/dvtm-status | 13+++++++++++++
Abin/echo | 4++++
Abin/edit | 7+++++++
Abin/ff2touch | 11+++++++++++
Abin/fig | 67+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Abin/flac-split | 5+++++
Abin/fun-psyche | 387+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Abin/fun-troll | 16++++++++++++++++
Abin/git-all | 9+++++++++
Abin/git-count | 4++++
Abin/git-dog | 3+++
Abin/git-mirror | 11+++++++++++
Abin/git-s | 4++++
Abin/git-stat | 3+++
Abin/git-update | 7+++++++
Abin/header | 18++++++++++++++++++
Abin/http-0x0.st | 3+++
Abin/http-icanhazip.com | 3+++
Abin/http-wttr.in | 3+++
Abin/ii-client | 14++++++++++++++
Abin/include | 8++++++++
Abin/io-session | 3+++
Abin/io-uri | 3+++
Abin/light | 11+++++++++++
Abin/lines | 16++++++++++++++++
Abin/make-a | 10++++++++++
Abin/mdoc | 74++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Abin/mfilter | 94+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Abin/mount-key | 7+++++++
Abin/mread | 5+++++
Abin/msearch | 5+++++
Abin/mv-flac | 40++++++++++++++++++++++++++++++++++++++++
Abin/mv-groupdir | 21+++++++++++++++++++++
Abin/mv-sane | 17+++++++++++++++++
Abin/nft-nat | 26++++++++++++++++++++++++++
Abin/o | 2++
Abin/pack | 63+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Abin/piano | 122+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Abin/play | 10++++++++++
Abin/plumb | 3+++
Abin/proto | 94+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Abin/rfc | 16++++++++++++++++
Abin/session | 32++++++++++++++++++++++++++++++++
Abin/shell | 9+++++++++
Abin/sound | 14++++++++++++++
Abin/ssh-paste | 9+++++++++
Abin/start-acme | 11+++++++++++
Abin/suckless-patch-mail | 8++++++++
Abin/term-black | 3+++
Abin/term-clear | 3+++
Abin/term-white | 3+++
Abin/tty-theme | 346+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Abin/tty-video | 5+++++
Abin/update-agenda | 10++++++++++
Abin/update-sfeed | 36++++++++++++++++++++++++++++++++++++
Abin/web | 66++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Abin/woman | 3+++
Abin/xdg-open | 158+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mdot/profile | 2+-
66 files changed, 2788 insertions(+), 1 deletion(-)

diff --git a/bin/80 b/bin/80 @@ -0,0 +1,15 @@ +#!/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/agent b/bin/agent @@ -0,0 +1,7 @@ +#!/bin/sh -e +# start all authentication agents + +if ! pgrep -f "ssh-agent -a $HOME/.ssh/agent" +then rm -f "$HOME/.ssh/agent" + ssh-agent -a "$HOME/.ssh/agent" +fi diff --git a/bin/bitreich-blog b/bin/bitreich-blog @@ -0,0 +1,414 @@ +#!/usr/bin/env python2 +# coding=utf-8 +# +# Copy me if you can. +# by 20h +# + +import os +import sys +import re +import codecs +import glob +from subprocess import Popen, PIPE +import getopt +import tempfile +from datetime import datetime +import pytz + +# Config at base/blogrc +DEFAULTBASE = "~/.blog" + +class git(object): + def __init__(self, base=None): + if base == None: + base = DEFAULTBASE + self.base = os.path.expanduser(base) + if not os.path.exists(self.base): + os.makedirs(self.base, 0o750) + + if self.base[-1] != os.sep: + self.pages = "%s%s" % (self.base, os.sep) + else: + self.pages = path + + self.keycache = None + + """ I/O helper functions. """ + def getfile(self, fi): + fd = codecs.open(fi, mode="r", encoding="utf-8") + text = fd.read() + fd.close() + return text + + def putfile(self, fi, content): + #content = content.decode("utf-8") + fd = codecs.open(fi, mode="w+", encoding="utf-8") + fd.write(content) + fd.close() + return None + + def mkpath(self, path, fi=None): + if path[-1] != os.sep: + path = "%s%s" % (path, os.sep) + if fi != None: + path = "%s%s" % (path, fi) + + return path + + def recursedir(self, path): + subdirs = [] + files = os.listdir(path) + files.sort() + for f in files: + npath = self.mkpath(path, f) + if os.path.isfile(npath) or \ + os.path.islink(npath): + yield npath + else: + subdirs.append(f) + + for s in subdirs: + npath = self.mkpath(path, s) + if s == ".git": + continue + for j in self.recursedir(npath): + yield j + + def makesearchlist(self, fun, path): + li = [] + npath = self.mkpath(path) + for i in fun(path): + i = i.replace(npath, "") + if i == "blogrc": + continue + i = i.replace(".md", "") + li.append(i) + return li + + """ Git command functions. """ + def git(self, cmd): + gitdir = "%s.git" % (self.pages) + workdir = self.pages + gitcmd = "git --git-dir=%s --work-tree=%s %s" % (gitdir, + workdir, cmd) + + p = Popen(gitcmd, stdout=PIPE, shell=True) + result = p.stdout.read() + + return [result, p.wait()] + + def gitpath(self, file): + return "%s%s.md" % (self.pages, file) + + def gitfile(self, file): + return "%s.md" % (file) + + def init(self): + self.git("init") + + def add(self, file): + self.git("add %s" % (file)) + + def rm(self, file): + self.git("rm %s" % (file)) + + def mv(self, old, new): + self.git("mv %s %s" % (old, new)) + + def commit(self, msg): + self.git("commit --allow-empty --no-verify --message=\"%s\"" \ + " --author=\"psw <psw@psw>\"" % (msg)) + self.git("gc") + + def log(self, page): + changes = [] + if page == "": + file = "" + else: + file = self.gitpath(page) + (result, status) = self.git("log" \ + " --pretty=format:'%%H>%%T>%%an>%%ae>%%aD>%%s'" \ + " -- %s" % (file)) + for line in result.split("\n"): + change = {} + entries = line.split(">") + change["author"] = entries[2] + change["email"] = entries[3] + change["date"] = entries[4] + change["message"] = entries[5] + change["commit"] = entries[0] + try: + (task, cpage) = entries[5].split(" ") + except: + cpage = page + change["page"] = cpage + changes.append(change) + + return changes + + def showcommit(self, page, commit): + (file, status) = self.git("cat-file -p %s:%s.md" \ + % (commit, page)) + return file + + """ Dictionary abstraction functions. """ + def __setitem__(self, page, value): + file = self.gitpath(page) + needadd = False + if os.path.exists(file) == False: + needadd = True + self.putfile(file, value) + + self.add(file) + if needadd: + self.commit("Added: %s" % (page)) + else: + self.commit("Changed: %s" % (page)) + + def __delitem__(self, page): + file = self.gitpath(page) + os.remove(file) + + self.rm(file) + self.commit("Deleted: %s" % (page)) + + def __getitem__(self, page): + try: + return self.getfile(self.gitpath(page)) + except IOError as err: + return "" + + def getlog(self, page): + log = self.log(page) + ret = "" + for i in log: + ret += "%s %s %s %s %s %s\n" % (i["commit"], + i["author"], + i["email"], i["date"], i["page"], + i["message"]) + return ret + + def mkkeycache(self): + if self.keycache == None: + self.keycache = self.makesearchlist(self.recursedir, + self.pages) + + def keys(self): + self.mkkeycache() + return self.keycache + + def __contains__(self, item): + return item in self.keys() + + def search(self, query): + results = [] + for i in self.keys(): + m = re.search(query, i) + if m != None: + results.append(i) + return results + + def move(self, old, new): + opath = self.gitpath(old) + npath = self.gitpath(new) + self.mv(opath, npath) + self.commit("Moved: %s -> %s" % (old, new)) + +def editor(content): + try: + app = os.environ.get("EDITOR") + except KeyError: + app = "vim" + + tfile = tempfile.mkstemp(suffix=".md") + fd = codecs.open(tfile[1], mode="w+", encoding="utf-8") + fd.write(content) + fname = tfile[1] + + p = Popen("%s %s" % (app, fname), shell=True) + sts = p.wait() + + fd.seek(0) + data = fd.read() + fd.close() + os.remove(fname) + + return (sts, data) + +def getcfgvalue(cfg, key, defvalue=""): + for i in cfg: + if i[0] == key: + if len(i) > 2: + return i[1:] + elif len(i) == 1: + return "" + else: + return i[1] + return defvalue + +def readcfg(cfgf, splitn=1): + lcfg = [] + lpath = os.path.expanduser(cfgf) + + try: + cfd = open(lpath, "r") + except IOError: + return None + + line = cfd.readline() + while line != "": + line = line.rstrip("\n ") + if line == "" or line[0] == "#": + line = cfd.readline() + continue + + lcfg.append(line.split(" ", splitn)) + line = cfd.readline() + + return lcfg + +def usage(app): + app = os.path.basename(app) + sys.stderr.write("usage: %s [-onh] [-b base] [-a|[-d|-e|-c|-s] item" \ + "|-l|-r old new]\n" % (app)) + sys.exit(1) + +def main(args): + try: + opts, largs = getopt.getopt(args[1:], "haslb:odecrpn") + except getopt.GetoptError as err: + print str(err) + usage(args[0]) + + dorm = False + doedit = False + docommit = False + dosearch = False + dolist = False + dorename = False + dopublish = False + tostdout = False + doadd = False + justnames = False + base = DEFAULTBASE + for o, a in opts: + if o == "-h": + usage(args[0]) + elif o == "-l": + dolist = True + elif o == "-e": + doedit = True + elif o == "-d": + dorm = True + elif o == "-c": + docommit = True + elif o == "-s": + dosearch = True + elif o == "-b": + base = a + elif o == "-o": + tostdout = True + elif o == "-r": + dorename = True + elif o == "-a": + doadd = True + elif o == "-p": + dopublish = True + elif o == "-n": + justnames = True + else: + assert False, "unhandled option" + + val = "" + if doedit == True or dosearch == True or dorm == True \ + or tostdout == True or dopublish == True: + if len(largs) < 1: + usage(args[0]) + val = "_".join(largs) + elif dorename == True: + if len(largs) < 2: + usage(args[0]) + + lgit = git(base) + + if doedit == True or doadd == True: + if doadd == True: + dt = pytz.utc.localize(datetime.utcnow()) + datestr = dt.strftime("%Y-%m-%d %H:%M:%S.%f %Z (%z)") + val = dt.strftime("%Y-%m-%dT%H-%M-%S-%f") + content = lgit[val] + if content == "" and doadd == True: + content = "# %s\n\n" % (datestr) + + (sts, data) = editor(content) + if data == content: + print "No changes made. Quitting." + else: + print "Some changes made. Committing." + lgit[val] = data + print val + elif tostdout == True and docommit == False: + sys.stdout.write(lgit[val].encode("utf-8")) + elif dorename == True: + lgit.move(largs[0], largs[1]) + elif dorm == True: + del lgit[val] + elif docommit == True: + commits = lgit.getlog(val) + if tostdout == True: + sys.stdout.write(commits) + else: + editor(commits) + elif dosearch == True: + results = lgit.search(val) + for r in results: + print r + elif dolist == True: + for k in lgit.keys(): + title = lgit[k].split("\n")[2].encode("utf-8") + if justnames == True: + print k + else: + print "%s :: %s" % (k, title) + elif dopublish == True: + cfg = readcfg("%s/blogrc" % (base)) + publishcp = getcfgvalue(cfg, "publishcp") + publishcmd = getcfgvalue(cfg, "publishcmd") + + if publishcp == "": + sys.stderr.write("No 'publishcp' was specified. " \ + "Doing no cp.\n") + else: + sys.stdout.write("Copying over file '%s' ..." % (largs[0])) + sys.stdout.flush() + p = Popen(publishcp % (lgit.gitpath(largs[0])), \ + stdout=PIPE, shell=True) + result = p.stdout.read() + if len(result) > 0: + print result + else: + print "done" + + if publishcmd == "": + sys.stderr.write("No 'publishcmd' was specified. " \ + "Doing nothing.\n") + else: + sys.stdout.write("Executing blog command '%s' ..." % \ + (publishcmd)) + sys.stdout.flush() + p = Popen(publishcmd % (lgit.gitfile(largs[0])), \ + stdout=PIPE, shell=True) + result = p.stdout.read() + if len(result) > 0: + print result + else: + print "done" + else: + usage(args[0]) + + return 0 + +if __name__ == "__main__": + sys.exit(main(sys.argv)) + diff --git a/bin/bitreich-export-git b/bin/bitreich-export-git @@ -0,0 +1,76 @@ +#!/bin/sh -e + +#set -x + +BRUSER="josuah@bitreich.org" +if [ -z "$BRUSER" ]; +then + BRUSER="$USER@bitreich.org" +fi + +if [ $# -lt 3 ]; +then + printf 'usage: %s srcrepo repo description\n' "$(basename "$0")" >&2 + exit 1 +fi + +if [ -z "${1##/*}" ]; +then + srcrepo="$1" +else + srcrepo="$PWD/$1" +fi +repo="$2" +shift 2 +description="$@" + +printf 'Exporting %s (%s) to ssh://%s/scm/%s ... \n' \ + "$srcrepo" "$description" "$BRUSER" "$repo" + +ssh "$BRUSER" -- mkdir -p "\$HOME/scm/" + +# temp dir for bare git repository. +baretmpdir="$(mktemp -d)" +cd "${baretmpdir}" + +git clone --bare "$srcrepo" "$repo" +printf "git://bitreich.org/%s git://hg6vgqziawt5s4dj.onion%s\n" \ + "${repo}" "${repo}" > "${repo}/url" + +printf '[core] + repositoryformatversion = 0 + filemode = true + bare = true + +[gitweb] + owner = %s <%s> +' "$(git config user.name)" "$(git config user.email)" > "${repo}/config" + +printf '%s\n' "$description" > "${repo}/description" + +scp -r "$repo" "$BRUSER:/scm/" + +printf '[core] + repositoryformatversion = 0 + filemode = true + +[remote "origin"] + fetch = +refs/heads/*:refs/remotes/origin/* + url = ssh://%s/scm/%s +[branch "master"] + remote = origin + merge = refs/heads/master +' "$BRUSER" "$repo" > "$srcrepo/.git/config" + +# Hooks. +ssh "$BRUSER" -- "ln -sf /br/scm/post-receive /br/scm/$repo/hooks/post-receive" + +# Run the git hooks on bitreich. +ssh "$BRUSER" -- "/br/scm/mk-stagit-gph $repo" +ssh "$BRUSER" -- "/br/scm/mk-stagit-tag $repo" + +# cleanup +rm -rf "${baretmpdir}" + +printf 'Export done.\n' + diff --git a/bin/bitreich-paste b/bin/bitreich-paste @@ -0,0 +1,13 @@ +#!/9/bin/rc -e + +DST=josuah@bitreich.org +DSTDIR=/bitreich/gopher/paste + +ssh $DST ' + set -e + cd '$DSTDIR' + tmp=$(mktemp "p-XXXXXX.txt") + cat >$tmp + chmod g+rw "$tmp" + echo "$tmp" +' | sed 's,^,gopher://bitreich.org/0/p/,' diff --git a/bin/blih b/bin/blih @@ -0,0 +1,286 @@ +#!/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 @@ -0,0 +1,18 @@ +#!/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) shift + cat "$@" >$CLIP + ;; +(-o) cat "$CLIP" + ;; +(*) echo 'usage: clip -[io] [file...]' + ;; +esac diff --git a/bin/dvtm-status b/bin/dvtm-status @@ -0,0 +1,13 @@ +#!/9/bin/rc -e +# start dvtm with a status and command fifo + +DVTM_STATUS_FIFO=/tmp/dvtm-status.$pid +DVTM_CMD_FIFO=/tmp/dvtm-cmd.$pid +mkfifo -m 600 $DVTM_STATUS_FIFO $DVTM_CMD_FIFO + +slstatus -s >$DVTM_STATUS_FIFO & + +dvtm -s $DVTM_STATUS_FIFO -c $DVTM_CMD_FIFO $* + +kill $apid +rm $DVTM_STATUS_FIFO diff --git a/bin/echo b/bin/echo @@ -0,0 +1,4 @@ +#!/bin/sh -e +# print the arguments separated by one space and then a newline. + +printf '%s\n' "$*" diff --git a/bin/edit b/bin/edit @@ -0,0 +1,7 @@ +#!/bin/sh -e +# script to be used as EDITOR + +command -v vi && EDITOR='vi' + +cd "$(dirname "$1")" +exec $EDITOR "$(basename "$1")" diff --git a/bin/ff2touch b/bin/ff2touch @@ -0,0 +1,11 @@ +#!/bin/sh -e +# setup a braille drawing of an image as an ls result + +IFS=' +' +i=0 + +for line in $(ff2braille | tr / -) +do touch "$(printf %02x%s "$i" "$line")" + i=$((expr i + 1)) +done diff --git a/bin/fig b/bin/fig @@ -0,0 +1,67 @@ +#!/bin/sh -e +# various text transformation utilities + +case $1 in +(mirror) + sed -e 's/a/ɒ/g' -e 's/b/d/g' -e 's/c/ɔ/g' -e 's/d/b/g' \ + -e 's/e/ɘ/g' -e 's/f/Ꮈ/g' -e 's/g/ǫ/g' -e 's/h/ʜ/g' \ + -e 's/i/i/g' -e 's/j/ꞁ/g' -e 's/k/ʞ/g' -e 's/l/|/g' \ + -e 's/m/m/g' -e 's/n/ᴎ/g' -e 's/o/o/g' -e 's/p/q/g' \ + -e 's/q/p/g' -e 's/r/ɿ/g' -e 's/s/ꙅ/g' -e 's/t/ƚ/g' \ + -e 's/u/u/g' -e 's/v/v/g' -e 's/w/w/g' -e 's/x/x/g' \ + -e 's/y/ʏ/g' -e 's/z/ƹ/g' -e 's/A/A/g' -e 's/B/ᙠ/g' \ + -e 's/C/Ɔ/g' -e 's/D/ᗡ/g' -e 's/E/Ǝ/g' -e 's/F/ꟻ/g' \ + -e 's/G/Ꭾ/g' -e 's/H/H/g' -e 's/I/I/g' -e 's/J/Ⴑ/g' \ + -e 's/K/⋊/g' -e 's/L/⅃/g' -e 's/M/M/g' -e 's/N/Ͷ/g' \ + -e 's/O/O/g' -e 's/P/ꟼ/g' -e 's/Q/Ọ/g' -e 's/R/Я/g' \ + -e 's/S/Ꙅ/g' -e 's/T/T/g' -e 's/U/U/g' -e 's/V/V/g' \ + -e 's/W/W/g' -e 's/X/X/g' -e 's/Y/Y/g' -e 's/Z/Ƹ/g' | + tr ')(][}{><' '()[]{}<>' | rev + ;; +(reverse) + sed -e 's/a/ɐ/g' -e 's/c/ɔ/g' -e 's/e/ǝ/g' -e 's/f/ɟ/g' \ + -e 's/g/ƃ/g' -e 's/h/ɥ/g' -e 's/i/ᴉ/g' -e 's/j/ɾ/g' \ + -e 's/k/ʞ/g' -e 's/l/j/g' -e 's/m/ɯ/g' -e 's/o/o/g' \ + -e 's/r/ɹ/g' -e 's/s/s/g' -e 's/t/ʇ/g' -e 's/v/ʌ/g' \ + -e 's/w/ʍ/g' -e 's/x/x/g' -e 's/y/ʎ/g' -e 's/z/z/g' \ + -e 's/A/∀/g' -e 's/B/B/g' -e 's/C/Ɔ/g' -e 's/D/D/g' \ + -e 's/E/Ǝ/g' -e 's/F/Ⅎ/g' -e 's/G/פ/g' -e 's/H/H/g' \ + -e 's/I/I/g' -e 's/J/ſ/g' -e 's/K/K/g' -e 's/L/˥/g' \ + -e 's/M/W/g' -e 's/N/N/g' -e 's/O/O/g' -e 's/P/Ԁ/g' \ + -e 's/Q/Q/g' -e 's/R/R/g' -e 's/S/S/g' -e 's/T/┴/g' \ + -e 's/U/∩/g' -e 's/V/Λ/g' -e 's/W/M/g' -e 's/X/X/g' \ + -e 's/Y/⅄/g' -e 's/Z/Z/g' -e 's/0/0/g' -e 's/1/Ɩ/g' \ + -e 's/2/ᄅ/g' -e 's/3/Ɛ/g' -e 's/4/ㄣ/g' -e 's/5/ϛ/g' \ + -e 's/7/ㄥ/g' -e 's/8/8/g' -e 's/&/⅋/g' -e 's/_/‾/g' | + tr 'bqdpnu69' 'qbpdun96' | rev + ;; +(fullwidth) + sed -e 's/!/!/g' -e 's/"/"/g' -e 's/#/#/g' -e 's/\$/$/g' \ + -e 's/%/%/g' -e 's/&/&/g' -e 's/'\''/'/g' -e 's/(/(/g' \ + -e 's/)/)/g' -e 's/\*/*/g' -e 's/+/+/g' -e 's/,/,/g' \ + -e 's/-/-/g' -e 's/\././g' -e 's/\////g' -e 's/0/0/g' \ + -e 's/1/1/g' -e 's/2/2/g' -e 's/3/3/g' -e 's/4/4/g' \ + -e 's/5/5/g' -e 's/6/6/g' -e 's/7/7/g' -e 's/8/8/g' \ + -e 's/9/9/g' -e 's/:/:/g' -e 's/;/;/g' -e 's/</</g' \ + -e 's/=/=/g' -e 's/>/>/g' -e 's/?/?/g' -e 's/@/@/g' \ + -e 's/A/A/g' -e 's/B/B/g' -e 's/C/C/g' -e 's/D/D/g' \ + -e 's/E/E/g' -e 's/F/F/g' -e 's/G/G/g' -e 's/H/H/g' \ + -e 's/I/I/g' -e 's/J/J/g' -e 's/K/K/g' -e 's/L/L/g' \ + -e 's/M/M/g' -e 's/N/N/g' -e 's/O/O/g' -e 's/P/P/g' \ + -e 's/Q/Q/g' -e 's/R/R/g' -e 's/S/S/g' -e 's/T/T/g' \ + -e 's/U/U/g' -e 's/V/V/g' -e 's/W/W/g' -e 's/X/X/g' \ + -e 's/Y/Y/g' -e 's/Z/Z/g' -e 's/\[/[/g' -e 's/\\/\/g' \ + -e 's/]/]/g' -e 's/\^/^/g' -e 's/_/_/g' -e 's/`/`/g' \ + -e 's/a/a/g' -e 's/b/b/g' -e 's/c/c/g' -e 's/d/d/g' \ + -e 's/e/e/g' -e 's/f/f/g' -e 's/g/g/g' -e 's/h/h/g' \ + -e 's/i/i/g' -e 's/j/j/g' -e 's/k/k/g' -e 's/l/l/g' \ + -e 's/m/m/g' -e 's/n/n/g' -e 's/o/o/g' -e 's/p/p/g' \ + -e 's/q/q/g' -e 's/r/r/g' -e 's/s/s/g' -e 's/t/t/g' \ + -e 's/u/u/g' -e 's/v/v/g' -e 's/w/w/g' -e 's/x/x/g' \ + -e 's/y/y/g' -e 's/z/z/g' -e 's/{/{/g' -e 's/|/|/g' \ + -e 's/}/}/g' -e 's/~/~/g' -e 's/ / /g' + ;; +(*) + echo 'usage: fig mirror | reverse | fullwidth\n' + ;; +esac diff --git a/bin/flac-split b/bin/flac-split @@ -0,0 +1,5 @@ +#!/9/bin/rc -e + +if (! ~ $#* 2) exec echo 'usage: '$0' file.cue file.flac' + +shnsplit -n %02d -t %a--%n-%t -o flac -f $1 $2 diff --git a/bin/fun-psyche b/bin/fun-psyche @@ -0,0 +1,387 @@ +#!/9/bin/rc -e + +*=`{echo $* | tr '[:space:]' _ | fold -w 1} + +b=`{printf '\033[31;1m'} +e=`{printf '\033[0m'} +r=`{printf '\033[7m'} + +printf '\033[2J' + +printf '\033[H%s' ' + _____ _ ___ ___,--._________ + _/ ____\ ||/ /// /_____,(_X_) ____ \___ + __/ __ \\\\\o||||//______/ \ \_____/ .__\_____:__ + ___/ _|||||||||||||_ \________|___________|_________ + | _____________ | C22 |.-..-..-..-..-..-..-..-..-..-.| + ::=:| ___ |:=:__ || || || || || || || || || || || + ::=:| |:=:__\ |:=::=::=::=::=::=::=::=::=::=:| + ::=:| P S Y C H E |:=._ \\_/--/--/--/--/--/--/--/--/--/--" + ::=:| ___ |:=._\ \___/ / / _/ / / / / / + ::=;| _____________ |:=._\\______/ / / __/ / / / / + _/ |_______________| \\________/ / / ___/ / / / + (_)__//|||||||\\\\\\_____ \_________/ / (_)___/ _/ _/ + |\__/ ||""""" |||\\____ \___________/ _______/ / + | |-|TTTT|//" \___ \______________/ ________/ + (_) `-|____|/_______\________________/ +' + +sleep 0.1 + +printf '\033[H%s' ' + _____ _ ___ ___,--._________ + _/ ____\ ||/ /// /_____,(_X_) ____ \___ + __/ __ \\\\\o||||//______/ \ \_____/ .__\_____:__ + ___/ _||||'$b'|||'$e'||||||_ \________|___________|_________ + | _____________ | C22 |.-..-..-..-..-..-..-..-..-..-.| + ::=:| ___ |:=:__ || || || || || || || || || || || + ::=:| |:=:__\ |:=::=::=::=::=::=::=::=::=::=:| + ::=:| P S Y C H E |:=._ \\_/--/--/--/--/--/--/--/--/--/--" + ::=:| ___ |:=._\ \___/ / / _/ / / / / / + ::=;| _____________ |:=._\\______/ / / __/ / / / / + _/ |_______________| \\________/ / / ___/ / / / + (_)__//||'$b'|||||'$e'\\\\\\_____ \_________/ / (_)___/ _/ _/ + |\__/ ||""""" |||\\____ \___________/ _______/ / + | |-|TTTT|//" \___ \______________/ ________/ + (_) `-|____|/_______\________________/ +' + +sleep 0.1 + +printf '\033[H%s' ' + _____ _ ___ ___,--._________ + _/ ____\ ||/ /// /_____,(_X_) ____ \___ + __/ __ \\\'$b'\\o|||'$e'|//______/ \ \_____/ .__\_____:__ + ___/ _||'$b'||||||||'$e'|||_ \________|___________|_________ + | _____________ | C22 |.-..-..-..-..-..-..-..-..-..-.| + ::=:| ___ |:=:__ || || || || || || || || || || || + ::=:| |:=:__\ |:=::=::=::=::=::=::=::=::=::=:| + ::=:| P S Y C H E |:=._ \\_/--/--/--/--/--/--/--/--/--/--" + ::=:| ___ |:=._\ \___/ / / _/ / / / / / + ::=;| _____________ |:=._\\______/ / / __/ / / / / + _/ |_______________| \\________/ / / ___/ / / / + (_)__//|'$b'||||||\\'$e'\\\\_____ \_________/ / (_)___/ _/ _/ + |\__/ ||"'$b'""""'$e' |||\\____ \___________/ _______/ / + | |-|TTTT|//" \___ \______________/ ________/ + (_) `-|____|/_______\________________/ +' + +sleep 0.1 + +printf '\033[H%s' ' + _____ _ ___ ___,--._________ + _/ ____\ ||/ '$b'/// '$e'/_____,(_X_) ____ \___ + __/ __ '$b'\\\\\o||||//'$e'______/ \ \_____/ .__\_____:__ + ___/ _'$b'|||||||||||||'$e'_ \________|___________|_________ + | _____________ | C22 |.-..-..-..-..-..-..-..-..-..-.| + ::=:| ___ |:=:__ || || || || || || || || || || || + ::=:| |:=:__\ |:=::=::=::=::=::=::=::=::=::=:| + ::=:| P S Y C H E |:=._ \\_/--/--/--/--/--/--/--/--/--/--" + ::=:| ___ |:=._\ \___/ / / _/ / / / / / + ::=;| _____________ |:=._\\______/ / / __/ / / / / + _/ |_______________| \\________/ / / ___/ / / / + (_)__'$b'//|||||||\\\\\\'$e'_____ \_________/ / (_)___/ _/ _/ + |\__/ '$b'||""""" |||'$e'\\____ \___________/ _______/ / + | |-|TTTT|//" \___ \______________/ ________/ + (_) `-|____|/_______\________________/ +' + +sleep 0.1 + +printf '\033[H%s' ' + _____ '$b' _'$e' ___ ___,--._________ + _/ __'$b'__\ ||/ /// /_____'$e',(_X_) ____ \___ + __/ '$b'__ \\\\\'$e'o'$b'||||//______/'$e' \ \_____/ .__\_____:__ + ___/ _'$b'|||||'$e'|||||'$b'|||'$e'_ \________|___________|_________ + | _____________ | C22 |.-..-..-..-..-..-..-..-..-..-.| + ::=:| ___ |:=:__ || || || || || || || || || || || + ::=:| |:=:__\ |:=::=::=::=::=::=::=::=::=::=:| + ::=:| P S Y C H E |:=._ \\_/--/--/--/--/--/--/--/--/--/--" + ::=:| ___ |:=._\ \___/ / / _/ / / / / / + ::=;| _____________ |:=._\\______/ / / __/ / / / / + '$b'_'$e'/ |_______________| \\________/ / / ___/ / / / + '$b'(_)__//||'$e'|||||'$b'\\\\\\_____'$e' \_________/ / (_)___/ _/ _/ + |\__/ '$b'||""""" |||\\____'$e' \___________/ _______/ / + | '$b'|'$e'-|TTTT|'$b'//" \___ \'$e'______________/ ________/ + (_) `-|____|/_______\________________/ +' + +sleep 0.1 + +printf '\033[H%s' ' + '$b'_____'$e' _ '$b'___'$e' ___,--._________ + '$b'_/ __'$e'__'$b'\'$e' ||/ '$b'/// /'$e'_____'$b','$e'(_X_) ____ \___ + '$b'__/'$e' __ \'$b'\'$e'\\\o||||//___'$b'___/'$e' \ \_____/ .__\_____:__ + '$b'___/'$e' _||'$b'|'$e'||||||||||_ \________|___________|_________ + | _____________ | C22 |.-..-..-..-..-..-..-..-..-..-.| + '$b'::'$e'=:| ___ |:=:__ || || || || || || || || || || || + '$b'::'$e'=:| |:=:__\ |:=::=::=::=::=::=::=::=::=::=:| + '$b'::'$e'=:| P S Y C H E |:=._ \\_/--/--/--/--/--/--/--/--/--/--" + '$b'::'$e'=:| ___ |:=._\ \___/ / / _/ / / / / / + '$b'::'$e'=;| _____________ |:=._\\______/ / / __/ / / / / + _/ |_______________| \\________/ / / ___/ / / / + '$b'(_)__/'$e'/|||||||\\\\\\'$b'_____'$e' \_________/ / (_)___/ _/ _/ + '$b'|\__/'$e' ||'$b'"""""'$e' '$b'|||\\____ \_'$e'__________/ _______/ / + | '$b'|-'$e'|TTTT|'$b'//" \___ \_______'$e'_______/ ________/ + (_) '$b'`-'$e'|____|'$b'/'$e'_______'$b'\___'$e'_____________/ +' + +sleep 0.1 + +printf '\033[H%s' ' + _____ _ ___ ___,--._________ + '$b'_'$e'/ ____\ ||/ /// /_____,(_'$b'X'$e'_) ____ \___ + '$b'_'$e'_/ __ \\\\\o||||//______/ \ \_____/ .__\_____:__ + '$b'_'$e'__/ _|||||||||||||_ \________|___________|_________ + | _____________ | C22 |.-..-..-..-..-..-..-..-..-..-.| + :'$b':='$e':| ___ |:=:__ || || || || || || || || || || || + :'$b':='$e':| |:=:__\ |:=::=::=::=::=::=::=::=::=::=:| + :'$b':='$e':| P S Y C H E |:=._ \\_/--/--/--/--/--/--/--/--/--/--" + :'$b':='$e':| ___ |:=._\ \___/ / / _/ / / / / / + :'$b':='$e';| _____________ |:=._\\______/ / / __/ / / / / + '$b' _/'$e' |_______________| \\________/ / / ___/ / / / + '$b'(_)'$e'__//|||||||\\\\\\_____ \_________/ / (_)___/ _/ _/ + '$b'|'$e'\__/ ||""""" |||\\____ '$b'\_____'$e'______/ _______/ / + '$b'|'$e' |-|'$b'TTTT'$e'|//" '$b'\___ \______________'$e'/ ________/ + '$b'(_)'$e' `-|____|/_______'$b'\________________/'$e' +' + +sleep 0.1 + +printf '\033[H%s' ' + _____ _ ___ ___,--._________ + _/ ____\ ||/ /// /_____,(_X_) ____ \___ + __/ __ \\\\\o||||//______/ \ \_____/ .__\_____:__ + ___/ _|||||||||||||_ \________|___________|_________ + | _____________ | C22 |.-..-..-..-..-..-..-..-..-..-.| + ::'$b'=:'$e'| ___ |:=:__ || || || || || || || || || || || + ::'$b'=:'$e'| |:=:__\ |:=::=::=::=::=::=::=::=::=::=:| + ::'$b'=:'$e'| P S Y C H E |:=._ \\_/--/--/--/--/--/--/--/--/--/--" + ::'$b'=:'$e'| ___ |:=._\ \___/ / / _/ / / / / / + ::'$b'=;'$e'| _____________ |:=._\\______/ / / __/ / / / / + _/ |_______________| \\________/ / / ___/ / / / + (_)__//|||||||\\\\\\_____ \_________/ / (_)___/ _/ _/ + |\__/ ||""""" |||\\____ \____'$b'_______/'$e' _______/ / + | |-|'$b'TTTT'$e'|//" \___ \________'$b'______/ ________/'$e' + (_) `-|____|/_______\_____'$b'___________/'$e' +' + +sleep 0.1 + +printf '\033[H%s' ' + _____ _ ___ ___,--._________ + _/ ____\ ||/ /// /_____,(_'$b'X'$e'_) ____ \___ + __/ __ \\\\\o||||//______/ \ \_____/ .__\_____:__ + ___/ _|||||||||||||_ \________|___________|_________ + | _____________ | C22 |.-..-..-..-..-..-..-..-..-..-.| + ::='$b':'$e'| ___ |:=:__ || || || || || || || || || || || + ::='$b':'$e'| |:=:__\ |:=::=::=::=::=::=::=::=::=::=:| + ::='$b':'$e'| P S Y C H E |:=._ \\_/--/--/--/--/--/--/--/--/--/--" + ::='$b':'$e'| ___ |:=._\ \___/ / / _/ / / / / / + ::='$b';'$e'| _____________ |:=._\\______/ / / __/ / / / / + _/ |_______________| \\________/ / '$b'/'$e' ___/ / / '$b'/'$e' + (_)__//|||||||\\\\\\_____ \_________/ '$b'/'$e' (_)___/ '$b'_/ _/'$e' + |\__/ ||""""" |||\\____ \___________'$b'/'$e' '$b'_______/ /'$e' + | |-|'$b'TTTT'$e'|//" \___ \______________/ '$b'________/'$e' + (_) `-|____|/_______\________________/ +' + +sleep 0.1 + +printf '\033[H%s' ' + _____ _ ___ ___'$b',--._________'$e' + _/ ____\ ||/ /// /_____,(_X_) ____ '$b'\___'$e' + __/ __ \\\\\o||||//______/ \ \_____/ .__\_____:__ + ___/ _|||||||||||||_ \________|___________|_________ + | _____________ | C22 |.-..-..-..-..-..-..-..-..-..-.| + ::=:| ___ |'$b':'$e'=:__ || || || || || || || || || || || + ::=:| |'$b':'$e'=:__\ |:=::=::=::=::=::=::=::=::=::=:| + ::=:| P S Y C H E |'$b':'$e'=._ \\_/--/--/--/--/--/--/--/--/--/--" + ::=:| ___ |'$b':'$e'=._\ \___/ / / _/ / / / '$b'/ /'$e' + ::=;| _____________ |'$b':'$e'=._\\______/ / / '$b'__/'$e' / / '$b'/ /'$e' + _/ |_______________| \\________/ / '$b'/'$e' ___/ / '$b'/ /'$e' + (_)__//|||||||\\\\\\_____ \_________/ '$b'/'$e' (_)___/ '$b'_/ _/'$e' + |\__/ ||""""" |||\\____ \___________/ _______/ / + | |-|'$b'TTTT'$e'|//" \___ \______________/ ________/ + (_) `-|____|/_______\________________/ +' + +sleep 0.1 + +printf '\033[H%s' ' + _____ _ ___ ___,--._________ + _/ ____\ ||/ /// /_____,(_X_) ____ '$b'\___'$e' + __/ __ \\\\\o||||//______/ \ \_____/ .__\_____'$b':'$e'__ + ___/ _|||||||||||||_ \________|___________|_________ + | _____________ | C22 |.-..-..-..-..-..-..-..-..-..-.| + ::=:| ___ |'$b':='$e':__ || || || || || || || || || || || + ::=:| |'$b':='$e':__\ |:=::=::=::=::=::=::=::=::=::=:| + ::=:| P S Y C H E |'$b':='$e'._ \\_/--/--/--/--/--'$b'/'$e'--/--/--'$b'/'$e'--'$b'/'$e'--" + ::=:| ___ |'$b':='$e'._\ \___/ / / _/ '$b'/'$e' / / '$b'/ /'$e' + ::=;| _____________ |'$b':='$e'._\\______/ / / '$b'__/'$e' / / / / + _/ |_______________| \\________/ / / '$b'__'$e'_/ / / / + (_)__//|||||||\\\\\\_____ \_________/ / '$b'(_)'$e'___/ _/ _/ + |\__/ ||""""" |||\\____ \___________/ _______/ / + | |-|TTTT|//" \___ \______________/ ________/ + (_) `-|____|/_______\________________/ +' + +sleep 0.1 + +printf '\033[H%s' ' + _____ _ ___ ___,--._________ + _/ ____\ ||/ /// /_____,(_X_) ____ \___ + __/ __ \\\\\o||||//______/ \ \_____/ .__\_____:__ + ___/ _|||||||||||||_ \________|___________|_________ + | _____________ | C22 |.-..-..-..-..-..-..-..-..-..-.| + ::=:| ___ |:'$b'=:'$e'__ || || || || || ||'$r' '$e'|| || ||'$r' '$e'||'$r' '$e'|| + ::=:| |:'$b'=:'$e'__\ |:=::=::=::=::=::=::=::=::=::=:| + ::=:| P S Y C H E |:'$b'=.'$e'_ \\_/--/--/--/--/--'$b'/'$e'--/--/--'$b'/'$e'--'$b'/'$e'--" + ::=:| ___ |:'$b'=.'$e'_\ \___/ / / _/ / '$b'/'$e' / / / + ::=;| _____________ |:'$b'=.'$e'_\\______/ / / __/ '$b'/'$e' / / / + _/ |_______________| \\________/ / / '$b'___/ /'$e' / / + (_)__//|||||||\\\\\\_____ \_________/ / (_)'$b'___/'$e' _/ _/ + |\__/ ||""""" |||\\____ \___________/ _______/ / + | |-|TTTT|//" \___ \______________/ ________/ + (_) `-|____|/_______\________________/ +' + +sleep 0.1 + +printf '\033[H%s' ' + _____ _ ___ ___,--._________ + _/ ____\ ||/ /// /_____,(_X_) ____ \___ + __/ __ \\\\\o||||//______/ \ \_____/ .__\_____:__ + ___/ _|||||||||||||_ \________|___________|_________ + | _____________ | C22 |.-..-..-..-..-..-..-..-..-..-.| + ::=:| ___ |:=:'$b'__'$e' || || || || || ||'$r' '$e'|| || ||'$r' '$e'||'$r' '$e'|| + ::=:| |:=:'$b'__'$e'\ |:=::=::=::=::=::=::=::=::=::=:| + ::=:| P S Y C H E |:=.'$b'_ '$e'\\_/--/--/--/--/--/--'$b'/'$e'--'$b'/'$e'--/--/--" + ::=:| ___ |:=.'$b'_\'$e' \___/ / / _/ / '$b'/ /'$e' / / + ::=;| _____________ |:=.'$b'_\'$e'\______/ / / __/ / / / / + _/ |_______________| '$b'\\'$e'________/ / / ___/ / / / + (_)__//|||||||\\\\\\_____ '$b'\__'$e'_______/ / (_)___/ _/ _/ + |\__/ ||""""" |||\\____ \___________/ _______/ / + | |-|TTTT|//" \___ \______________/ ________/ + (_) `-|____|/_______\________________/ +' + +sleep 0.1 + +printf '\033[H%s' ' + _____ _ ___ ___,--._________ + _/ ____\ ||/ /// /_____,(_X_) ____ \___ + __/ __ \\\\\o||||//______/ \ \_____/ .__\_____:__ + ___/ _|||||||||||||_ \________|___________|_________ + | _____________ | C22 |.-..-..-..-..-..-..-..-..-..-.| + ::=:| ___ |:=:_'$b'_'$e' || || || || || ||'$r' '$e'||'$r' '$e'||'$r' '$e'||'$r' '$e'||'$r' '$e'|| + ::=:| |:=:_'$b'_\'$e' |:=::=::=::=::=::=::=::=::=::=:| + ::=:| P S Y C H E |:=._'$b' \\_/'$e'--'$b'/'$e'--/--/--/--/--'$b'/'$e'--'$b'/'$e'--/--/--" + ::=:| ___ |:=._'$b'\ \___/'$e' / / _/ / / / / / + ::=;| _____________ |:=._'$b'\\____'$e'__/ / / __/ / / / / + _/ |_______________| \'$b'\____'$e'____/ / / ___/ / / / + (_)__//|||||||\\\\\\_____ '$b'\______'$e'___/ / (_)___/ _/ _/ + |\__/ ||""""" |||\\____ \___________/ _______/ / + | |-|TTTT|//" \___ \______________/ ________/ + (_) `-|____|/_______\________________/ +' + +sleep 0.1 + +printf '\033[H%s' ' + _____ _ ___ ___,--._________ + _/ ____\ ||/ /// /_____,(_X_) ____ \___ + __/ __ \\\\\o||||//______/ \ \_____/ .__\_____:__ + ___/ _|||||||||||||_ \________|___________|_________ + | _____________ | C22 |.-..-..-..-..-..-..-..-..-..-.| + ::=:| ___ |:=:__ ||'$r' '$e'||'$r' '$e'|| || || ||'$r' '$e'||'$r' '$e'||'$r' '$e'||'$r' '$e'||'$r' '$e'|| + ::=:| |:=:__\ |:=::=::=::=::=::=::=::=::=::=:| + ::=:| P S Y C H E |:=._ \\_'$b'/'$e'--'$b'/'$e'--/--/--/--/--/--/--/--/--" + ::=:| ___ |:=._\ \___/ '$b'/'$e' / _/ / / / / / + ::=;| _____________ |:=._\\___'$b'___/'$e' / / __/ / / / / + _/ |_______________| \\____'$b'____/ /'$e' / ___/ / / / + (_)__//|||||||\\\\\\_____ \_'$b'________/'$e' / (_)___/ _/ _/ + |\__/ ||""""" |||\\____ \___________/ _______/ / + | |-|TTTT|//" \___ \______________/ ________/ + (_) `-|____|/_______\________________/ +' + +sleep 0.1 + +printf '\033[H%s' ' + _____ _ ___ ___,--._________ + _/ ____\ ||/ /// /_____,(_X_) ____ \___ + __/ __ \\\\\o||||//______/ \ \_____/ .__\_____:__ + ___/ _|||||||||||||_ \________|___________|_________ + | _____________ | C22 |.-..-..-..-..-..-..-..-..-..-.| + ::=:| ___ |:=:__ ||'$r' '$e'||'$r' '$e'|| || || ||'$r' '$e'||'$r' '$e'||'$r' '$e'||'$r' '$e'||'$r' '$e'|| + ::=:| |:=:__\ |:=::=::=::=::=::=::=::=::=::=:| + ::=:| P S Y C H E |:=._ \\_/--/--'$b'/'$e'--'$b'/'$e'--/--/--/--/--/--/--" + ::=:| ___ |:=._\ \___/ '$b'/ / _/'$e' / / / / / + ::=;| _____________ |:=._\\______'$b'/ / /'$e' __/ / / / / + _/ |_______________| \\________/ '$b'/'$e' / ___/ / / / + (_)__//|||||||\\\\\\_____ \_________/ / (_)___/ _/ _/ + |\__/ ||""""" |||\\____ \___________/ _______/ / + | |-|TTTT|//" \___ \______________/ ________/ + (_) `-|____|/_______\________________/ +' + +sleep 0.1 + +printf '\033[H%s' ' + _____ _ ___ ___,--._________ + _/ ____\ ||/ /// /_____,(_X_) ____ \___ + __/ __ \\\\\o||||//______/ \ \_____/ .__\_____:__ + ___/ _|||||||||||||_ \________|___________|_________ + | _____________ | C22 |.-..-..-..-..-..-..-..-..-..-.| + ::=:| ___ |:=:__ ||'$r' '$e'||'$r' '$e'||'$r' '$e'||'$r' '$e'|| ||'$r' '$e'||'$r' '$e'||'$r' '$e'||'$r' '$e'||'$r' '$e'|| + ::=:| |:=:__\ |:=::=::=::=::=::=::=::=::=::=:| + ::=:| P S Y C H E |:=._ \\_/--/--'$b'/'$e'--'$b'/'$e'--'$b'/'$e'--/--/--/--/--/--" + ::=:| ___ |:=._\ \___/ / / '$b'_/'$e' / / / / / + ::=;| _____________ |:=._\\______/ / /'$e' __/ / / / / + _/ |_______________| \\________/ / / ___/ / / / + (_)__//|||||||\\\\\\_____ \_________/ / (_)___/ _/ _/ + |\__/ ||""""" |||\\____ \___________/ _______/ / + | |-|TTTT|//" \___ \______________/ ________/ + (_) `-|____|/_______\________________/ +' + +sleep 0.1 + +printf '\033[H%s' ' + _____ _ ___ ___,--._________ + _/ ____\ ||/ /// /_____,(_X_) ____ \___ + __/ __ \\\\\o||||//______/ \ \_____/ .__\_____:__ + ___/ _|||||||||||||_ \________|___________|_________ + | _____________ | C22 |.-..-..-..-..-..-..-..-..-..-.| + ::=:| ___ |:=:__ ||'$r' '$e'||'$r' '$e'||'$r' '$e'||'$r' '$e'||'$r' '$e'||'$r' '$e'||'$r' '$e'||'$r' '$e'||'$r' '$e'||'$r' '$e'|| + ::=:| |:=:__\ |:=::=::=::=::=::=::=::=::=::=:| + ::=:| P S Y C H E |:=._ \\_/--/--/--/--/--'$b'/'$e'--/--/--/--/--" + ::=:| ___ |:=._\ \___/ / / _/ / / / / / + ::=;| _____________ |:=._\\______/ / / __/ / / / / + _/ |_______________| \\________/ / / ___/ / / / + (_)__//|||||||\\\\\\_____ \_________/ / (_)___/ _/ _/ + |\__/ ||""""" |||\\____ \___________/ _______/ / + | |-|TTTT|//" \___ \______________/ ________/ + (_) `-|____|/_______\________________/ +' + +sleep 0.1 + +printf '\033[H%s' ' + _____ _ ___ ___,--._________ + _/ ____\ ||/ /// /_____,(_X_) ____ \___ + __/ __ \\\\\o||||//______/ \ \_____/ .__\_____:__ + ___/ _|||||||||||||_ \________|___________|_________ + | _____________ | C22 |.-..-..-..-..-..-..-..-..-..-.| + ::=:| ___ |:=:__ ||'$r' '$e'||'$r' '$e'||'$r' '$e'||'$r' '$e'||'$r' '$e'||'$r' '$e'||'$r' '$e'||'$r' '$e'||'$r' '$e'||'$r' '$e'|| + ::=:| |:=:__\ |:=::=::=::=::=::=::=::=::=::=:| + ::=:| P S Y C H E |:=._ \\_/--/--/--/--/--/--/--/--/--/--" + ::=:| ___ |:=._\ \___/ / / _/ / / / / / + ::=;| _____________ |:=._\\______/ / / __/ / / / / + _/ |_______________| \\________/ / / ___/ / / / + (_)__//|||||||\\\\\\_____ \_________/ / (_)___/ _/ _/ + |\__/ ||""""" |||\\____ \___________/ _______/ / + | |-|TTTT|//" \___ \______________/ ________/ + (_) `-|____|/_______\________________/ +' diff --git a/bin/fun-troll b/bin/fun-troll @@ -0,0 +1,16 @@ +#!/bin/sh -e + +while n=$(dd if=/dev/urandom bs=2 count=1 2>/dev/null | od -A n -t d1) +do if test ${n#* } -lt 80 + then printf '\033[%s;%sH' $n + + printf '\033[10C\v%s' ',--------.' + printf '\033[11D\v%s' '/ ,===-=== `.' + printf '\033[14D\v%s' '//__(*= (*-.\\' + printf '\033[16D\v%s' '(((,__` ,c-).~~))' + printf '\033[16D\v%s' '\ \ `------'\''||' + printf '\033[14D\v%s' '\ `-.______, |' + printf '\033[13D\v%s' '`-._ ------ |' + printf '\033[9D\v%s' '`-.____/' + fi +done diff --git a/bin/git-all b/bin/git-all @@ -0,0 +1,9 @@ +#!/bin/sh -e +# execute arguments for each git directories found in pwd + +find $PWD -name .git | while IFS='' read -r repo +do cd "$(dirname "$dir")" + printf '\n%-50s' "$(pwd)" >&2 + git status -s --branch >&2 + "$@" +done diff --git a/bin/git-count b/bin/git-count @@ -0,0 +1,4 @@ +#!/bin/sh -e +# print the summary of lines added vs removed + +expr "$(git diff | grep '^+' | wc -l)" - "$(git diff | grep '^-' | wc -l)" diff --git a/bin/git-dog b/bin/git-dog @@ -0,0 +1,3 @@ +#!/bin/sh -e + +git log --all --graph --decorate --branches --date short --oneline diff --git a/bin/git-mirror b/bin/git-mirror @@ -0,0 +1,11 @@ +#!/bin/sh -e +# setup a mirror from a remote git repository + +test $# = 0 && exec echo 'usage: git mirror <repo>' + +name=$(basename "$1" .git) + +! test -d "$name" && git clone --bare "$1" "$name" + +cd "$name" +git config remote.origin.fetch 'refs/heads/*:refs/heads/*' diff --git a/bin/git-s b/bin/git-s @@ -0,0 +1,4 @@ +#!/bin/sh -e +# short status + +git status -s --branch diff --git a/bin/git-stat b/bin/git-stat @@ -0,0 +1,3 @@ +#!/bin/sh -e + +git log --all --graph --decorate --branches --stat "$@" diff --git a/bin/git-update b/bin/git-update @@ -0,0 +1,7 @@ +#!/bin/sh -e + +test $# = 0 && exec echo 'usage: git update <repo>' + +cd "$1" +git config remote.origin.fetch 'refs/heads/*:refs/heads/*' +git remote update diff --git a/bin/header b/bin/header @@ -0,0 +1,18 @@ +#!/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 @@ -0,0 +1,3 @@ +#!/bin/sh -e + +curl -F 'file=@-' http://0x0.st diff --git a/bin/http-icanhazip.com b/bin/http-icanhazip.com @@ -0,0 +1,3 @@ +#!/bin/sh -e + +wget -qO- http://icanhazip.com diff --git a/bin/http-wttr.in b/bin/http-wttr.in @@ -0,0 +1,3 @@ +#!/bin/sh -e + +wget -qO- http://wttr.in diff --git a/bin/ii-client b/bin/ii-client @@ -0,0 +1,14 @@ +#!/bin/sh -e +trap 'true' INT + +while true +do c=$(exec ls -d ./out */out */*/out | exec sed 's,/out,,' | exec iomenu) + test "$c" && case "$(exec printf '%s\n' view chat | exec iomenu)" in + (view) + eel <$c/out | less + ;; + (chat) + exec tail -f -n 80 "$c/out" | exec eel | shuntty "$c> " >$c/in + ;; + esac +done diff --git a/bin/include b/bin/include @@ -0,0 +1,8 @@ +#!/bin/sh -e + +for inc in "$@" +do if test -f "$inc.h" + then printf '#include "%s"\n' "$inc.h" + else printf '#include <%s>\n' "$inc.h" + fi +done diff --git a/bin/io-session b/bin/io-session @@ -0,0 +1,3 @@ +#!/bin/sh -e + +exec session "$(session | iomenu)" true diff --git a/bin/io-uri b/bin/io-uri @@ -0,0 +1,3 @@ +#!/bin/sh -e + +exec xdg-open "$(iomenu <"$HOME/conf/data/uri")" diff --git a/bin/light b/bin/light @@ -0,0 +1,11 @@ +#!/bin/sh -e +# adjust display brightness + +case $(uname) in +(OpenBSD) + wsconsctl display.brightness="${1:-100}" + ;; +(Linux) + su -c "printf '%d' '${1:-2000}' >/sys/class/backlight/*/brightness" + ;; +esac diff --git a/bin/lines b/bin/lines @@ -0,0 +1,16 @@ +#!/bin/sh -e +# count lines of C code in a directory + +du -a "${1:-.}" | awk -F '\t' ' + +/\.[ch]$/ { + cmd = "exec wc -l '\''"$2"'\''"; + cmd | getline l; + close(cmd); + printf("%7d %s\n", l, $2); + total += l; +} + +END { + print total; +}' diff --git a/bin/make-a b/bin/make-a @@ -0,0 +1,10 @@ +#!/bin/sh -e + +echo makelib "${1}_"*.c | + fold -s -w 78 | + sed 's,\.c,\.o,g; $ s,$, ,; s,$,\\,' +echo "$1.h:" + +echo ./makelib "lib$1.a" "${1}_"*.c | + fold -s -w 70 | + sed 's,^, ,; s,\.c,\.o,g; s,$,\\,; $s,\\$,,' diff --git a/bin/mdoc b/bin/mdoc @@ -0,0 +1,74 @@ +#!/bin/sh -e +# print stub of an mdoc man page or parts of it + +test $# = 1 || exec "$0" -h + +case $1 in + +(dd) date +'.Dd $Mdocdate: %B %d %Y$' + exit 0 + ;; +(bd) printf '.Bd -literal -offset indent\n' + sed -e 's/\\/\\\\/g' -e 's/^\./\\./' + printf '.Ed' + exit 0 + ;; +(start) date +'.Dd $Mdocdate: %B %d %Y$' + exec cat <<'EOF' +.Dt PROGNAME section +.Os +. +. +.Sh NAME +. +.Nm progname +.Nd one line about what it does +. +. +.Sh SYNOPSIS +. +.Nm progname +.Op Fl options +.Ar +. +. +.Sh DESCRIPTION +. +The +.Nm +utility +. +. +.\" .Sh CONTEXT +.\" For section 9 functions only. +.\" .Sh RETURN VALUES +.\" For sections 2, 3, and 9 function return values only. +.\" .Sh ENVIRONMENT +.\" For sections 1, 6, 7, and 8 only. +.\" .Sh FILES +.\" .Sh EXIT STATUS +.\" For sections 1, 6, and 8 only. +.\" .Sh EXAMPLES +.\" .Sh DIAGNOSTICS +.\" For sections 1, 4, 6, 7, 8, and 9 printf/stderr messages only. +.\" .Sh ERRORS +.\" For sections 2, 3, 4, and 9 errno settings only. +.\" .Sh SEE ALSO +.\" .Xr foobar 1 +.\" .Sh STANDARDS +.\" .Sh HISTORY +. +. +.Sh AUTHORS +. +.An Josuah Demangeon +.Aq Mt mail@josuah.net +. +. +.\" .Sh CAVEATS +.\" .Sh BUGS +EOF + ;; +(*) echo 'usage: mdoc {dd,db,start}' + ;; +esac diff --git a/bin/mfilter b/bin/mfilter @@ -0,0 +1,94 @@ +#!/bin/sh -e +# read and filter mails using mblaze + +cd "$HOME/mail" + +MBLAZE="${MBLAZE:-$HOME/.mblaze/}" + +minc INBOX >$MBLAZE/seq.mfilter + +test "$1" = -a && mdirs . | mlist >$MBLAZE/seq.mfilter + +f() { + mkdir -p "$1/cur" "$1/new" "$1/tmp" + printf '%-35s ' "$1" >&2 + mpick -t "$2" <$MBLAZE/seq.mfilter | while IFS='' read -r file + do ! test "$file" = "$1/new" && mv "$file" "$1/new" + done +} + +f actux.eu.org '"To" ~~~ "*@actux.eu.org*"' +f amazon.com '"From" ~~~ "*@amazon.*"' +f amnesty.org '"From" ~~~ "*amnesty.*"' +f bandcamp.com '"From" ~~~ "*Cryo Chamber*"' +f bandcamp.com '"From" ~~~ "*bandcamp.com*"' +f bandcamp.com '"From" ~~~ "*makeupandvanityset.com*"' +f breizh-entropy.org '"List-Id" ~~~ "*breizh-entropy.org*"' +f coinbase.com '"From" ~~~ "*coinbase.com*"' +f crous-paris.fr '"From" ~~~ "*crous-paris.fr*"' +f crous-rennes.fr '"From" ~~~ "*crous-rennes.fr*"' +f dragonflybsd.org--hammer '"List-Id" ~~~ "*hammer.dragonflybsd.org*"' +f dragonflybsd.org--kernel '"List-Id" ~~~ "*kernel.dragonflybsd.org*"' +f dropbox.com '"From" ~~~ "*dropbox.*"' +f ebay.com '"From" ~~~ "*ebay.*"' +f epitech.eu--bde '"From" ~~~ "*bde.epitech.rennes@gmail.com*"' +f epitech.eu--intra '"From" ~~~ "*@intra.epitech.eu*"' +f epitech.eu--marvin '"From" ~~~ "*nao.marvin@epitech.eu*"' +f epitech.eu '"From" ~~~ "*@epitech.eu*"' +f epitech.eu '"From" ~~~ "*ionis-group.org*"' +f etudiant.gouv.fr '"From" ~~~ "*etudiant.gouv.fr*"' +f fosdem.org--announce '"List-Id" ~~~ "*fosdem.lists.fosdem.org*"' +f fosdem.org--distributions '"List-Id" ~~~ "*distributions-devroom.lists.fosdem.org*"' +f fosdem.org--network '"List-Id" ~~~ "*network-devroom.lists.fosdem.org*"' +f fosdem.org--security '"List-Id" ~~~ "*security-devroom.lists.fosdem.org*"' +f fosdem.org '"From" ~~~ "*fosdem.org*"' +f free.fr '"From" ~~~ "*@free-mobile.fr*"' +f freebsd.org '"From" ~~~ "*freebsd.org*"' +f freenode.net '"From" ~~~ "*freenode.net*"' +f fsf.org '"From" ~~~ "*fsf.org*"' +f gandi.net '"From" ~~~ "*gandi.net*"' +f github.com '"From" ~~~ "*github.com*"' +f gobolinux.org '"List-Id" ~~~ "*gobolinux.org*"' +f google.com '"From" ~~~ "*google.com*"' +f gopherproject.org '"List-Id" ~~~ "*gopher-project*"' +f grifon.fr '"List-Id" ~~~ "*grifon.fr*"' +f keybase.io '"From" ~~~ "*keybase.io*"' +f lobste.rs '"From" ~~~ "*@lobste.rs*"' +f meetup.com '"From" ~~~ "*meetup.com*"' +f netsukuku.freaknet.org '"List-Id" ~~~ "*netsukuku.lists.dyne.org*"' +f nixers.net '"From" ~~~ "*@nixers.net*"' +f noip.com '"From" ~~~ "*@noip.com*"' +f openbsd.org--advocacy '"List-ID" ~~~ "*advocacy.openbsd.org*"' +f openbsd.org--announce '"List-ID" ~~~ "*announce.openbsd.org*"' +f openbsd.org--tech '"List-ID" ~~~ "*tech.openbsd.org*"' +f paypal.com '"From" ~~~ "*paypal.*"' +f reddit.com '"From" ~~~ "*@reddit.*"' +f reddit.com '"From" ~~~ "*@redditmail.com*"' +f researchgate.net '"From" ~~~ "*@researchgate.*"' +f researchgate.net '"From" ~~~ "*@researchgatemail.*"' +f sabotage.tech '"Mailing-List" ~~~ "*sabotage*@lists.openwall.com*"' +f skarnet.org '"List-Post" ~~~ "*@list.skarnet.org*"' +f suckless.org '"List-Id" ~~~ "*suckless.org*"' +f tarsnap.com '"From" ~~~ "*tarsnap.com*"' +f transports '"From" ~~~ "*BlaBlaCar*"' +f transports '"From" ~~~ "*flixbus*"' +f transports '"From" ~~~ "*keolis.com*"' +f transports '"From" ~~~ "*megabus*"' +f transports '"From" ~~~ "*oui.sncf*"' +f transports '"From" ~~~ "*ouibus*"' +f transports '"From" ~~~ "*ouigo*"' +f transports '"From" ~~~ "*sncf.com*"' +f transports '"From" ~~~ "*sobus.com*"' +f transports '"From" ~~~ "*trainline.com*"' +f univ-rennes1.fr '"List-Id" ~~~ "*univ-rennes1.fr*"' +f wikimedia.org '"From" ~~~ "*wikimedia.org*"' +f wordpress.com '"From" ~~~ "*wordpress.com*"' +f yammer.com '"From" ~~~ "*yammer.com*"' +f youtube.com '"From" ~~~ "*youtube.com*"' + +mdirs . | sort | while IFS='' read -r dir +do echo "$dir" | sed 's,.*/,#,' + MAILSEQ=$dir/seq + mlist -s "$dir" | mseq -S >/dev/null + mscan -f '%6n %u %D %20f %t%2i%120S' 2>/dev/null +done >index diff --git a/bin/mount-key b/bin/mount-key @@ -0,0 +1,7 @@ +#!/bin/sh -ex + +case $(uname) in +(Linux) + mount -o umask=077,uid=$(id -u josuah) "$1" /mnt/key/ + ;; +esac diff --git a/bin/mread b/bin/mread @@ -0,0 +1,5 @@ +#!/bin/sh -e + +test $# = 1 && INBOX=$1 || INBOX=INBOX +mlist /home/mail/$INBOX | msort -dr | mseq -S +mless diff --git a/bin/msearch b/bin/msearch @@ -0,0 +1,5 @@ +#!/bin/sh -e + +mdirs /home/mail | mlist | mpick "$@" | msort -rd | mseq -S + +mscan diff --git a/bin/mv-flac b/bin/mv-flac @@ -0,0 +1,40 @@ +#!/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 @@ -0,0 +1,21 @@ +#!/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/mv-sane b/bin/mv-sane @@ -0,0 +1,17 @@ +#!/9/bin/rc -e +# remove evil characters + +if (! ~ $#* 0) cd $1 + +ifs=' +' +for (file in `{find . -depth ! -path .}) { + new=`{dirname $file}^/^`{ + basename $file | + tr -s '\t #&;*?<>|"''()[]{}\_=+' - | + sed -r 's,^([0-9]*)\.*,\1,; s,^-,,; s,-$,,' + } + + if (! test $file '=' $new) + mv $file $new +} diff --git a/bin/nft-nat b/bin/nft-nat @@ -0,0 +1,26 @@ +#!/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 @@ -0,0 +1 @@ +xdg-open+ \ No newline at end of file diff --git a/bin/pack b/bin/pack @@ -0,0 +1,63 @@ +#!/bin/sh -e +# source-based package manager that fetches compile and install + +PACKDIR=$HOME/conf/pack + +export PACK=$PACKDIR/$2 +export DEST=/local +export PREFIX=$DEST/opt/$2 +export SOURCE=$DEST/src/$2 + +case $1 in +(-t) test -d "$SOURCE" && exit 0 + mkdir -p "$SOURCE" + IFS="" read -r url <$PACK/tar + wget -O - "$url" | case $url in + (*.tgz|*.tar.gz) gzip -d - ;; + (*.tbz|*.tar.bz2) bzip2 -d - ;; + (*.txz|*.tar.xz) xz -d - ;; + esac | tar -xf - -C "$SOURCE" || exec rm -rf "$SOURCE" + mv "$SOURCE"/*/* "$SOURCE" + rmdir "$SOURCE"/* 2>/dev/null || true + ;; +(-g) test -d "$SOURCE" && exit 0 + IFS="" read -r url <$PACK/git + git clone "$url" "$SOURCE" + ;; +(-c) test -d "$SOURCE" && exit 0 + mkdir -p "$SOURCE" + cd "$SOURCE" + read -r url path <$PACK/cvs + cvs -qd "$url" checkout -P "$path" + ;; +(-d) test -f "$PACK/tar" && exec "$0" -t "$2" + test -f "$PACK/git" && exec "$0" -g "$2" + test -f "$PACK/cvs" && exec "$0" -c "$2" + ;; +(-b) test -d "$SOURCE" || "$0" -d "$2" + cd "$SOURCE" + mkdir -p "$PREFIX" + exec "$PACK/build" + ;; +(-i) test -d "$PREFIX" || "$0" -b "$2" || rm -rf "$PREFIX" + cd "$PREFIX" + find -L . -type d | xargs -n 1 -I {} mkdir -p "$DEST/{}" + find -L . -type f | xargs -n 1 -I {} ln -sf "$PREFIX/{}" "$DEST/{}" + ;; +(-r) cd "$PREFIX" + find . -type f | xargs -I {} rm -f "$DEST/{}" + rm -rf "$PREFIX" + ;; +(-u) "$0" -r "$2" + rm -rf "$SOURCE" + "$0" -i "$2" + ;; +(-l) ls "$PACKDIR" + ;; +(*) echo 'usage: pack -[tgcdiru] package' + echo ' -t download from tar -b build package -l list packages' + echo ' -g download from git -i install package' + echo ' -c donwload from cvs -r remove package' + echo ' -d download from any -u update package' + ;; +esac diff --git a/bin/piano b/bin/piano @@ -0,0 +1,122 @@ +#!/usr/bin/awk -f +# console piano using speaker-test + +# _________________________________________________________________________ +# | | | | | | | | | | | | | | | | | | | | | | | | | +# | |Db| |Eb| | |Gb| |Ab| |Bb| | |Db| |Eb| | |Gb| |Ab| |Bb| | +# | |C#| |D#| | |F#| |G#| |A#| | |C#| |D#| | |F#| |G#| |A#| | +# | |__| |__| | |__| |__| |__| | |__| |__| | |__| |__| |__| | +# | | | | | | | | | | | | | | | +# | C | D | E | F | G | A | B | C | D | E | F | G | A | B | +# |____|____|____|____|_____|____|____|____|____|____|____|_____|____|____| + +# ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ______ +# |Esc |F1 |F2 |F3 |F4 |F5 |F6 |F7 |F8 |F9 |F10 |F11 |F12 |Del | +# |____|____|____|____|____|____|____|____|____|____|____|____|____|______| +# | | |C#Eb|D#Eb| |F#Gb|G#Ab|A#Bb| |C#Db|D#Ab| |F#Gb|Bkspc | +# |____|____|____|____|____|____|____|____|____|____|____|____|____|______| +# |Tab |C |D |E |F |G |A |B |C |D |E |F |G | | +# |_____|____|____|____|____|____|____|____|____|____|____|____|____| <-' | +# |Caps | |C#Eb|D#Eb| |F#Gb|G#Ab|A#Bb| |C#Db|D#Eb| | | | +# |______|____|____|____|____|____|____|____|____|____|____|____|____|____| +# |Shift |C |D |E |F |G |A |B |C |D |E |Shift | +# |_______|____|____|____|____|____|____|____|____|____|____|_____________| +# |Ctrl |Super |Alt |Space |Alt Gr|Opt |Ctrl | +# |______|______|______|_______________________________|______|_____|_____| + +# qwerty +# ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ______ +# |Esc |F1 |F2 |F3 |F4 |F5 |F6 |F7 |F8 |F9 |F10 |F11 |F12 |Del | +# |____|____|____|____|____|____|____|____|____|____|____|____|____|______| +# |` ~ |1 ! |2 @ |3 # |4 $ |5 % |6 ^ |7 & |8 * |9 ( |0 ) |- _ |= + |Bkspc | +# |____|____|____|____|____|____|____|____|____|____|____|____|____|______| +# |Tab |Q |W |E |R |T |Y |U |I |O |P |[ { |] } | | +# |_____|____|____|____|____|____|____|____|____|____|____|____|____| <-' | +# |Caps |A |S |D |F |G |H |J |K |L |; : |' " |\ | | | +# |______|____|____|____|____|____|____|____|____|____|____|____|____|____| +# |Shift |Z |X |C |V |B |N |M |, < |. > |/ ? |Shift | +# |_______|____|____|____|____|____|____|____|____|____|____|_____________| +# |Ctrl |Super |Alt |Space |Alt Gr|Opt |Ctrl | +# |______|______|______|_______________________________|______|_____|_____| + +# dvorak +# ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ______ +# |Esc |F1 |F2 |F3 |F4 |F5 |F6 |F7 |F8 |F9 |F10 |F11 |F12 |Del | +# |____|____|____|____|____|____|____|____|____|____|____|____|____|______| +# |` ~ |1 ! |2 @ |3 # |4 $ |5 % |6 ^ |7 & |8 * |9 ( |0 ) |[ { |] } |Bkspc | +# |____|____|____|____|____|____|____|____|____|____|____|____|____|______| +# |Tab |' " |, < |. > |P |Y |F |G |C |R |L |/ ? |= + | | +# |_____|____|____|____|____|____|____|____|____|____|____|____|____| <-' | +# |Caps |A |O |E |U |I |D |H |T |N |S |- _ |\ | | | +# |______|____|____|____|____|____|____|____|____|____|____|____|____|____| +# |Shift |; : |Q |J |K |X |B |M |W |V |Z |Shift | +# |_______|____|____|____|____|____|____|____|____|____|____|_____________| +# |Ctrl |Super |Alt |Space |Alt Gr|Opt |Ctrl | +# |______|______|______|_______________________________|______|_____|_____| + +BEGIN { + CMD = "sh -c './sine %d | tr a-z0-9 0 | aucat -i - & sleep 0.4; kill $!' &" + + qwerty = "zsxdcvgbhnjm,l.;/" "q2w3er5t6y7ui9o0p[=]"; + QWERTY = "ZSXDCVGBHNJM<L>:/" "Q@W#ER%T^Y&UI(O)P{+}"; + qwerty = qwerty QWERTY; + + dvorak = ";oqejkixdbhmwnvsz" "'\''2,3.p5y6f7gc9r0l/]="; + DVORAK = ":OQEJKIXDBHMWNVSZ" "\"@<#>P%Y^F&GC(R)L?}+"; + dvorak = dvorak DVORAK; + + layout = qwerty; + + # notes frequencies + + C0 = 16 " "; Cd0 = 17 " "; D0 = 18 " "; Dd0 = 19 " "; + E0 = 21 " "; F0 = 22 " "; Fd0 = 23 " "; G0 = 25 " "; + Gd0 = 26 " "; A0 = 28 " "; Ad0 = 29 " "; B0 = 31 " "; + C1 = 33 " "; Cd1 = 35 " "; D1 = 37 " "; Dd1 = 39 " "; + E1 = 41 " "; F1 = 44 " "; Fd1 = 46 " "; G1 = 49 " "; + Gd1 = 52 " "; A1 = 55 " "; Ad1 = 58 " "; B1 = 62 " "; + C2 = 65 " "; Cd2 = 69 " "; D2 = 73 " "; Dd2 = 78 " "; + E2 = 82 " "; F2 = 87 " "; Fd2 = 93 " "; G2 = 98 " "; + Gd2 = 104 " "; A2 = 110 " "; Ad2 = 117 " "; B2 = 123 " "; + C3 = 131 " "; Cd3 = 139 " "; D3 = 147 " "; Dd3 = 156 " "; + E3 = 165 " "; F3 = 175 " "; Fd3 = 185 " "; G3 = 196 " "; + Gd3 = 208 " "; A3 = 220 " "; Ad3 = 233 " "; B3 = 247 " "; + C4 = 262 " "; Cd4 = 277 " "; D4 = 294 " "; Dd4 = 311 " "; + E4 = 330 " "; F4 = 349 " "; Fd4 = 370 " "; G4 = 392 " "; + Gd4 = 415 " "; A4 = 440 " "; Ad4 = 466 " "; B4 = 494 " "; + C5 = 523 " "; Cd5 = 554 " "; D5 = 587 " "; Dd5 = 622 " "; + E5 = 659 " "; F5 = 698 " "; Fd5 = 740 " "; G5 = 784 " "; + Gd5 = 831 " "; A5 = 880 " "; Ad5 = 932 " "; B5 = 988 " "; + C6 = 1047 " "; Cd6 = 1109 " "; D6 = 1175 " "; Dd6 = 1245 " "; + E6 = 1319 " "; F6 = 1397 " "; Fd6 = 1480 " "; G6 = 1568 " "; + Gd6 = 1661 " "; A6 = 1760 " "; Ad6 = 1865 " "; B6 = 1976 " "; + C7 = 2093 " "; Cd7 = 2217 " "; D7 = 2349 " "; Dd7 = 2489 " "; + E7 = 2637 " "; F7 = 2794 " "; Fd7 = 2960 " "; G7 = 3136 " "; + Gd7 = 3322 " "; A7 = 3520 " "; Ad7 = 3729 " "; B7 = 3951 " "; + C8 = 4186 " "; Cd8 = 4435 " "; D8 = 4699 " "; Dd8 = 4978 " "; + E8 = 5274 " "; F8 = 5588 " "; Fd8 = 5920 " "; G8 = 6272 " "; + Gd8 = 6645 " "; A8 = 7040 " "; Ad8 = 7459 " "; B8 = 7902 " "; + + row1 = C3 Cd3 D3 Dd3 E3 F3 Fd3 G3 Gd3 A3 Ad3 B3 C4 Cd4 D4 Dd4 E4; + row2 = C4 Cd4 D4 Dd4 E4 F4 Fd4 G4 Gd4 A4 Ad4 B4 C5 Cd5 D5 Dd5 E5 F5 Fd5 G5; + + split(row1 row2, frequencies, " "); + + system("stty raw -echo"); + + while (1) { + cmd = "dd bs=1 count=1 2>/dev/null" + cmd | getline key + close(cmd); + + if (key == "\003") + break + + if (note = frequencies[index(layout, key)]) { + printf(CMD"\r\n", 1 / note * 300000); + system(sprintf(CMD, 1 / note * 300000)); + } + } + + system("stty -raw echo"); +} diff --git a/bin/play b/bin/play @@ -0,0 +1,10 @@ +#!/9/bin/rc +# play every music/video file in a dir + +for (a in $*) { + if (test -d $a) + for (song in `{find $a -type f | sort}) + play $song + if not + ffplay -autoexit $a +} diff --git a/bin/plumb b/bin/plumb @@ -0,0 +1,3 @@ +#!/9/bin/rc -e + +exec xdg-open `{sselp} diff --git a/bin/proto b/bin/proto @@ -0,0 +1,94 @@ +#!/usr/bin/awk -f +# generate .h prototypes out of a .c file with space for alignment + +# target must be a multiple of 8 +function space(pos, target) +{ + if (pos > target) + return pos; + printf("\t"); + pos += 8 - (pos - 1) % 8; + for (; pos < target; pos += 8) + printf("\t"); + return pos; +} + +function print_args(pos, args) +{ + while (pos + length(args) + 1 > COL_MAX) { + head = substr(args, 1, COL_MAX - pos); + sub(",[^,]*$", "", head); + + printf("%s,\n", head); pos = 0; + pos = space(pos, COL_ARGS); + printf(" "); pos++; + + args = substr(args, length(head) + 1); + sub(", *", "", args); + } + printf("%s;\n", args); +} + +BEGIN { + COL_SYMBOL = 16; + COL_ARGS = 32; + COL_MAX = 80; +} + +FILENAME == "main.c" { + next; +} + +#ARGC > 1 && FNR == 1 { +# sub(".*/", "", FILENAME); +# printf("\n/* %s */\n", FILENAME); +#} + +/^[a-zA-Z0-9_]*\(/ { + if (match(type, "static") || match($0, ";$")) + next; + + ptr = type; + if (sub(" *[*]+", "", type)) + gsub("[^*]", "", ptr); + else + ptr = " "; + + symbol = $0; + sub("\\(.*", "", symbol); + sub("[a-zA-Z0-9_]*\\(", "("); + + if (symbol == "main") + next; + + pos = 0; + printf("%s", type); pos += length(type); + pos = space(pos, COL_SYMBOL); + printf("%s", ptr); pos += length(ptr); + printf("%s", symbol); pos += length(symbol); + pos = space(pos, COL_ARGS); + + IN = 1; +} + +IN { + args = args " " $0; +} + +IN && /\)$/ { + gsub("[ \t]+", " ", args); + sub("^ ", "", args); + gsub("[*][a-zA-Z0-9_]+,", "*,", args); + gsub("[*][a-zA-Z0-9_]+\\)", "*)", args); + gsub("[ ][a-zA-Z0-9_]+,", ",", args); + gsub("[ ][a-zA-Z0-9_]+\\)", ")", args); + + print_args(pos, args); + + args = "" + IN = 0; +} + +{ + type = $0; +} diff --git a/bin/rfc b/bin/rfc @@ -0,0 +1,16 @@ +#!/9/bin/rc +# from a rfc number: fetch, cleanup, open in pager + +if (! ~ $#* 1) + echo 'usage: rfc {rfc####,####}' + +rfc=`{echo $1 | sed -r 's,.*/,,; s,[^0-9]*([1-9][0-9]*).*,\1,'} +echo $rfc + +dir=$home/tmp/text/rfc +mkdir -p $dir + +if (! test -f $dir/$rfc.txt) + wget -O $dir/$rfc.txt https://tools.ietf.org/rfc/rfc$rfc.txt + +exec $PAGER $dir/$rfc.txt diff --git a/bin/session b/bin/session @@ -0,0 +1,32 @@ +#!/bin/sh -e +# wrapper over abduco for supporting any length session names + +test $# = 1 && exec echo 'usage: session <name> <cmd> [<args>...] <filename>' + +mkdir -p "$HOME/.abduco" +touch "$HOME/.abduco/names" + +# only keep existing session in the names list +s=$(abduco | sed -rn 's,.* ,-e^,p') +if test "$s" +then grep $s "$HOME/.abduco/names" | sort -k2 -uo "$HOME/.abduco/names" +else true >"$HOME/.abduco/names" +fi + +test $# = 0 && exec cut -f 2 "$HOME/.abduco/names" + +# get the real path name +name=$1 +test -h "$1" && name=$(readlink -f $1) +test -e "$1" && name=$(cd "$(dirname "$1")"; pwd)/$(basename "$1") +test -d "$1" && name=$(cd "$1"; pwd)/ +shift + +hash=$(printf %s "$name" | cksum | cut -d ' ' -f 1) +printf '%s\t%s\n' "$hash" "$name" >>"$HOME/.abduco/names" + +#test "$ABDUCO" && ABDUCO=$name exec abduco -n "$hash" "$@" + +printf '\033]0;%s\a' "$name" >&2 + +ABDUCO=$name exec abduco -A "$hash" "$@" diff --git a/bin/shell b/bin/shell @@ -0,0 +1,9 @@ +#!/bin/sh -e + +test $# = 1 && cd "$1" + +ls -p + +printf '\033]0;%s\a' "$PWD/-$(uname -n)" >&2 + +exec sh diff --git a/bin/sound b/bin/sound @@ -0,0 +1,14 @@ +#!/bin/sh -e + +sound="${1:-0}" + +case $(uname) in +(OpenBSD) + mixerctl outputs.master.mute="off" + mixerctl outputs.master="$sound" + ;; +(Linux) + amixer set Master on >/dev/null + amixer set Master "$sound" + ;; +esac diff --git a/bin/ssh-paste b/bin/ssh-paste @@ -0,0 +1,9 @@ +#!/bin/sh -e + +dir=$(cat $* | ssh srv@josuah.net " + cd 'josuah.net' + mktemp /p/XXXXXX | tee /dev/stderr | xargs tee >/dev/null +") + +echo "gopher://josuah.net/0/$dir" +echo "http://josuah.net/$dir" diff --git a/bin/start-acme b/bin/start-acme @@ -0,0 +1,11 @@ +#!/9/bin/rc + +if (test -f $home/acme.dump) + exec acme \ + -l $home/acme.dump \ + -f $PLAN9/font/pelm/unicode.8.font \ + -F $PLAN9/font/pelm/unicode.8.font $* +if not + exec acme \ + -f $PLAN9/font/pelm/unicode.8.font \ + -F $PLAN9/font/pelm/unicode.8.font $* diff --git a/bin/suckless-patch-mail b/bin/suckless-patch-mail @@ -0,0 +1,8 @@ +#!/9/bin/rc -e + +back=1 +if (! ~ $#* 0) back=$1 + +git send-email --to hackers@suckless.org -$back \ + --subject-prefix `{basename `{pwd}}^'][PATCH' \ + --smtp-server `{whatis msmtp} diff --git a/bin/term-black b/bin/term-black @@ -0,0 +1,3 @@ +#!/bin/sh -e + +printf '\033[?5l' diff --git a/bin/term-clear b/bin/term-clear @@ -0,0 +1,3 @@ +#!/9/bin/rc + +printf '\033[H\033[J' diff --git a/bin/term-white b/bin/term-white @@ -0,0 +1,3 @@ +#!/bin/sh + +exec printf '\033[?5h' diff --git a/bin/tty-theme b/bin/tty-theme @@ -0,0 +1,346 @@ +#!/bin/sh +# set the theme for the tty from a simple file format + +# `vtfontcvt -h 8 -w 4 miniwi-8.bdf miniwi-8.fnt`, then it's just a `vidcontrol -f miniwi-8.fnt` away + +# normal bold +# 0 8 black +# 1 9 red +# 2 A green +# 3 B orange +# 4 C blue +# 5 D magenta +# 6 E cyan +# 7 F white + +show="0" i="0" + +printf '\033[H\033[J' + +while read -r color hex +do + if [ "$hex" ] + then + printf '\033]P%s%s' "$color" "$hex" + show="1" + elif [ "$color" ] + then + name="$color" + elif [ "$show" -eq 1 ] + then + i="$((i + 1))" + printf '%3s %-20s' "$i" "$name" + + for color in 0 1 2 3 4 5 6 7 + do + printf ' \033[3%sm___\033[1m___\033[m' "$color" + done + printf '\033[J\n\n' + + show="0" + fi + + [ "$1" ] && [ "$i" -ge "$1" ] && return 0 +done << EOF + +lolidaisuki + +0 1d1d1d +1 b52839 +2 246734 +3 fa9043 +4 4a5cdb +5 99267b +6 15c9c9 +7 dcdcbb +8 333333 +9 fa564b +A 06a535 +B ffaf2b +C 9ca4eb +D ed4db3 +E 62f2f2 +F bc9977 + + +alien + +0 000910 +1 ccccbb +2 aaddbb +3 aaddaa +4 aacccc +5 bbbbcc +6 aaddcc +7 cceedd +8 aaccbb +9 ddddcc +A bbeecc +B cceebb +C bbdddd +D ccccdd +E bbeedd +F fff0f8 + + +coal + +0 000000 +1 ee3333 +2 88ff44 +3 ffcc55 +4 77aaaa +5 85678f +6 55ee99 +7 eeddbb +8 555555 +9 ff6666 +A aaff66 +B ffff99 +C aaddff +D b294bb +E 99ffbb +F ffffff + + +drakula + +0 282a36 +1 cc4343 +2 42c763 +3 ffb86c +4 6272a4 +5 bd93f9 +6 6fb9c9 +7 e6e6d5 +8 888db4 +9 ff5555 +A 50fa7b +B f1fa8c +C 8196d6 +D ff79c6 +E 8be9fd +F ffffff + + +exo + +0 350600 +1 e62828 +2 77b23e +3 d6722e +4 689db3 +5 936599 +6 30c87e +7 acf88d +8 9b6963 +9 ff5454 +A a0d669 +B ff9e5d +C 94dfff +D 9b78ce +E 77ffbd +F ffffff + + +ghost + +0 000000 +1 91265C +2 439a64 +3 ccdd66 +4 55aaaa +5 516583 +6 4a8f86 +7 99bbbb +8 334444 +9 E71E5B +A 72f4a0 +B f5ff8B +C 99bbff +D 676cb0 +E 00ffff +F ffffff + + +gotham + +0 0a0f14 +1 c33027 +2 26a98b +3 edb54c +4 195465 +5 4e5165 +6 33859d +7 98d1ce +8 406068 +9 d26939 +A 30dbb3 +B ffd280 +C 268099 +D 888ba5 +E 599caa +F d3ebe9 + + +gruvbox + +0 282828 +1 cc241d +2 98971a +3 d79921 +4 458588 +5 b16286 +6 689d6a +7 d5c4a1 +8 928374 +9 fb4934 +A b8bb26 +B fabd2f +C 83a598 +D d2869b +E 8ec07c +F ffffff + + +matrix + +0 000000 +1 883300 +2 00aa55 +3 55aa33 +4 339977 +5 668877 +6 119977 +7 99ffaa +8 338844 +9 aa7733 +A 00ff88 +B 88ee66 +C 33dd88 +D 77bb99 +E 66ddbb +F ffffff + + +monokai + +0 48483e +1 dc2566 +2 8fc029 +3 d4c96e +4 55bcce +5 9358fe +6 56b7a5 +7 acada1 +8 76715e +9 fa2772 +A a7e22e +B e7db75 +C 66d9ee +D ae82ff +E 66efd5 +F dfe1d3 + + +pink + +0 090a0f +1 f44444 +2 28684f +3 c8907e +4 422d52 +5 710130 +6 2a7e86 +7 bbbbbb +8 3e4053 +9 f44444 +A 43c291 +B f49a7e +C 542a52 +D 9e0f37 +E 688e95 +F ffffff + + +solarized-dark + +0 002b36 +1 dc322f +2 859900 +3 b58900 +4 268bd2 +5 6c71c4 +6 2aa198 +7 93a1a1 +8 657b83 +9 dc322f +A 859900 +B b58900 +C 268bd2 +D 6c71c4 +E 2aa198 +F fdf6e3 + + +solarized-light + +0 ffddbb +1 d0154b +2 779900 +3 ffa700 +4 096daf +5 dd6699 +6 00aa88 +7 000000 +8 bb9988 +9 d0154b +A 779900 +B ffa700 +C 096daf +D 897f74 +E 00aa88 +F 222222 + + +zenburn + +0 191d1b +1 9C6363 +2 60b48a +3 dfaf8f +4 506070 +5 dc8cc3 +6 8cd0d3 +7 dcdccc +8 709080 +9 dca3a3 +A bfebbf +B f0dfaf +C 94bff3 +D ec93d3 +E 93e0e3 +F ffffff + + +datahill + +0 080011 +1 cc1122 +2 22cc66 +3 edb54c +4 195465 +5 4e5165 +6 33a08d +7 aaccbb +8 407060 +9 ff6644 +A 44ff99 +B ffdd88 +C 337799 +D 888ba5 +E 66ffee +F eeffff +EOF + +printf '\033[J' diff --git a/bin/tty-video b/bin/tty-video @@ -0,0 +1,5 @@ +#!/9/bin/rc +# play a video in current linux TTY using mplayer + +size=`{tr ',' ' ' </sys/class/graphics/fb0/virtual_size} +mplayer -vm -vo fbdev2 $1 -vf scale -zoom -x $size(1) -y $size(2) diff --git a/bin/update-agenda b/bin/update-agenda @@ -0,0 +1,10 @@ +#!/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 @@ -0,0 +1,36 @@ +#!/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/bin/web b/bin/web @@ -0,0 +1,66 @@ +#!/bin/sh -e +# handle http[s]:// links +ifs=' + ' +uri='https?://([^:/#?]*)?(:([^/#?]*))?(/([^#?]*))?([#?].*)?' +read -r host port file << EOF +$(echo $1 | sed -r 's,'$uri',:\1 :\3 :\5,') +EOF +user=${user#:} host=${host#:} port=${port#:} file=${file#:} + +echo "$file" + +case $file in +(*.pdf|*.ps) + type=doc + ;; +(*.jpg|*.png|*.gif) + type=image + ;; +(*.webm|*.mp4|*.mkv|*.ogv|*.avi|\ +*.mp3|*.ogg|*.opus|*.wav|*.flac) + exec ffplay "$1" + ;; +(*.txt) + type=text + ;; +(*) + type='' +esac + +if test "$type" +then name=$(basename "$file" | tr -s '\t #&;*?<>|"''()[]{}\_=+' -) + file=$HOME/tmp/$type/$name + mkdir -p $HOME/tmp/$type + wget -O $file $1 + echo $file + exec xdg-open $file +fi + +case $host in +(*vimeo.com|*youtube.com|*youtu.be|*openload.co) + mkdir -p "$HOME/tmp/video/$host" + cd "$HOME/tmp/video/$host" + file=$PWD/$(youtube-dl --get-filename "$1") + mkdir -p "$(dirname "$file")" + youtube-dl -o "$(echo "$file" | sed 's,%,%%,g')" "$1" + exec xdg-open "$file" + ;; +(*bandcamp.com) + mkdir -p "$HOME/tmp/music/$host" + cd "$HOME/tmp/music/$host" + file=$PWD/$(youtube-dl --get-filename "$1") + youtube-dl "$1" + exec xdg-open "$file" + ;; +(tools.ietf.org) + rfc=$(echo "$path" | sed 's,.*/,,') + rfc=$(echo "$rfc" | sed 's,.txt$,,') + exec rfc "$rfc" + ;; +(*) + if test "$DISPLAY" + then exec tabbed -r 3 surf -gips -e '' -a a@ "$1" & + else exec session "$1" links "$1" + fi +esac diff --git a/bin/woman b/bin/woman @@ -0,0 +1,3 @@ +#!/9/bin/rc -e + +man -T ascii $* | col -b diff --git a/bin/xdg-open b/bin/xdg-open @@ -0,0 +1,158 @@ +#!/bin/sh -e +# open the argument according to its name + +uri='[^@:/#]+://(([^@:/#]*)@)?([^:/#]*)?(:([^/#]*))?(/([^#]*))?(#.*)?' +read -r user host port file << EOF +$(echo $1 | sed -r 's,'$uri',:\2 :\3 :\5 :\7,') +EOF +user=${user#:} host=${host#:} port=${port#:} file=${file#:} + +test $# = 0 && exec echo 'usage: xdg-open <pattern>' + +case $1 in (*://*.onion) exec torsocks "$0" "$1" ;; esac + +case $1 in +('') + exit 1 + ;; +(git://*) + 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" + ;; +(9p://*) + dir=/mnt/9p/$host + mkdir -p "$dir" + exec 9pfs "$host" "$dir" + ;; +(ftp://*) + exec session "$1" ftp "$1" + ;; +(gopher://*) + exec sacc "$1" + ;; +(http://*|https://*) + exec web "$1" + ;; +(irc://*) + exec echo not implemented + ;; +(news://*) + exec session "$1" links "$1" + ;; +(sftp://*) + test -z "$port" && port='22' + exec session "$1" sftp -P $port $host + ;; +(ssh://*) + test "$user" && host=$user@$host + test "$port" && port=-p' '$port + exec session "$1" ssh $port "$host" + ;; +(telnet://*) + exec session "$1" telnet "$port" "$host" + ;; +(radio://*|radios://*) + exec session "$1" ffplay "$(echo "$1" | sed 's,radio,http,')" + ;; +(vnc://*) + exec vncviewer -use8 $(echo "$1" | sed 's,vnc://,,') & exit + ;; +(*://*) + exec echo unsupported protocol + ;; +(*.torrent) + exec echo "TODO: use transmission" + ;; +(*.img|*.iso) + exec session "$1" qemu-system-x86_64 -m 333M "$1" + ;; +(*.ps) + exec gs "$1" & + ;; +(*.pdf) + exec mupdf "$1" & + ;; +(*.png|*.PNG) + png2ff <"$1" | lel & + ;; +(*.jpg|*.jpeg|*.JPG|*.JPEG) + jpg2ff <"$1" | lel & + ;; +(*.gif) + exec session "$1" ffplay -loop 0 "$1" + ;; +(*.opus|*.mp3|*.flac|*.ogg|*.vorbis|*.wav|*.webm|*.mp4|*.mkv|*.ogv|*.avi|\ +*/music/*) + exec session "$1" ffplay "$1" + ;; +(*.[0-9]|*.[0-9]p|*.[0-9].gz) + exec session $1 mandoc -a -T utf8 "$1" + ;; +(*.o|*.a) + exec session "$1" sh -c "objdump -D '$1' | less" "$1" + ;; +(*.ics) + exec session "$1" sh -c "ics2txt txt '$1' | less" "$1" + ;; +(*.html) + exec links "$1" + ;; +(*.tgz) + file=$(echo "$1" | sed 's,.tgz$,.tar.gz,') + mv "$1" "$file" + exec xdg-open "$file" + ;; +(*.tbz) + file=$(echo "$1" | sed 's,.tbz$,.tar.bz2,') + mv "$1" "$file" + exec xdg-open "$file" + ;; +(*.txz) + file=$(echo $1 | sed 's,.txz$,.tar.xz,') + mv "$1" "$file" + exec xdg-open "$file" + ;; +(*.bz2) + file=$(echo $1 | sed 's,.bz2,,') + bzip2 -ds "$1" + exec xdg-open "$file" + ;; +(*.gz) + file=$(echo $1 | sed 's,.gz,,') + gzip -d "$1" + exec xdg-open "$file" + ;; +(*.xz) + file=$(echo $1 | sed 's,.xz,,') + xz -d "$1" + exec xdg-open "$file" + ;; +(*.tar) + exec tar -xf "$1" + ;; +(*.rar) + exec unrar x "$1" + ;; +(*.zip) + exec unzip <"$1" + ;; +(*.Z) + exec uncompress "$1" + ;; +(*.7z) + exec 7z x "$1" + ;; +(*.deb) + exec ar vx "$1" + ;; +(*) + if test -d "$1" + then exec session "$1" shell "$1" + else exec session "$1" edit "$1" + fi +esac diff --git a/dot/profile b/dot/profile @@ -23,7 +23,7 @@ export LC_TIME=en_US.UTF-8 export PLAN9=/usr/local/9base export PATH=/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/sbin -export PATH=/local/bin:$HOME/bin:$PATH:/usr/X11R6/bin:$PLAN9/bin +export PATH=/local/bin:$HOME/conf/bin:$PATH:/usr/X11R6/bin:$PLAN9/bin export MANPATH=/usr/man:/usr/share/man:/usr/local/man:/usr/local/share/man export MANPATH=/local/share/man:$MANPATH:$PLAN9/share/man