dotless

automated dotfiles setup for all my systems
git clone git://git.daat.foo/dotless.git
Log | Files | Refs | README | LICENSE

commit d93922195e31059fa957c20ee1f96b528c808ae9
parent 59b73ffa9266bd85bfae1c6a6e6e80e18a43f452
Author: cowmonk <cowmonk@based.pt>
Date:   Thu,  9 Apr 2026 02:50:37 +0000

POSIX compliance and new configurations

Making the Makefile actually posix by enforcing pdpmake --posix. Had to
remove all % pattern rules. It's whatever, makes the Makefile actually
more readable.

yash is my preferred shell, so, I decided to add this to my
configuration, hopefully it's adaquate.

Diffstat:
MMakefile | 103++++++++++++++++++++++++++++++++++---------------------------------------------
MREADME | 9+++++----
Mconfig.mk | 3++-
Afiles/config/yash/profile | 228+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Afiles/config/yash/rc | 5+++++
5 files changed, 284 insertions(+), 64 deletions(-)

diff --git a/Makefile b/Makefile @@ -9,74 +9,59 @@ SHELL = /bin/sh include config.mk -.PHONY: all build install clean distclean +.PHONY: all build pull extract install clean distclean all: build -$(SRCDIR)/%.tar.gz: +$(SRCDIR)/$(NAME_dwm).tar.gz: @[ -d "$(SRCDIR)" ] || mkdir -p "$(SRCDIR)" - @echo "pulling all sources..." - @if [ ! -f "$(SRCDIR)/$(NAME_dwm).tar.gz" ]; then \ - echo "pulling ${NAME_dwm}"; \ - curl -fLo "${SRCDIR}/${NAME_dwm}.tar.gz" ${URL_dwm}; \ - else \ - printf "> \033[92malready pulled $(NAME_dwm).tar.gz...\n\033[0m"; \ - fi - @if [ ! -f "$(SRCDIR)/$(NAME_st).tar.gz" ]; then \ - echo "pulling ${NAME_st}"; \ - curl -fLo "${SRCDIR}/${NAME_st}.tar.gz" ${URL_st}; \ - else \ - printf "> \033[92malready pulled $(NAME_st).tar.gz...\n\033[0m"; \ - fi - @if [ ! -f "$(SRCDIR)/$(NAME_dmenu).tar.gz" ]; then \ - echo "pulling ${NAME_dmenu}"; \ - curl -fLo "${SRCDIR}/${NAME_dmenu}.tar.gz" ${URL_dmenu}; \ - else \ - printf "> \033[92malready pulled $(NAME_dmenu).tar.gz...\n\033[0m"; \ - fi - @if [ ! -f "$(SRCDIR)/$(NAME_slstatus).tar.gz" ]; then \ - echo "pulling ${NAME_slstatus}"; \ - curl -fLo "${SRCDIR}/${NAME_slstatus}.tar.gz" ${URL_slstatus}; \ - else \ - printf "> \033[92malready pulled $(NAME_slstatus).tar.gz...\n\033[0m"; \ - fi - @printf "\033[1mpulled all sources!\n\033[0m" - -$(EXTDIR)/%: $(SRCDIR)/%.tar.gz - @echo "extracting..." + @echo "pulling ${NAME_dwm}" + @curl -fLo "${SRCDIR}/${NAME_dwm}.tar.gz" "${URL_dwm}" + +$(SRCDIR)/$(NAME_st).tar.gz: + @[ -d "$(SRCDIR)" ] || mkdir -p "$(SRCDIR)" + @echo "pulling ${NAME_st}" + @curl -fLo "${SRCDIR}/${NAME_st}.tar.gz" "${URL_st}" + +$(SRCDIR)/$(NAME_dmenu).tar.gz: + @[ -d "$(SRCDIR)" ] || mkdir -p "$(SRCDIR)" + @echo "pulling ${NAME_dmenu}" + @curl -fLo "${SRCDIR}/${NAME_dmenu}.tar.gz" "${URL_dmenu}" + +$(SRCDIR)/$(NAME_slstatus).tar.gz: + @[ -d "$(SRCDIR)" ] || mkdir -p "$(SRCDIR)" + @echo "pulling ${NAME_slstatus}" + @curl -fLo "${SRCDIR}/${NAME_slstatus}.tar.gz" "${URL_slstatus}" + +$(EXTDIR)/$(NAME_dwm): $(SRCDIR)/$(NAME_dwm).tar.gz @[ -d "$(EXTDIR)" ] || mkdir -p "$(EXTDIR)" - @if [ ! -f "$(EXTDIR)/$(NAME_dwm)" ]; then \ - echo "extracting $(NAME_dwm).tar.gz..."; \ - tar -xzf "$(SRCDIR)/$(NAME_dwm).tar.gz" -C "$(EXTDIR)"; \ - else \ - printf "> \033[92malready extracted $(NAME_dwm).tar.gz...\n\033[0m"; \ - fi - @if [ ! -f "$(SRCDIR)/$(NAME_st)" ]; then \ - echo "extracting $(NAME_st).tar.gz..."; \ - tar -xzf "$(SRCDIR)/$(NAME_st).tar.gz" -C "$(EXTDIR)"; \ - else \ - printf "> \033[92malready extracted $(NAME_st).tar.gz...\n\033[0m"; \ - fi - @if [ ! -f "$(SRCDIR)/$(NAME_dmenu)" ]; then \ - echo "extracting $(NAME_dmenu).tar.gz..."; \ - tar -xzf "$(SRCDIR)/$(NAME_dmenu).tar.gz" -C "$(EXTDIR)"; \ - else \ - printf "> \033[92malready extracted $(NAME_dmenu).tar.gz...\n\033[0m"; \ - fi - @if [ ! -f "$(SRCDIR)/$(NAME_slstatus)" ]; then \ - echo "extracting $(NAME_slstatus).tar.gz..."; \ - tar -xzf "$(SRCDIR)/$(NAME_slstatus).tar.gz" -C "$(EXTDIR)"; \ - else \ - printf "> \033[92malready extracted $(NAME_slstatus).tar.gz...\n\033[0m"; \ - fi - @printf "\033[1mextracted all sources!\n\033[0m" + @echo "extracting $(NAME_dwm).tar.gz..." + @tar -xzf "$(SRCDIR)/$(NAME_dwm).tar.gz" -C "$(EXTDIR)" + +$(EXTDIR)/$(NAME_st): $(SRCDIR)/$(NAME_st).tar.gz + @echo "extracting $(NAME_st).tar.gz..." + @tar -xzf "$(SRCDIR)/$(NAME_st).tar.gz" -C "$(EXTDIR)" -build: $(EXTDIR)/% +$(EXTDIR)/$(NAME_dmenu): $(SRCDIR)/$(NAME_dmenu).tar.gz + @echo "extracting $(NAME_dmenu).tar.gz..." + @tar -xzf "$(SRCDIR)/$(NAME_dmenu).tar.gz" -C "$(EXTDIR)" +$(EXTDIR)/$(NAME_slstatus): $(SRCDIR)/$(NAME_slstatus).tar.gz + @echo "extracting $(NAME_slstatus).tar.gz..." + @tar -xzf "$(SRCDIR)/$(NAME_slstatus).tar.gz" -C "$(EXTDIR)" + +pull: $(SRCDIR)/$(NAME_dwm).tar.gz $(SRCDIR)/$(NAME_st).tar.gz $(SRCDIR)/$(NAME_dmenu).tar.gz $(SRCDIR)/$(NAME_slstatus).tar.gz + @printf "\033[1mpulled all sources!\n\033[0m" + +extract: pull + @printf "\033[1mextracted all sources!\n\033[0m" -install: +build: extract + +install: build clean: distclean: clean - @rm -rf "$(SRCDIR)" + @rm -r "$(SRCDIR)" + @rm -r "$(EXTDIR)" diff --git a/README b/README @@ -13,7 +13,7 @@ Problem is that, running on a pure tty is tedious work, however since all my sys utilities before I get a GUI, it makes sense for me to create a "POSIX" makefile system to build all of it. However, this is intended to be easily "customizable", so users should be able to easily configure anything. -This has been tested with pdpmake (though without --posix), it will work with any competent make build system on any Unix-y +This has been tested with pdpmake (with --posix), it will work with any competent make build system on any Unix-y platform (NetBSD/OpenBSD/FreeBSD). Solaris support isn't planned, but it's trivial to get it working because the nature of suckless. @@ -22,6 +22,7 @@ Building There are several options, however the defaults are very serviceable for any Linux distro on a desktop. Here are the options (these are parsed as ENV variables): - PREFIX - install prefix (default is `/`) + - YASH - install yash configuration - LAPTOP - enables certain keybinds (media keys) and battery monitoring - SCRIPTS - installs optional scripts (auto-enabled if LAPTOP mode is enabled) - VOL - default volume step (primarily for LAPTOP mode); if unset default is 5 @@ -31,10 +32,10 @@ There are several options, however the defaults are very serviceable for any Lin - FONT - default font for dmenu/dwm; passed as a string (default: cozette:size=10) - ST_FONT - default font for st (terminal handles font weirdly) (default: cozette:size=12) -Here is an example of a user using dotless for a laptop installing to a /usr/local prefix on OpenBSD: +Here is an example of a user using dotless for a laptop installing to a /usr/local prefix on OpenBSD whist using yash shell: ```sh -$ make PREFIX=/usr/local LAPTOP=1 BSD=1 -$ doas make PREFIX=/usr/local LAPTOP=1 BSD=1 install # yes, I prefer opendoas +$ make PREFIX=/usr/local LAPTOP=1 BSD=1 YASH=1 +$ doas make PREFIX=/usr/local LAPTOP=1 BSD=1 YASH=1 install # yes, I prefer opendoas ``` Patches diff --git a/config.mk b/config.mk @@ -5,12 +5,13 @@ # paths PREFIX ?= / -TOP = $(shell pwd) +TOP = $(PWD) SRCDIR = $(TOP)/sources EXTDIR = $(TOP)/extracted # Optional configurations LAPTOP ?= 0 # laptop mode enables certain keybinds and battery monitoring +YASH ?= 0 # install yash configuration SCRIPTS ?= 0 # whether or not to install the useful scripts (auto enable if laptop mode is enabled) VOL ?= 0 # default volume step percent (default is 5 when at 0) BSD ?= 0 # enables support for the BSDs (in config.mk and stuff) diff --git a/files/config/yash/profile b/files/config/yash/profile @@ -0,0 +1,228 @@ +# +# yash profile +# +# my "custom" funni configuration +# tbh it's just cherry picked configuration from the default config +# + +set --brace-expand +set --extended-glob +set --no-unset + +if command --identify --builtin-command history >/dev/null; then + + # don't save commands starting with a space in history + set --hist-space + + # prevent clearing history by accident + history() + if [ -t 0 ] && ( + for arg do + case "${arg}" in + (-[drsw]?* | --*=*) ;; + (-*c*) exit;; + esac + done + false + ) then + printf 'history: seems you are trying to clear the whole history.\n' >&2 + printf 'are you sure? (yes/no) ' >&2 + case "$(head -n 1)" in + ([Yy]*) command history "$@";; + (*) printf 'history: cancelled.\n' >&2;; + esac + else + command history "$@" + fi + +fi + +# if yash is built with line-editing enabled... +if command --identify --builtin-command bindkey >/dev/null; then + # print job status update ASAP, but only while line-editing + set --notify-le + + # some terminfo data are broken; meta flags have to be ignored for UTF-8 + set --le-no-conv-meta + + # enable command line prediction + set --le-predict + + set -o vi +fi + +case $- in (*m*) + trap - TSTP TTIN TTOU +esac + +# variables needed for command history + +if ! [ "${HISTFILE-}" ]; then + HISTFILE=${XDG_STATE_HOME:-~/.local/state}/yash/history + + # handle old default history path + if [ -f ~/.yash_history ]; then + printf 'Note: The default history file location has been changed to "%s".\n' "$HISTFILE" >&2 + HISTFILE=~/.yash_history + printf 'Please consider moving the existing file from the current location "%s".\n' "$HISTFILE" >&2 + fi +fi + +# create HISTFILE parent directory if missing +! [ -d "${HISTFILE%/*}" ] && mkdir -p "${HISTFILE%/*}" + +HISTSIZE=5000 + +# HISTRMDUP makes prediction less accurate +# HISTRMDUP=500 + +# default mail check interval is too long +MAILCHECK=0 + +# emulate bash's $SHLVL +if [ "${_old_shlvl+set}" != set ]; then + _old_shlvl=${SHLVL-} +fi +SHLVL=$((_old_shlvl+1)) 2>/dev/null || SHLVL=1 +export SHLVL + +# initialize event handlers +COMMAND_NOT_FOUND_HANDLER=() +PROMPT_COMMAND=() +POST_PROMPT_COMMAND=() +YASH_AFTER_CD=() + +if [[ "$(id -u)" -eq 0 ]]; then + export YASH_PS1='\[\fro.\]${USER} [\[\fD.\] ${PWD/#"$HOME"/\~} \[\fro.\]]$ \[\fD.\]' +else + export YASH_PS1='\[\fgo.\]${USER} [\[\fD.\] ${PWD/#"$HOME"/\~} \[\fgo.\]]$ \[\fD.\]' +fi +export YASH_PS1S="\fD." + +# PS1='${LOGNAME}@${HOSTNAME%%.*} '$PS1 + +case "$TERM" in + (xterm|xterm[+-]*|gnome|gnome[+-]*|putty|putty[+-]*|cygwin) + _tsl='\033];' _fsl='\a' ;; + (*) + _tsl=$( (tput tsl 0; echo) 2>/dev/null | + sed -e 's;\\;\\\\;g' -e 's;;\\033;g' -e 's;;\\a;g' -e 's;%;%%;g') + _fsl=$( (tput fsl ; echo) 2>/dev/null | + sed -e 's;\\;\\\\;g' -e 's;;\\033;g' -e 's;;\\a;g' -e 's;%;%%;g') ;; +esac +# if terminal window title can be changed... +if [ "$_tsl" ] && [ "$_fsl" ]; then + # set terminal window title on each prompt + _set_term_title() + if [ -t 2 ]; then + printf "$_tsl"'%s@%s:%s'"$_fsl" "${LOGNAME}" "${HOSTNAME%%.*}" \ + "${${PWD:/$HOME/\~}/#$HOME\//\~\/}" >&2 + fi + PROMPT_COMMAND=("$PROMPT_COMMAND" '_set_term_title') + + # reset window title when changing host or user + ssh() { + if [ -t 2 ]; then printf "$_tsl"'ssh %s'"$_fsl" "$*" >&2; fi + command ssh "$@" + } + su() { + if [ -t 2 ]; then printf "$_tsl"'su %s'"$_fsl" "$*" >&2; fi + command su "$@" + } + sudo() { + if [ -t 2 ]; then printf "$_tsl"'sudo %s'"$_fsl" "$*" >&2; fi + command sudo "$@" + } + doas() { + if [ -t 2 ]; then printf "$_tsl"'doas %s'"$_fsl" "$*" >&2; fi + command doas "$@" + } +fi + +# define function that updates $_vcs_info and $_vcs_root +_update_vcs_info() { + typeset type branch + { + read --raw-mode type + read --raw-mode _vcs_root + read --raw-mode branch + } <( + exec 2>/dev/null + typeset COMMAND_NOT_FOUND_HANDLER= + while true; do + if [ -e .git ] || [ . -ef "${GIT_WORK_TREE-}" ]; then + printf 'git\n%s\n' "${GIT_WORK_TREE:-$PWD}" + git branch --no-color | sed -n '/^\*/s/^..//p' + exit + elif [ -d .hg ]; then + printf 'hg\n%s\n' "$PWD" + exec cat .hg/branch + elif [ -d .svn ]; then + printf 'svn\n' + _vcs_root=$(svn info --show-item=wc-root) + printf '%s\n' "$_vcs_root" + path=$(svn info --show-item=relative-url) + case $path in + (*/branches/*) + printf '%s\n' "${${path#*/branches/}%%/*}" + esac + exit + fi + if [ / -ef . ] || [ . -ef .. ]; then + exit + fi + \command cd -P .. + done + ) + case "$type#$branch" in + (hg#default) _vcs_info='hg';; + (git#master) _vcs_info='git';; + (*# ) _vcs_info="$type";; + (* ) _vcs_info="$type@$branch";; + esac + + YASH_PS1R="\fc.${_vcs_info}" +} +# update $_vcs_info on each prompt +PROMPT_COMMAND=("$PROMPT_COMMAND" '_update_vcs_info') + +# these aliases choose a version controlling program for the current directory +alias _vcs='${${_vcs_info:?not in a version-controlled directory}%%@*}' +alias ci='_vcs commit' +alias co='_vcs checkout' +alias di='_vcs diff' +alias log='_vcs log' +alias st='_vcs status' +alias up='_vcs update' + +# when a directory name is entered as a command, treat as "cd" +_autocd() +if [ -d "$1" ]; then + HANDLED=true + cd -- "$@" + break -i +fi +COMMAND_NOT_FOUND_HANDLER=("$COMMAND_NOT_FOUND_HANDLER" '_autocd "$@"') + +# treat command names starting with % as "fg" +_autofg() +if [ $# -eq 1 ]; then + case $1 in (%*) + HANDLED=true + fg "$1" + break -i + esac +fi +COMMAND_NOT_FOUND_HANDLER=("$COMMAND_NOT_FOUND_HANDLER" '_autofg "$@"') + +# print file type when executing non-executable files +_file_type() +if [ -e "$1" ] && ! [ -d "$1" ]; then + file -- "$1" +fi +COMMAND_NOT_FOUND_HANDLER=("$COMMAND_NOT_FOUND_HANDLER" '_file_type "$@"') + +bindkey --vi-insert '\^L' clear-and-redraw-all +bindkey --vi-command '\^L' clear-and-redraw-all + +# vim: set et sw=8 sts=8 tw=78 ft=sh: diff --git a/files/config/yash/rc b/files/config/yash/rc @@ -0,0 +1,5 @@ +. --autoload --no-alias $HOME/.config/yash/profile + +# put all custom configuration after this + +# vim: set et sw=8 sts=8 tw=78 ft=sh: