diff --git a/.config/git/prepare-commit-msg b/.config/git/prepare-commit-msg index e571f40..cab7202 100755 --- a/.config/git/prepare-commit-msg +++ b/.config/git/prepare-commit-msg @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/bash -e # # This hook adds a comment for guidance about the commit message # format on top of the default commit message. @@ -13,22 +13,53 @@ COMMIT_MSG_FILE=$1 COMMIT_SOURCE=$2 SHA1=$3 -beginswith() { case $2 in "$1"*) true;; *) false;; esac; } +# Function to test if a string starts with another string +beginswith() { + case $2 in + ("$1"*) return 0 ;; + (*) return 1 ;; + esac +} original=$(cat "$COMMIT_MSG_FILE") + if beginswith $'\n#' "$original"; then - # Find common path prefix of changed files - path=$(while read file - do test -z "$count" && common="$file" && count=$(expr length "$file") || - while expr substr "$file" 1 $count != substr "$common" 1 $count >/dev/null - do let count-- - done - done <<<"$(git -P diff --cached --name-only -r)" && - expr substr "$common" 1 "$count" | sed 's|.local/bin/scripts|bin|') || exit 0 - case "$path" in ([0-9]-*) path="${path#*-}";; esac - { - # Remove initial dot, file extension, trailing slash/dash/underscore - echo "$path" | sed 's|^\.||;s|\.\([a-z]*\)$||;s|[/_-]\?$|: |' - echo "$original" - } > "$COMMIT_MSG_FILE" + + # Find common path prefix of changed files + path="" + count=0 + common="" + + while read -r file; do + if [ -z "$common" ]; then + common="$file" + count=${#file} + else + while [ $count -gt 0 ]; do + prefix=${file:0:$count} + common_prefix=${common:0:$count} + [ "$prefix" = "$common_prefix" ] && break + count=$((count - 1)) + done + fi + done < "$COMMIT_MSG_FILE" + fi diff --git a/.config/yadm/bootstrap b/.config/yadm/bootstrap index aad7322..a09a55b 100755 --- a/.config/yadm/bootstrap +++ b/.config/yadm/bootstrap @@ -9,12 +9,14 @@ link() { # So that bootstrapping works right after cloning with the correct env variables source "$HOME/.zshenv" +# TODO: Setup instalee + SECTION "Dotfiles Preparation" highlight "Remove conflicting Manjaro Sway Dotfiles" rmexist() { for arg - do test -e "$arg" && echo -n "$arg: " && rm -vrI "$arg" + do test -e "$arg" && printf "$arg: " && rm -vrI "$arg" done } rmexist "$XDG_CONFIG_HOME/nvim/init.lua" "$HOME/.emacs.d/" @@ -80,8 +82,9 @@ subhighlight "Setup kakoune plugin loader" cloneshallow plug.kak robertmeta "$XDG_CONFIG_HOME/kak/plugins/plug.kak" # TODO kakoune research: quit doc buffer, multi cursor, work on line +# TODO first brew install - insert brew bundle? instalee migration from bundle? subhighlight 'Doom Emacs' -doom sync +git clone --depth 1 https://github.com/hlissner/doom-emacs ${XDG_CONFIG_HOME:-$HOME/.config}/emacs && ${XDG_CONFIG_HOME:-$HOME/.config}/emacs/bin/doom install case $(uname) in (Darwin) exit 0;; esac # LINUX SPECIFIC diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc index 7504b00..d8d541f 100644 --- a/.config/zsh/.zshrc +++ b/.config/zsh/.zshrc @@ -5,7 +5,7 @@ if test "$PWD" = "$HOME" && test "$0" != "$SHELL"; then timew | head -3 fi 2>/dev/null || return 0 -ls -F --color=always +LSCOLORS=${LSCOLORS:-Ex} ls -F --color=always # Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.config/zsh/.zshrc. # Initialization code that may require console input (password prompts, [y/n] diff --git a/.zshenv b/.zshenv index 98ffb8e..3d63ed7 100644 --- a/.zshenv +++ b/.zshenv @@ -89,6 +89,7 @@ BIN="$HOME/.local/bin" test -d "$XDG_DATA_HOME/gem/ruby" && ruby_bins="$(ls -d $XDG_DATA_HOME/gem/ruby/*/bin 2>/dev/null | head -1)" export PATH="$BIN/scripts:$BIN:$RBENV_ROOT/shims:$PATH:$XDG_CONFIG_HOME/emacs/bin:$N_PREFIX:$GOPATH/bin:$ANDROID_SDK_ROOT/platform-tools:$CARGO_HOME/bin:$KREW_ROOT/bin:$ruby_bins:$HOME/.rvm/bin" +# TODO this is too early - editors may later be added to PATH export ALTERNATE_EDITOR="$( if command -v nvim >/dev/null then echo nvim