bin: fix little scripting issues

This commit is contained in:
xeruf 2021-10-22 17:15:09 +02:00
parent 546a01b43e
commit 0e37530ddd
5 changed files with 10 additions and 8 deletions

View File

@ -59,9 +59,8 @@ pathadd() {
} }
# ZSH completion and stuff {{{1 # ZSH completion and stuff {{{1
alias rs="reset && exec $SHELL" alias rs="reset && exec $SHELL"
alias hist='print -z $(history | tac | fzf --tiebreak=index --bind="'"del:execute(echo \"'/;{4..}$/d'\" && sed '/;{4..}$/d' -i.bak $HISTFILE)"'" | sed "s|^ \+||" | cut -d" " -f5-)' alias hist='print -z $(history | tac | fzf --tiebreak=index --bind='"'"'del:execute(sed "\;$(echo {4..})$d" -i.bak $HISTFILE)'"'"' | sed "s|^ \+||" | cut -d" " -f5-)'
CONFIG_SHELL_FUNCTIONS="${BASH_SOURCE[0]:-${(%):-%x}}" CONFIG_SHELL_FUNCTIONS="${BASH_SOURCE[0]:-${(%):-%x}}"
edshell() { edshell() {

View File

@ -1,4 +1,6 @@
#!/bin/sh #!/bin/sh
{
echo "$# Args: $@" echo "$# Args: $@"
echo "${@:-default}" | sed 's/\(\w\+\)/\1-w/g' echo "${@:-default}" | sed 's/\(\w\+\)/\1-w/g'
#echo "Last arg: ${@:$#}" #echo "Last arg: ${@:$#}"
} | tee /tmp/args$(date +%s)

View File

@ -17,7 +17,7 @@ tput setaf 4 && $elevate file -E "$last" | ( grep -v --color=never 'directory$'
case "$($elevate file --dereference --mime "$last")" in case "$($elevate file --dereference --mime "$last")" in
*inode/directory*) tput sgr0 && $(test -x "$last" || echo "sudo") ls -l --color=always --human-readable --group-directories-first --file-type --dereference-command-line --all "$@" | less -XF;; *inode/directory*) tput sgr0 && $(test -x "$last" || echo "sudo") ls -l --color=always --human-readable --group-directories-first --file-type --dereference-command-line --all "$@" | less -XF;;
*binary) expr "$(file "$last")" : ".*compressed" >/dev/null && /usr/share/nvim/runtime/macros/less.sh "$@";; *binary) expr "$(file "$last")" : ".*compressed" >/dev/null && /usr/share/nvim/runtime/macros/less.sh "$@";;
*) $elevate bat --style header "$@" $(test -n "$elevate" || echo "--pager='less -XF'") *) $elevate bat --style header "$@" "$(test -n "$elevate" || echo "--pager=less -XF")"
tput setaf 3 && $elevate stat --format '%A size %sB, birth: %.10w mod %.10y' "$last" tput setaf 3 && $elevate stat --format '%A size %sB, birth: %.10w mod %.10y' "$last"
;; ;;
esac esac

View File

@ -3,7 +3,10 @@ suffix="${2:-bak}"
orig="${1%%.$suffix}" orig="${1%%.$suffix}"
smv () { smv () {
eval source=\$$(($#-1)) eval source=\$$(($#-1))
test -w "$source" && mv -v "$@" || sudo mv -v "$@" if test -w "$source"
then mv -v "$@"
else sudo mv -v "$@"
fi
} }
if test -e "$orig.$suffix" if test -e "$orig.$suffix"
then then

View File

@ -1,5 +1,6 @@
export DATA="$(test -d $HOME/data && echo $HOME/data || echo $HOME/daten)" export DATA="$(test -d $HOME/data && echo $HOME/data || echo $HOME/daten)"
export MUSIC="$DATA/music" export MUSIC="$DATA/music"
export JOURNAL="$DATA/2-standards/notes/journal"
# xdg # xdg
export XDG_DATA_HOME="$HOME/.local/share" export XDG_DATA_HOME="$HOME/.local/share"
@ -51,7 +52,7 @@ export CONFIG_SHELLS="$XDG_CONFIG_HOME/shell"
# environment # environment
which nvim >/dev/null && export EDITOR='nvim' || export EDITOR='vim' which nvim >/dev/null && export EDITOR='nvim' || export EDITOR='vim'
export LESS="--RAW-CONTROL-CHARS --ignore-case --LONG-PROMPT --jump-target=5 $(test $(less --version | head -1 | cut -f2 -d' ') -ge 590 && echo --incsearch)" export LESS="--RAW-CONTROL-CHARS --ignore-case --LONG-PROMPT --jump-target=5 $(test $(less --version | head -1 | cut -f2 -d' ') -ge 590 && echo --incsearch)"
export IGNOREDIRS="-x dev -x .sync -x .stfolder -x .git -x .gradle -x .idea -x out -x *build -x dist_newstyle -x generated -x cache -x node_modules" export IGNOREDIRS="-x dev -x .sync -x .stfolder -x .git -x .gradle -x .idea -x out -x *build -x dist_newstyle -x generated -x cache -x node_modules -x virtualenv"
# red stderr # red stderr
test -f "/usr/lib/libstderred.so" && export LD_PRELOAD="/usr/lib/libstderred.so${LD_PRELOAD:+:$LD_PRELOAD}" test -f "/usr/lib/libstderred.so" && export LD_PRELOAD="/usr/lib/libstderred.so${LD_PRELOAD:+:$LD_PRELOAD}"
# software config # software config
@ -99,9 +100,6 @@ export CTEST_PROGRESS_OUTPUT=1
export CTEST_OUTPUT_ON_FAILURE=1 export CTEST_OUTPUT_ON_FAILURE=1
export CTEST_PARALLEL_LEVEL=3 export CTEST_PARALLEL_LEVEL=3
export JOURNAL="$DATA/2-standards/notes/journal"
if test -z "${DISPLAY}" && test "$XDG_VTNR" -eq 1 && test -d "$JOURNAL"; then if test -z "${DISPLAY}" && test "$XDG_VTNR" -eq 1 && test -d "$JOURNAL"; then
echo "What do you want to do?" echo "What do you want to do?"
while test $(echo "$intention" | wc -c) -lt 6 while test $(echo "$intention" | wc -c) -lt 6