From eefbd029b55b2782b0d7b11b4989ce0ca9b256cd Mon Sep 17 00:00:00 2001 From: Mitch Riedstra Date: Tue, 15 Oct 2019 20:56:41 -0400 Subject: Massive organization of my dotfiles --- .gitignore | 3 - btrfs-snap.sh | 23 -- build/vim | 18 ++ crt/ibm-amber.json | 26 --- crt/ibm-blue.json | 26 --- crt/ibm-green.json | 26 --- crt/ibm-grey-color.json | 26 --- crt/ibm-grey.json | 26 --- crt/profont-color.json | 26 --- kernel_package.sh | 23 -- kernel_upgrade.sh | 26 --- keys/barracuda.txt | 1 - keys/personal.txt | 1 - linux/kernel/package.sh | 23 ++ linux/kernel/upgrade.sh | 26 +++ lvm-snapshot.sh | 31 --- mkshrc.txt | 1 - net/vlan.sh | 48 ---- net/workstation.sh | 48 ---- openbsd_net.sh | 83 ------- send.sh | 23 -- shell/build.sh | 17 -- shell/conf | 23 +- snap/btrfs.sh | 23 ++ snap/lvm.sh | 31 +++ terminal-colors | 585 ------------------------------------------------ tmux.conf | 91 -------- tmux/tmux.conf | 91 ++++++++ tmux/tmux_helper.sh | 28 +++ tmux/tmx.sh | 55 +++++ tmux_helper.sh | 28 --- tmx.sh | 55 ----- util/hexify.c | 11 + util/terminal-colors | 585 ++++++++++++++++++++++++++++++++++++++++++++++++ util/zram.sh | 27 +++ vim-build.sh | 16 -- vimrc | 50 +++++ zram.sh | 27 --- 38 files changed, 980 insertions(+), 1297 deletions(-) delete mode 100644 btrfs-snap.sh create mode 100755 build/vim delete mode 100644 crt/ibm-amber.json delete mode 100644 crt/ibm-blue.json delete mode 100644 crt/ibm-green.json delete mode 100644 crt/ibm-grey-color.json delete mode 100644 crt/ibm-grey.json delete mode 100644 crt/profont-color.json delete mode 100755 kernel_package.sh delete mode 100755 kernel_upgrade.sh delete mode 120000 keys/barracuda.txt delete mode 120000 keys/personal.txt create mode 100755 linux/kernel/package.sh create mode 100755 linux/kernel/upgrade.sh delete mode 100644 lvm-snapshot.sh delete mode 120000 mkshrc.txt delete mode 100644 net/vlan.sh delete mode 100644 net/workstation.sh delete mode 100755 openbsd_net.sh delete mode 100644 send.sh create mode 100644 snap/btrfs.sh create mode 100644 snap/lvm.sh delete mode 100644 terminal-colors delete mode 100644 tmux.conf create mode 100644 tmux/tmux.conf create mode 100644 tmux/tmux_helper.sh create mode 100644 tmux/tmx.sh delete mode 100644 tmux_helper.sh delete mode 100644 tmx.sh create mode 100644 util/hexify.c create mode 100644 util/terminal-colors create mode 100755 util/zram.sh delete mode 100755 vim-build.sh create mode 100644 vimrc delete mode 100755 zram.sh diff --git a/.gitignore b/.gitignore index 03f402c..30944a7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,2 @@ *.txz *.7z -mkshrc -ashrc -bashrc diff --git a/btrfs-snap.sh b/btrfs-snap.sh deleted file mode 100644 index cc2e5a9..0000000 --- a/btrfs-snap.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh -set -x -set -e -timestamp() { - date +%m.%d.%y_%H.%M.%S -} - -rootfs="glibc" -snap="${rootfs}-snap" - -cd /ROOT - -if [ -e "$snap" ] ; then - btrfs sub del "$snap" -fi - -if ! [ -e "bak" ] ; then - btrfs sub create "bak" -fi - -btrfs sub snap -r "$rootfs" "bak/${rootfs}-$(timestamp)" -btrfs sub snap "$rootfs" "$snap" -sed -i.bak -e"s/subvol=${rootfs}/subvol=${snap}/g" "${snap}/etc/fstab" diff --git a/build/vim b/build/vim new file mode 100755 index 0000000..51779e3 --- /dev/null +++ b/build/vim @@ -0,0 +1,18 @@ +#!/bin/sh +# Build vim from source code, with my usual options + +set -e +set -x + +./configure \ + --enable-multibyte \ + --with-x \ + --enable-perlinterp=yes \ + --enable-pythoninterp=yes \ + --enable-python3interp=yes \ + --enable-rubyinterp=yes \ + --with-gnome \ + --prefix=$HOME/pkg + +make -j$(nproc) +make install diff --git a/crt/ibm-amber.json b/crt/ibm-amber.json deleted file mode 100644 index 98f63e9..0000000 --- a/crt/ibm-amber.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "ambientLight": 0, - "backgroundColor": "#000000", - "bloom": 0.4, - "brightness": 0.5, - "burnIn": 0, - "chromaColor": 0, - "contrast": 0.85, - "customCommand": "", - "flickering": 0, - "fontColor": "#ffaa00", - "fontName": "IBM_3278", - "fontWidth": 1, - "frameName": "NO_FRAME", - "glowingLine": 0, - "horizontalSync": 0, - "jitter": 0, - "rasterization": 0, - "rbgShift": 0, - "saturationColor": 0.9743, - "screenCurvature": 0.1, - "staticNoise": 0, - "useCustomCommand": false, - "windowOpacity": 1, - "name": "ibm-amber" -} diff --git a/crt/ibm-blue.json b/crt/ibm-blue.json deleted file mode 100644 index 8c59f09..0000000 --- a/crt/ibm-blue.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "ambientLight": 0, - "backgroundColor": "#000000", - "bloom": 0.4, - "brightness": 0.5, - "burnIn": 0, - "chromaColor": 0, - "contrast": 0.85, - "customCommand": "", - "flickering": 0, - "fontColor": "#0055ff", - "fontName": "IBM_3278", - "fontWidth": 1, - "frameName": "NO_FRAME", - "glowingLine": 0, - "horizontalSync": 0, - "jitter": 0, - "rasterization": 0, - "rbgShift": 0, - "saturationColor": 0.9743, - "screenCurvature": 0.1, - "staticNoise": 0, - "useCustomCommand": false, - "windowOpacity": 1, - "name": "ibm-blue" -} diff --git a/crt/ibm-green.json b/crt/ibm-green.json deleted file mode 100644 index 2e1a0a6..0000000 --- a/crt/ibm-green.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "ambientLight": 0, - "backgroundColor": "#000000", - "bloom": 0.4, - "brightness": 0.5, - "burnIn": 0, - "chromaColor": 0, - "contrast": 0.85, - "customCommand": "", - "flickering": 0, - "fontColor": "#00ff5b", - "fontName": "IBM_3278", - "fontWidth": 1, - "frameName": "NO_FRAME", - "glowingLine": 0, - "horizontalSync": 0, - "jitter": 0, - "rasterization": 0, - "rbgShift": 0, - "saturationColor": 0.9743, - "screenCurvature": 0.1, - "staticNoise": 0, - "useCustomCommand": false, - "windowOpacity": 1, - "name": "ibm-green" -} diff --git a/crt/ibm-grey-color.json b/crt/ibm-grey-color.json deleted file mode 100644 index 89cffb7..0000000 --- a/crt/ibm-grey-color.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "ambientLight": 0, - "backgroundColor": "#000000", - "bloom": 0.4, - "brightness": 0.5, - "burnIn": 0, - "chromaColor": 1, - "contrast": 0.85, - "customCommand": "", - "flickering": 0, - "fontColor": "#afafaf", - "fontName": "IBM_3278", - "fontWidth": 1, - "frameName": "NO_FRAME", - "glowingLine": 0, - "horizontalSync": 0, - "jitter": 0, - "rasterization": 0, - "rbgShift": 0, - "saturationColor": 0.9743, - "screenCurvature": 0.1, - "staticNoise": 0, - "useCustomCommand": false, - "windowOpacity": 1, - "name": "ibm-grey-color" -} diff --git a/crt/ibm-grey.json b/crt/ibm-grey.json deleted file mode 100644 index 77023e5..0000000 --- a/crt/ibm-grey.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "ambientLight": 0, - "backgroundColor": "#000000", - "bloom": 0.4, - "brightness": 0.5, - "burnIn": 0, - "chromaColor": 0, - "contrast": 0.85, - "customCommand": "", - "flickering": 0, - "fontColor": "#afafaf", - "fontName": "IBM_3278", - "fontWidth": 1, - "frameName": "NO_FRAME", - "glowingLine": 0, - "horizontalSync": 0, - "jitter": 0, - "rasterization": 0, - "rbgShift": 0, - "saturationColor": 0.9743, - "screenCurvature": 0.1, - "staticNoise": 0, - "useCustomCommand": false, - "windowOpacity": 1, - "name": "ibm-grey" -} diff --git a/crt/profont-color.json b/crt/profont-color.json deleted file mode 100644 index 32ebd48..0000000 --- a/crt/profont-color.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "ambientLight": 0, - "backgroundColor": "#000000", - "bloom": 0.4, - "brightness": 0.5, - "burnIn": 0, - "chromaColor": 1, - "contrast": 0.85, - "customCommand": "", - "flickering": 0, - "fontColor": "#afafaf", - "fontName": "IBM_3278", - "fontWidth": 1, - "frameName": "NO_FRAME", - "glowingLine": 0, - "horizontalSync": 0, - "jitter": 0, - "rasterization": 0, - "rbgShift": 0, - "saturationColor": 0.9743, - "screenCurvature": 0.1, - "staticNoise": 0, - "useCustomCommand": false, - "windowOpacity": 1, - "name": "profont-color" -} diff --git a/kernel_package.sh b/kernel_package.sh deleted file mode 100755 index 14a23b2..0000000 --- a/kernel_package.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh -set -e -set -x - -if [ $(id -u) -ne 0 ] ; then - echo "You must be root" - exit 1; -fi - -if [ -z "$1" ] ; then - echo "Usage: $0 \$version" - echo "Will place currently installed kernel \$version in the current directory" - exit 1; -fi -version="$1"; shift - -tar -C / -cvf - \ - "/usr/lib/modules/$version" \ - "/boot/config-$version" \ - "/boot/vmlinuz-$version" \ - "/boot/System.map-${version}" \ - "/boot/initramfs-${version}.img" \ - | gzip -3c > $version.tar.gz diff --git a/kernel_upgrade.sh b/kernel_upgrade.sh deleted file mode 100755 index dab1518..0000000 --- a/kernel_upgrade.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh -set -e -set -x -version="$(sed 11q Makefile \ - | sed -n \ - -e's/^VERSION = //p' \ - -e's/^PATCHLEVEL = //p' \ - -e's/^SUBLEVEL = //p' \ - | tr '\n' '.' \ - | sed -e's/\.$//')" -localversion="$(sed 25q .config \ - | sed -rn \ - -e's/^CONFIG_LOCALVERSION="(.*)"$/\1/p')" -if [ -z "$version" ] ; then - exit 1; -fi -CPUs="$(nproc)" -# git checkout v$version -make -j$CPUs "$@" olddefconfig bzImage modules -sudo make -j$CPUs install modules_install -cd / -sudo sh -c 'umask 002; sh /etc/kernel.d/post-install/10-dkms linux '"${version}${localversion}" -cd - -sudo dracut -f --kver "${version}${localversion}" -sudo grub-mkconfig -o /boot/grub/grub.cfg -echo "You'll have to update grub by hand there bud" diff --git a/keys/barracuda.txt b/keys/barracuda.txt deleted file mode 120000 index 5c238a3..0000000 --- a/keys/barracuda.txt +++ /dev/null @@ -1 +0,0 @@ -barracuda \ No newline at end of file diff --git a/keys/personal.txt b/keys/personal.txt deleted file mode 120000 index 1a6df4b..0000000 --- a/keys/personal.txt +++ /dev/null @@ -1 +0,0 @@ -personal \ No newline at end of file diff --git a/linux/kernel/package.sh b/linux/kernel/package.sh new file mode 100755 index 0000000..14a23b2 --- /dev/null +++ b/linux/kernel/package.sh @@ -0,0 +1,23 @@ +#!/bin/sh +set -e +set -x + +if [ $(id -u) -ne 0 ] ; then + echo "You must be root" + exit 1; +fi + +if [ -z "$1" ] ; then + echo "Usage: $0 \$version" + echo "Will place currently installed kernel \$version in the current directory" + exit 1; +fi +version="$1"; shift + +tar -C / -cvf - \ + "/usr/lib/modules/$version" \ + "/boot/config-$version" \ + "/boot/vmlinuz-$version" \ + "/boot/System.map-${version}" \ + "/boot/initramfs-${version}.img" \ + | gzip -3c > $version.tar.gz diff --git a/linux/kernel/upgrade.sh b/linux/kernel/upgrade.sh new file mode 100755 index 0000000..dab1518 --- /dev/null +++ b/linux/kernel/upgrade.sh @@ -0,0 +1,26 @@ +#!/bin/sh +set -e +set -x +version="$(sed 11q Makefile \ + | sed -n \ + -e's/^VERSION = //p' \ + -e's/^PATCHLEVEL = //p' \ + -e's/^SUBLEVEL = //p' \ + | tr '\n' '.' \ + | sed -e's/\.$//')" +localversion="$(sed 25q .config \ + | sed -rn \ + -e's/^CONFIG_LOCALVERSION="(.*)"$/\1/p')" +if [ -z "$version" ] ; then + exit 1; +fi +CPUs="$(nproc)" +# git checkout v$version +make -j$CPUs "$@" olddefconfig bzImage modules +sudo make -j$CPUs install modules_install +cd / +sudo sh -c 'umask 002; sh /etc/kernel.d/post-install/10-dkms linux '"${version}${localversion}" +cd - +sudo dracut -f --kver "${version}${localversion}" +sudo grub-mkconfig -o /boot/grub/grub.cfg +echo "You'll have to update grub by hand there bud" diff --git a/lvm-snapshot.sh b/lvm-snapshot.sh deleted file mode 100644 index 4991495..0000000 --- a/lvm-snapshot.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh -set -e - -vg="x230" -lv="root" -snap_name="${lv}-snap" -mountpoint="/mnt/snap" -PERCENT="100" - -mount_fs() { - _device="$1"; shift - _opts="nouuid,rw" - _mntpoint="$1"; shift - if ! [ -d "$_mntpoint" ] ; then - mkdir "$_mntpoint" - fi - mount -o "$_opts" "$_device" "$_mntpoint" -} - -# If snapshot doesn't exist -if ! lvm lvs "$vg/$snap_name" >/dev/null 2>&1 ; then - lvm lvcreate "$vg/$lv" -s --name "$snap_name" -l "${PERCENT}%ORIGIN" - mount_fs "/dev/$vg/$snap_name" "$mountpoint" - sed -i.bak -r "s@(/dev/${vg}/${lv})@\1${snap_name}@" \ - "$mountpoint/etc/fstab" - umount "$mountpoint" -else - printf 'Cannot continue snapshot "%s" already exists.\n' \ - "$vg/$snap_name" - exit 1; -fi diff --git a/mkshrc.txt b/mkshrc.txt deleted file mode 120000 index 81ef8a0..0000000 --- a/mkshrc.txt +++ /dev/null @@ -1 +0,0 @@ -mkshrc \ No newline at end of file diff --git a/net/vlan.sh b/net/vlan.sh deleted file mode 100644 index 2ca1f0c..0000000 --- a/net/vlan.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/sh -set -e -# A short script to setup the network on a server creating bridges for each -# vlan specified. - -# Why? NetworkManager sucks and so do other network utilities. This is simple -# and fits the need of creating a virtual machine host that can place VMs -# on any one of the vlans. - -defaultrouter="10.9.8.7" -nameservers="10.11.12.13 10.12.14.16" -vlan_ifs="eth0 eth1 eth3" -eth0_vlan_ids="10" -eth0_vlan_10_inet="10.10.1.2/24" -eth1_vlan_ids="20 34 38 60 160 240 432" -eth1_vlan_60_inet="10.60.8.2/24" -eth3_vlan_ids=50 -eth3_vlan_50_inet="10.50.0.1/24" -echo="echo" - -for if in $vlan_ifs ; do - $echo ip link set up $if - eval vlan_ids="\$${if}_vlan_ids" - - for id in $vlan_ids; do - $echo ip link add link $if name ${if}.${id} type vlan id ${id} - $echo brctl addbr vlan${id} - $echo brctl addif vlan${id} ${if}.${id} - $echo ip link set up ${if}.${id} - - eval inet="\$${if}_vlan_${id}_inet" - if ! [ -z "$inet" ] ; then - $echo ip -4 addr add "$inet" dev ${if}.${id}. - fi - done -done - -$echo ip route add default via $defaultrouter - -$echo truncate -s 0 /etc/resolv.conf -for ns in $nameservers ; do - if ! [ -z "$echo" ] ; then - echo echo nameserver $ns '>>' /etc/resolv.conf - else - echo nameserver $ns >> /etc/resolv.conf - fi -done - diff --git a/net/workstation.sh b/net/workstation.sh deleted file mode 100644 index 7639a6e..0000000 --- a/net/workstation.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/sh -# net.sh -# Sets up a bridged network specifically for use on a laptop or workstation. -# Called by `/etc/rc.local` on my Void Linux machine - -bridges="vbr0 br0" - -br0_ifs="enp2s0" -# vbr0_ifs="" -vbr0_inet="10.33.33.1/24" -vbr0_inet6="fc00:333::1/64" - -assign_inet_for_if() { -_if="$1" ; shift -eval _inet="\$${_if}_inet" -for addr in $_inet ; do - ip -4 addr add $addr dev $br -done -} - -assign_inet6_for_if() { -_if="$1" ; shift -eval _inet="\$${_if}_inet6" -for addr in $_inet ; do - ip -6 addr add $addr dev $br -done -} - -for br in $bridges ; do - brctl addbr $br - ip link set up "$br" - - eval _ifs="\$${br}_ifs" - for _if in $_ifs ; do - brctl addif "$br" "$_if" - ip link set up "$_if" - done - - assign_inet_for_if "${br}" - assign_inet6_for_if "${br}" -done - -for _if in $_ifs ; do - assign_inet_for_if "$_if" - assign_inet6_for_if "$_if" - - ip link set up "$_if" -done diff --git a/openbsd_net.sh b/openbsd_net.sh deleted file mode 100755 index ad8993d..0000000 --- a/openbsd_net.sh +++ /dev/null @@ -1,83 +0,0 @@ -#!/bin/sh -set -e - -# No trailing slash -conf_dir="/etc/net" -interface="iwn0" - -help(){ -cat < ../mkshrc - -cat \ - notice \ - aliases \ - utils \ - colors \ - bash \ - > ../bashrc - -cat \ - notice \ - aliases \ - utils \ - colors \ - ash \ - > ../ashrc diff --git a/shell/conf b/shell/conf index 8ea9d27..efd8710 100644 --- a/shell/conf +++ b/shell/conf @@ -1,11 +1,15 @@ SHELL_CONFIG=".mkshrc" COLOR=0 +case "$TERM" in + xterm*) COLOR=1;; + *256color) COLOR=1;; +esac export EDITORS="ed vi vim " export PATH="$HOME/bin:$PATH" -UPDATE_URL="https://www.rygel.us/etc/" +UPDATE_URL="https://git.riedstra.us/mitch/dotfiles.git/plain/" VIM_GIT_URL="https://git.riedstra.us/mitch/vim-cfg.git" VIM_BASIC_URL="https://git.riedstra.us/mitch/vim-cfg.git/plain/basic.vim" @@ -23,33 +27,30 @@ fi set_pager set_editor # requires misc -set_go +# set_go setaliases setsudoaliases + +# checkSSHAgent # Nasty conditional for support of many different shells if + ! [ -z "$KSH_VERSION" ] || [ $SHELL = "/bin/ksh" ] || [ $SHELL = "/bin/mksh" ] || [ $SHELL = "/usr/bin/mksh" ] || - [ $SHELL = "/usr/local/bin/mksh" ] || - ! [ -z "$KSH_VERSION" ] + [ $SHELL = "/usr/local/bin/mksh" ] then export HISTFILE="$HOME/.ksh_history" set -o emacs bind ^L=clear-screen - if [ $COLOR -eq 1 ] ; then - set_prompt - else - set_basic_prompt - fi elif [ $SHELL = "/bin/sh" ] && [ "$(uname)" = "FreeBSD" ] ; then set -o emacs export PS1="$(whoami)"'@\h:\w \$ ' -else - [ $SHELL = "/bin/sh" ] && export PS1="$ " +elif ! [ -z "$BASH" ] ; then + export PROMPT_COMMAND="set_my_title" fi if [ $COLOR -eq 1 ] ; then diff --git a/snap/btrfs.sh b/snap/btrfs.sh new file mode 100644 index 0000000..cc2e5a9 --- /dev/null +++ b/snap/btrfs.sh @@ -0,0 +1,23 @@ +#!/bin/sh +set -x +set -e +timestamp() { + date +%m.%d.%y_%H.%M.%S +} + +rootfs="glibc" +snap="${rootfs}-snap" + +cd /ROOT + +if [ -e "$snap" ] ; then + btrfs sub del "$snap" +fi + +if ! [ -e "bak" ] ; then + btrfs sub create "bak" +fi + +btrfs sub snap -r "$rootfs" "bak/${rootfs}-$(timestamp)" +btrfs sub snap "$rootfs" "$snap" +sed -i.bak -e"s/subvol=${rootfs}/subvol=${snap}/g" "${snap}/etc/fstab" diff --git a/snap/lvm.sh b/snap/lvm.sh new file mode 100644 index 0000000..4991495 --- /dev/null +++ b/snap/lvm.sh @@ -0,0 +1,31 @@ +#!/bin/sh +set -e + +vg="x230" +lv="root" +snap_name="${lv}-snap" +mountpoint="/mnt/snap" +PERCENT="100" + +mount_fs() { + _device="$1"; shift + _opts="nouuid,rw" + _mntpoint="$1"; shift + if ! [ -d "$_mntpoint" ] ; then + mkdir "$_mntpoint" + fi + mount -o "$_opts" "$_device" "$_mntpoint" +} + +# If snapshot doesn't exist +if ! lvm lvs "$vg/$snap_name" >/dev/null 2>&1 ; then + lvm lvcreate "$vg/$lv" -s --name "$snap_name" -l "${PERCENT}%ORIGIN" + mount_fs "/dev/$vg/$snap_name" "$mountpoint" + sed -i.bak -r "s@(/dev/${vg}/${lv})@\1${snap_name}@" \ + "$mountpoint/etc/fstab" + umount "$mountpoint" +else + printf 'Cannot continue snapshot "%s" already exists.\n' \ + "$vg/$snap_name" + exit 1; +fi diff --git a/terminal-colors b/terminal-colors deleted file mode 100644 index cbd7dcb..0000000 --- a/terminal-colors +++ /dev/null @@ -1,585 +0,0 @@ -#!/usr/bin/env python - -"""2.3.0 John Eikenberry GPL-3+ http://zhar.net/projects/ - -Copyright - Copyright (C) 2010-2015 John Eikenberry - -License - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Description - My goal in writing this script was to provide all the functionality of all - the various perl/sh scripts found around the web in one place with some - additional bells and whistles. - - It automatically detects 8, 16, 88, 256 color capabilities (via ncurses) - and displays the appropriate color charts. It can display the colors as - blocks or (2d) cubes optionally with color values overlaid in int or hex - values. It can show the full rgb text string as well. It can also show the - display with a vertical (default) or horizontal orientation. It has the - option of additional padding and supports -h --help as well. - - It also works as a utility for converting between 256 and 88 color values. - -Development - A note on coding style. I was playing around with using classes as simple - module-esque namespaces; i.e. having classes that have all staticmethods - and never get instatiated. As a side effect of this it makes calls at the - module level thus this script is not really importable, thus limiting - reuse. - -Contributors - Isaac Cammann - cube display bugfix - Jan Larres - submitted patches for.. - - compact rgb display - - use of color intensity to determine foreground contrast color - - 16 color SGR ANSI chart - - 88 color rgb display bugfix - -""" -from __future__ import print_function - -__version__ = __doc__.split('\n')[0] - -import sys -import curses -from optparse import OptionParser, OptionGroup, make_option -from math import ceil, sqrt -from inspect import getdoc -from functools import wraps - -# output constants -fg_escape = "\x1b[38;5;%dm" -bg_escape = "\x1b[48;5;%dm" -clear = "\x1b[0m" - -def _get_options(args): - """ Setup and parse options. - """ - option_list = [ - make_option("-b", "--block", action="store_true", dest="block", - default=True, help="Display as block format (vs cube) [default]."), - make_option("-c", "--cube-slice", action="store_true", dest="cube", - default=False, help="Display as cube slices (vs block)."), - make_option("-f", "--foreground", action="store_true", - dest="foreground", default=False, - help="Use color for foreground text."), - make_option("-l", "--rgb", action="store_true", dest="rgb", - default=False, help="Long format. RGB values as text."), - make_option("-n", "--numbers", action="store_true", dest="numbers", - default=False, help="Include color escape numbers on chart."), - make_option("-o", "--ansicodes", action="store_true", - dest="ansicodes", default=False, - help="Display 16 color chart with SGR ANSI escape codes."), - make_option("-p", "--padding", action="store_true", dest="padding", - default=False, help="Add extra padding (helps discern colors)."), - make_option("-t", "--test", action="store_true", dest="test", - default=False, help="Run tests."), - make_option("-v", "--vertical", action="store_true", dest="vertical", - default=True, help="Display with vertical orientation [default]."), - make_option("-x", "--hex", action="store_true", dest="hex", - default=False, help="Include hex color numbers on chart."), - make_option("-z", "--horizontal", action="store_true", - dest="horizontal", default=False, - help="Display with horizontal orientation."), - ] - - parser = OptionParser(version=__version__, option_list=option_list) - - convert_option_list = [ - make_option("-r", "--256to88", action="store", dest="reduce", - metavar="N", type="int", - help="Convert (reduce) 256 color value N to an 88 color value."), - make_option("-e", "--88to256", action="store", dest="expand", - metavar="N", type="int", - help="Convert (expand) 88 color value N to an 256 color value."), - ] - group = OptionGroup(parser, "Conversion options") - group.add_options(option_list=convert_option_list) - parser.add_option_group(group) - - (opts, args) = parser.parse_args(args) - return opts - -# instantiate global options based on command arguments -options = _get_options(sys.argv[1:]) -# don't allow -f by itself -options.foreground = options.foreground and ( - options.numbers or options.hex or options.rgb) - -class _staticmethods(type): - """ Got tired of adding @staticmethod in front of every method. - """ - def __new__(mcs, n, b, d): - """ turn all methods in to staticmethods. - staticmethod() deals correctly with class attributes. - """ - for (n, f) in d.items(): - if callable(f): - d[n] = staticmethod(f) - return type.__new__(mcs, n, b, d) - -def _cached(f): - """ Memoize function w/ no params - """ - _cache = {} - @wraps(f) - def cache(): - if None not in _cache: - _cache[None] = f() - return _cache[None] - return cache - - -class term16(object): - """ Basic 16 color terminal. - """ - __metaclass__ = _staticmethods - - def label(n, esc): - """ color label for 256 color values - >>> options.numbers = True - >>> term16.label(95, lambda n: '') - ' 95 ' - >>> options.numbers = False - >>> options.hex = True - >>> term16.label(95, lambda n: '') - ' 5f ' - """ - if options.numbers: - return esc(n) + "%3d " % n - elif options.hex: - return esc(n) + " %2x " % n - return esc(n) + " " - - def _render(): - """ 16 color info - >>> term16._render()[0][-1] - '\\x1b[48;5;7m\\x1b[38;5;15m \\x1b[0m' - >>> len(term16._render()) - 2 - >>> len(term16._render()[0]) - 8 - """ - if options.foreground: - esc = lambda n: fg_escape % n - else: - esc = lambda n: bg_escape % n + fg_escape % (15 if n < 9 else 0) - return [[term16.label(n, esc) + clear for n in range(8)], - [term16.label(n, esc) + clear for n in range(8, 16)]] - - def ansicodes(): - """ base 16 SGR ANSI escape codes - >>> term16.ansicodes()[0][:6] - [' 0m ', ' 1m ', ' 30m ', ' 1;30m ', ' 31m ', ' 1;31m '] - >>> term16.ansicodes()[1][:6] - [' ', ' _ ', ' 40m ', ' 41m ', ' 42m ', ' 43m '] - >>> len(term16.ansicodes()[2]) - 18 - >>> term16.ansicodes()[2][17][0] - '\\x1b[1;37m\\x1b[_ gYw \\x1b[0m' - """ - fg_codes = ['0m', '1m'] + [fg for pair in - [["{}m".format(i), "1;{}m".format(i)] for i in range(30, 38)] - for fg in pair] - bg_codes = ["_"] + ["{}m".format(n) for n in range(40, 48)] - - x_labels = ["%6s " % fg for fg in fg_codes] - y_labels = [' ' * 6] - y_labels.extend(["{: ^5}".format(bg) for bg in bg_codes]) - - text, esc_code = " gYw ", "\x1b[%s" - - codes = [[esc_code % fg + esc_code % bg + text + clear - for bg in bg_codes] for fg in fg_codes] - - return x_labels, y_labels, codes - - def ansicodes_display(): - """ 16 SGR ANSI escape codes in traditional format - """ - x_labels, y_labels, codes = term16.ansicodes() - - print(' '.join(y_labels)) - for i, code in enumerate(codes): - print(x_labels[i], end='') - print(' '.join(code)) - - def display(): - """ display 16 color info - """ - print("System colors:") - colors = term16._render() - padding = ' ' if options.padding else '' - for r in colors: - print(padding.join(i for i in r)) - if options.padding: print() - - -class term256(term16): - """ eg. xterm-256 - """ - - @_cached - def _rgb_lookup(): - """ color rgb lookup dict - >>> term256._rgb_lookup()[16] - (0, 0, 0) - >>> term256._rgb_lookup()[128] - (175, 0, 215) - >>> term256._rgb_lookup()[255] - (238, 238, 238) - """ - # color increment is based on xterm/rxvt palette - cincr = [0] + [95+40*n for n in range(5)] - color_rgb = [rgb(i, j, k) - for i in cincr for j in cincr for k in cincr] - color_rgb = dict(zip(range(16, len(color_rgb)+16), color_rgb)) - greys = [rgb(*((n,)*3)) for n in range(8, 248, 10)] - greys = dict(zip(range(232, 256), greys)) - color_rgb.update(greys) - return color_rgb - - def _to_rgb(n): - """ Convert color value to rgb tuple. - >>> term256._to_rgb(128) - (175, 0, 215) - """ - return term256._rgb_lookup()[n] - - def _rgb_color_table(): - """ 256 color info - >>> term256._rgb_color_table()[0][0] - '\\x1b[38;5;16m 16: \\x1b[38;5;255m\\x1b[48;5;16m#000000\\x1b[0m' - >>> term256._rgb_color_table()[-1][-1] - '\\x1b[38;5;255m 255: \\x1b[38;5;16m\\x1b[48;5;255m#eeeeee\\x1b[0m' - """ - rgbl = term256._rgb_lookup() - label_num = "% 4d: " - label_val = "%s" - if options.foreground: - render = lambda n: fg_escape % n + label_num % n + \ - label_val % str(rgbl[n]) + clear - else: - render = lambda n: fg_escape % n + label_num % n + \ - fg_escape % (16 if rgbl[n].is_light() else 255) \ - + bg_escape % n + label_val % str(rgbl[n]) + clear - return [[render(n) for n in [i+j for j in range(6)]] - for i in range(16, 256, 6)] - - def _rgb_display(): - """ display colors with rgb hex info - """ - colors = term256._rgb_color_table() - padding = ' ' if options.padding else '' - while colors: - rows, colors = colors[:6], colors[6:] - if not options.horizontal: - rows = zip(*rows) - for r in rows: - print(padding.join(i for i in r)) - if options.padding: print() - print() - - def _colors(): - """ 256 color numbers - """ - return [[i+j for j in range(6)] for i in range(16, 232, 6)] - - def _greyscale(): - """ 256 greyscale numbers - """ - return [[i+j for j in range(12)] for i in range(232, 256, 12)] - - def _render(palette): - """ compact 256 color info - """ - if options.foreground: - esc = lambda n: fg_escape % n - render = lambda n: term256.label(n, esc) + clear - else: - esc = lambda n: fg_escape % \ - (16 if term256._to_rgb(n).is_light() else 255) - render = lambda n: bg_escape % n + term256.label(n, esc) + clear - return [[render(n) for n in i] for i in iter(palette)] - - def _compact_display(): - """ display colors in compact format - """ - colors = term256._render(term256._colors()) - if options.cube: - _cube_display(colors) - elif options.block: - _block_display(colors) - print() - greys = term256._render(term256._greyscale()) - padding = ' ' if options.padding else '' - for r in greys: - print(padding.join(i for i in r)) - if options.padding: print() - - def display(): - """ display 256 color info (+ 16 in compact format) - """ - if options.rgb: - print("Xterm RGB values for 6x6x6 color cube and greyscale.") - print() - term256._rgb_display() - else: - term16.display() - print() - print("6x6x6 color cube and greyscale:") - term256._compact_display() - - -class term88(term16): - """ xterm-88 or urxvt - """ - - @_cached - def _rgb_lookup(): - """ color rgb lookup dict - """ - # color increment is based on rxvt palette - cincr = [0, 0x8b, 0xcd, 0xff] - color_rgb = [rgb(i, j, k) - for i in cincr for j in cincr for k in cincr] - color_rgb = dict(zip(range(16, len(color_rgb)+16), color_rgb)) - greys = [rgb(*((n,)*3)) - for n in [0x2e, 0x5c, 0x73, 0x8b, 0xa2, 0xb9, 0xd0, 0xe7]] - greys = dict(zip(range(80, 88), greys)) - color_rgb.update(greys) - return color_rgb - - def _to_rgb(n): - """ Convert color value to rgb tuple. - """ - return term88._rgb_lookup()[n] - - def _rgb_color_table(): - """ 88 color info - """ - rgbl = term88._rgb_lookup() - label_num = "% 4d: " - label_val = "%s" - if options.foreground: - render = lambda n: fg_escape % n + label_num % n + \ - label_val % str(rgbl[n]) + clear - else: - render = lambda n: fg_escape % n + label_num % n + \ - fg_escape % (16 if rgbl[n].is_light() else 87) \ - + bg_escape % n + label_val % str(rgbl[n]) + clear - return [[render(n) for n in [i+j for j in range(4)]] - for i in range(16, 88, 4)] - - def _rgb_display(): - """ display colors with rgb hex info - """ - colors = term88._rgb_color_table() - while colors: - rows, colors = colors[:4], colors[4:] - for r in zip(*rows): - print(''.join(i for i in r)) - print() - - def _render(palette): - """ 88 color info - """ - if options.foreground: - esc = lambda n: fg_escape % n - render = lambda n: term88.label(n, esc) + clear - else: - esc = lambda n: fg_escape % \ - (16 if term88._to_rgb(n).is_light() else 87) - render = lambda n: bg_escape % n + term88.label(n, esc) + clear - return [[render(n) for n in i] for i in iter(palette)] - - def _colors(): - """ 88 color numbers - """ - return [[i+j for j in range(4)] for i in range(16, 80, 4)] - - def _greyscale(): - """ 88 greyscale numbers - """ - return [range(80, 88)] - - - def display(): - """ display 16 + 88 color info - """ - if options.rgb: - print("Xterm RGB values for 4x4x4 color cube and greyscale.") - print() - term88._rgb_display() - else: - padding = ' ' if options.padding else '' - term16.display() - print() - print("4x4x4 color cube and greyscale:") - colors = term88._render(term88._colors()) - if options.cube: - _cube_display(colors) - elif options.block: - _block_display(colors) - print() - greys = term88._render(term88._greyscale()) - for r in greys: - print(padding.join(i for i in r)) - -class rgb(tuple): - """ An RGB, (red, green, blue) tuple. Takes integers. - """ - def __new__(cls, r, g, b): - """ We want 3 colors. - """ - return super(rgb, cls).__new__(cls, (r, g, b)) - - def __str__(self): - """ Display in compact rgb format. - """ - return "#%02x%02x%02x" % self - - def is_light(self): - """ Is this color light (or dark). - """ - red, green, blue = self[0], self[1], self[2] - intensity = red*0.2126 + green*0.7152 + blue*0.0722 - return intensity > 127 - - -def _cube_display(colors): - """ Display color cube as color aligned flatten cube sides. - """ - padding = ' ' if options.padding else '' - if options.horizontal: - def _horizontal(colors): - size = int(sqrt(len(colors))) - for n in (n*size for n in range(size)): - colors[n:n+size] = zip(*colors[n:n+size]) - while colors: - rows, colors = colors[:size*2], colors[size*2:] - for n in range(size): - print(padding.join(i - for i in rows[n]+tuple(reversed(rows[n+size])))) - if options.padding: print(padding) - if colors: print() - _horizontal(colors) - else: #options.vertical - default - def _vertical(colors): - size = int(sqrt(len(colors))) - top = [colors[n:len(colors):size*2] for n in range(size)] - bottom = [colors[n+size:len(colors):size*2] - for n in reversed(range(size))] - for group in [top, bottom]: - for rows in group: - for r in rows: - print(padding.join(i for i in r), end=' ') - if options.padding: print(padding, end=' ') - if options.padding: print() - print() - _vertical(colors) - -def _block_display(colors): - """ Display color cube as cube sides organized by color #s (default). - """ - padding = ' ' if options.padding else '' - size = int(sqrt(len(colors))) - if not options.horizontal: - for n in (n*size for n in range(size)): - colors[n:n+size] = zip(*colors[n:n+size]) - while colors: - half = size*(size//2) - rows, colors = colors[:half], colors[half:] - for n in range(size): - for r in rows[n:len(rows):size]: - print(padding.join(i for i in r), end=' ') - if options.padding: print(padding, end=' ') - if options.padding: print() - print() - if colors: print() - -def convert88to256(n): - """ 88 (4x4x4) color cube to 256 (6x6x6) color cube values - """ - if n < 16: - return n - elif n > 79: - return 234 + (3 * (n - 80)) - else: - def m(n): - "0->0, 1->1, 2->3, 3->5" - return n and n + n-1 or n - b = n - 16 - x = b % 4 - y = (b // 4) % 4 - z = b // 16 - return 16 + m(x) + (6 * m(y) + 36 * m(z)) - -def convert256to88(n): - """ 256 (6x6x6) color cube to 88 (4x4x4) color cube values - """ - if n < 16: - return n - elif n > 231: - if n < 234: - return 0 - return 80 + ((n - 234) // 3) - else: - def m(n, _ratio=(4./6.)): - if n < 2: - return int(ceil(_ratio*n)) - else: - return int(_ratio*n) - b = n - 16 - x = b % 6 - y = (b // 6) % 6 - z = b // 36 - return 16 + m(x) + (4 * m(y) + 16 * m(z)) - -def _terminal(): - """ detect # of colors supported by terminal and return appropriate - terminal class - """ - curses.setupterm() - num_colors = curses.tigetnum('colors') - if num_colors > 0: - return {16:term16, 88:term88, 256:term256}.get(num_colors, term16) - -def main(): - if options.test: - print("Running tests...") - import doctest - doctest.testmod() - print("Done.") - elif options.reduce: - v = convert256to88(options.reduce) - # reconvert back to display reduction in context - print("%s (equivalent to 256 value: %s)" % (v, convert88to256(v))) - elif options.expand: - print(convert88to256(options.expand)) - else: - term = _terminal() - if term is None: - print("Your terminal reports that it has no color support.") - else: - if options.ansicodes: - print(getdoc(term16.ansicodes_display)) - term16.ansicodes_display() - else: - term.display() - -if __name__ == "__main__": - main() diff --git a/tmux.conf b/tmux.conf deleted file mode 100644 index d1b3dc0..0000000 --- a/tmux.conf +++ /dev/null @@ -1,91 +0,0 @@ - -# *OLD* way to set styles -# set -g status-bg green -# set -g status-fg black -# set-window-option -g window-status-current-bg black -# set-window-option -g window-status-current-fg green - -# New way: -set -g status-style "fg=green,bg=black" -set-window-option -g window-status-current-style "bg=green,fg=black" -set -g status-right "#[fg=black,bg=green] #(whoami)@#h|m:#(sh $HOME/.tmux_helper.sh memory)|l:#(sh $HOME/.tmux_helper.sh load)|#(sh $HOME/.tmux_helper.sh s_uptime)" - - -# Pretty nifty little option to mirror input for all panes -bind M-s setw synchronize-panes - -# Allow the hotkeys to be switched using M-x to C-x, M-b to C-b, and so forth -bind M-x set prefix C-x -bind M-b set prefix C-b -bind M-a set prefix C-a - -# set -g mode-mouse on -setw -g mode-keys vi -# setw -g aggressive-resize on - -# This has previously not given me any issues other than 'set termguicolors' in -# vim -# set -g default-terminal "screen-256color" - -# This seems to fix that problem, it may cause other issues but I'm going to -# keep an eye on it -set-option -g default-terminal "xterm-256color" -set-option -ga terminal-overrides ",xterm*:Tc" - - -# Don't let command rename our windows -set-option -g allow-rename off - -# Press v to "visually" and y to "yank" the text -# Press `c-b ]` to paste -# If you ever want to look up a keybind use `c-b ?` -bind-key -T copy-mode-vi v send-keys -X begin-selection -bind-key -T copy-mode-vi y send-keys -X copy-selection - -# This one is also useful if you don't want to do what is listed above -# bind p paste-buffer - -# Rather large histroy buffer so I don't lose shit -set-option -g history-limit 16000 - -# Fix for certian applications such as Nvim -set -sg escape-time 0 - -# Select panes with vim like bindings -bind-key M-k select-pane -U -bind-key M-j select-pane -D -bind-key M-h select-pane -L -bind-key M-l select-pane -R - - -# Reload configuration -bind-key r source ~/.tmux.conf -# Respawn the pane ( Useful with certain -bind-key M-r respawn-pane - - -# Change the status line a little bit, most are close to defaults -set -g status-left-length 16 -set -g status-left "[#S] " -set -g status-right "#[fg=green,bg=black] #(whoami)@#h|m:#(sh $HOME/.tmux_helper.sh memory)|l:#(sh $HOME/.tmux_helper.sh load)|#(sh $HOME/.tmux_helper.sh uptime)" - -set -g status-right-length 40 -set -g window-status-format "#I:#W#F" - -set -g set-titles on -set -g set-titles-string "tmux: #{session_name} [#I]#{window_name} -- #T" - - -# If you still want to select text out of the terminal as you normally would -# You should hold the shift key ( Linux ) Option/Alt works in iTerm2 on MacOS -# Does not seem to work with the native terminal. -set -g mouse on - -# Old mouse method -# set-option -g mode-mouse on -# set-option -g mouse-resize-pane on -# set-option -g mouse-select-pane on -# set-option -g mouse-select-window on - -# If you want any local configuration -source ~/.tmux.conf.local diff --git a/tmux/tmux.conf b/tmux/tmux.conf new file mode 100644 index 0000000..c80958d --- /dev/null +++ b/tmux/tmux.conf @@ -0,0 +1,91 @@ + +# *OLD* way to set styles +# set -g status-bg green +# set -g status-fg black +# set-window-option -g window-status-current-bg black +# set-window-option -g window-status-current-fg green + +# New way: +set -g status-style "fg=green,bg=black" +set-window-option -g window-status-current-style "bg=green,fg=black" +set -g status-right "#[fg=black,bg=green] #(whoami)@#h|m:#(sh $HOME/.tmux_helper.sh memory)|l:#(sh $HOME/.tmux_helper.sh load)|#(sh $HOME/.tmux_helper.sh uptime)" +# For a basic tmux configuration without the helper +# set -g status-right "#[fg=black,bg=green] #(whoami)@#h" + +# Pretty nifty little option to mirror input for all panes +bind M-s setw synchronize-panes + +# Allow the hotkeys to be switched using M-x to C-x, M-b to C-b, and so forth +bind M-x set prefix C-x +bind M-b set prefix C-b +bind M-a set prefix C-a + +# set -g mode-mouse on +setw -g mode-keys vi +# setw -g aggressive-resize on + +# This has previously not given me any issues other than 'set termguicolors' in +# vim +# set -g default-terminal "screen-256color" + +# This seems to fix that problem, it may cause other issues but I'm going to +# keep an eye on it +set-option -g default-terminal "tmux-256color" +set-option -ga terminal-overrides ",xterm*:Tc" + + +# Don't let command rename our windows +set-option -g allow-rename off + +# Press v to "visually" and y to "yank" the text +# Press `c-b ]` to paste +# If you ever want to look up a keybind use `c-b ?` +bind-key -T copy-mode-vi v send-keys -X begin-selection +bind-key -T copy-mode-vi y send-keys -X copy-selection + +# This one is also useful if you don't want to do what is listed above +# bind p paste-buffer + +# Rather large histroy buffer so I don't lose shit +set-option -g history-limit 16000 + +# Fix for certian applications such as Nvim +set -sg escape-time 0 + +# Select panes with vim like bindings +bind-key M-k select-pane -U +bind-key M-j select-pane -D +bind-key M-h select-pane -L +bind-key M-l select-pane -R + + +# Reload configuration +bind-key r source ~/.tmux.conf +# Respawn the pane # Useful if you have `set -g remain-on-exit on` or so +bind-key M-r respawn-pane + + +# Change the status line a little bit, most are close to defaults +set -g status-left-length 16 +set -g status-left "[#S] " + +set -g status-right-length 40 +set -g window-status-format "#I:#W#F" + +set -g set-titles on +set -g set-titles-string "tmux: #{session_name} [#I]#{window_name} -- #T" + + +# If you still want to select text out of the terminal as you normally would +# You should hold the shift key ( Linux ) Option/Alt works in iTerm2 on MacOS +# Does not seem to work with the native terminal. +set -g mouse on + +# Old mouse method +# set-option -g mode-mouse on +# set-option -g mouse-resize-pane on +# set-option -g mouse-select-pane on +# set-option -g mouse-select-window on + +# If you want any local configuration +source ~/.tmux.conf.local diff --git a/tmux/tmux_helper.sh b/tmux/tmux_helper.sh new file mode 100644 index 0000000..7ce68bd --- /dev/null +++ b/tmux/tmux_helper.sh @@ -0,0 +1,28 @@ +#!/bin/sh + + +# Little helper script to clean up the nasty embeded commands in my tmux configuration +# Functions ripped out of `mkshrc`, worth checking out + +_sys_memory() { + if [ `uname` = "Linux" ] ; then + vmstat | tail -n1 | awk '{print $4/1024}' | sed -e's/\..*$//g' + elif [ `uname` = "FreeBSD" ] ; then + vmstat | tail -n1 | awk '{print $5/1024}' | sed -e's/\..*$//g' + elif [ `uname` = "OpenBSD" ] ; then + vmstat | sed -n '$p' | awk '{print $4}' | sed 's/M$//' + fi +} + +_sys_load() { + # Works on BSD too, neat. + uptime | sed -re's/^.*load averages?: ([0-9]+\.[0-9]+).*$/\1/g' +} + +_sys_uptime() { + # Took awhile to figure out, but this works on BSD as well + uptime | sed -re's/^.*up[ ]+//g' -e's/^([^,]*),.*/\1/g' -e's/^([^ ]+)[ ]*(.).*/\1\2/g' +} + + +_sys_$1 diff --git a/tmux/tmx.sh b/tmux/tmx.sh new file mode 100644 index 0000000..0d66c27 --- /dev/null +++ b/tmux/tmx.sh @@ -0,0 +1,55 @@ +#!/bin/sh + +# Modified further by Mitchell Riedstra to be compatible with /bin/sh + +# +# Modified TMUX start script from: +# http://forums.gentoo.org/viewtopic-t-836006-start-0.html +# +# Store it to `~/bin/tmx` and issue `chmod +x`. +# + +# Works because bash automatically trims by assigning to variables and by +# passing arguments +trim() { echo $1; } + +if [ -z "$1" ]; then + echo "Specify session name as the first argument" + exit +fi + +# Only because I often issue `ls` to this script by accident +if [ "$1" == "ls" ]; then + tmux ls + exit +fi + +base_session="$1" +# This actually works without the trim() on all systems except OSX +tmux_nb=$(trim `tmux ls | grep "^$base_session" | wc -l`) +if [ "$tmux_nb" == "0" ]; then + echo "Launching tmux base session $base_session ..." + tmux new-session -s $base_session +else + # Make sure we are not already in a tmux session + if [ -z "$TMUX" ]; then + # Kill defunct sessions first + old_sessions=$(tmux ls 2>/dev/null | egrep "^[0-9]{14}.*[0-9]+\)$" | cut -f 1 -d:) + for old_session_id in $old_sessions; do + tmux kill-session -t $old_session_id + done + + echo "Launching copy of base session $base_session ..." + # Session is is date and time to prevent conflict + session_id=`date +%Y%m%d%H%M%S` + # Create a new session (without attaching it) and link to base session + # to share windows + tmux new-session -d -t $base_session -s $session_id + # Create a new window in that session + #tmux new-window + # Attach to the new session + tmux attach-session -t $session_id + # When we detach from it, kill the session + tmux kill-session -t $session_id + fi +fi diff --git a/tmux_helper.sh b/tmux_helper.sh deleted file mode 100644 index 7ce68bd..0000000 --- a/tmux_helper.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh - - -# Little helper script to clean up the nasty embeded commands in my tmux configuration -# Functions ripped out of `mkshrc`, worth checking out - -_sys_memory() { - if [ `uname` = "Linux" ] ; then - vmstat | tail -n1 | awk '{print $4/1024}' | sed -e's/\..*$//g' - elif [ `uname` = "FreeBSD" ] ; then - vmstat | tail -n1 | awk '{print $5/1024}' | sed -e's/\..*$//g' - elif [ `uname` = "OpenBSD" ] ; then - vmstat | sed -n '$p' | awk '{print $4}' | sed 's/M$//' - fi -} - -_sys_load() { - # Works on BSD too, neat. - uptime | sed -re's/^.*load averages?: ([0-9]+\.[0-9]+).*$/\1/g' -} - -_sys_uptime() { - # Took awhile to figure out, but this works on BSD as well - uptime | sed -re's/^.*up[ ]+//g' -e's/^([^,]*),.*/\1/g' -e's/^([^ ]+)[ ]*(.).*/\1\2/g' -} - - -_sys_$1 diff --git a/tmx.sh b/tmx.sh deleted file mode 100644 index 0d66c27..0000000 --- a/tmx.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/sh - -# Modified further by Mitchell Riedstra to be compatible with /bin/sh - -# -# Modified TMUX start script from: -# http://forums.gentoo.org/viewtopic-t-836006-start-0.html -# -# Store it to `~/bin/tmx` and issue `chmod +x`. -# - -# Works because bash automatically trims by assigning to variables and by -# passing arguments -trim() { echo $1; } - -if [ -z "$1" ]; then - echo "Specify session name as the first argument" - exit -fi - -# Only because I often issue `ls` to this script by accident -if [ "$1" == "ls" ]; then - tmux ls - exit -fi - -base_session="$1" -# This actually works without the trim() on all systems except OSX -tmux_nb=$(trim `tmux ls | grep "^$base_session" | wc -l`) -if [ "$tmux_nb" == "0" ]; then - echo "Launching tmux base session $base_session ..." - tmux new-session -s $base_session -else - # Make sure we are not already in a tmux session - if [ -z "$TMUX" ]; then - # Kill defunct sessions first - old_sessions=$(tmux ls 2>/dev/null | egrep "^[0-9]{14}.*[0-9]+\)$" | cut -f 1 -d:) - for old_session_id in $old_sessions; do - tmux kill-session -t $old_session_id - done - - echo "Launching copy of base session $base_session ..." - # Session is is date and time to prevent conflict - session_id=`date +%Y%m%d%H%M%S` - # Create a new session (without attaching it) and link to base session - # to share windows - tmux new-session -d -t $base_session -s $session_id - # Create a new window in that session - #tmux new-window - # Attach to the new session - tmux attach-session -t $session_id - # When we detach from it, kill the session - tmux kill-session -t $session_id - fi -fi diff --git a/util/hexify.c b/util/hexify.c new file mode 100644 index 0000000..3aec576 --- /dev/null +++ b/util/hexify.c @@ -0,0 +1,11 @@ +#include + +int main() { + int c; + while ((c = getchar()) != EOF) { + printf("\\x%X", c); + if ( c == '\n' ) { + puts(""); + } + } +} diff --git a/util/terminal-colors b/util/terminal-colors new file mode 100644 index 0000000..cbd7dcb --- /dev/null +++ b/util/terminal-colors @@ -0,0 +1,585 @@ +#!/usr/bin/env python + +"""2.3.0 John Eikenberry GPL-3+ http://zhar.net/projects/ + +Copyright + Copyright (C) 2010-2015 John Eikenberry + +License + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Description + My goal in writing this script was to provide all the functionality of all + the various perl/sh scripts found around the web in one place with some + additional bells and whistles. + + It automatically detects 8, 16, 88, 256 color capabilities (via ncurses) + and displays the appropriate color charts. It can display the colors as + blocks or (2d) cubes optionally with color values overlaid in int or hex + values. It can show the full rgb text string as well. It can also show the + display with a vertical (default) or horizontal orientation. It has the + option of additional padding and supports -h --help as well. + + It also works as a utility for converting between 256 and 88 color values. + +Development + A note on coding style. I was playing around with using classes as simple + module-esque namespaces; i.e. having classes that have all staticmethods + and never get instatiated. As a side effect of this it makes calls at the + module level thus this script is not really importable, thus limiting + reuse. + +Contributors + Isaac Cammann - cube display bugfix + Jan Larres - submitted patches for.. + - compact rgb display + - use of color intensity to determine foreground contrast color + - 16 color SGR ANSI chart + - 88 color rgb display bugfix + +""" +from __future__ import print_function + +__version__ = __doc__.split('\n')[0] + +import sys +import curses +from optparse import OptionParser, OptionGroup, make_option +from math import ceil, sqrt +from inspect import getdoc +from functools import wraps + +# output constants +fg_escape = "\x1b[38;5;%dm" +bg_escape = "\x1b[48;5;%dm" +clear = "\x1b[0m" + +def _get_options(args): + """ Setup and parse options. + """ + option_list = [ + make_option("-b", "--block", action="store_true", dest="block", + default=True, help="Display as block format (vs cube) [default]."), + make_option("-c", "--cube-slice", action="store_true", dest="cube", + default=False, help="Display as cube slices (vs block)."), + make_option("-f", "--foreground", action="store_true", + dest="foreground", default=False, + help="Use color for foreground text."), + make_option("-l", "--rgb", action="store_true", dest="rgb", + default=False, help="Long format. RGB values as text."), + make_option("-n", "--numbers", action="store_true", dest="numbers", + default=False, help="Include color escape numbers on chart."), + make_option("-o", "--ansicodes", action="store_true", + dest="ansicodes", default=False, + help="Display 16 color chart with SGR ANSI escape codes."), + make_option("-p", "--padding", action="store_true", dest="padding", + default=False, help="Add extra padding (helps discern colors)."), + make_option("-t", "--test", action="store_true", dest="test", + default=False, help="Run tests."), + make_option("-v", "--vertical", action="store_true", dest="vertical", + default=True, help="Display with vertical orientation [default]."), + make_option("-x", "--hex", action="store_true", dest="hex", + default=False, help="Include hex color numbers on chart."), + make_option("-z", "--horizontal", action="store_true", + dest="horizontal", default=False, + help="Display with horizontal orientation."), + ] + + parser = OptionParser(version=__version__, option_list=option_list) + + convert_option_list = [ + make_option("-r", "--256to88", action="store", dest="reduce", + metavar="N", type="int", + help="Convert (reduce) 256 color value N to an 88 color value."), + make_option("-e", "--88to256", action="store", dest="expand", + metavar="N", type="int", + help="Convert (expand) 88 color value N to an 256 color value."), + ] + group = OptionGroup(parser, "Conversion options") + group.add_options(option_list=convert_option_list) + parser.add_option_group(group) + + (opts, args) = parser.parse_args(args) + return opts + +# instantiate global options based on command arguments +options = _get_options(sys.argv[1:]) +# don't allow -f by itself +options.foreground = options.foreground and ( + options.numbers or options.hex or options.rgb) + +class _staticmethods(type): + """ Got tired of adding @staticmethod in front of every method. + """ + def __new__(mcs, n, b, d): + """ turn all methods in to staticmethods. + staticmethod() deals correctly with class attributes. + """ + for (n, f) in d.items(): + if callable(f): + d[n] = staticmethod(f) + return type.__new__(mcs, n, b, d) + +def _cached(f): + """ Memoize function w/ no params + """ + _cache = {} + @wraps(f) + def cache(): + if None not in _cache: + _cache[None] = f() + return _cache[None] + return cache + + +class term16(object): + """ Basic 16 color terminal. + """ + __metaclass__ = _staticmethods + + def label(n, esc): + """ color label for 256 color values + >>> options.numbers = True + >>> term16.label(95, lambda n: '') + ' 95 ' + >>> options.numbers = False + >>> options.hex = True + >>> term16.label(95, lambda n: '') + ' 5f ' + """ + if options.numbers: + return esc(n) + "%3d " % n + elif options.hex: + return esc(n) + " %2x " % n + return esc(n) + " " + + def _render(): + """ 16 color info + >>> term16._render()[0][-1] + '\\x1b[48;5;7m\\x1b[38;5;15m \\x1b[0m' + >>> len(term16._render()) + 2 + >>> len(term16._render()[0]) + 8 + """ + if options.foreground: + esc = lambda n: fg_escape % n + else: + esc = lambda n: bg_escape % n + fg_escape % (15 if n < 9 else 0) + return [[term16.label(n, esc) + clear for n in range(8)], + [term16.label(n, esc) + clear for n in range(8, 16)]] + + def ansicodes(): + """ base 16 SGR ANSI escape codes + >>> term16.ansicodes()[0][:6] + [' 0m ', ' 1m ', ' 30m ', ' 1;30m ', ' 31m ', ' 1;31m '] + >>> term16.ansicodes()[1][:6] + [' ', ' _ ', ' 40m ', ' 41m ', ' 42m ', ' 43m '] + >>> len(term16.ansicodes()[2]) + 18 + >>> term16.ansicodes()[2][17][0] + '\\x1b[1;37m\\x1b[_ gYw \\x1b[0m' + """ + fg_codes = ['0m', '1m'] + [fg for pair in + [["{}m".format(i), "1;{}m".format(i)] for i in range(30, 38)] + for fg in pair] + bg_codes = ["_"] + ["{}m".format(n) for n in range(40, 48)] + + x_labels = ["%6s " % fg for fg in fg_codes] + y_labels = [' ' * 6] + y_labels.extend(["{: ^5}".format(bg) for bg in bg_codes]) + + text, esc_code = " gYw ", "\x1b[%s" + + codes = [[esc_code % fg + esc_code % bg + text + clear + for bg in bg_codes] for fg in fg_codes] + + return x_labels, y_labels, codes + + def ansicodes_display(): + """ 16 SGR ANSI escape codes in traditional format + """ + x_labels, y_labels, codes = term16.ansicodes() + + print(' '.join(y_labels)) + for i, code in enumerate(codes): + print(x_labels[i], end='') + print(' '.join(code)) + + def display(): + """ display 16 color info + """ + print("System colors:") + colors = term16._render() + padding = ' ' if options.padding else '' + for r in colors: + print(padding.join(i for i in r)) + if options.padding: print() + + +class term256(term16): + """ eg. xterm-256 + """ + + @_cached + def _rgb_lookup(): + """ color rgb lookup dict + >>> term256._rgb_lookup()[16] + (0, 0, 0) + >>> term256._rgb_lookup()[128] + (175, 0, 215) + >>> term256._rgb_lookup()[255] + (238, 238, 238) + """ + # color increment is based on xterm/rxvt palette + cincr = [0] + [95+40*n for n in range(5)] + color_rgb = [rgb(i, j, k) + for i in cincr for j in cincr for k in cincr] + color_rgb = dict(zip(range(16, len(color_rgb)+16), color_rgb)) + greys = [rgb(*((n,)*3)) for n in range(8, 248, 10)] + greys = dict(zip(range(232, 256), greys)) + color_rgb.update(greys) + return color_rgb + + def _to_rgb(n): + """ Convert color value to rgb tuple. + >>> term256._to_rgb(128) + (175, 0, 215) + """ + return term256._rgb_lookup()[n] + + def _rgb_color_table(): + """ 256 color info + >>> term256._rgb_color_table()[0][0] + '\\x1b[38;5;16m 16: \\x1b[38;5;255m\\x1b[48;5;16m#000000\\x1b[0m' + >>> term256._rgb_color_table()[-1][-1] + '\\x1b[38;5;255m 255: \\x1b[38;5;16m\\x1b[48;5;255m#eeeeee\\x1b[0m' + """ + rgbl = term256._rgb_lookup() + label_num = "% 4d: " + label_val = "%s" + if options.foreground: + render = lambda n: fg_escape % n + label_num % n + \ + label_val % str(rgbl[n]) + clear + else: + render = lambda n: fg_escape % n + label_num % n + \ + fg_escape % (16 if rgbl[n].is_light() else 255) \ + + bg_escape % n + label_val % str(rgbl[n]) + clear + return [[render(n) for n in [i+j for j in range(6)]] + for i in range(16, 256, 6)] + + def _rgb_display(): + """ display colors with rgb hex info + """ + colors = term256._rgb_color_table() + padding = ' ' if options.padding else '' + while colors: + rows, colors = colors[:6], colors[6:] + if not options.horizontal: + rows = zip(*rows) + for r in rows: + print(padding.join(i for i in r)) + if options.padding: print() + print() + + def _colors(): + """ 256 color numbers + """ + return [[i+j for j in range(6)] for i in range(16, 232, 6)] + + def _greyscale(): + """ 256 greyscale numbers + """ + return [[i+j for j in range(12)] for i in range(232, 256, 12)] + + def _render(palette): + """ compact 256 color info + """ + if options.foreground: + esc = lambda n: fg_escape % n + render = lambda n: term256.label(n, esc) + clear + else: + esc = lambda n: fg_escape % \ + (16 if term256._to_rgb(n).is_light() else 255) + render = lambda n: bg_escape % n + term256.label(n, esc) + clear + return [[render(n) for n in i] for i in iter(palette)] + + def _compact_display(): + """ display colors in compact format + """ + colors = term256._render(term256._colors()) + if options.cube: + _cube_display(colors) + elif options.block: + _block_display(colors) + print() + greys = term256._render(term256._greyscale()) + padding = ' ' if options.padding else '' + for r in greys: + print(padding.join(i for i in r)) + if options.padding: print() + + def display(): + """ display 256 color info (+ 16 in compact format) + """ + if options.rgb: + print("Xterm RGB values for 6x6x6 color cube and greyscale.") + print() + term256._rgb_display() + else: + term16.display() + print() + print("6x6x6 color cube and greyscale:") + term256._compact_display() + + +class term88(term16): + """ xterm-88 or urxvt + """ + + @_cached + def _rgb_lookup(): + """ color rgb lookup dict + """ + # color increment is based on rxvt palette + cincr = [0, 0x8b, 0xcd, 0xff] + color_rgb = [rgb(i, j, k) + for i in cincr for j in cincr for k in cincr] + color_rgb = dict(zip(range(16, len(color_rgb)+16), color_rgb)) + greys = [rgb(*((n,)*3)) + for n in [0x2e, 0x5c, 0x73, 0x8b, 0xa2, 0xb9, 0xd0, 0xe7]] + greys = dict(zip(range(80, 88), greys)) + color_rgb.update(greys) + return color_rgb + + def _to_rgb(n): + """ Convert color value to rgb tuple. + """ + return term88._rgb_lookup()[n] + + def _rgb_color_table(): + """ 88 color info + """ + rgbl = term88._rgb_lookup() + label_num = "% 4d: " + label_val = "%s" + if options.foreground: + render = lambda n: fg_escape % n + label_num % n + \ + label_val % str(rgbl[n]) + clear + else: + render = lambda n: fg_escape % n + label_num % n + \ + fg_escape % (16 if rgbl[n].is_light() else 87) \ + + bg_escape % n + label_val % str(rgbl[n]) + clear + return [[render(n) for n in [i+j for j in range(4)]] + for i in range(16, 88, 4)] + + def _rgb_display(): + """ display colors with rgb hex info + """ + colors = term88._rgb_color_table() + while colors: + rows, colors = colors[:4], colors[4:] + for r in zip(*rows): + print(''.join(i for i in r)) + print() + + def _render(palette): + """ 88 color info + """ + if options.foreground: + esc = lambda n: fg_escape % n + render = lambda n: term88.label(n, esc) + clear + else: + esc = lambda n: fg_escape % \ + (16 if term88._to_rgb(n).is_light() else 87) + render = lambda n: bg_escape % n + term88.label(n, esc) + clear + return [[render(n) for n in i] for i in iter(palette)] + + def _colors(): + """ 88 color numbers + """ + return [[i+j for j in range(4)] for i in range(16, 80, 4)] + + def _greyscale(): + """ 88 greyscale numbers + """ + return [range(80, 88)] + + + def display(): + """ display 16 + 88 color info + """ + if options.rgb: + print("Xterm RGB values for 4x4x4 color cube and greyscale.") + print() + term88._rgb_display() + else: + padding = ' ' if options.padding else '' + term16.display() + print() + print("4x4x4 color cube and greyscale:") + colors = term88._render(term88._colors()) + if options.cube: + _cube_display(colors) + elif options.block: + _block_display(colors) + print() + greys = term88._render(term88._greyscale()) + for r in greys: + print(padding.join(i for i in r)) + +class rgb(tuple): + """ An RGB, (red, green, blue) tuple. Takes integers. + """ + def __new__(cls, r, g, b): + """ We want 3 colors. + """ + return super(rgb, cls).__new__(cls, (r, g, b)) + + def __str__(self): + """ Display in compact rgb format. + """ + return "#%02x%02x%02x" % self + + def is_light(self): + """ Is this color light (or dark). + """ + red, green, blue = self[0], self[1], self[2] + intensity = red*0.2126 + green*0.7152 + blue*0.0722 + return intensity > 127 + + +def _cube_display(colors): + """ Display color cube as color aligned flatten cube sides. + """ + padding = ' ' if options.padding else '' + if options.horizontal: + def _horizontal(colors): + size = int(sqrt(len(colors))) + for n in (n*size for n in range(size)): + colors[n:n+size] = zip(*colors[n:n+size]) + while colors: + rows, colors = colors[:size*2], colors[size*2:] + for n in range(size): + print(padding.join(i + for i in rows[n]+tuple(reversed(rows[n+size])))) + if options.padding: print(padding) + if colors: print() + _horizontal(colors) + else: #options.vertical - default + def _vertical(colors): + size = int(sqrt(len(colors))) + top = [colors[n:len(colors):size*2] for n in range(size)] + bottom = [colors[n+size:len(colors):size*2] + for n in reversed(range(size))] + for group in [top, bottom]: + for rows in group: + for r in rows: + print(padding.join(i for i in r), end=' ') + if options.padding: print(padding, end=' ') + if options.padding: print() + print() + _vertical(colors) + +def _block_display(colors): + """ Display color cube as cube sides organized by color #s (default). + """ + padding = ' ' if options.padding else '' + size = int(sqrt(len(colors))) + if not options.horizontal: + for n in (n*size for n in range(size)): + colors[n:n+size] = zip(*colors[n:n+size]) + while colors: + half = size*(size//2) + rows, colors = colors[:half], colors[half:] + for n in range(size): + for r in rows[n:len(rows):size]: + print(padding.join(i for i in r), end=' ') + if options.padding: print(padding, end=' ') + if options.padding: print() + print() + if colors: print() + +def convert88to256(n): + """ 88 (4x4x4) color cube to 256 (6x6x6) color cube values + """ + if n < 16: + return n + elif n > 79: + return 234 + (3 * (n - 80)) + else: + def m(n): + "0->0, 1->1, 2->3, 3->5" + return n and n + n-1 or n + b = n - 16 + x = b % 4 + y = (b // 4) % 4 + z = b // 16 + return 16 + m(x) + (6 * m(y) + 36 * m(z)) + +def convert256to88(n): + """ 256 (6x6x6) color cube to 88 (4x4x4) color cube values + """ + if n < 16: + return n + elif n > 231: + if n < 234: + return 0 + return 80 + ((n - 234) // 3) + else: + def m(n, _ratio=(4./6.)): + if n < 2: + return int(ceil(_ratio*n)) + else: + return int(_ratio*n) + b = n - 16 + x = b % 6 + y = (b // 6) % 6 + z = b // 36 + return 16 + m(x) + (4 * m(y) + 16 * m(z)) + +def _terminal(): + """ detect # of colors supported by terminal and return appropriate + terminal class + """ + curses.setupterm() + num_colors = curses.tigetnum('colors') + if num_colors > 0: + return {16:term16, 88:term88, 256:term256}.get(num_colors, term16) + +def main(): + if options.test: + print("Running tests...") + import doctest + doctest.testmod() + print("Done.") + elif options.reduce: + v = convert256to88(options.reduce) + # reconvert back to display reduction in context + print("%s (equivalent to 256 value: %s)" % (v, convert88to256(v))) + elif options.expand: + print(convert88to256(options.expand)) + else: + term = _terminal() + if term is None: + print("Your terminal reports that it has no color support.") + else: + if options.ansicodes: + print(getdoc(term16.ansicodes_display)) + term16.ansicodes_display() + else: + term.display() + +if __name__ == "__main__": + main() diff --git a/util/zram.sh b/util/zram.sh new file mode 100755 index 0000000..bacfb1f --- /dev/null +++ b/util/zram.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +if [ $(id -u) -ne 0 ] ; then + echo "Please run as root" + exit 1; +fi + + +start() { + modprobe zram + echo lz4 > /sys/block/zram0/comp_algorithm + echo 2G > /sys/block/zram0/disksize + + mkswap --label zram0 /dev/zram0 + swapon --priority 100 /dev/zram0 + + sysctl vm.swappiness=100 +} + +stop() { + swapoff /dev/zram0 + modprobe -r zram + + sysctl vm.swappiness=60 +} + +$1 diff --git a/vim-build.sh b/vim-build.sh deleted file mode 100755 index 7c11e40..0000000 --- a/vim-build.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh -set -e -set -x - -./configure \ - --enable-multibyte \ - --with-x \ - --enable-perlinterp=yes \ - --enable-pythoninterp=yes \ - --enable-python3interp=yes \ - --enable-rubyinterp=yes \ - --with-gnome \ - --prefix=$HOME/pkg - -make -j$(nproc) -make install diff --git a/vimrc b/vimrc new file mode 100644 index 0000000..393a4c4 --- /dev/null +++ b/vimrc @@ -0,0 +1,50 @@ +" See the full vim configuration: https://git.riedstra.us/mitch/vim-cfg.git/about/ +" Basic vimrc for systems you don't want to copy the full one to +set encoding=utf-8 " The encoding displayed. +set fileencoding=utf-8 " The encoding written to file. +set background=dark " Since most terminals I have dark backgrounds +set nu " Line 'nu'mbers +set listchars=tab:▸\ ,eol:¬,trail:• " Listchars are used to show normally + " invisible chars such as tabs, EOL and + " trailing whitespace +" set listchars=tab:\|\ " Alternative listchars w/o special chars. +set colorcolumn=80 " Sets a "coloured" coloumn to tell you where your line + " breaks should be so you don't piss off people using + " a terminal. +set ic " Case insensitive search by default +set hls " Highlight my searches by default +set updatecount=0 " Do not write swap files +set nocompatible " Don't be compatbile with 'vi' +set tabstop=4 " Tab width +set shiftwidth=4 +set noexpandtab " Do **NOT** turn tabs into spaces by default +" Be smart about the mouse +set mouse+=a +if &term =~ '^screen' + " tmux knows the extended mouse mode + set ttymouse=xterm2 +endif +syntax on " Syntax highlighting by default + + +set nomodeline " I know how to setup my editor, I don't need your + " changes to my vim configuration. + +" Use \-n in normal mode to toggle line numbers +nmap n :set invnu +" Use \-l in normal mode to toggle listchars +nmap l :set list! + +" Use \-s to pop open a spelling menu. use ]s to search forwards and [s to go +" backwards. +" Apparently this also doesn't work if spell checking isn't enabled +" at the time you enable it. +set spell +nnoremap \s ea +set nospell + +" set hidden " This will allow you to change buffers w/o saving + +" Omni completion, c-x c-o in insert/append mode +" filetype plugin on +" set omnifunc=syntaxcomplete#Complete diff --git a/zram.sh b/zram.sh deleted file mode 100755 index bacfb1f..0000000 --- a/zram.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh - -if [ $(id -u) -ne 0 ] ; then - echo "Please run as root" - exit 1; -fi - - -start() { - modprobe zram - echo lz4 > /sys/block/zram0/comp_algorithm - echo 2G > /sys/block/zram0/disksize - - mkswap --label zram0 /dev/zram0 - swapon --priority 100 /dev/zram0 - - sysctl vm.swappiness=100 -} - -stop() { - swapoff /dev/zram0 - modprobe -r zram - - sysctl vm.swappiness=60 -} - -$1 -- cgit v1.2.3