aboutsummaryrefslogtreecommitdiffstats
path: root/etc/ksh
diff options
context:
space:
mode:
authorensa <@>2023-02-04 20:03:47 -0800
committerensa <@>2023-02-04 20:52:52 -0800
commit75ee668954833ab6ba9287ed5eb16a9957edcac2 (patch)
tree07d9f88939ab0fd93d93c6f4ddbbc7b548a812f0 /etc/ksh
parentebae3707b36e9a83014ef08271d75bd9826bb999 (diff)
downloadcfg-75ee668954833ab6ba9287ed5eb16a9957edcac2.tar.gz
restructure, cleanups, greener pastures, new additions
config and data are now etc and share, to better match my homedir bin: generally, shellcheck errors (where there's actually a problem) have been fixed bother now includes alternate support for libnotify as well as my notif comm-sel now loops, so spawning programs doesn't require multiple runs fcard: my flashcard script accepts a tsv's path on $1, expecting: the word on column 1 the defintion on column 2 (optional) the section on column 3 if $2 is specified, only runs through lines with that string as its section fl: added aesgcm to the url detector string, because of profanity cleaned up urlparse now outputs the urls, one per line, making it more unixy flc: a quick script. uses fl's output to do what fl once did on its own. kbsetup now lacks escape xcape magic, qmk does that for me now. lh: general cleanup. added and removed a site for the video extract section metamv: gives arguments self-describing names based off metadata. mainly just for sorting FLACs off bandcamp this might not be entirely safe. use your own discretion. notif: xnotify wasn't happy with the previous design. it was sending notifications in pieces. this new one's an absolute mess but it works well, is smaller, and faster op: changed the pdf bit to allow variants smv: file is self-explanatory applies the pipeline specified in "$1" to every file name specified after it xbg: contains a fallback if xwallpaper isn't downloaded or its path is empty. yw: just a quick and dirty line for watching things in mpv using yt-dlp. etc: X11/: xprofile now includes the latest xnotify initialization. xresources prevents a variable collision also updates new xnotify resource names and changes which program to pipe the screen to. mpd/mpd.conf just updates to path structure. yt-dlp/* too many changes to describe. should be fairly self-explanatory. ksh/: prompt.ksh: the $ is green now. hooray! lf/lfrc: removed ttmsh function. i use my server for that now. newsboat/config: external-url-viewer is now non-python. zathura/zathurarc: font is now hermit. aliasrc: exa is no more. vis is also no more. youtube-dl is dead. long live yt-dlp. shrc: locale vars changed to ones than glibc is ok with
Diffstat (limited to 'etc/ksh')
-rw-r--r--etc/ksh/completions.ksh40
-rw-r--r--etc/ksh/diraliases17
-rw-r--r--etc/ksh/functions/l.10
-rw-r--r--etc/ksh/functions/man_complete4
-rw-r--r--etc/ksh/functions/mc4
-rw-r--r--etc/ksh/functions/mpvpin4
-rw-r--r--etc/ksh/functions/pcl8
-rw-r--r--etc/ksh/functions/pct8
-rw-r--r--etc/ksh/functions/pkg_complete5
-rw-r--r--etc/ksh/functions/update_completion_manpages8
-rw-r--r--etc/ksh/functions/update_completion_packages_obsd8
-rw-r--r--etc/ksh/functions/update_completion_pkg_inst_obsd4
-rw-r--r--etc/ksh/functions/update_completions6
-rw-r--r--etc/ksh/kshrc36
-rw-r--r--etc/ksh/prompt.ksh20
15 files changed, 182 insertions, 0 deletions
diff --git a/etc/ksh/completions.ksh b/etc/ksh/completions.ksh
new file mode 100644
index 0000000..11e0b10
--- /dev/null
+++ b/etc/ksh/completions.ksh
@@ -0,0 +1,40 @@
+#!/bin/ksh
+
+COMPLETIONFILES="$HOME_CACHE/ksh/precompletions"
+if ! [[ -d $COMPLETIONFILES ]]; then
+ mkdir -p $COMPLETIONFILES;
+fi
+#pkg_* completions
+if ! [[ -e $COMPLETIONFILES/packages ]]; then
+ update_completion_packages
+fi
+
+#set -A complete_pa -- $(<$COMPLETIONFILES/packages)
+set -A complete_pd -- $(ls -1 /var/db/pkg)
+#set -A complete_pi -- $complete_pa
+
+#man completions
+if ! [[ -e $COMPLETIONFILES/manpages ]]; then
+ update_completion_manpages
+fi
+
+#set -A complete_man -- $(<$COMPLETIONFILES/manpages)
+
+
+# pip completions
+
+set -A complete_pip_1 -- install download uninstall freeze list show check config search wheel hash help
+set -A complete_pip_2 -- --user
+set -A complete_pip_3 -- --upgrade
+
+# pass completions
+update_complete_pass() {
+ pass_list=$(pass ls)
+ set -A complete_pass_1 -- init passphrase add import show export ls
+ set -A complete_pass_2 -- $pass_list
+ set -A complete_pcl_1 -- $pass_list
+ set -A complete_pct_1 -- $pass_list
+}
+update_complete_pass
+pass_export() { pass export "$1" && update_complete_pass; }
+pass_show() { pass show "$1" && update_complete_pass; }
diff --git a/etc/ksh/diraliases b/etc/ksh/diraliases
new file mode 100644
index 0000000..f926827
--- /dev/null
+++ b/etc/ksh/diraliases
@@ -0,0 +1,17 @@
+#!/bin/ksh
+alias -d src=~/src
+alias -d git=~src/vcs
+alias -d vcs=~/local/src
+alias -d conf="$HOME_ETC"
+alias -d data="$HOME_DATA"
+alias -d cache="$HOME_CACHE"
+alias -d vis=~conf/vis
+alias -d ksh=~conf/ksh
+alias -d xdg=~/share/xdg
+alias -d doc=~xdg/doc
+alias -d pic=~xdg/pic
+alias -d mus=~xdg/mus
+alias -d vid=~xdg/vid
+alias -d dl=~xdg/dl
+alias -d bin=~/bin
+alias -d pass=~data/pass
diff --git a/etc/ksh/functions/l. b/etc/ksh/functions/l.
new file mode 100644
index 0000000..e4a759e
--- /dev/null
+++ b/etc/ksh/functions/l.
@@ -0,0 +1,10 @@
+#!/bin/ksh
+function l. {
+ if [[ -n "$1" ]]; then
+ ( cd "$1" 2>/dev/null ||\
+ { echo "$0: $1 - No such directory" >&2 ; exit; }
+ ls -d .* )
+ else
+ ls -d .*
+ fi
+}
diff --git a/etc/ksh/functions/man_complete b/etc/ksh/functions/man_complete
new file mode 100644
index 0000000..bab26dd
--- /dev/null
+++ b/etc/ksh/functions/man_complete
@@ -0,0 +1,4 @@
+#!/bin/ksh
+man_complete() {
+ set -A complete_man -- $(<~cache/ksh/precompletions/manpages)
+}
diff --git a/etc/ksh/functions/mc b/etc/ksh/functions/mc
new file mode 100644
index 0000000..db8a46f
--- /dev/null
+++ b/etc/ksh/functions/mc
@@ -0,0 +1,4 @@
+#!/bin/ksh
+mc() {
+ mkdir "$1" && cd "$1";
+}
diff --git a/etc/ksh/functions/mpvpin b/etc/ksh/functions/mpvpin
new file mode 100644
index 0000000..7fabc6c
--- /dev/null
+++ b/etc/ksh/functions/mpvpin
@@ -0,0 +1,4 @@
+#!/bin/ksh
+mpvpin() {
+ mpv --no-terminal --title "PIN" "$1" >/dev/null 2>&1 &
+}
diff --git a/etc/ksh/functions/pcl b/etc/ksh/functions/pcl
new file mode 100644
index 0000000..42ad224
--- /dev/null
+++ b/etc/ksh/functions/pcl
@@ -0,0 +1,8 @@
+#!/bin/ksh
+function pcl {
+ if [ -z "$2" ]; then
+ pass show "$1"|head -1|xclip -l 1 -r
+ else
+ pass show "$1"|head -1|xclip -sel c -l 1 -r
+ fi
+}
diff --git a/etc/ksh/functions/pct b/etc/ksh/functions/pct
new file mode 100644
index 0000000..b80abff
--- /dev/null
+++ b/etc/ksh/functions/pct
@@ -0,0 +1,8 @@
+#!/bin/ksh
+function pct {
+ if [ -z "$2" ]; then
+ pass show "$1"|tail -1|xclip -l 1 -r
+ else
+ pass show "$1"|tail -1|xclip -sel c -l 1 -r
+ fi
+}
diff --git a/etc/ksh/functions/pkg_complete b/etc/ksh/functions/pkg_complete
new file mode 100644
index 0000000..2664527
--- /dev/null
+++ b/etc/ksh/functions/pkg_complete
@@ -0,0 +1,5 @@
+#!/bin/ksh
+pkg_complete() {
+ set -A complete_pa -- $(<~cache/ksh/precompletions/packages)
+ set -A complete_pi -- $complete_pa
+}
diff --git a/etc/ksh/functions/update_completion_manpages b/etc/ksh/functions/update_completion_manpages
new file mode 100644
index 0000000..dc4e77a
--- /dev/null
+++ b/etc/ksh/functions/update_completion_manpages
@@ -0,0 +1,8 @@
+#!/bin/ksh
+update_completion_manpages() {
+ rm $XDG_CACHE_HOME/ksh/precompletions/manpages
+ for manpage in $(man -kw Nm~.);
+ do
+ basename $manpage|sed 's/\..*//'>>$XDG_CACHE_HOME/ksh/precompletions/manpages
+ done
+}
diff --git a/etc/ksh/functions/update_completion_packages_obsd b/etc/ksh/functions/update_completion_packages_obsd
new file mode 100644
index 0000000..2de477f
--- /dev/null
+++ b/etc/ksh/functions/update_completion_packages_obsd
@@ -0,0 +1,8 @@
+#!/bin/ksh
+update_completion_packages() {
+ if [[ -e /usr/local/share/ports-INDEX ]]; then
+ sed 's/|.*$//' /usr/local/share/ports-INDEX>$XDG_CACHE_HOME/ksh/precompletions/packages
+ else
+ echo "install portslist if you want the completions for pkg_add and pkg_info" > /dev/stderr
+ fi
+}
diff --git a/etc/ksh/functions/update_completion_pkg_inst_obsd b/etc/ksh/functions/update_completion_pkg_inst_obsd
new file mode 100644
index 0000000..0442a77
--- /dev/null
+++ b/etc/ksh/functions/update_completion_pkg_inst_obsd
@@ -0,0 +1,4 @@
+#!/bin/ksh
+update_completion_pkg_inst() {
+ ls -1 /var/db/pkg>$XDG_CACHE_HOME/ksh/precompletions/pkg_inst
+}
diff --git a/etc/ksh/functions/update_completions b/etc/ksh/functions/update_completions
new file mode 100644
index 0000000..cc1e82b
--- /dev/null
+++ b/etc/ksh/functions/update_completions
@@ -0,0 +1,6 @@
+#!/bin/ksh
+update_completions() {
+ update_completion_packages&
+ update_completion_pkg_inst&
+ update_completion_manpages&
+}
diff --git a/etc/ksh/kshrc b/etc/ksh/kshrc
new file mode 100644
index 0000000..28b3c0c
--- /dev/null
+++ b/etc/ksh/kshrc
@@ -0,0 +1,36 @@
+#!/bin/ksh
+. $HOME/etc/shrc
+KSHCONFIG="$HOME_ETC/ksh"
+FPATH="$HOME_ETC/ksh/functions"
+alias functions="cat \$FPATH/*|grep -vF '#!/bin/ksh'"
+
+HISTFILE="$HOME_DATA/ksh/histfile"
+if ! [[ -d $(dirname "$HISTFILE") ]]; then
+ mkdir -p $(dirname "$HISTFILE");
+fi
+HISTSIZE=5000
+HISTCONTROL="ignoredups"
+FCEDIT="$EDITOR"
+TMPDIR="$HOME_CACHE/ksh"
+if ! [[ -d "$TMPDIR" ]]; then
+ mkdir -p "$TMPDIR";
+fi
+# shortcut for cloning
+GITHUB="https://github.com"
+# make pfetch show what i want
+export PF_INFO="ascii title os host shell editor wm pkgs palette"
+# fix manpath so local man pages work
+# crude *bsd detection
+if [[ -d /usr/X11R6 ]]; then
+export MANPATH="/usr/share/man:/usr/X11R6/man:/usr/local/man:$HOME_DATA/man"
+else
+export MANPATH="/usr/share/man:/usr/local/share/man:$HOME_DATA/man"
+fi
+set -o vi
+
+#load ksh external configs
+[[ -f "$HOME_ETC/lf/lfcd.sh" ]] && . "$HOME_ETC/lf/lfcd.sh"
+[[ -f "$KSHCONFIG/diraliases" ]] && . "$KSHCONFIG/diraliases"
+[[ -f "$HOME_ETC/aliasrc" ]] && . "$HOME_ETC/aliasrc"
+[[ -f "$KSHCONFIG/completions.ksh" ]] && . "$KSHCONFIG/completions.ksh"
+[[ -f "$KSHCONFIG/prompt.ksh" ]] && . "$KSHCONFIG/prompt.ksh"
diff --git a/etc/ksh/prompt.ksh b/etc/ksh/prompt.ksh
new file mode 100644
index 0000000..070d394
--- /dev/null
+++ b/etc/ksh/prompt.ksh
@@ -0,0 +1,20 @@
+#!/bin/ksh
+SEP="▍"
+RSEP="▐"
+#_PS1='\[\033[';
+#_END='m\]';
+#_CLEAR=0; _FG_BLACK=30; _BG_BLACK=40
+#_BRIGHT=1; _FG_RED=31; _BG_RED=41
+#_DIM=2; _FG_GREEN=32; _BG_GREEN=42
+#_UNDER=4; _FG_YELLOW=33; _BG_YELLOW=43
+#_BLINK=5; _FG_BLUE=34; _BG_BLUE=44
+#_REVERSE=7; _FG_MAGENTA=35; _BG_MAGENTA=45
+#_HIDDEN=8; _FG_CYAN=36; _BG_CYAN=46
+# _FG_WHITE=37; _BG_WHITE=47
+vcs() {
+ if git status >/dev/null 2>&1; then
+ _GIT_BRANCH="$(git branch|grep -F '*'|sed 's/* //')"
+ printf ' %s' "$_GIT_BRANCH"
+ fi
+}
+PS1='\[\033[0;7;32m\]$?\[\033[0;32;45m\]$SEP\[\033[0;7;35m\]\A\[\033[0;35m\]$SEP\[\033[0;1;31m\]\u\[\033[0;32m\]@\[\033[1;34m\]\h\[\033[0;36m\]$RSEP\[\033[7m\]\w\[\033[0;36m\]$SEP\[\033[0;32m\]$(vcs)\n\[\033[0;32m\]\$\[\033[0m\] '