refacts bash/profile setup

This commit is contained in:
2026-04-21 11:19:45 +02:00
parent 5bd960d386
commit f150ed2750
52 changed files with 3446 additions and 724 deletions

108
.bash/toolchains/vifm.sh Normal file
View File

@@ -0,0 +1,108 @@
#!/usr/bin/env bash
# VIFM configuration - migrated from .bash_vifm
vifm() {
\cat <<-"HELP"
Use bash build-in:
- cd (ch dir), ls or tree (list), find
- mkdir (make dir), touch (make file), rm (remove)
- cp (copy), mv (move+rename)
- cat (print file), head (print first lines), tail (print last lines)
- ln (link), chmod (change perm), chown (change owner)
- file/dir info: stat , file , mimetype
- cd stack: pushd, popd, dirs -v
Use helpers:
- rsync (copy), fd (verbo-less find), chafa (ascii images viewer)
- m (marks, `cd "$m<name>"`), cd-kdialog
- trash-* (trash)
Use bash/terminal features:
- history search (`cd`)
- tab completion
- substitution: `!#:`, `!!:`
- globbing: `*`, `?`, `{}``for file in *; do; done`
Use GUI:
- open . or open <file/dir>
- dolphin
Use VIM:
- ls > <batch>.sh → vim <batch>.sh → :wq → bash <batch>.sh
Use vim aliases?:
- y (yank), p (paste), P (paste and clear)
- y [file(s)|dir(s)]; p | xargs -I{} <cp|mv|…> {}; P
Use `$PROMPT_COMMAND`:
- `PROMPT_COMMAND+='; ls -A'; PROMPT_COMMAND="${PROMPT_COMMAND/; ls -A}"`
HELP
}
m() {
if [[ "-d" == "$1" ]]; then
unset "m$2"
crossSession "m$2"
return 0
fi
if [[ -z "$1" ]]; then
printenv | grep -e '^m' | sort | xargs -I{} echo \${}
return 0
fi
if [[ "--help" == "$1" ]]; then
\cat <<-"HELP"
m [--help]
Lists all marks or print this help.
m -d <name>
Deletes mark <name>. Unsets variable and cross session variable.
m <name> [path]
Sets mark <name> to current directory or [path].
The mark is just a bash variable, use `$m<name>`.
cd $m<name>
cd to mark <name>.
HELP
return 0
fi
local n="m$1"
[[ -z "${!n}" ]] || return 1
[[ -z "$2" ]] && local p="$(pwd)" || local p="$(readlink -f $2)"
crossSession "$n" "$p"
export $n="$p"
}
alias cd-kdialog='cd "$(kdialog --getexistingdirectory --title "Vyberte složku" 2>/dev/null)"'
alias fd='fdfind'
# vim-like aliases?
alias dw='rm'
alias cw='mv'
alias g='fdfind'
# yanked files
export YANKED=()
p() {
for f in "${YANKED[@]}"; do
IFS=$'' echo "$f"
done
} # p | xargs -I{} …
P() { YANKED=(); echo 'YANKED=()'; }
y() {
local pwd
pwd="$(pwd)"
if [[ -z "$1" ]]; then
YANKED=("$pwd")
else
for f in "$@"; do
if [[ "$f" == /* ]]; then
YANKED+=("$f")
elif [[ "$f" == ./* || "$f" == '.' ]]; then
YANKED+=("$pwd${f:1}")
else
YANKED+=("$pwd/$f")
fi
done
fi
echo "$(p)"
}
# tab completion
[[ $(command -v _complete_alias) ]] || source "$BASH_DOTFILES/shell/complete-alias/complete_alias"
source <(fdfind --gen-completions)
complete -F _complete_alias fd
complete -F _complete_alias dw
complete -F _complete_alias cw
complete -F _complete_alias g