config

OpenBSD system configuration
git clone git://jacobedwards.org/config
Log | Files | Refs | README

commit 58d000277647cfca27248539a649462c7bbcd783
parent 180f2bfc439479082768ebdb893e85b3f58e46b2
Author: Jacob R. Edwards <jacobouno@protonmail.com>
Date:   Sun, 23 May 2021 19:51:18 -0700

Simplify ksh configuration and fix Makefile

- Move more complex functions to shell scripts
- Define all shell functions in kshrc

Diffstat:
Mlocal/Makefile | 7+++----
Alocal/bin/.local/bin/fed | 7+++++++
Alocal/bin/.local/bin/fp | 9+++++++++
Mlocal/ksh/.config/kshrc | 44++++++++++++++++++++++++++++++++++++++++----
Dlocal/shell/.local/share/shell/cd | 8--------
Dlocal/shell/.local/share/shell/etc | 4----
Dlocal/shell/.local/share/shell/gopher | 4----
Dlocal/shell/.local/share/shell/history | 5-----
Dlocal/shell/.local/share/shell/mpc | 21---------------------
Dlocal/shell/.local/share/shell/openbsd | 14--------------
Dlocal/shell/.local/share/shell/simple | 25-------------------------
Dlocal/shell/.local/share/shell/smc | 20--------------------
12 files changed, 59 insertions(+), 109 deletions(-)

