summary refs log tree commit diff
path: root/home
diff options
context:
space:
mode:
Diffstat (limited to 'home')
-rwxr-xr-xhome/.bin/bri.c77
-rwxr-xr-xhome/.bin/dtch.c254
-rwxr-xr-xhome/.bin/hnel.c115
-rwxr-xr-xhome/.bin/jrp.c273
-rwxr-xr-xhome/.bin/pbd.c136
-rwxr-xr-xhome/.bin/sup7
-rwxr-xr-xhome/.bin/tup7
-rwxr-xr-xhome/.bin/up12
-rwxr-xr-xhome/.bin/wake.c41
-rwxr-xr-xhome/.bin/watch.c100
-rwxr-xr-xhome/.bin/xx.c117
-rw-r--r--home/.config/git/config15
-rw-r--r--home/.config/git/ignore2
-rw-r--r--home/.config/htop/htoprc26
-rw-r--r--home/.config/nvim/colors/trivial.vim56
-rw-r--r--home/.config/nvim/init.vim36
-rw-r--r--home/.config/nvim/syntax/nasm.vim527
-rw-r--r--home/.gdbinit1
-rw-r--r--home/.gnupg/gpg-agent.conf2
-rw-r--r--home/.hushlogin0
-rw-r--r--home/.inputrc1
-rw-r--r--home/.psqlrc9
-rw-r--r--home/.ssh/config17
-rw-r--r--home/.zshrc69
24 files changed, 1900 insertions, 0 deletions
diff --git a/home/.bin/bri.c b/home/.bin/bri.c
new file mode 100755
index 00000000..d085814b
--- /dev/null
+++ b/home/.bin/bri.c
@@ -0,0 +1,77 @@
+#if 0
+set -e
+bin=$(dirname $0)
+cc -Wall -Wextra -pedantic $@ -o $bin/bri $0
+sudo chown root:root $bin/bri
+sudo chmod u+s $bin/bri
+exit
+#endif
+
+// Backlight brightness control.
+
+#include <dirent.h>
+#include <err.h>
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+#include <sysexits.h>
+#include <unistd.h>
+
+static const char *CLASS = "/sys/class/backlight";
+
+int main(int argc, char *argv[]) {
+    int error;
+
+    if (argc < 2) errx(EX_USAGE, "usage: bri N | +... | -...");
+
+    error = chdir(CLASS);
+    if (error) err(EX_IOERR, "%s", CLASS);
+
+    DIR *dir = opendir(".");
+    if (!dir) err(EX_IOERR, "%s", CLASS);
+
+    struct dirent *entry;
+    while (NULL != (errno = 0, entry = readdir(dir))) {
+        if (entry->d_name[0] == '.') continue;
+
+        error = chdir(entry->d_name);
+        if (error) err(EX_IOERR, "%s", entry->d_name);
+        break;
+    }
+    if (!entry) {
+        if (errno) err(EX_IOERR, "%s", CLASS);
+        errx(EX_CONFIG, "empty %s", CLASS);
+    }
+
+    char *value = argv[1];
+
+    if (value[0] == '+' || value[0] == '-') {
+        FILE *actual = fopen("actual_brightness", "r");
+        if (!actual) err(EX_IOERR, "actual_brightness");
+
+        unsigned int brightness;
+        int match = fscanf(actual, "%u", &brightness);
+        if (match == EOF) err(EX_IOERR, "actual_brightness");
+        if (match < 1) err(EX_DATAERR, "actual_brightness");
+
+        size_t count = strnlen(value, 15);
+        if (value[0] == '+') {
+            brightness += 16 * count;
+        } else {
+            brightness -= 16 * count;
+        }
+
+        char buf[15];
+        snprintf(buf, sizeof(buf), "%u", brightness);
+
+        value = buf;
+    }
+
+    FILE *brightness = fopen("brightness", "w");
+    if (!brightness) err(EX_IOERR, "brightness");
+
+    int count = fprintf(brightness, "%s", value);
+    if (count < 0) err(EX_IOERR, "brightness");
+
+    return EX_OK;
+}
diff --git a/home/.bin/dtch.c b/home/.bin/dtch.c
new file mode 100755
index 00000000..a37eeeeb
--- /dev/null
+++ b/home/.bin/dtch.c
@@ -0,0 +1,254 @@
+#if 0
+set -e
+bin=$(dirname $0)
+cc -Wall -Wextra -pedantic $@ -lutil -o $bin/dtch $0
+ln -f $bin/dtch $bin/atch
+exit
+#endif
+
+// Session attach and detach.
+
+#include <err.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <poll.h>
+#include <pwd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/un.h>
+#include <sys/wait.h>
+#include <sysexits.h>
+#include <termios.h>
+#include <unistd.h>
+
+#if defined __FreeBSD__
+#include <libutil.h>
+#elif defined __linux__
+#include <pty.h>
+#else
+#include <util.h>
+#endif
+
+static struct passwd *getUser(void) {
+    uid_t uid = getuid();
+    struct passwd *user = getpwuid(uid);
+    if (!user) err(EX_OSFILE, "/etc/passwd");
+    return user;
+}
+
+static struct sockaddr_un sockAddr(const char *home, const char *name) {
+    struct sockaddr_un addr = { .sun_family = AF_LOCAL };
+    snprintf(addr.sun_path, sizeof(addr.sun_path), "%s/.dtch/%s", home, name);
+    return addr;
+}
+
+static ssize_t writeAll(int fd, const char *buf, size_t len) {
+    ssize_t writeLen;
+    while (0 < (writeLen = write(fd, buf, len))) {
+        buf += writeLen;
+        len -= writeLen;
+    }
+    return writeLen;
+}
+
+char z;
+struct iovec iov = { .iov_base = &z, .iov_len = 1 };
+
+static ssize_t sendFd(int sock, int fd) {
+    size_t len = CMSG_LEN(sizeof(int));
+    char buf[len];
+    struct msghdr msg = {
+        .msg_iov = &iov,
+        .msg_iovlen = 1,
+        .msg_control = buf,
+        .msg_controllen = len,
+    };
+
+    struct cmsghdr *cmsg = CMSG_FIRSTHDR(&msg);
+    cmsg->cmsg_len = len;
+    cmsg->cmsg_level = SOL_SOCKET;
+    cmsg->cmsg_type = SCM_RIGHTS;
+    *(int *)CMSG_DATA(cmsg) = fd;
+
+    return sendmsg(sock, &msg, 0);
+}
+
+static int recvFd(int sock) {
+    size_t len = CMSG_LEN(sizeof(int));
+    char buf[len];
+    struct msghdr msg = {
+        .msg_iov = &iov,
+        .msg_iovlen = 1,
+        .msg_control = buf,
+        .msg_controllen = len,
+    };
+
+    ssize_t n = recvmsg(sock, &msg, 0);
+    if (n < 0) return -1;
+
+    struct cmsghdr *cmsg = CMSG_FIRSTHDR(&msg);
+    if (!cmsg) { errno = ENOMSG; return -1; }
+    if (cmsg->cmsg_type != SCM_RIGHTS) { errno = EBADMSG; return -1; }
+
+    return *(int *)CMSG_DATA(cmsg);
+}
+
+static struct sockaddr_un addr;
+
+static void unlinkAddr(void) {
+    unlink(addr.sun_path);
+}
+
+static int dtch(int argc, char *argv[]) {
+    int error;
+
+    struct passwd *user = getUser();
+
+    char *name = user->pw_name;
+    char *cmd = user->pw_shell;
+    if (argc > 2) {
+        name = argv[1];
+        cmd = argv[2];
+        argv += 2;
+    } else if (argc > 1) {
+        name = argv[1];
+        argv++;
+    }
+
+    int home = open(user->pw_dir, 0);
+    if (home < 0) err(EX_IOERR, "%s", user->pw_dir);
+    error = mkdirat(home, ".dtch", S_IRWXU);
+    if (error && errno != EEXIST) err(EX_IOERR, "%s/.dtch", user->pw_dir);
+    error = close(home);
+    if (error) err(EX_IOERR, "%s", user->pw_dir);
+
+    int server = socket(PF_LOCAL, SOCK_STREAM, 0);
+    if (server < 0) err(EX_OSERR, "socket");
+
+    addr = sockAddr(user->pw_dir, name);
+    error = bind(server, (struct sockaddr *)&addr, sizeof(addr));
+    if (error) err(EX_IOERR, "%s", addr.sun_path);
+    atexit(unlinkAddr);
+
+    error = chmod(addr.sun_path, 0600);
+    if (error) err(EX_IOERR, "%s", addr.sun_path);
+
+    int master;
+    pid_t pid = forkpty(&master, NULL, NULL, NULL);
+    if (pid < 0) err(EX_OSERR, "forkpty");
+
+    if (!pid) {
+        error = close(server);
+        if (error) warn("close(%d)", server);
+        execvp(cmd, argv);
+        err(EX_OSERR, "%s", cmd);
+    }
+
+    error = listen(server, 0);
+    if (error) err(EX_OSERR, "listen");
+
+    for (;;) {
+        int client = accept(server, NULL, NULL);
+        if (client < 0) err(EX_IOERR, "accept(%d)", server);
+
+        ssize_t len = sendFd(client, master);
+        if (len < 0) warn("sendmsg(%d)", client);
+
+        len = recv(client, &z, sizeof(z), 0);
+        if (len < 0) warn("recv(%d)", client);
+
+        error = close(client);
+        if (error) warn("close(%d)", client);
+
+        pid_t dead = waitpid(pid, NULL, WNOHANG);
+        if (dead < 0) warn("waitpid(%d)", pid);
+        if (dead) exit(EX_OK);
+    }
+}
+
+static struct termios saveTerm;
+
+static void restoreTerm(void) {
+    tcsetattr(STDERR_FILENO, TCSADRAIN, &saveTerm);
+    printf(
+        "\x1b[?1049l" // rmcup
+        "\x1b\x63\x1b[!p\x1b[?3;4l\x1b[4l\x1b>" // reset
+    );
+}
+
+static int atch(int argc, char *argv[]) {
+    int error;
+
+    struct passwd *user = getUser();
+    char *name = (argc > 1) ? argv[1] : user->pw_name;
+
+    int client = socket(PF_LOCAL, SOCK_STREAM, 0);
+    if (client < 0) err(EX_OSERR, "socket");
+
+    struct sockaddr_un addr = sockAddr(user->pw_dir, name);
+    error = connect(client, (struct sockaddr *)&addr, sizeof(addr));
+    if (error) err(EX_IOERR, "%s", addr.sun_path);
+
+    int master = recvFd(client);
+    if (master < 0) err(EX_IOERR, "recvmsg(%d)", client);
+
+    struct winsize window;
+    error = ioctl(STDERR_FILENO, TIOCGWINSZ, &window);
+    if (error) err(EX_IOERR, "ioctl(%d, TIOCGWINSZ)", STDERR_FILENO);
+
+    error = ioctl(master, TIOCSWINSZ, &window);
+    if (error) err(EX_IOERR, "ioctl(%d, TIOCSWINSZ)", master);
+
+    error = tcgetattr(STDERR_FILENO, &saveTerm);
+    if (error) err(EX_IOERR, "tcgetattr(%d)", STDERR_FILENO);
+    atexit(restoreTerm);
+
+    struct termios raw;
+    cfmakeraw(&raw);
+    error = tcsetattr(STDERR_FILENO, TCSADRAIN, &raw);
+    if (error) err(EX_IOERR, "tcsetattr(%d)", STDERR_FILENO);
+
+    char ctrlL = CTRL('L');
+    ssize_t len = write(master, &ctrlL, 1);
+    if (len < 0) err(EX_IOERR, "write(%d)", master);
+
+    struct pollfd fds[2] = {
+        { .fd = STDIN_FILENO, .events = POLLIN },
+        { .fd = master, .events = POLLIN },
+    };
+
+    while (0 < poll(fds, 2, -1)) {
+        char buf[4096];
+        ssize_t len;
+
+        if (fds[0].revents) {
+            len = read(STDIN_FILENO, buf, sizeof(buf));
+            if (len < 0) err(EX_IOERR, "read(%d)", STDIN_FILENO);
+
+            if (len && buf[0] == CTRL('Q')) exit(EX_OK);
+
+            len = writeAll(master, buf, len);
+            if (len < 0) err(EX_IOERR, "write(%d)", master);
+        }
+
+        if (fds[1].revents) {
+            len = read(master, buf, sizeof(buf));
+            if (len < 0) err(EX_IOERR, "read(%d)", master);
+            len = writeAll(STDOUT_FILENO, buf, len);
+            if (len < 0) err(EX_IOERR, "write(%d)", STDOUT_FILENO);
+        }
+    }
+    err(EX_IOERR, "poll([%d,%d])", STDIN_FILENO, master);
+}
+
+int main(int argc, char *argv[]) {
+    switch (argv[0][0]) {
+        case 'd': return dtch(argc, argv);
+        case 'a': return atch(argc, argv);
+    }
+    return EX_USAGE;
+}
diff --git a/home/.bin/hnel.c b/home/.bin/hnel.c
new file mode 100755
index 00000000..3aec85b3
--- /dev/null
+++ b/home/.bin/hnel.c
@@ -0,0 +1,115 @@
+#if 0
+exec cc -Wall -Wextra -pedantic $@ -lutil -o $(dirname $0)/hnel $0
+#endif
+
+// PTY wrapper for preserving HJKL in Tarmak layouts.
+
+#include <err.h>
+#include <poll.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <sys/ioctl.h>
+#include <sys/wait.h>
+#include <sysexits.h>
+#include <termios.h>
+#include <unistd.h>
+
+#if defined __FreeBSD__
+#include <libutil.h>
+#elif defined __linux__
+#include <pty.h>
+#else
+#include <util.h>
+#endif
+
+static char table[256] = {
+    ['n'] = 'j', ['N'] = 'J', [CTRL('N')] = CTRL('J'),
+    ['e'] = 'k', ['E'] = 'K', [CTRL('E')] = CTRL('K'),
+    ['j'] = 'e', ['J'] = 'E', [CTRL('J')] = CTRL('E'),
+    ['k'] = 'n', ['K'] = 'N', [CTRL('K')] = CTRL('N'),
+};
+
+static ssize_t writeAll(int fd, const char *buf, size_t len) {
+    ssize_t writeLen;
+    while (0 < (writeLen = write(fd, buf, len))) {
+        buf += writeLen;
+        len -= writeLen;
+    }
+    return writeLen;
+}
+
+static struct termios saveTerm;
+
+static void restoreTerm(void) {
+    tcsetattr(STDERR_FILENO, TCSADRAIN, &saveTerm);
+}
+
+int main(int argc, char *argv[]) {
+    int error;
+
+    if (argc < 2) return EX_USAGE;
+
+    error = tcgetattr(STDERR_FILENO, &saveTerm);
+    if (error) err(EX_IOERR, "tcgetattr");
+    atexit(restoreTerm);
+
+    struct termios raw;
+    cfmakeraw(&raw);
+    error = tcsetattr(STDERR_FILENO, TCSADRAIN, &raw);
+    if (error) err(EX_IOERR, "tcsetattr");
+
+    struct winsize window;
+    error = ioctl(STDERR_FILENO, TIOCGWINSZ, &window);
+    if (error) err(EX_IOERR, "ioctl(%d, TIOCGWINSZ)", STDERR_FILENO);
+
+    int master;
+    pid_t pid = forkpty(&master, NULL, NULL, &window);
+    if (pid < 0) err(EX_OSERR, "forkpty");
+
+    if (!pid) {
+        execvp(argv[1], argv + 1);
+        err(EX_OSERR, "%s", argv[1]);
+    }
+
+    bool enable = true;
+
+    struct pollfd fds[2] = {
+        { .fd = STDIN_FILENO, .events = POLLIN },
+        { .fd = master, .events = POLLIN },
+    };
+    while (0 < poll(fds, 2, -1)) {
+        char buf[4096];
+        ssize_t len;
+
+        if (fds[0].revents) {
+            len = read(STDIN_FILENO, buf, sizeof(buf));
+            if (len < 0) err(EX_IOERR, "read(%d)", STDIN_FILENO);
+
+            if (len == 1) {
+                if (buf[0] == CTRL('S')) {
+                    enable = !enable;
+                    continue;
+                }
+
+                unsigned char c = buf[0];
+                if (enable && table[c]) buf[0] = table[c];
+            }
+
+            len = writeAll(master, buf, len);
+            if (len < 0) err(EX_IOERR, "write(%d)", master);
+        }
+
+        if (fds[1].revents) {
+            len = read(master, buf, sizeof(buf));
+            if (len < 0) err(EX_IOERR, "read(%d)", master);
+            len = writeAll(STDOUT_FILENO, buf, len);
+            if (len < 0) err(EX_IOERR, "write(%d)", STDOUT_FILENO);
+        }
+
+        int status;
+        pid_t dead = waitpid(pid, &status, WNOHANG);
+        if (dead < 0) err(EX_OSERR, "waitpid(%d)", pid);
+        if (dead) return WIFEXITED(status) ? WEXITSTATUS(status) : EX_SOFTWARE;
+    }
+    err(EX_IOERR, "poll");
+}
diff --git a/home/.bin/jrp.c b/home/.bin/jrp.c
new file mode 100755
index 00000000..9317ac8e
--- /dev/null
+++ b/home/.bin/jrp.c
@@ -0,0 +1,273 @@
+#if 0
+exec cc -Wall -Wextra -pedantic $@ $0 -ledit -o $(dirname $0)/jrp
+#endif
+
+// JIT RPN calculator.
+
+#include <err.h>
+#include <histedit.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/mman.h>
+#include <sysexits.h>
+#include <unistd.h>
+
+typedef unsigned long qop;
+typedef unsigned int dop;
+
+typedef long qvalue;
+typedef int dvalue;
+typedef unsigned long uvalue;
+
+typedef qvalue *(*jitFn)(qvalue *);
+typedef void (*rtFn)(qvalue);
+
+static char *formatBin(qvalue val) {
+    static char buf[sizeof(qvalue) * 8 + 1];
+    uvalue uval = val;
+    size_t i = sizeof(buf);
+    do {
+        buf[--i] = '0' + (uval & 1);
+    } while (uval >>= 1);
+    return &buf[i];
+}
+
+static void rtPrintAscii(qvalue val) {
+    printf("%c\n", (char)val);
+}
+static void rtPrintBin(qvalue val) {
+    printf("%s\n", formatBin(val));
+}
+static void rtPrintOct(qvalue val) {
+    printf("%lo\n", val);
+}
+static void rtPrintDec(qvalue val) {
+    printf("%ld\n", val);
+}
+static void rtPrintHex(qvalue val) {
+    printf("%lx\n", val);
+}
+
+static const dop DOP_NOP  = 0x90666666; // nop
+static const dop DOP_PUSH = 0xc7c74857; // push rdi; mov rdi, strict dword 0
+static const dop DOP_DROP = 0x9066665f; // pop rdi
+static const dop DOP_DUP  = 0x90666657; // push rdi
+static const dop DOP_SWAP = 0x243c8748; // xchg rdi, [rsp]
+static const dop DOP_NEG  = 0x90dff748; // neg rdi
+static const dop DOP_ADD  = 0xc7014858; // pop rax; add rdi, rax
+static const dop DOP_QUO  = 0x90c78948; // mov rdi, rax
+static const dop DOP_REM  = 0x90d78948; // mov rdi, rdx
+static const dop DOP_NOT  = 0x90d7f748; // not rdi
+static const dop DOP_AND  = 0xc7214858; // pop rax; and rdi, rax
+static const dop DOP_OR   = 0xc7094858; // pop rax; or rdi, rax
+static const dop DOP_XOR  = 0xc7314858; // pop rax; xor rdi, rax
+
+static const qop QOP_PROL = 0x5ffc8948e5894855; // push rbp; mov rbp, rsp; mov rsp, rdi; pop rdi
+static const qop QOP_EPIL = 0x5dec8948e0894857; // push rdi; mov rax, rsp; mov rsp, rbp; pop rbp
+static const qop QOP_RET  = 0x90666666906666c3; // ret
+static const qop QOP_CRT  = 0xb848906690e58748; // xchg rsp, rbp; mov rax, strict qword 0
+static const qop QOP_CALL = 0x90665fe58748d0ff; // call rax; xchg rsp, rbp; pop rdi
+static const qop QOP_PUSH = 0xbf48906690666657; // push rdi; mov rdi, strict qword 0
+static const qop QOP_SUB  = 0x9066665f243c2948; // sub [rsp], rdi; pop rdi
+static const qop QOP_MUL  = 0x906666f8af0f4858; // pop rax; imul rdi, rax
+static const qop QOP_DIV  = 0x9066fff748994858; // pop rax; cqo; idiv rdi
+static const qop QOP_SHL  = 0x5f2424d348f98948; // mov rcx, rdi; shl qword [rsp], cl; pop rdi
+static const qop QOP_SHR  = 0x5f242cd348f98948; // mov rcx, rdi; shr qword [rsp], cl; pop rdi
+
+static int radix = 10;
+
+static struct {
+    qop *base;
+    qop *ptr;
+    dop dop;
+} code;
+
+static struct {
+    qvalue *base;
+    qvalue *limit;
+    qvalue *ptr;
+} stack;
+
+static void jitDop(dop op) {
+    if (code.dop) {
+        *code.ptr++ = (qop)op << 32 | code.dop;
+        code.dop = 0;
+    } else {
+        code.dop = op;
+    }
+}
+
+static void jitQop(qop op) {
+    if (code.dop) jitDop(DOP_NOP);
+    *code.ptr++ = op;
+}
+
+static void jitPush(qvalue imm) {
+    if ((dvalue)imm == imm) {
+        jitQop(DOP_PUSH | (qop)imm << 32);
+    } else {
+        jitQop(QOP_PUSH);
+        jitQop((qop)imm);
+    }
+}
+
+static void jitCall(rtFn fn) {
+    jitQop(QOP_CRT);
+    jitQop((qop)fn);
+    jitQop(QOP_CALL);
+}
+
+static void jitBegin(void) {
+    code.ptr = code.base;
+    jitQop(QOP_PROL);
+}
+
+static void jitEnd(void) {
+    jitQop(QOP_EPIL);
+    jitQop(QOP_RET);
+}
+
+static void jitInit(void) {
+    code.base = mmap(0, getpagesize(), PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
+    if (code.base == MAP_FAILED) err(EX_OSERR, "mmap");
+}
+
+static void stackInit(void) {
+    stack.base = mmap(0, 2 * getpagesize(), PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
+    if (stack.base == MAP_FAILED) err(EX_OSERR, "mmap");
+    stack.limit = stack.base + getpagesize() / sizeof(qvalue);
+    stack.ptr = stack.limit;
+}
+
+static void jitExec(void) {
+    int error;
+    error = mprotect(code.base, getpagesize(), PROT_READ | PROT_EXEC);
+    if (error) err(EX_OSERR, "mprotect");
+    stack.ptr = ((jitFn)code.base)(stack.ptr);
+    if (stack.ptr > stack.limit) stack.ptr = stack.limit;
+    error = mprotect(code.base, getpagesize(), PROT_READ | PROT_WRITE);
+    if (error) err(EX_OSERR, "mprotect");
+}
+
+static void jitSrc(const char *src) {
+    bool quote = false;
+    while (*src) {
+        if (quote) {
+            jitPush(*src++);
+            quote = false;
+            continue;
+        }
+
+        switch (*src) {
+            case ' ': break;
+            case 39: quote = true; break;
+            case 'B': radix = 2;   break;
+            case 'O': radix = 8;   break;
+            case 'D': radix = 10;  break;
+            case 'X': radix = 16;  break;
+            case ';': jitDop(DOP_DROP); break;
+            case ':': jitDop(DOP_DUP);  break;
+            case 92:  jitDop(DOP_SWAP); break;
+            case '_': jitDop(DOP_NEG);  break;
+            case '+': jitDop(DOP_ADD);  break;
+            case '-': jitQop(QOP_SUB);  break;
+            case '*': jitQop(QOP_MUL);  break;
+            case '/': jitQop(QOP_DIV); jitDop(DOP_QUO); break;
+            case '%': jitQop(QOP_DIV); jitDop(DOP_REM); break;
+            case '~': jitDop(DOP_NOT);  break;
+            case '&': jitDop(DOP_AND);  break;
+            case '|': jitDop(DOP_OR);   break;
+            case '^': jitDop(DOP_XOR);  break;
+            case '<': jitQop(QOP_SHL);  break;
+            case '>': jitQop(QOP_SHR);  break;
+            case ',': jitCall(rtPrintAscii); break;
+            case '.': switch (radix) {
+                case 2:  jitCall(rtPrintBin); break;
+                case 8:  jitCall(rtPrintOct); break;
+                case 10: jitCall(rtPrintDec); break;
+                case 16: jitCall(rtPrintHex); break;
+            } break;
+
+            default: {
+                char *rest;
+                qvalue val = strtol(src, &rest, radix);
+                if (rest != src) {
+                    src = rest;
+                    jitPush(val);
+                    continue;
+                }
+            }
+        }
+
+        src++;
+    }
+}
+
+static void jitDump(const char *path, FILE *file) {
+    size_t nitems = code.ptr - code.base;
+    size_t written = fwrite(code.base, sizeof(qop), nitems, file);
+    if (written < nitems) err(EX_IOERR, "%s", path);
+}
+
+static char *prompt(EditLine *el __attribute((unused))) {
+    static char buf[4096];
+    char *bufPtr = buf;
+    for (qvalue *stackPtr = stack.limit - 1; stackPtr >= stack.ptr; --stackPtr) {
+        size_t bufLen = sizeof(buf) - (bufPtr - buf) - 2;
+        switch (radix) {
+            case 2:  bufPtr += snprintf(bufPtr, bufLen, " %s", formatBin(*stackPtr)); break;
+            case 8:  bufPtr += snprintf(bufPtr, bufLen, " %lo", *stackPtr); break;
+            case 10: bufPtr += snprintf(bufPtr, bufLen, " %ld", *stackPtr); break;
+            case 16: bufPtr += snprintf(bufPtr, bufLen, " %lx", *stackPtr); break;
+        }
+    }
+    buf[0] = '[';
+    if (bufPtr == buf) bufPtr++;
+    *bufPtr++ = ']';
+    *bufPtr++ = ' ';
+    *bufPtr = 0;
+    return buf;
+}
+
+int main(int argc, char *argv[]) {
+    FILE *file = NULL;
+    char *path = getenv("JRP_DUMP");
+    if (path) {
+        file = fopen(path, "w");
+        if (!file) err(EX_CANTCREAT, "%s", path);
+    }
+
+    jitInit();
+    stackInit();
+
+    if (argc > 1) {
+        jitBegin();
+        for (int i = 1; i < argc; ++i)
+            jitSrc(argv[i]);
+        jitEnd();
+        if (file) jitDump(path, file);
+        jitExec();
+        return EX_OK;
+    }
+
+    EditLine *el = el_init(argv[0], stdin, stdout, stderr);
+    el_set(el, EL_PROMPT, prompt);
+    el_set(el, EL_SIGNAL, true);
+
+    for (;;) {
+        int count;
+        const char *line = el_gets(el, &count);
+        if (count < 0) err(EX_IOERR, "el_gets");
+        if (!line) break;
+
+        jitBegin();
+        jitSrc(line);
+        jitEnd();
+        if (file) jitDump(path, file);
+        jitExec();
+    }
+
+    el_end(el);
+    return EX_OK;
+}
diff --git a/home/.bin/pbd.c b/home/.bin/pbd.c
new file mode 100755
index 00000000..01e5c07d
--- /dev/null
+++ b/home/.bin/pbd.c
@@ -0,0 +1,136 @@
+#if 0
+set -e
+bin=$(dirname $0)
+cc -Wall -Wextra -pedantic $@ -o $bin/pbd $0
+ln -f $bin/pbd $bin/pbcopy
+ln -f $bin/pbd $bin/pbpaste
+exit
+#endif
+
+// TCP server which pipes between macOS pbcopy and pbpaste, and pbcopy and
+// pbpaste implementations which connect to it.
+
+#include <arpa/inet.h>
+#include <err.h>
+#include <netinet/in.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/socket.h>
+#include <sys/wait.h>
+#include <sysexits.h>
+#include <unistd.h>
+
+static void spawn(const char *cmd, int childFd, int parentFd) {
+    pid_t pid = fork();
+    if (pid < 0) err(EX_OSERR, "fork");
+
+    if (pid) {
+        int status;
+        pid_t wait = waitpid(pid, &status, 0);
+        if (wait < 0) err(EX_OSERR, "waitpid");
+
+        if (status) {
+            warnx("child %s status %d", cmd, status);
+        }
+    } else {
+        int fd = dup2(parentFd, childFd);
+        if (fd < 0) err(EX_OSERR, "dup2");
+
+        int error = execlp(cmd, cmd, NULL);
+        if (error) err(EX_OSERR, "execlp");
+    }
+}
+
+static int pbd(void) {
+    int error;
+
+    int server = socket(PF_INET, SOCK_STREAM, 0);
+    if (server < 0) err(EX_OSERR, "socket");
+
+    struct sockaddr_in addr = {
+        .sin_family = AF_INET,
+        .sin_port = htons(7062),
+        .sin_addr = { .s_addr = htonl(0x7f000001) },
+    };
+
+    error = bind(server, (struct sockaddr *)&addr, sizeof(addr));
+    if (error) err(EX_OSERR, "bind");
+
+    error = listen(server, 1);
+    if (error) err(EX_OSERR, "listen");
+
+    for (;;) {
+        int client = accept(server, NULL, NULL);
+        if (client < 0) err(EX_OSERR, "accept");
+
+        spawn("pbpaste", STDOUT_FILENO, client);
+
+        uint8_t p;
+        ssize_t peek = recv(client, &p, 1, MSG_PEEK);
+        if (peek < 0) err(EX_IOERR, "recv");
+
+        if (peek) {
+            spawn("pbcopy", STDIN_FILENO, client);
+        }
+
+        error = close(client);
+        if (error) err(EX_IOERR, "close");
+    }
+}
+
+static int pbdClient(void) {
+    int client = socket(PF_INET, SOCK_STREAM, 0);
+    if (client < 0) err(EX_OSERR, "socket");
+
+    struct sockaddr_in addr = {
+        .sin_family = AF_INET,
+        .sin_port = htons(7062),
+        .sin_addr = { .s_addr = htonl(0x7f000001) },
+    };
+
+    int error = connect(client, (struct sockaddr *)&addr, sizeof(addr));
+    if (error) err(EX_OSERR, "connect");
+
+    return client;
+}
+
+static void copy(int fdIn, int fdOut) {
+    char readBuf[4096];
+    ssize_t readLen;
+    while (0 < (readLen = read(fdIn, readBuf, sizeof(readBuf)))) {
+        char *writeBuf = readBuf;
+        ssize_t writeLen;
+        while (0 < (writeLen = write(fdOut, writeBuf, readLen))) {
+            writeBuf += writeLen;
+            readLen -= writeLen;
+        }
+        if (writeLen < 0) err(EX_IOERR, "write");
+    }
+    if (readLen < 0) err(EX_IOERR, "read");
+}
+
+static int pbcopy(void) {
+    int client = pbdClient();
+    copy(STDIN_FILENO, client);
+    return EX_OK;
+}
+
+static int pbpaste(void) {
+    int client = pbdClient();
+    int error = shutdown(client, SHUT_WR);
+    if (error) err(EX_OSERR, "shutdown");
+    copy(client, STDOUT_FILENO);
+    return EX_OK;
+}
+
+int main(int argc __attribute((unused)), char *argv[]) {
+    if (!argv[0][0] || !argv[0][1]) return EX_USAGE;
+    switch (argv[0][2]) {
+        case 'd': return pbd();
+        case 'c': return pbcopy();
+        case 'p': return pbpaste();
+    }
+    return EX_USAGE;
+}
diff --git a/home/.bin/sup b/home/.bin/sup
new file mode 100755
index 00000000..7a69d9d0
--- /dev/null
+++ b/home/.bin/sup
@@ -0,0 +1,7 @@
+#!/usr/bin/env zsh
+set -o errexit -o nounset -o pipefail
+
+dir=$(mktemp -d)
+screencapture -i "$dir/capture.png"
+up "$dir/capture.png"
+rm -r "$dir"
diff --git a/home/.bin/tup b/home/.bin/tup
new file mode 100755
index 00000000..29af9b0a
--- /dev/null
+++ b/home/.bin/tup
@@ -0,0 +1,7 @@
+#!/usr/bin/env zsh
+set -o errexit -o nounset -o pipefail
+
+dir=$(mktemp -d)
+cat > "$dir/input.txt"
+up "$dir/input.txt"
+rm -r "$dir"
diff --git a/home/.bin/up b/home/.bin/up
new file mode 100755
index 00000000..3a25e112
--- /dev/null
+++ b/home/.bin/up
@@ -0,0 +1,12 @@
+#!/usr/bin/env zsh
+set -o errexit -o nounset -o pipefail
+
+ts=$(date +%s)
+rand=$(openssl rand -hex 4)
+ext=${1##*.}
+url=$(printf 'tmp.cmcenroe.me/%x%s.%s' "$ts" "$rand" "$ext")
+
+scp -q "$1" "tmp.cmcenroe.me:/usr/local/www/$url"
+
+echo "https://$url"
+type pbcopy > /dev/null && echo -n "https://$url" | pbcopy
diff --git a/home/.bin/wake.c b/home/.bin/wake.c
new file mode 100755
index 00000000..2f314975
--- /dev/null
+++ b/home/.bin/wake.c
@@ -0,0 +1,41 @@
+#if 0
+exec cc -Wall -Wextra -Wpedantic $@ -o $(dirname $0)/wake $0
+#endif
+
+#include <err.h>
+#include <netinet/in.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <sys/socket.h>
+#include <sysexits.h>
+
+#define MAC 0x04, 0x7D, 0x7B, 0xD5, 0x6A, 0x53
+
+const uint8_t payload[] = {
+    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+    MAC, MAC, MAC, MAC, MAC, MAC, MAC, MAC,
+    MAC, MAC, MAC, MAC, MAC, MAC, MAC, MAC,
+};
+
+int main() {
+    int sock = socket(PF_INET, SOCK_DGRAM, 0);
+    if (sock < 0) err(EX_OSERR, "socket");
+
+    int on = 1;
+    int error = setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &on, sizeof(on));
+    if (error) err(EX_OSERR, "setsockopt");
+
+    struct sockaddr_in addr = {
+        .sin_family = AF_INET,
+        .sin_port = 9,
+        .sin_addr.s_addr = INADDR_BROADCAST,
+    };
+
+    ssize_t len = sendto(
+        sock, payload, sizeof(payload), 0,
+        (struct sockaddr *)&addr, sizeof(addr)
+    );
+    if (len < 0) err(EX_IOERR, "sendto");
+
+    return EX_OK;
+}
diff --git a/home/.bin/watch.c b/home/.bin/watch.c
new file mode 100755
index 00000000..c13f6d71
--- /dev/null
+++ b/home/.bin/watch.c
@@ -0,0 +1,100 @@
+#if 0
+exec cc -Wall -Wextra -Wpedantic -o $(dirname $0)/watch $0
+#endif
+
+/*
+ * Execute a command each time files change.
+ *
+ * Copyright (c) 2017, Curtis McEnroe <programble@gmail.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <sys/types.h>
+
+#include <err.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <sys/event.h>
+#include <sys/wait.h>
+#include <sysexits.h>
+#include <unistd.h>
+
+static void watch(int kq, char *path) {
+    int fd = open(path, O_RDONLY);
+    if (fd < 0) err(EX_IOERR, "%s", path);
+
+    struct kevent event = {
+        .ident = fd,
+        .filter = EVFILT_VNODE,
+        .flags = EV_ADD | EV_CLEAR,
+        .fflags = NOTE_WRITE | NOTE_DELETE,
+        .udata = path,
+    };
+    int nevents = kevent(kq, &event, 1, NULL, 0, NULL);
+    if (nevents < 0) err(EX_IOERR, "kevent");
+}
+
+static void exec(char *const argv[]) {
+    pid_t pid = fork();
+    if (pid < 0) err(EX_OSERR, "fork");
+
+    if (!pid) {
+        execvp(argv[0], argv);
+        err(EX_OSERR, "%s", argv[0]);
+    }
+
+    int status;
+    pid = wait(&status);
+    if (pid < 0) err(EX_OSERR, "wait");
+
+    if (WIFEXITED(status)) {
+        warnx("exit %d", WEXITSTATUS(status));
+    } else if (WIFSIGNALED(status)) {
+        warnx("signal %d", WTERMSIG(status));
+    } else {
+        warnx("status %d", status);
+    }
+}
+
+int main(int argc, char *argv[]) {
+    if (argc < 3) return EX_USAGE;
+
+    int kq = kqueue();
+    if (kq < 0) err(EX_OSERR, "kqueue");
+
+    int index;
+    for (index = 1; index < argc - 1; ++index) {
+        if (argv[index][0] == '-') {
+            index++;
+            break;
+        }
+        watch(kq, argv[index]);
+    }
+
+    exec(&argv[index]);
+
+    for (;;) {
+        struct kevent event;
+        int nevents = kevent(kq, NULL, 0, &event, 1, NULL);
+        if (nevents < 0) err(EX_IOERR, "kevent");
+
+        if (event.fflags & NOTE_DELETE) {
+            close(event.ident);
+            watch(kq, event.udata);
+        }
+
+        exec(&argv[index]);
+    }
+}
diff --git a/home/.bin/xx.c b/home/.bin/xx.c
new file mode 100755
index 00000000..78d8db4c
--- /dev/null
+++ b/home/.bin/xx.c
@@ -0,0 +1,117 @@
+#if 0
+exec cc -Wall -Wextra -pedantic $@ -o $(dirname $0)/xx $0
+#endif
+
+// Hexdump.
+
+#include <ctype.h>
+#include <err.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sysexits.h>
+#include <unistd.h>
+
+static bool allZero(const uint8_t *buf, size_t len) {
+    for (size_t i = 0; i < len; ++i)
+        if (buf[i]) return false;
+    return true;
+}
+
+enum {
+    FLAG_ASCII  = 1 << 0,
+    FLAG_OFFSET = 1 << 1,
+    FLAG_SKIP   = 1 << 2,
+    FLAG_UNDUMP = 1 << 3,
+};
+
+static void dump(size_t cols, size_t group, uint8_t flags, FILE *file) {
+    uint8_t buf[cols];
+    size_t offset = 0, len = 0;
+    for (;;) {
+        offset += len;
+        len = fread(buf, 1, sizeof(buf), file);
+        if (!len) break;
+
+        if ((flags & FLAG_SKIP) && len == sizeof(buf)) {
+            static bool skip;
+            if (allZero(buf, len)) {
+                if (!skip) printf("*\n");
+                skip = true;
+                continue;
+            }
+            skip = false;
+        }
+
+        if (flags & FLAG_OFFSET) {
+            printf("%08zx:  ", offset);
+        }
+
+        for (size_t i = 0; i < len; ++i) {
+            if (group && i && !(i % group)) printf(" ");
+            printf("%02x ", buf[i]);
+        }
+
+        if (flags & FLAG_ASCII) {
+            for (size_t i = len; i < cols; ++i) {
+                printf((group && !(i % group)) ? "    " : "   ");
+            }
+            printf(" ");
+            for (size_t i = 0; i < len; ++i) {
+                if (group && i && !(i % group)) printf(" ");
+                printf("%c", isprint(buf[i]) ? buf[i] : '.');
+            }
+        }
+
+        printf("\n");
+        if (len < sizeof(buf)) break;
+    }
+}
+
+static void undump(FILE *file) {
+    uint8_t byte;
+    int match;
+    while (1 == (match = fscanf(file, " %hhx", &byte))) {
+        printf("%c", byte);
+    }
+    if (match == 0) errx(EX_DATAERR, "invalid input");
+}
+
+int main(int argc, char *argv[]) {
+    size_t cols = 16;
+    size_t group = 8;
+    uint8_t flags = FLAG_ASCII | FLAG_OFFSET;
+    char *path = NULL;
+
+    int opt;
+    while (0 < (opt = getopt(argc, argv, "ac:fg:hku"))) {
+        switch (opt) {
+            case 'a': flags ^= FLAG_ASCII; break;
+            case 'f': flags ^= FLAG_OFFSET; break;
+            case 'k': flags ^= FLAG_SKIP; break;
+            case 'u': flags ^= FLAG_UNDUMP; break;
+            case 'c': cols = strtoul(optarg, NULL, 10); break;
+            case 'g': group = strtoul(optarg, NULL, 10); break;
+            default:
+                fprintf(stderr, "usage: xx [-afku] [-c cols] [-g group] [file]\n");
+                return (opt == 'h') ? EX_OK : EX_USAGE;
+        }
+    }
+    if (!cols) return EX_USAGE;
+    if (argc > optind) {
+        path = argv[optind];
+    }
+
+    FILE *file = path ? fopen(path, "r") : stdin;
+    if (!file) err(EX_NOINPUT, "%s", path);
+
+    if (flags & FLAG_UNDUMP) {
+        undump(file);
+    } else {
+        dump(cols, group, flags, file);
+    }
+
+    if (ferror(file)) err(EX_IOERR, "%s", path);
+    return EX_OK;
+}
diff --git a/home/.config/git/config b/home/.config/git/config
new file mode 100644
index 00000000..c34f0a9b
--- /dev/null
+++ b/home/.config/git/config
@@ -0,0 +1,15 @@
+[user]
+    name = Curtis McEnroe
+    email = programble@gmail.com
+
+[commit]
+    gpgSign = true
+
+[rebase]
+    autosquash = true
+
+[pretty]
+    log = %Cred%h %Creset%s%C(yellow)%d %Cgreen(%ar) %Cblue<%an>
+
+[include]
+    path = ./private
diff --git a/home/.config/git/ignore b/home/.config/git/ignore
new file mode 100644
index 00000000..380a01a1
--- /dev/null
+++ b/home/.config/git/ignore
@@ -0,0 +1,2 @@
+*.DS_store
+.pult*
diff --git a/home/.config/htop/htoprc b/home/.config/htop/htoprc
new file mode 100644
index 00000000..f8c272a3
--- /dev/null
+++ b/home/.config/htop/htoprc
@@ -0,0 +1,26 @@
+# Beware! This file is rewritten by htop when settings are changed in the interface.
+# The parser is also very primitive, and not human-friendly.
+fields=0 48 17 18 39 2 46 47 49 1 
+sort_key=47
+sort_direction=1
+hide_threads=0
+hide_kernel_threads=1
+hide_userland_threads=1
+shadow_other_users=0
+show_thread_names=0
+show_program_path=1
+highlight_base_name=1
+highlight_megabytes=1
+highlight_threads=1
+tree_view=1
+header_margin=0
+detailed_cpu_time=0
+cpu_count_from_zero=0
+update_process_names=0
+account_guest_in_cpu_meter=0
+color_scheme=0
+delay=15
+left_meters=AllCPUs Memory Swap 
+left_meter_modes=1 1 1 
+right_meters=Tasks LoadAverage Uptime 
+right_meter_modes=2 2 2 
diff --git a/home/.config/nvim/colors/trivial.vim b/home/.config/nvim/colors/trivial.vim
new file mode 100644
index 00000000..89aab2d6
--- /dev/null
+++ b/home/.config/nvim/colors/trivial.vim
@@ -0,0 +1,56 @@
+hi clear
+syntax reset
+let colors_name = 'trivial'
+let &t_Co = 16
+
+hi Normal ctermbg=NONE ctermfg=NONE
+
+hi ColorColumn ctermbg=Black
+hi EndOfBuffer ctermfg=DarkGray
+hi VertSplit cterm=NONE ctermbg=NONE ctermfg=DarkGray
+hi LineNr ctermfg=DarkGray
+hi MatchParen ctermbg=DarkGray ctermfg=White
+hi ModeMsg ctermfg=DarkGray
+hi NonText ctermfg=DarkGray
+hi Search ctermbg=NONE ctermfg=Yellow
+hi StatusLine cterm=NONE ctermbg=Black ctermfg=LightGray
+hi StatusLineNC cterm=NONE ctermbg=Black ctermfg=DarkGray
+hi Folded ctermbg=Black ctermfg=DarkGray
+hi Visual cterm=inverse ctermbg=NONE
+hi Comment ctermfg=DarkBlue
+
+hi Constant ctermfg=NONE
+hi String ctermfg=DarkCyan
+hi link Character String
+
+hi Identifier cterm=NONE ctermfg=NONE
+
+hi Statement ctermfg=LightGray
+
+hi PreProc ctermfg=DarkGreen
+hi Macro ctermfg=DarkYellow
+hi link PreCondit Macro
+
+hi Type ctermfg=NONE
+hi StorageClass ctermfg=LightGray
+hi link Structure StorageClass
+hi link Typedef Structure
+
+hi Special ctermfg=LightGray
+hi SpecialComment ctermfg=LightBlue
+hi SpecialKey ctermfg=DarkGray
+
+hi Underlined ctermfg=NONE
+hi Error ctermbg=NONE ctermfg=LightRed
+hi Todo ctermbg=NONE ctermfg=LightBlue
+
+" Language-specifics.
+
+hi diffAdded ctermfg=Green
+hi diffRemoved ctermfg=Red
+
+hi link rustModPath Identifier
+
+hi link rubyDefine Structure
+hi link rubyStringDelimiter String
+hi link rubySymbol String
diff --git a/home/.config/nvim/init.vim b/home/.config/nvim/init.vim
new file mode 100644
index 00000000..f09485de
--- /dev/null
+++ b/home/.config/nvim/init.vim
@@ -0,0 +1,36 @@
+set hidden
+set undofile
+set shortmess=atI
+set wildmode=list:longest
+set splitbelow splitright
+command! W w
+autocmd BufNewFile,BufRead *.asm,*.mac setfiletype nasm
+
+set tabstop=8 expandtab shiftwidth=4 shiftround smartindent
+autocmd FileType sh,zsh,ruby setlocal shiftwidth=2
+set ignorecase smartcase inccommand=nosplit
+nmap <leader><leader> :nohlsearch<CR>
+set foldmethod=syntax foldlevel=99
+
+autocmd TermOpen * setlocal statusline=%{b:term_title}
+autocmd BufEnter term://* startinsert
+tmap <C-w> <C-\><C-n><C-w>
+
+set title
+set scrolloff=1
+set number colorcolumn=80,100
+set list listchars=tab:»·,trail:·
+colorscheme trivial
+
+noremap n j
+noremap e k
+noremap k n
+noremap j e
+noremap N J
+noremap E K
+noremap K N
+noremap J E
+nmap <C-w>n <C-w>j
+nmap <C-w>e <C-w>k
+nmap <C-w>N <C-w>J
+nmap <C-w>E <C-w>K
diff --git a/home/.config/nvim/syntax/nasm.vim b/home/.config/nvim/syntax/nasm.vim
new file mode 100644
index 00000000..7eeb9abb
--- /dev/null
+++ b/home/.config/nvim/syntax/nasm.vim
@@ -0,0 +1,527 @@
+" Vim syntax file
+" Language:	NASM - The Netwide Assembler (v0.98)
+" Maintainer:	Andriy Sokolov	<andriy145@gmail.com>
+" Original Author:	Manuel M.H. Stol	<Manuel.Stol@allieddata.nl>
+" Former Maintainer:	Manuel M.H. Stol	<Manuel.Stol@allieddata.nl>
+" Last Change:	2012 Feb 7
+" NASM Home:	http://www.nasm.us/
+
+
+
+" Setup Syntax:
+"  Clear old syntax settings
+if version < 600
+  syn clear
+elseif exists("b:current_syntax")
+  finish
+endif
+"  Assembler syntax is case insensetive
+syn case ignore
+
+
+
+" Vim search and movement commands on identifers
+if version < 600
+  "  Comments at start of a line inside which to skip search for indentifiers
+  set comments=:;
+  "  Identifier Keyword characters (defines \k)
+  set iskeyword=@,48-57,#,$,.,?,@-@,_,~
+else
+  "  Comments at start of a line inside which to skip search for indentifiers
+  setlocal comments=:;
+  "  Identifier Keyword characters (defines \k)
+  setlocal iskeyword=@,48-57,#,$,.,?,@-@,_,~
+endif
+
+
+
+" Comments:
+syn region  nasmComment		start=";" keepend end="$" contains=@nasmGrpInComments
+syn region  nasmSpecialComment	start=";\*\*\*" keepend end="$"
+syn keyword nasmInCommentTodo	contained TODO FIXME XXX[XXXXX]
+syn cluster nasmGrpInComments	contains=nasmInCommentTodo
+syn cluster nasmGrpComments	contains=@nasmGrpInComments,nasmComment,nasmSpecialComment
+
+
+
+" Label Identifiers:
+"  in NASM: 'Everything is a Label'
+"  Definition Label = label defined by %[i]define or %[i]assign
+"  Identifier Label = label defined as first non-keyword on a line or %[i]macro
+syn match   nasmLabelError	"$\=\(\d\+\K\|[#.@]\|\$\$\k\)\k*\>"
+syn match   nasmLabel		"\<\(\h\|[?@]\)\k*\>"
+syn match   nasmLabel		"[\$\~]\(\h\|[?@]\)\k*\>"lc=1
+"  Labels starting with one or two '.' are special
+syn match   nasmLocalLabel	"\<\.\(\w\|[#$?@~]\)\k*\>"
+syn match   nasmLocalLabel	"\<\$\.\(\w\|[#$?@~]\)\k*\>"ms=s+1
+if !exists("nasm_no_warn")
+  syn match  nasmLabelWarn	"\<\~\=\$\=[_.][_.\~]*\>"
+endif
+if exists("nasm_loose_syntax")
+  syn match   nasmSpecialLabel	"\<\.\.@\k\+\>"
+  syn match   nasmSpecialLabel	"\<\$\.\.@\k\+\>"ms=s+1
+  if !exists("nasm_no_warn")
+    syn match   nasmLabelWarn	"\<\$\=\.\.@\(\d\|[#$\.~]\)\k*\>"
+  endif
+  " disallow use of nasm internal label format
+  syn match   nasmLabelError	"\<\$\=\.\.@\d\+\.\k*\>"
+else
+  syn match   nasmSpecialLabel	"\<\.\.@\(\h\|[?@]\)\k*\>"
+  syn match   nasmSpecialLabel	"\<\$\.\.@\(\h\|[?@]\)\k*\>"ms=s+1
+endif
+"  Labels can be dereferenced with '$' to destinguish them from reserved words
+syn match   nasmLabelError	"\<\$\K\k*\s*:"
+syn match   nasmLabelError	"^\s*\$\K\k*\>"
+syn match   nasmLabelError	"\<\~\s*\(\k*\s*:\|\$\=\.\k*\)"
+
+
+
+" Constants:
+syn match   nasmStringError	+["'`]+
+syn match   nasmString		+\("[^"]\{-}"\|'[^']\{-}'\|`[^"]\{-}`\)+
+syn match   nasmBinNumber	"\<[0-1_]\+b\>"
+syn match   nasmBinNumber	"\<\~[0-1_]\+b\>"lc=1
+syn match   nasmOctNumber	"\<\(\o\|_\)\+q\>"
+syn match   nasmOctNumber	"\<\~\(\o\|_\)\+q\>"lc=1
+syn match   nasmDecNumber	"\<\(\d\|_\)\+\>"
+syn match   nasmDecNumber	"\<\~\(\d\|_\)\+\>"lc=1
+syn match   nasmHexNumber	"\<\(\d\(\x\|_\)*h\|0x\(\x\|_\)\+\|\$\d\(\x\|_\)*\)\>"
+syn match   nasmHexNumber	"\<\~\(\d\(\x\|_\)*h\|0x\(\x\|_\)\+\|\$\d\(\x\|_\)*\)\>"lc=1
+syn match   nasmFltNumber	"\<\(\d\|_\)\+\.\(\d\|_\)*\(e[+-]\=\d\+\)\=\>"
+syn keyword nasmFltNumber	Inf Infinity Indefinite NaN SNaN QNaN
+syn match   nasmNumberError	"\<\~\s*\d\+\.\d*\(e[+-]\=\d\+\)\=\>"
+
+
+" Netwide Assembler Storage Directives:
+"  Storage types
+syn keyword nasmTypeError	DF EXTRN FWORD RESF TBYTE
+syn keyword nasmType		FAR NEAR SHORT
+syn keyword nasmType		BYTE WORD DWORD QWORD DQWORD HWORD DHWORD TWORD
+syn keyword nasmType		CDECL FASTCALL NONE PASCAL STDCALL
+syn keyword nasmStorage		DB DW DD DQ DDQ DT
+syn keyword nasmStorage		RESB RESW RESD RESQ RESDQ REST
+syn keyword nasmStorage		EXTERN GLOBAL COMMON
+"  Structured storage types
+syn match   nasmTypeError	"\<\(AT\|I\=\(END\)\=\(STRUCT\=\|UNION\)\|I\=END\)\>"
+syn match   nasmStructureLabel	contained "\<\(AT\|I\=\(END\)\=\(STRUCT\=\|UNION\)\|I\=END\)\>"
+"   structures cannot be nested (yet) -> use: 'keepend' and 're='
+syn cluster nasmGrpCntnStruc	contains=ALLBUT,@nasmGrpInComments,nasmMacroDef,@nasmGrpInMacros,@nasmGrpInPreCondits,nasmStructureDef,@nasmGrpInStrucs
+syn region  nasmStructureDef	transparent matchgroup=nasmStructure keepend start="^\s*STRUCT\>"hs=e-5 end="^\s*ENDSTRUCT\>"re=e-9 contains=@nasmGrpCntnStruc
+syn region  nasmStructureDef	transparent matchgroup=nasmStructure keepend start="^\s*STRUC\>"hs=e-4  end="^\s*ENDSTRUC\>"re=e-8  contains=@nasmGrpCntnStruc
+syn region  nasmStructureDef	transparent matchgroup=nasmStructure keepend start="\<ISTRUCT\=\>" end="\<IEND\(STRUCT\=\)\=\>" contains=@nasmGrpCntnStruc,nasmInStructure
+"   union types are not part of nasm (yet)
+"syn region  nasmStructureDef	transparent matchgroup=nasmStructure keepend start="^\s*UNION\>"hs=e-4 end="^\s*ENDUNION\>"re=e-8 contains=@nasmGrpCntnStruc
+"syn region  nasmStructureDef	transparent matchgroup=nasmStructure keepend start="\<IUNION\>" end="\<IEND\(UNION\)\=\>" contains=@nasmGrpCntnStruc,nasmInStructure
+syn match   nasmInStructure	contained "^\s*AT\>"hs=e-1
+syn cluster nasmGrpInStrucs	contains=nasmStructure,nasmInStructure,nasmStructureLabel
+
+
+
+" PreProcessor Instructions:
+" NAsm PreProcs start with %, but % is not a character
+syn match   nasmPreProcError	"%{\=\(%\=\k\+\|%%\+\k*\|[+-]\=\d\+\)}\="
+if exists("nasm_loose_syntax")
+  syn cluster nasmGrpNxtCtx	contains=nasmStructureLabel,nasmLabel,nasmLocalLabel,nasmSpecialLabel,nasmLabelError,nasmPreProcError
+else
+  syn cluster nasmGrpNxtCtx	contains=nasmStructureLabel,nasmLabel,nasmLabelError,nasmPreProcError
+endif
+
+"  Multi-line macro
+syn cluster nasmGrpCntnMacro	contains=ALLBUT,@nasmGrpInComments,nasmStructureDef,@nasmGrpInStrucs,nasmMacroDef,@nasmGrpPreCondits,nasmMemReference,nasmInMacPreCondit,nasmInMacStrucDef
+syn region  nasmMacroDef	matchgroup=nasmMacro keepend start="^\s*%macro\>"hs=e-5 start="^\s*%imacro\>"hs=e-6 end="^\s*%endmacro\>"re=e-9 contains=@nasmGrpCntnMacro,nasmInMacStrucDef
+if exists("nasm_loose_syntax")
+  syn match  nasmInMacLabel	contained "%\(%\k\+\>\|{%\k\+}\)"
+  syn match  nasmInMacLabel	contained "%\($\+\(\w\|[#\.?@~]\)\k*\>\|{$\+\(\w\|[#\.?@~]\)\k*}\)"
+  syn match  nasmInMacPreProc	contained "^\s*%\(push\|repl\)\>"hs=e-4 skipwhite nextgroup=nasmStructureLabel,nasmLabel,nasmInMacParam,nasmLocalLabel,nasmSpecialLabel,nasmLabelError,nasmPreProcError
+  if !exists("nasm_no_warn")
+    syn match nasmInMacLblWarn	contained "%\(%[$\.]\k*\>\|{%[$\.]\k*}\)"
+    syn match nasmInMacLblWarn	contained "%\($\+\(\d\|[#\.@~]\)\k*\|{\$\+\(\d\|[#\.@~]\)\k*}\)"
+    hi link nasmInMacCatLabel	nasmInMacLblWarn
+  else
+    hi link nasmInMacCatLabel	nasmInMacLabel
+  endif
+else
+  syn match  nasmInMacLabel	contained "%\(%\(\w\|[#?@~]\)\k*\>\|{%\(\w\|[#?@~]\)\k*}\)"
+  syn match  nasmInMacLabel	contained "%\($\+\(\h\|[?@]\)\k*\>\|{$\+\(\h\|[?@]\)\k*}\)"
+  hi link nasmInMacCatLabel	nasmLabelError
+endif
+syn match   nasmInMacCatLabel	contained "\d\K\k*"lc=1
+syn match   nasmInMacLabel	contained "\d}\k\+"lc=2
+if !exists("nasm_no_warn")
+  syn match  nasmInMacLblWarn	contained "%\(\($\+\|%\)[_~][._~]*\>\|{\($\+\|%\)[_~][._~]*}\)"
+endif
+syn match   nasmInMacPreProc	contained "^\s*%pop\>"hs=e-3
+syn match   nasmInMacPreProc	contained "^\s*%\(push\|repl\)\>"hs=e-4 skipwhite nextgroup=@nasmGrpNxtCtx
+"   structures cannot be nested (yet) -> use: 'keepend' and 're='
+syn region  nasmInMacStrucDef	contained transparent matchgroup=nasmStructure keepend start="^\s*STRUCT\>"hs=e-5 end="^\s*ENDSTRUCT\>"re=e-9 contains=@nasmGrpCntnMacro
+syn region  nasmInMacStrucDef	contained transparent matchgroup=nasmStructure keepend start="^\s*STRUC\>"hs=e-4  end="^\s*ENDSTRUC\>"re=e-8  contains=@nasmGrpCntnMacro
+syn region  nasmInMacStrucDef	contained transparent matchgroup=nasmStructure keepend start="\<ISTRUCT\=\>" end="\<IEND\(STRUCT\=\)\=\>" contains=@nasmGrpCntnMacro,nasmInStructure
+"   union types are not part of nasm (yet)
+"syn region  nasmInMacStrucDef	contained transparent matchgroup=nasmStructure keepend start="^\s*UNION\>"hs=e-4 end="^\s*ENDUNION\>"re=e-8 contains=@nasmGrpCntnMacro
+"syn region  nasmInMacStrucDef	contained transparent matchgroup=nasmStructure keepend start="\<IUNION\>" end="\<IEND\(UNION\)\=\>" contains=@nasmGrpCntnMacro,nasmInStructure
+syn region  nasmInMacPreConDef	contained transparent matchgroup=nasmInMacPreCondit start="^\s*%ifnidni\>"hs=e-7 start="^\s*%if\(idni\|n\(ctx\|def\|idn\|num\|str\)\)\>"hs=e-6 start="^\s*%if\(ctx\|def\|idn\|nid\|num\|str\)\>"hs=e-5 start="^\s*%ifid\>"hs=e-4 start="^\s*%if\>"hs=e-2 end="%endif\>" contains=@nasmGrpCntnMacro,nasmInMacPreCondit,nasmInPreCondit
+" Todo: allow STRUC/ISTRUC to be used inside preprocessor conditional block
+syn match   nasmInMacPreCondit	contained transparent "ctx\s"lc=3 skipwhite nextgroup=@nasmGrpNxtCtx
+syn match   nasmInMacPreCondit	contained "^\s*%elifctx\>"hs=e-7 skipwhite nextgroup=@nasmGrpNxtCtx
+syn match   nasmInMacPreCondit	contained "^\s*%elifnctx\>"hs=e-8 skipwhite nextgroup=@nasmGrpNxtCtx
+syn match   nasmInMacParamNum	contained "\<\d\+\.list\>"me=e-5
+syn match   nasmInMacParamNum	contained "\<\d\+\.nolist\>"me=e-7
+syn match   nasmInMacDirective	contained "\.\(no\)\=list\>"
+syn match   nasmInMacMacro	contained transparent "macro\s"lc=5 skipwhite nextgroup=nasmStructureLabel
+syn match   nasmInMacMacro	contained "^\s*%rotate\>"hs=e-6
+syn match   nasmInMacParam	contained "%\([+-]\=\d\+\|{[+-]\=\d\+}\)"
+"   nasm conditional macro operands/arguments
+"   Todo: check feasebility; add too nasmGrpInMacros, etc.
+"syn match   nasmInMacCond	contained "\<\(N\=\([ABGL]E\=\|[CEOSZ]\)\|P[EO]\=\)\>"
+syn cluster nasmGrpInMacros	contains=nasmMacro,nasmInMacMacro,nasmInMacParam,nasmInMacParamNum,nasmInMacDirective,nasmInMacLabel,nasmInMacLblWarn,nasmInMacMemRef,nasmInMacPreConDef,nasmInMacPreCondit,nasmInMacPreProc,nasmInMacStrucDef
+
+"   Context pre-procs that are better used inside a macro
+if exists("nasm_ctx_outside_macro")
+  syn region nasmPreConditDef	transparent matchgroup=nasmCtxPreCondit start="^\s*%ifnctx\>"hs=e-6 start="^\s*%ifctx\>"hs=e-5 end="%endif\>" contains=@nasmGrpCntnPreCon
+  syn match  nasmCtxPreProc	"^\s*%pop\>"hs=e-3
+  if exists("nasm_loose_syntax")
+    syn match   nasmCtxLocLabel	"%$\+\(\w\|[#.?@~]\)\k*\>"
+  else
+    syn match   nasmCtxLocLabel	"%$\+\(\h\|[?@]\)\k*\>"
+  endif
+  syn match nasmCtxPreProc	"^\s*%\(push\|repl\)\>"hs=e-4 skipwhite nextgroup=@nasmGrpNxtCtx
+  syn match nasmCtxPreCondit	contained transparent "ctx\s"lc=3 skipwhite nextgroup=@nasmGrpNxtCtx
+  syn match nasmCtxPreCondit	contained "^\s*%elifctx\>"hs=e-7 skipwhite nextgroup=@nasmGrpNxtCtx
+  syn match nasmCtxPreCondit	contained "^\s*%elifnctx\>"hs=e-8 skipwhite nextgroup=@nasmGrpNxtCtx
+  if exists("nasm_no_warn")
+    hi link nasmCtxPreCondit	nasmPreCondit
+    hi link nasmCtxPreProc	nasmPreProc
+    hi link nasmCtxLocLabel	nasmLocalLabel
+  else
+    hi link nasmCtxPreCondit	nasmPreProcWarn
+    hi link nasmCtxPreProc	nasmPreProcWarn
+    hi link nasmCtxLocLabel	nasmLabelWarn
+  endif
+endif
+
+"  Conditional assembly
+syn cluster nasmGrpCntnPreCon	contains=ALLBUT,@nasmGrpInComments,@nasmGrpInMacros,@nasmGrpInStrucs
+syn region  nasmPreConditDef	transparent matchgroup=nasmPreCondit start="^\s*%ifnidni\>"hs=e-7 start="^\s*%if\(idni\|n\(def\|idn\|num\|str\)\)\>"hs=e-6 start="^\s*%if\(def\|idn\|nid\|num\|str\)\>"hs=e-5 start="^\s*%ifid\>"hs=e-4 start="^\s*%if\>"hs=e-2 end="%endif\>" contains=@nasmGrpCntnPreCon
+syn match   nasmInPreCondit	contained "^\s*%el\(if\|se\)\>"hs=e-4
+syn match   nasmInPreCondit	contained "^\s*%elifid\>"hs=e-6
+syn match   nasmInPreCondit	contained "^\s*%elif\(def\|idn\|nid\|num\|str\)\>"hs=e-7
+syn match   nasmInPreCondit	contained "^\s*%elif\(n\(def\|idn\|num\|str\)\|idni\)\>"hs=e-8
+syn match   nasmInPreCondit	contained "^\s*%elifnidni\>"hs=e-9
+syn cluster nasmGrpInPreCondits	contains=nasmPreCondit,nasmInPreCondit,nasmCtxPreCondit
+syn cluster nasmGrpPreCondits	contains=nasmPreConditDef,@nasmGrpInPreCondits,nasmCtxPreProc,nasmCtxLocLabel
+
+"  Other pre-processor statements
+syn match   nasmPreProc		"^\s*%\(rep\|use\)\>"hs=e-3
+syn match   nasmPreProc		"^\s*%line\>"hs=e-4
+syn match   nasmPreProc		"^\s*%\(clear\|error\|fatal\)\>"hs=e-5
+syn match   nasmPreProc		"^\s*%\(endrep\|strlen\|substr\)\>"hs=e-6
+syn match   nasmPreProc		"^\s*%\(exitrep\|warning\)\>"hs=e-7
+syn match   nasmDefine		"^\s*%undef\>"hs=e-5
+syn match   nasmDefine		"^\s*%\(assign\|define\)\>"hs=e-6
+syn match   nasmDefine		"^\s*%i\(assign\|define\)\>"hs=e-7
+syn match   nasmDefine		"^\s*%unmacro\>"hs=e-7
+syn match   nasmInclude		"^\s*%include\>"hs=e-7
+" Todo: Treat the line tail after %fatal, %error, %warning as text
+
+"  Multiple pre-processor instructions on single line detection (obsolete)
+"syn match   nasmPreProcError	+^\s*\([^\t "%';][^"%';]*\|[^\t "';][^"%';]\+\)%\a\+\>+
+syn cluster nasmGrpPreProcs	contains=nasmMacroDef,@nasmGrpInMacros,@nasmGrpPreCondits,nasmPreProc,nasmDefine,nasmInclude,nasmPreProcWarn,nasmPreProcError
+
+
+
+" Register Identifiers:
+"  Register operands:
+syn match   nasmGen08Register	"\<[A-D][HL]\>"
+syn match   nasmGen16Register	"\<\([A-D]X\|[DS]I\|[BS]P\)\>"
+syn match   nasmGen32Register	"\<E\([A-D]X\|[DS]I\|[BS]P\)\>"
+syn match   nasmGen64Register	"\<R\([A-D]X\|[DS]I\|[BS]P\|[89]\|1[0-5]\|[89][WD]\|1[0-5][WD]\)\>"
+syn match   nasmSegRegister	"\<[C-GS]S\>"
+syn match   nasmSpcRegister	"\<E\=IP\>"
+syn match   nasmFpuRegister	"\<ST\o\>"
+syn match   nasmMmxRegister	"\<MM\o\>"
+syn match   nasmSseRegister	"\<XMM\o\>"
+syn match   nasmCtrlRegister	"\<CR\o\>"
+syn match   nasmDebugRegister	"\<DR\o\>"
+syn match   nasmTestRegister	"\<TR\o\>"
+syn match   nasmRegisterError	"\<\(CR[15-9]\|DR[4-58-9]\|TR[0-28-9]\)\>"
+syn match   nasmRegisterError	"\<X\=MM[8-9]\>"
+syn match   nasmRegisterError	"\<ST\((\d)\|[8-9]\>\)"
+syn match   nasmRegisterError	"\<E\([A-D][HL]\|[C-GS]S\)\>"
+"  Memory reference operand (address):
+syn match   nasmMemRefError	"[[\]]"
+syn cluster nasmGrpCntnMemRef	contains=ALLBUT,@nasmGrpComments,@nasmGrpPreProcs,@nasmGrpInStrucs,nasmMemReference,nasmMemRefError
+syn match   nasmInMacMemRef	contained "\[[^;[\]]\{-}\]" contains=@nasmGrpCntnMemRef,nasmPreProcError,nasmInMacLabel,nasmInMacLblWarn,nasmInMacParam
+syn match   nasmMemReference	"\[[^;[\]]\{-}\]" contains=@nasmGrpCntnMemRef,nasmPreProcError,nasmCtxLocLabel
+
+
+
+" Netwide Assembler Directives:
+"  Compilation constants
+syn keyword nasmConstant	__BITS__ __DATE__ __FILE__ __FORMAT__ __LINE__
+syn keyword nasmConstant	__NASM_MAJOR__ __NASM_MINOR__ __NASM_VERSION__
+syn keyword nasmConstant	__TIME__
+"  Instruction modifiers
+syn match   nasmInstructnError	"\<TO\>"
+syn match   nasmInstrModifier	"\(^\|:\)\s*[C-GS]S\>"ms=e-1
+syn keyword nasmInstrModifier	A16 A32 O16 O32
+syn match   nasmInstrModifier	"\<F\(ADD\|MUL\|\(DIV\|SUB\)R\=\)\s\+TO\>"lc=5,ms=e-1
+"   the 'to' keyword is not allowed for fpu-pop instructions (yet)
+"syn match   nasmInstrModifier	"\<F\(ADD\|MUL\|\(DIV\|SUB\)R\=\)P\s\+TO\>"lc=6,ms=e-1
+"  NAsm directives
+syn keyword nasmRepeat		TIMES
+syn keyword nasmDirective	ALIGN[B] INCBIN EQU NOSPLIT SPLIT
+syn keyword nasmDirective	ABSOLUTE BITS SECTION SEGMENT
+syn keyword nasmDirective	ENDSECTION ENDSEGMENT
+syn keyword nasmDirective	__SECT__
+"  Macro created standard directives: (requires %include)
+syn case match
+syn keyword nasmStdDirective	ENDPROC EPILOGUE LOCALS PROC PROLOGUE USES
+syn keyword nasmStdDirective	ENDIF ELSE ELIF ELSIF IF
+"syn keyword nasmStdDirective	BREAK CASE DEFAULT ENDSWITCH SWITCH
+"syn keyword nasmStdDirective	CASE OF ENDCASE
+syn keyword nasmStdDirective	DO ENDFOR ENDWHILE FOR REPEAT UNTIL WHILE EXIT
+syn case ignore
+"  Format specific directives: (all formats)
+"  (excluded: extension directives to section, global, common and extern)
+syn keyword nasmFmtDirective	ORG
+syn keyword nasmFmtDirective	EXPORT IMPORT GROUP UPPERCASE SEG WRT
+syn keyword nasmFmtDirective	LIBRARY
+syn case match
+syn keyword nasmFmtDirective	_GLOBAL_OFFSET_TABLE_ __GLOBAL_OFFSET_TABLE_
+syn keyword nasmFmtDirective	..start ..got ..gotoff ..gotpc ..plt ..sym
+syn case ignore
+
+
+
+" Standard Instructions:
+syn match   nasmInstructnError	"\<\(F\=CMOV\|SET\)N\=\a\{0,2}\>"
+syn keyword nasmInstructnError	CMPS MOVS LCS LODS STOS XLAT
+syn match   nasmStdInstruction	"\<MOV\>"
+syn match   nasmInstructnError	"\<MOV\s[^,;[]*\<CS\>\s*[^:]"he=e-1
+syn match   nasmStdInstruction	"\<\(CMOV\|J\|SET\)\(N\=\([ABGL]E\=\|[CEOSZ]\)\|P[EO]\=\)\>"
+syn match   nasmStdInstruction	"\<POP\>"
+syn keyword nasmStdInstruction	AAA AAD AAM AAS ADC ADD AND
+syn keyword nasmStdInstruction	BOUND BSF BSR BSWAP BT[C] BTR BTS
+syn keyword nasmStdInstruction	CALL CBW CDQ CLC CLD CMC CMP CMPSB CMPSD CMPSW CMPSQ
+syn keyword nasmStdInstruction	CMPXCHG CMPXCHG8B CPUID CWD[E] CQO
+syn keyword nasmStdInstruction	DAA DAS DEC DIV ENTER
+syn keyword nasmStdInstruction	IDIV IMUL INC INT[O] IRET[D] IRETW IRETQ
+syn keyword nasmStdInstruction	JCXZ JECXZ JMP
+syn keyword nasmStdInstruction	LAHF LDS LEA LEAVE LES LFS LGS LODSB LODSD LODSQ
+syn keyword nasmStdInstruction	LODSW LOOP[E] LOOPNE LOOPNZ LOOPZ LSS
+syn keyword nasmStdInstruction	MOVSB MOVSD MOVSW MOVSX MOVSQ MOVZX MUL NEG NOP NOT
+syn keyword nasmStdInstruction	OR POPA[D] POPAW POPF[D] POPFW POPFQ
+syn keyword nasmStdInstruction	PUSH[AD] PUSHAW PUSHF[D] PUSHFW PUSHFQ
+syn keyword nasmStdInstruction	RCL RCR RETF RET[N] ROL ROR
+syn keyword nasmStdInstruction	SAHF SAL SAR SBB SCASB SCASD SCASW
+syn keyword nasmStdInstruction	SHL[D] SHR[D] STC STD STOSB STOSD STOSW STOSQ SUB
+syn keyword nasmStdInstruction	TEST XADD XCHG XLATB XOR
+syn keyword nasmStdInstruction	LFENCE MFENCE SFENCE
+
+
+" System Instructions: (usually privileged)
+"  Verification of pointer parameters
+syn keyword nasmSysInstruction	ARPL LAR LSL VERR VERW
+"  Addressing descriptor tables
+syn keyword nasmSysInstruction	LLDT SLDT LGDT SGDT
+"  Multitasking
+syn keyword nasmSysInstruction	LTR STR
+"  Coprocessing and Multiprocessing (requires fpu and multiple cpu's resp.)
+syn keyword nasmSysInstruction	CLTS LOCK WAIT
+"  Input and Output
+syn keyword nasmInstructnError	INS OUTS
+syn keyword nasmSysInstruction	IN INSB INSW INSD OUT OUTSB OUTSB OUTSW OUTSD
+"  Interrupt control
+syn keyword nasmSysInstruction	CLI STI LIDT SIDT
+"  System control
+syn match   nasmSysInstruction	"\<MOV\s[^;]\{-}\<CR\o\>"me=s+3
+syn keyword nasmSysInstruction	HLT INVD LMSW
+syn keyword nasmSseInstruction	PREFETCHT0 PREFETCHT1 PREFETCHT2 PREFETCHNTA
+syn keyword nasmSseInstruction	RSM SFENCE SMSW SYSENTER SYSEXIT UD2 WBINVD
+"  TLB (Translation Lookahead Buffer) testing
+syn match   nasmSysInstruction	"\<MOV\s[^;]\{-}\<TR\o\>"me=s+3
+syn keyword nasmSysInstruction	INVLPG
+
+" Debugging Instructions: (privileged)
+syn match   nasmDbgInstruction	"\<MOV\s[^;]\{-}\<DR\o\>"me=s+3
+syn keyword nasmDbgInstruction	INT1 INT3 RDMSR RDTSC RDPMC WRMSR
+
+
+" Floating Point Instructions: (requires FPU)
+syn match   nasmFpuInstruction	"\<FCMOVN\=\([AB]E\=\|[CEPUZ]\)\>"
+syn keyword nasmFpuInstruction	F2XM1 FABS FADD[P] FBLD FBSTP
+syn keyword nasmFpuInstruction	FCHS FCLEX FCOM[IP] FCOMP[P] FCOS
+syn keyword nasmFpuInstruction	FDECSTP FDISI FDIV[P] FDIVR[P] FENI FFREE
+syn keyword nasmFpuInstruction	FIADD FICOM[P] FIDIV[R] FILD
+syn keyword nasmFpuInstruction	FIMUL FINCSTP FINIT FIST[P] FISUB[R]
+syn keyword nasmFpuInstruction	FLD[1] FLDCW FLDENV FLDL2E FLDL2T FLDLG2
+syn keyword nasmFpuInstruction	FLDLN2 FLDPI FLDZ FMUL[P]
+syn keyword nasmFpuInstruction	FNCLEX FNDISI FNENI FNINIT FNOP FNSAVE
+syn keyword nasmFpuInstruction	FNSTCW FNSTENV FNSTSW FNSTSW
+syn keyword nasmFpuInstruction	FPATAN FPREM[1] FPTAN FRNDINT FRSTOR
+syn keyword nasmFpuInstruction	FSAVE FSCALE FSETPM FSIN FSINCOS FSQRT
+syn keyword nasmFpuInstruction	FSTCW FSTENV FST[P] FSTSW FSUB[P] FSUBR[P]
+syn keyword nasmFpuInstruction	FTST FUCOM[IP] FUCOMP[P]
+syn keyword nasmFpuInstruction	FXAM FXCH FXTRACT FYL2X FYL2XP1
+
+
+" Multi Media Xtension Packed Instructions: (requires MMX unit)
+"  Standard MMX instructions: (requires MMX1 unit)
+syn match   nasmInstructnError	"\<P\(ADD\|SUB\)U\=S\=[DQ]\=\>"
+syn match   nasmInstructnError	"\<PCMP\a\{0,2}[BDWQ]\=\>"
+syn keyword nasmMmxInstruction	EMMS MOVD MOVQ
+syn keyword nasmMmxInstruction	PACKSSDW PACKSSWB PACKUSWB PADDB PADDD PADDW
+syn keyword nasmMmxInstruction	PADDSB PADDSW PADDUSB PADDUSW PAND[N]
+syn keyword nasmMmxInstruction	PCMPEQB PCMPEQD PCMPEQW PCMPGTB PCMPGTD PCMPGTW
+syn keyword nasmMmxInstruction	PMACHRIW PMADDWD PMULHW PMULLW POR
+syn keyword nasmMmxInstruction	PSLLD PSLLQ PSLLW PSRAD PSRAW PSRLD PSRLQ PSRLW
+syn keyword nasmMmxInstruction	PSUBB PSUBD PSUBW PSUBSB PSUBSW PSUBUSB PSUBUSW
+syn keyword nasmMmxInstruction	PUNPCKHBW PUNPCKHDQ PUNPCKHWD
+syn keyword nasmMmxInstruction	PUNPCKLBW PUNPCKLDQ PUNPCKLWD PXOR
+"  Extended MMX instructions: (requires MMX2/SSE unit)
+syn keyword nasmMmxInstruction	MASKMOVQ MOVNTQ
+syn keyword nasmMmxInstruction	PAVGB PAVGW PEXTRW PINSRW PMAXSW PMAXUB
+syn keyword nasmMmxInstruction	PMINSW PMINUB PMOVMSKB PMULHUW PSADBW PSHUFW
+
+
+" Streaming SIMD Extension Packed Instructions: (requires SSE unit)
+syn match   nasmInstructnError	"\<CMP\a\{1,5}[PS]S\>"
+syn match   nasmSseInstruction	"\<CMP\(N\=\(EQ\|L[ET]\)\|\(UN\)\=ORD\)\=[PS]S\>"
+syn keyword nasmSseInstruction	ADDPS ADDSS ANDNPS ANDPS
+syn keyword nasmSseInstruction	COMISS CVTPI2PS CVTPS2PI
+syn keyword nasmSseInstruction	CVTSI2SS CVTSS2SI CVTTPS2PI CVTTSS2SI
+syn keyword nasmSseInstruction	DIVPS DIVSS FXRSTOR FXSAVE LDMXCSR
+syn keyword nasmSseInstruction	MAXPS MAXSS MINPS MINSS MOVAPS MOVHLPS MOVHPS
+syn keyword nasmSseInstruction	MOVLHPS MOVLPS MOVMSKPS MOVNTPS MOVSS MOVUPS
+syn keyword nasmSseInstruction	MULPS MULSS
+syn keyword nasmSseInstruction	ORPS RCPPS RCPSS RSQRTPS RSQRTSS
+syn keyword nasmSseInstruction	SHUFPS SQRTPS SQRTSS STMXCSR SUBPS SUBSS
+syn keyword nasmSseInstruction	UCOMISS UNPCKHPS UNPCKLPS XORPS
+
+
+" Three Dimensional Now Packed Instructions: (requires 3DNow! unit)
+syn keyword nasmNowInstruction	FEMMS PAVGUSB PF2ID PFACC PFADD PFCMPEQ PFCMPGE
+syn keyword nasmNowInstruction	PFCMPGT PFMAX PFMIN PFMUL PFRCP PFRCPIT1
+syn keyword nasmNowInstruction	PFRCPIT2 PFRSQIT1 PFRSQRT PFSUB[R] PI2FD
+syn keyword nasmNowInstruction	PMULHRWA PREFETCH[W]
+
+
+" Vendor Specific Instructions:
+"  Cyrix instructions (requires Cyrix processor)
+syn keyword nasmCrxInstruction	PADDSIW PAVEB PDISTIB PMAGW PMULHRW[C] PMULHRIW
+syn keyword nasmCrxInstruction	PMVGEZB PMVLZB PMVNZB PMVZB PSUBSIW
+syn keyword nasmCrxInstruction	RDSHR RSDC RSLDT SMINT SMINTOLD SVDC SVLDT SVTS
+syn keyword nasmCrxInstruction	WRSHR
+"  AMD instructions (requires AMD processor)
+syn keyword nasmAmdInstruction	SYSCALL SYSRET
+
+
+" Undocumented Instructions:
+syn match   nasmUndInstruction	"\<POP\s[^;]*\<CS\>"me=s+3
+syn keyword nasmUndInstruction	CMPXCHG486 IBTS ICEBP INT01 INT03 LOADALL
+syn keyword nasmUndInstruction	LOADALL286 LOADALL386 SALC SMI UD1 UMOV XBTS
+
+
+
+" Synchronize Syntax:
+syn sync clear
+syn sync minlines=50		"for multiple region nesting
+syn sync match  nasmSync	grouphere nasmMacroDef "^\s*%i\=macro\>"me=s-1
+syn sync match	nasmSync	grouphere NONE	       "^\s*%endmacro\>"
+
+
+" Define the default highlighting.
+" For version 5.7 and earlier: only when not done already
+" For version 5.8 and later  : only when an item doesn't have highlighting yet
+if version >= 508 || !exists("did_nasm_syntax_inits")
+  if version < 508
+    let did_nasm_syntax_inits = 1
+    command -nargs=+ HiLink hi link <args>
+  else
+    command -nargs=+ HiLink hi def link <args>
+  endif
+
+  " Sub Links:
+  HiLink nasmInMacDirective	nasmDirective
+  HiLink nasmInMacLabel		nasmLocalLabel
+  HiLink nasmInMacLblWarn	nasmLabelWarn
+  HiLink nasmInMacMacro		nasmMacro
+  HiLink nasmInMacParam		nasmMacro
+  HiLink nasmInMacParamNum	nasmDecNumber
+  HiLink nasmInMacPreCondit	nasmPreCondit
+  HiLink nasmInMacPreProc	nasmPreProc
+  HiLink nasmInPreCondit	nasmPreCondit
+  HiLink nasmInStructure	nasmStructure
+  HiLink nasmStructureLabel	nasmStructure
+
+  " Comment Group:
+  HiLink nasmComment		Comment
+  HiLink nasmSpecialComment	SpecialComment
+  HiLink nasmInCommentTodo	Todo
+
+  " Constant Group:
+  HiLink nasmString		String
+  HiLink nasmStringError	Error
+  HiLink nasmBinNumber		Number
+  HiLink nasmOctNumber		Number
+  HiLink nasmDecNumber		Number
+  HiLink nasmHexNumber		Number
+  HiLink nasmFltNumber		Float
+  HiLink nasmNumberError	Error
+
+  " Identifier Group:
+  HiLink nasmLabel		Identifier
+  HiLink nasmLocalLabel		Identifier
+  HiLink nasmSpecialLabel	Special
+  HiLink nasmLabelError		Error
+  HiLink nasmLabelWarn		Todo
+
+  " PreProc Group:
+  HiLink nasmPreProc		PreProc
+  HiLink nasmDefine		Define
+  HiLink nasmInclude		Include
+  HiLink nasmMacro		Macro
+  HiLink nasmPreCondit		PreCondit
+  HiLink nasmPreProcError	Error
+  HiLink nasmPreProcWarn	Todo
+
+  " Type Group:
+  HiLink nasmType		Type
+  HiLink nasmStorage		StorageClass
+  HiLink nasmStructure		Structure
+  HiLink nasmTypeError		Error
+
+  " Directive Group:
+  HiLink nasmConstant		Constant
+  HiLink nasmInstrModifier	Operator
+  HiLink nasmRepeat		Repeat
+  HiLink nasmDirective		Keyword
+  HiLink nasmStdDirective	Operator
+  HiLink nasmFmtDirective	Keyword
+
+  " Register Group:
+  HiLink nasmCtrlRegister	Special
+  HiLink nasmDebugRegister	Debug
+  HiLink nasmTestRegister	Special
+  HiLink nasmRegisterError	Error
+  HiLink nasmMemRefError	Error
+
+  " Instruction Group:
+  HiLink nasmStdInstruction	Statement
+  HiLink nasmSysInstruction	Statement
+  HiLink nasmDbgInstruction	Debug
+  HiLink nasmFpuInstruction	Statement
+  HiLink nasmMmxInstruction	Statement
+  HiLink nasmSseInstruction	Statement
+  HiLink nasmNowInstruction	Statement
+  HiLink nasmAmdInstruction	Special
+  HiLink nasmCrxInstruction	Special
+  HiLink nasmUndInstruction	Todo
+  HiLink nasmInstructnError	Error
+
+  delcommand HiLink
+endif
+
+let b:current_syntax = "nasm"
+
+" vim:ts=8 sw=4
diff --git a/home/.gdbinit b/home/.gdbinit
new file mode 100644
index 00000000..9422460c
--- /dev/null
+++ b/home/.gdbinit
@@ -0,0 +1 @@
+set disassembly-flavor intel
diff --git a/home/.gnupg/gpg-agent.conf b/home/.gnupg/gpg-agent.conf
new file mode 100644
index 00000000..83ef4996
--- /dev/null
+++ b/home/.gnupg/gpg-agent.conf
@@ -0,0 +1,2 @@
+use-standard-socket
+default-cache-ttl 1800
diff --git a/home/.hushlogin b/home/.hushlogin
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/home/.hushlogin
diff --git a/home/.inputrc b/home/.inputrc
new file mode 100644
index 00000000..b2cc9d61
--- /dev/null
+++ b/home/.inputrc
@@ -0,0 +1 @@
+set editing-mode vi
diff --git a/home/.psqlrc b/home/.psqlrc
new file mode 100644
index 00000000..60f39755
--- /dev/null
+++ b/home/.psqlrc
@@ -0,0 +1,9 @@
+\set QUIET
+\set ON_ERROR_ROLLBACK interactive
+\timing on
+\setenv PAGER more
+\pset expanded auto
+\pset null ¤
+\pset linestyle unicode
+\pset border 1
+\unset QUIET
diff --git a/home/.ssh/config b/home/.ssh/config
new file mode 100644
index 00000000..4ae18c54
--- /dev/null
+++ b/home/.ssh/config
@@ -0,0 +1,17 @@
+IgnoreUnknown Include
+Include config_private
+
+HashKnownHosts yes
+
+SendEnv NETHACKOPTIONS
+
+Host tux.local thursday.local
+    ForwardAgent yes
+    RemoteForward 7062 127.0.0.1:7062
+
+Host april june
+    HostName %h.nyc3.do.cmcenroe.me
+    Port 2222
+
+Host tmp.cmcenroe.me
+    Port 2222
diff --git a/home/.zshrc b/home/.zshrc
new file mode 100644
index 00000000..77e4569d
--- /dev/null
+++ b/home/.zshrc
@@ -0,0 +1,69 @@
+unsetopt beep
+setopt nomatch interactive_comments
+setopt inc_append_history hist_ignore_dups
+HISTFILE=~/.history HISTSIZE=5000 SAVEHIST=5000
+
+autoload -Uz compinit && compinit
+autoload -Uz colors && colors
+
+bindkey -v
+KEYTIMEOUT=1
+
+OLDPATH=$PATH
+path=(
+  /sbin /bin
+  /usr/local/sbin /usr/local/bin
+  /usr/sbin /usr/bin
+  ~/.bin ~/.cargo/bin
+)
+
+export PAGER=less MANPAGER=less EDITOR=vim GIT_EDITOR=vim
+type nvim > /dev/null \
+  && EDITOR=nvim GIT_EDITOR=nvim MANPAGER="nvim -c 'set ft=man' -" \
+  && alias vim=nvim
+export GPG_TTY=$TTY
+
+export CLICOLOR=1
+[[ "$OSTYPE" =~ 'linux-gnu' ]] \
+  && alias ls='ls --color=auto' grep='grep --color' rm='rm -I'
+
+export NETHACKOPTIONS='name:June, role:Valkyrie, race:Human, gender:female,
+  align:neutral, dogname:Moro, catname:Baron, pickup_types:$!?+/=, color,
+  DECgraphics'
+
+alias gs='git status --short --branch' gd='git diff'
+alias gsh='git show' gl='git log --graph --pretty=log'
+alias gco='git checkout' gb='git branch' gm='git merge' gst='git stash'
+alias ga='git add' gmv='git mv' grm='git rm'
+alias gc='git commit' gca='gc --amend' gt='git tag'
+alias gp='git push' gu='git pull' gf='git fetch'
+alias gr='git rebase' gra='gr --abort' grc='gr --continue' grs='gr --skip'
+
+nasd() {
+  local tmp=$(mktemp)
+  cat > $tmp
+  nasm -p =(echo 'bits 64') -o >(ndisasm -b 64 /dev/stdin) $tmp
+  rm $tmp
+}
+
+setopt prompt_subst
+_prompt_git() {
+  local dotgit=.git head
+  [ -d "$dotgit" ] || dotgit=../.git
+  [ -d "$dotgit" ] || return 0
+  read head < "$dotgit/HEAD"
+  case "$head" in
+    ref:*) echo ":${head#*/*/}";;
+    *) echo ":${head:0:7}";;
+  esac
+}
+[ -n "$SSH_CLIENT" ] && _prompt_ssh='%F{magenta}'
+PROMPT="%(?.%F{green}$_prompt_ssh.%F{red})»%f "
+RPROMPT='%F{blue}%50<…<%~%F{yellow}$(_prompt_git)%f'
+
+_n() { _n() { echo } }
+_title() { print -Pn "\e]0;$1\a" }
+_title_precmd() { _title '%1~' }
+_title_preexec() { psvar=("$1") _title '%1~: %1v' }
+precmd_functions=(_n _title_precmd)
+preexec_functions=(_title_preexec)