From c647431f4ee2cb74eea18fda2d6eb23c7a463c52 Mon Sep 17 00:00:00 2001 From: xerus2000 <27jf@pm.me> Date: Mon, 19 Apr 2021 10:39:08 +0200 Subject: [PATCH] config: little shortcut adjustments --- .config/doom/config.el | 2 ++ .config/fd/ignore | 7 +++++-- .config/shell/functions | 23 ++++++++++++++++------- .local/bin/scripts/st-diff | 17 ++++++++++++----- 4 files changed, 35 insertions(+), 14 deletions(-) diff --git a/.config/doom/config.el b/.config/doom/config.el index a827245..4a5a332 100644 --- a/.config/doom/config.el +++ b/.config/doom/config.el @@ -148,6 +148,7 @@ (let ((current-prefix-arg '(4))) (call-interactively 'org-export-dispatch)) ) + ;; TODO name file according to subtree headline (defun org-export-dispatch-custom-date () (interactive) (let ((org-time-stamp-custom-formats @@ -176,6 +177,7 @@ "t" 'org-todo-or-insert "e" 'org-export-dispatch-custom-date "E" 'org-export-repeat + "n" 'org-add-note "d=" 'org-timestamp-up-week "rt" 'org-change-todo-in-region "ra" 'org-change-tag-in-region diff --git a/.config/fd/ignore b/.config/fd/ignore index 5bbb844..7c4b4ea 100644 --- a/.config/fd/ignore +++ b/.config/fd/ignore @@ -1,11 +1,14 @@ -.Trash-1000/ +.*Trash-1000/ lost+found/ .sync/ -.stversions/ +.stfolder/ .gradle/ cache/ cmake_build/ dist_newstyle/ +node_modules/ build/ +generated/ +out/ diff --git a/.config/shell/functions b/.config/shell/functions index 8cf9269..823da02 100644 --- a/.config/shell/functions +++ b/.config/shell/functions @@ -26,10 +26,16 @@ which lsb_release >/dev/null && export DIST=$(lsb_release --id | cut -d' ' -f2) unalias rd 2>/dev/null rd() { - test -d "$1" && find "$1" -type d -empty -printf "Removing %p\n" -delete || rm "$@" + while test $# -gt 0 + do + test -d "$1" && find "$1" -maxdepth 1 -type d -empty -printf "Removing %p\n" -delete || rm -iv "$@" + shift + done } rr() { mv "$@" /tmp } +calc='rlwrap -a bc -l' + alias j='jrnl' jn() { jrnl -to today "$@" | bat --style=plain --pager="less +G" } alias jnc='jn -contains' @@ -51,6 +57,12 @@ alias edpart='sudoedit /etc/fstab && sudo findmnt --verify' highlight() { echo "$1" } alias dedup='awk '"'"'!a[$0]++'"'" +listconf() { + { cat "$conf_cache"; test -f "$conf_extra" && cat "$conf_extra"; + fd --hidden --type file --size -1m --max-depth 1 . ~; + fd --hidden --type file --size -1m --max-depth 3 . --full-path "$XDG_CONFIG_HOME" /etc } | dedup +} + edconf() { conf_cache_dir="$XDG_CACHE_HOME/edconf" conf_cache="$conf_cache_dir/files" @@ -58,11 +70,8 @@ edconf() { conf_extra="$XDG_CONFIG_HOME/edconf-extra" mkdir -p "$conf_cache_dir" touch "$conf_cache" + sel=$(listconf | fzf -1 -0 --tiebreak=end,length --preview 'bat --color=always --style=numbers --line-range :200 {}' --query="$1" --history "$conf_cache_dir/searches") # | xargs file | grep text | cut -d':' -f1 # this filters out non-text files, but it's ridiculously slow - sel="$({ cat "$conf_cache"; test -f "$conf_extra" && cat "$conf_extra"; - fd --hidden --type file --size -1m --max-depth 1 . ~; - fd --hidden --type file --size -1m --max-depth 3 . --full-path "$XDG_CONFIG_HOME" /etc } | - dedup | fzf -1 -0 --tiebreak=end,length --preview 'bat --color=always --style=numbers --line-range :200 {}' --query="$1" --history "$conf_cache_dir/searches")" test "$sel" && ((echo "$sel" | cat - "$conf_cache" | head -30 >"$conf_tmp" && mv "$conf_tmp" "$conf_cache") & edit "$sel") } @@ -88,7 +97,7 @@ edbin() { alias l="ls -l --almost-all --human-readable --group-directories-first --file-type" cd() { - test ! -d "$1" && test $# -eq 1 && dir=$(find "$DATA" -maxdepth 2 -type d -name "$1*" | head -1) && + test ! -d "$1" && test $# -eq 1 && dir=$(f --glob "$1*" "$DATA" --maxdepth 2 --type d --max-results 1) && test -n "$dir" && cd "$dir" && return builtin cd $1 && command ls --file-type --group-directories-first --color=always --format=vertical -w $COLUMNS | head -3 @@ -269,7 +278,7 @@ cl() { # FILES -alias f="noglob $(test -x "$(which fd)" && echo fd || echo "fdfind") --hidden --no-ignore-vcs --one-file-system" +alias f="noglob $(which fd >/dev/null && echo fd || echo fdfind) --hidden --no-ignore-vcs --one-file-system" #alias f='find -not -path "*.sync*" -and -not \( -name daten -prune \)' #alias f1='find -mindepth 1 -maxdepth 1' diff --git a/.local/bin/scripts/st-diff b/.local/bin/scripts/st-diff index 325422c..8ce6c9f 100755 --- a/.local/bin/scripts/st-diff +++ b/.local/bin/scripts/st-diff @@ -1,6 +1,13 @@ #!/bin/sh -dif "$(st-unarchive "$1")" "$@" -test "$?" -eq "2" && exit 1 -echo "y to restore" -read answer -test "$answer" = "y" && st-restore "$1" || exit 0 +if test "$#" -gt 0 + then + dif "$(st-unarchive "$1")" "$@" + test "$?" -eq "2" && exit 1 + echo "y|r to restore, n|d to delete" + read reply + case "$reply" in + (y|r) st-restore "$1";; + (n|d) rm -v "$1";; + esac + else find -name '*sync-conflict*' -exec st-diff '{}' \; +fi