diff --git a/local/Makefile b/local/Makefile @@ -1,4 +1,4 @@ -CFLAGS = -s.config=local/config -s.local=local +CFLAGS = MODULES =\ bin\ dalias\ @@ -9,7 +9,6 @@ MODULES =\ mpv\ profile\ readline\ - shell\ sxiv\ tmux\ urls\ @@ -24,7 +23,7 @@ MODULES =\ all: install install: - cast ${CFLAGS} -p ${MODULES} ${HOME} + cast -s.config=local/config -s.local=local ${CFLAGS} -p ${MODULES} ${HOME} uninstall: - rm ${CFLAGS} -v `cast -v ${MODULES} ${HOME}` + rm -v `cast ${CFLAGS} -v ${MODULES} ${HOME}` diff --git a/local/bin/.local/bin/fed b/local/bin/.local/bin/fed @@ -0,0 +1,7 @@ +#!/bin/sh +# Copyright 2021 Jacob R. Edwards +# License: GPLv3 +# +# fed -- feed in XDG_DATA_HOME + +cd "${XDG_DATA_HOME:-$HOME/.local/share}/feed" && exec feed "$@" diff --git a/local/bin/.local/bin/fp b/local/bin/.local/bin/fp @@ -0,0 +1,9 @@ +#!/bin/sh +# Copyright 2021 Jacob R. Edwards +# License: GPLv3 +# +# fp -- edit executable from path + +IFS=' +' +progs=$(which "$@") && ${EDITOR:-vi} "$progs" diff --git a/local/ksh/.config/kshrc b/local/ksh/.config/kshrc @@ -1,6 +1,6 @@ # ksh rc file -set -Xab -o vi -o physical -o pipefail +set -Xabu -o vi -o physical -o pipefail HISTFILE="${XDG_DATA_HOME:-$HOME/.local/share}/ksh/$(date +%Y/%m)" HISTSIZE=820000 @@ -10,6 +10,42 @@ PS3='3> ' PS4='4> ' mkdir -p "$(dirname $HISTFILE)" -eval "$(sed 's/^/alias -d /' <"${XDG_CONFIG_HOME:-$HOME/.config}/dalias")" -. include -include cd etc history smc openbsd private simple + +wdlog="${XDG_DATA_HOME:-$HOME/.local/share}/cd" + +# cd +cd() { builtin cd "$@" && echo "$PWD" >>"$wdlog" ;} +cdl() { uniq <"$wdlog" | stest -d ;} +cdr() cd "$(cdl | egrep "${@:-.}" | tail -1)" +cds() cd "$(pwd | sed "s!$1!$2!g")" + +# history +hl() cat "$HISTFILE" +hs() { hl | egrep "$@"; } + +# OpenBSD package management +pa() doas pkg_add "$@" +pd() doas pkg_delete "$@" +pdd() doas sh -c 'pkg_delete "$@" && pkg_delete -a' pdd "$@" +pi() pkg_info -q "$@" +pl() pkg_locate "${@:-.}" +plist() portslist "$@" +pr() pkgroot "$@" +pt() pkgtree "$@" +pu() doas pkg_add -u "$@" + +# simple +curl() command curl -sS "$@" +doas() command doas -- "$@" +dsu() doas su "$@" +fn() functions "$@" +ls() 9 ls "$@" + +# short +c() command "$@" +d() doas "$@" +e() egrep "$@" +f() ${EDITOR:-vi} "$@" +g() git "$@" +l() ${PAGER:-less} "$@" +t() tmux "$@" diff --git a/local/shell/.local/share/shell/cd b/local/shell/.local/share/shell/cd @@ -1,8 +0,0 @@ -# cd shell functions - -PWDLOG="${XDG_DATA_HOME:-$HOME/.local/share}/cd" - -cd() { builtin cd "$@" && echo "$PWD" >>"$PWDLOG" ;} -cdl() { uniq <"$PWDLOG" | stest -d ;} -cdr() cd "$(cdl | egrep "${@:-.}" | tail -1)" -cds() cd "$(pwd | sed "s!$1!$2!g")" diff --git a/local/shell/.local/share/shell/etc b/local/shell/.local/share/shell/etc @@ -1,4 +0,0 @@ -# shell functions - -fp() (x=$(which "$@") && $EDITOR $x) -fed() (cd "${XDG_DATA_HOME:-$HOME/.local/share}/feed" && feed "$@") diff --git a/local/shell/.local/share/shell/gopher b/local/shell/.local/share/shell/gopher @@ -1,4 +0,0 @@ -# gopher shell functions - -veronica() (IFS='?' && exec gawk "/v2/vs/?${@:?No query}" floodgap.com) -vs() veronica "$@" diff --git a/local/shell/.local/share/shell/history b/local/shell/.local/share/shell/history @@ -1,5 +0,0 @@ -# history shell functions - -hl() cat "$HISTFILE" -hs() { hl | egrep "$@"; } -k() r diff --git a/local/shell/.local/share/shell/mpc b/local/shell/.local/share/shell/mpc @@ -1,21 +0,0 @@ -# mpc shell functions - -m() mpc "$@" -mf() { test $# -gt 0 && export MPC_FORMAT="$@" || unset MPC_FORMAT ;} - -# player -mP() m prev "$@" -mn() m next "$@" -mp() m play "$@" - -# queue -ma() m add "$@" -mc() m -q clear "$@" -mca() { mc && ma "$@" ;} - -# playlist -ml() m playlist "$@" - -# database -mL() m listall "$@" -mu() m update -w "$@" diff --git a/local/shell/.local/share/shell/openbsd b/local/shell/.local/share/shell/openbsd @@ -1,14 +0,0 @@ -# OpenBSD shell functions - -ncpu() sysctl -n hw.ncpufound "$@" -load() sysctl -n vm.loadavg "$@" - -# package management -pa() doas pkg_add "$@" -pd() doas pkg_delete "$@" -pi() pkg_info -q "$@" -pl() pkg_locate "${@:-.}" -pq() portslist "$@" -pr() pkgroot "$@" -pt() pkgtree "$@" -pu() doas pkg_add -u "$@" diff --git a/local/shell/.local/share/shell/simple b/local/shell/.local/share/shell/simple @@ -1,25 +0,0 @@ -# simple shell functions - -ap() apropos "$@" -curl() command curl -sS "$@" -date() command date "${@:-+%F %T %z}" -doas() command doas -- "$@" -dsu() doas su "$@" -esed() sed -E "$@" -fn() functions "$@" -grep() egrep "$@" -ls() 9 ls "$@" -md() mkdir "$@" -rd() rmdir "$@" -reload() . "${ENV:?unset}" -sfind() find . -maxdepth 1 -mindepth 1 "$@" -tolower() tr '[:upper:]' '[:lower:]' -toupper() tr '[:lower:]' '[:upper:]' - -c() command "$@" -d() doas "$@" -e() egrep "$@" -f() $EDITOR "$@" -g() git "$@" -l() $PAGER "$@" -t() tmux "$@" diff --git a/local/shell/.local/share/shell/smc b/local/shell/.local/share/shell/smc @@ -1,20 +0,0 @@ -# smc shell functions - -m() smc "$@" - -# player -mP() m qu seek -1 -mn() m qu seek +1 -mp() m st pl - -# queue -ma() m qu add -mc() m qu cl -mca() m qu tr - -# playlist -ml() m qu li - -# database -mL() m db li -mu() m db up