update server dotfiles
This commit is contained in:
parent
72e28e6cf2
commit
a8d446ab02
9 changed files with 203 additions and 178 deletions
|
@ -1,3 +1,3 @@
|
|||
#!/usr/bin/env bash
|
||||
kitty +icat --clear --silent --transfer-mode file
|
||||
kitty +kitten icat --clear --transfer-mode file
|
||||
|
||||
|
|
110
.config/lf/lfrc
110
.config/lf/lfrc
|
@ -2,75 +2,64 @@
|
|||
set ratios 1:2:4
|
||||
set shellopts '-eu'
|
||||
set ifs "\n"
|
||||
set findlen 1
|
||||
set scrolloff 10
|
||||
set icons
|
||||
set wrapscroll
|
||||
set period 1
|
||||
set findlen 2
|
||||
set previewer ~/.config/lf/preview
|
||||
set cleaner ~/.config/lf/clean
|
||||
set promptfmt "\033[34;1m%u\033[36m@\033[34m%h \033[35m[\033[0;1m%d\033[33m%f\033[35m]\033[0m"
|
||||
|
||||
cmd open ${{
|
||||
case $(file --mime-type "$(readlink -f $f)" -b) in
|
||||
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet) localc $fx ;;
|
||||
image/vnd.djvu|application/pdf|application/octet-stream|application/postscript) setsid -f zathura $fx >/dev/null 2>&1 ;;
|
||||
text/*|application/json|inode/x-empty) $EDITOR $fx;;
|
||||
image/x-xcf) setsid -f gimp $f >/dev/null 2>&1 ;;
|
||||
image/svg+xml) display -- $f ;;
|
||||
image/*) rotdir $f | grep -i "\.\(png\|jpg\|jpeg\|gif\|webp\|tif\|ico\)\(_large\)*$" |
|
||||
setsid -f sxiv -aio 2>/dev/null | while read -r file; do
|
||||
[ -z "$file" ] && continue
|
||||
lf -remote "send select \"$file\""
|
||||
lf -remote "send toggle"
|
||||
done &
|
||||
;;
|
||||
audio/*) mpv --audio-display=no $f ;;
|
||||
video/*) setsid -f mpv $f -quiet >/dev/null 2>&1 ;;
|
||||
application/pdf|application/vnd*|application/epub*) setsid -f zathura $fx >/dev/null 2>&1 ;;
|
||||
application/pgp-encrypted) $EDITOR $fx ;;
|
||||
*) for f in $fx; do setsid -f $OPENER $f >/dev/null 2>&1; done;;
|
||||
application/pgp-encrypted) $EDITOR $fx ;;
|
||||
esac
|
||||
}}
|
||||
|
||||
cmd mkdir $mkdir -p "$(echo $* | tr ' ' '\ ')"
|
||||
|
||||
cmd extract ${{
|
||||
clear; tput cup $(($(tput lines)/3)); tput bold
|
||||
set -f
|
||||
printf "%s\n\t" "$fx"
|
||||
printf "extract?[y/N]"
|
||||
read ans
|
||||
[ $ans = "y" ] && aunpack $fx
|
||||
clear; tput cup $(($(tput lines)/3)); tput bold
|
||||
set -f
|
||||
printf "%s\n\t" "$fx"
|
||||
printf "extract?[y/N]"
|
||||
read ans
|
||||
[ $ans = "y" ] && aunpack $fx
|
||||
}}
|
||||
|
||||
cmd delete ${{
|
||||
clear; tput cup $(($(tput lines)/3)); tput bold
|
||||
set -f
|
||||
printf "%s\n\t" "$fx"
|
||||
printf "delete?[y/N]"
|
||||
read ans
|
||||
[ $ans = "y" ] && rm -rf -- $fx
|
||||
clear; tput cup $(($(tput lines)/3)); tput bold
|
||||
set -f
|
||||
printf "%s\n\t" "$fx"
|
||||
printf "delete?[y/N]"
|
||||
read ans
|
||||
[ $ans = "y" ] && rm -rf -- $fx
|
||||
}}
|
||||
|
||||
cmd trash ${{
|
||||
clear; tput cup $(($(tput lines)/3)); tput bold
|
||||
set -f
|
||||
printf "%s\n\t" "$fx"
|
||||
printf "trash?[y/N]"
|
||||
read ans
|
||||
[ $ans = "y" ] && trash-put $fx
|
||||
clear; tput cup $(($(tput lines)/3)); tput bold
|
||||
set -f
|
||||
printf "%s\n\t" "$fx"
|
||||
printf "trash?[y/N]"
|
||||
read ans
|
||||
if [ $ans = "y" ]; then
|
||||
for f in $fx; do
|
||||
echo $f
|
||||
trash-put $f
|
||||
done
|
||||
fi
|
||||
}}
|
||||
|
||||
cmd rsyncto ${{
|
||||
clear; tput cup $(($(tput lines)/3)); tput bold
|
||||
set -f
|
||||
clear; echo "rsync to where?"
|
||||
read dest
|
||||
for x in $fx; do
|
||||
cmd rsyncto %{{
|
||||
clear; tput cup $(($(tput lines)/3)); tput bold
|
||||
set -f
|
||||
clear; echo "rsync to where?"
|
||||
read dest
|
||||
for x in $fx; do
|
||||
eval rsync -aAXHv \"$x\" \"$dest\"
|
||||
done &&
|
||||
notify-send "File(s) rsynced." "File(s) copies to $dest."
|
||||
done
|
||||
}}
|
||||
|
||||
# y (select for copy) and P to paste soft-link
|
||||
|
@ -93,21 +82,11 @@ cmd link %{{
|
|||
lf -remote "send clear"
|
||||
}}
|
||||
|
||||
cmd setbg "$1"
|
||||
cmd bulkrename $vidir
|
||||
|
||||
cmd git_branch ${{
|
||||
git branch | fzf | xargs git checkout
|
||||
pwd_shell=$(pwd)
|
||||
lf -remote "send $id updir"
|
||||
lf -remote "send $id cd \"$pwd_shell\""
|
||||
}}
|
||||
|
||||
|
||||
|
||||
cmd on-cd &{{
|
||||
DIR=$(echo $PWD | sed "s|$HOME|~|")
|
||||
printf "\033]0;$(hostname): $DIR\007" > /dev/tty
|
||||
printf "\033]0; $DIR\007" > /dev/tty
|
||||
}}
|
||||
on-cd
|
||||
|
||||
|
@ -137,31 +116,42 @@ cmd paste &{{
|
|||
cmd share $curl -F"file=@$fx" https://0x0.snaile.de | xclip -r -selection c
|
||||
|
||||
# Bindings
|
||||
map <c-f> $lf -remote "send $id select '$(fzf)'"
|
||||
map <c-c>a $lf -remote "send $id select '$(fzf)'"
|
||||
map <c-c>t $lf -remote "send $id select '$(cat ${XDG_DATA_HOME:-$HOME/.local/share}/lf/tags | sed 's/:\*$//' | fzf)'"
|
||||
map <c-c>f $lf -remote "send $id select '$(cat ${XDG_DATA_HOME:-$HOME/.local/share}/lf/shortcut-files | fzf)'"
|
||||
map <c-c>d $lf -remote "send $id cd '$(cat ${XDG_DATA_HOME:-$HOME/.local/share}/lf/shortcut-dirs | fzf)'"
|
||||
map J $dir=$(sed -e 's/\s*#.*//' -e '/^$/d' -e 's/^\S*\s*//' ${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs | fzf) && lf -remote "send $id cd $(eval echo $dir)"
|
||||
map D trash
|
||||
map <c-d> delete
|
||||
map E extract
|
||||
map T $trash-restore $PWD
|
||||
map <c-e> extract
|
||||
map R rsyncto
|
||||
map P link
|
||||
map S share
|
||||
map <c-g> $lazygit
|
||||
map V push :!$EDITOR<space>
|
||||
map <c-v> push :!$EDITOR<space>
|
||||
map <c-n> push :mkdir<space>
|
||||
map <c-t> push :&touch<space>
|
||||
map <c-r> reload
|
||||
map <c-s> set hidden!
|
||||
map <enter> shell
|
||||
map x $$f
|
||||
map X !$f
|
||||
map o &mimeopen $f
|
||||
map O $mimeopen --ask $f
|
||||
|
||||
map O $mimeopen -a $f
|
||||
map A rename # at the very end
|
||||
map a push A<c-a> # at the very beginning
|
||||
map I push A<a-b> # after extension
|
||||
map i push A<a-b><a-b><a-f> # before extension
|
||||
map c push A<c-u> # new rename
|
||||
map B bulkrename
|
||||
map b dupe
|
||||
map u :clear; unselect
|
||||
map n &echo $f | xclip -r -selection c
|
||||
map <esc> quit
|
||||
map N
|
||||
map g/ cd "/"
|
||||
map W &setsid $TERMINAL -e $SHELL -c "lf; $SHELL"
|
||||
|
||||
# source directory shortcuts
|
||||
# Load bookmark shortcuts
|
||||
source "~/.config/lf/shortcutrc"
|
||||
|
|
|
@ -1,73 +1,61 @@
|
|||
#!/usr/bin/env bash
|
||||
image() {
|
||||
file=$1
|
||||
f=$1
|
||||
w=$2
|
||||
h=$3
|
||||
x=$4
|
||||
y=$5
|
||||
kitty +icat --silent --transfer-mode file --place "${w}x${h}@${x}x${y}" "$file"
|
||||
chafa "$f" -f symbols -s "$((w-2))x$h" && exit 1
|
||||
echo -e "\e[31mImage previewer not installed\e[0m"
|
||||
exit 1
|
||||
}
|
||||
|
||||
video() {
|
||||
file=$1
|
||||
f=$1
|
||||
w=$2
|
||||
h=$3
|
||||
x=$4
|
||||
y=$5
|
||||
thumb="$(vidthumb "$file")"
|
||||
if [ "$thumb" != "" ]; then
|
||||
kitty +icat --silent --transfer-mode file --place "${w}x${h}@${x}x${y}" "$thumb"
|
||||
exit 1
|
||||
fi
|
||||
mediainfo "$file"
|
||||
exit 1
|
||||
thumb="$(vidthumb "$f")" || ( echo -e "\e[31mvidthumb script not in path\e[0m" && return 1 )
|
||||
image "$thumb" "$w" "$h" "$x" "$y"
|
||||
return 1
|
||||
}
|
||||
|
||||
batorcat() {
|
||||
file="$1"
|
||||
shift
|
||||
if command -v bat > /dev/null 2>&1; then
|
||||
bat --color=always --style=plain --pager=never "$file" "$@"
|
||||
elif command -v batcat > /dev/null 2>&1; then
|
||||
batcat --color=always --style=plain --pager=never "$file" "$@"
|
||||
else
|
||||
cat "$file"
|
||||
fi
|
||||
f=$1
|
||||
w=$2
|
||||
command -v bat > /dev/null 2>&1 && bat --color=always --style=plain --pager=never --terminal-width "$((w-2))" "$f" && exit 0
|
||||
command -v batcat > /dev/null 2>&1 && batcat --color=always --style=plain --pager=never --terminal-width "$((w-2))" "$f" && exit 0
|
||||
cat "$f" && exit 0
|
||||
}
|
||||
|
||||
CACHE="$HOME/.cache/lf/thumbnail.$(stat --printf '%n\0%i\0%F\0%s\0%W\0%Y' -- "$(readlink -f "$1")" | sha256sum | awk '{print $1}'))"
|
||||
|
||||
case "$(printf "%s\n" "$(readlink -f "$1")" | awk '{print tolower($0)}')" in
|
||||
*.md) glow "$1" && exit 0 ;;
|
||||
*.xml|*.html) w3m -dump "$1" && exit 0 ;;
|
||||
*.[1-8]) man "$1" | col -b && exit 0 ;;
|
||||
*.o) nm "$1" && exit 0 ;;
|
||||
esac
|
||||
|
||||
case "$(file -bL --mime-type $1)" in
|
||||
application/gzip) tar tzf "$1" ;;
|
||||
application/x-bzip2) tar tjf "$1" ;;
|
||||
application/x-xz) xz --list "$1" ;;
|
||||
application/x-tar) tar tf "$1" ;;
|
||||
application/zip) unzip -l "$1" ;;
|
||||
application/java-archive) unzip -l "$1" ;;
|
||||
application/x-rar) unrar l "$1" ;;
|
||||
application/x-7z-compressed) 7z l "$1" ;;
|
||||
application/x-iso9660-image) iso-info --no-header -l "$1" ;;
|
||||
application/x-bittorrent) transmission-show "$1" ;;
|
||||
application/vnd.sun.xml.writer) odt2txt "$1" ;;
|
||||
application/msword) catdoc "$1" ;;
|
||||
application/vnd.openxmlformats-officedocument.wordprocessingml.document) docx2txt < "$1" ;;
|
||||
application/vnd.ms-excel) ssconvert --export-type=Gnumeric_stf:stf_csv "$1" "fd://1" | batorcat --language=csv ;;
|
||||
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet) ssconvert --export-type=Gnumeric_stf:stf_csv "$1" "fd://1" | batorcat --language=csv ;;
|
||||
application/epub+zip) [ ! -f "$CACHE" ] && epub-thumbnailer "$1" "$CACHE" 1024; image "$CACHE" "$2" "$3" "$4" "$5" ;;
|
||||
application/pgp-encrypted) gpg -d -- "$1" ;;
|
||||
case "$(xdg-mime query filetype "$1")" in
|
||||
*/x-bzip-compressed-tar|*/x-compressed-tar|*/x-xz-compressed-tar) als -- "$1" && exit 0 || echo -e "\e[31matools not installed\e[0m" && exit 1;;
|
||||
*/x-7z-compressed|*/vnd.rar|*/x-tar|*/zip|*/x-java-archive|*/x-xz) 7z l "$1" | sed 1,11d && exit 0 || echo -e "\e[31m7zip not installed\e[0m" && exit 1;;
|
||||
*/x-cd-image) iso-info --no-header -l "$1" && exit 0 || echo -e "\e[31mlibcdio not installed\e[0m" && exit 1;;
|
||||
*/x-bittorrent) transmission-show "$1" && exit 0 || echo -e "\e[31mtransmission-cli not installed\e[0m" && exit 1;;
|
||||
*/vnd.sun.xml.writer) odt2txt "$1" && exit 0 || echo -e "\e[31modt2txt not installed\e[0m" && exit 1;;
|
||||
*/msword) catdoc "$1" && exit 0 || echo -e "\e[31mcatdoc not installed\e[0m" && exit 1;;
|
||||
*/vnd.openxmlformats-officedocument.wordprocessingml.document) docx2txt < "$1" && exit 0 || echo -e "\e[31mdocx2txt not installed\e[0m" && exit 1;;
|
||||
*/vnd.ms-excel) ssconvert --export-type=Gnumeric_stf:stf_csv "$1" "fd://1" | batorcat --language=csv && exit 0 || echo -e "\e[31mgnumeric not installed\e[0m" && exit 1;;
|
||||
*/vnd.openxmlformats-officedocument.spreadsheetml.sheet) ssconvert --export-type=Gnumeric_stf:stf_csv "$1" "fd://1" | batorcat --language=csv && exit 0 || echo -e "\e[31mgnumeric not installed\e[0m" && exit 1;;
|
||||
*/epub+zip) [ ! -f "$CACHE" ] && epub-thumbnailer "$1" "$CACHE" 1024; image "$CACHE" "$2" "$3" "$4" "$5" && exit 0 || echo -e "\e[31mepubthumbnailer not installed (https://github.com/marianosimone/epub-thumbnailer)\e[0m" && exit 1;;
|
||||
*/pgp-encrypted) gpg -d -- "$1" && exit 0 || echo -e "\e[31mgpg not installed\e[0m" && exit 1;;
|
||||
*/pkix-cert) openssl x509 -text -noout -in "$1" && exit 0 || echo -e "\e[31mopenssl not installed\e[0m" && exit 1;;
|
||||
image/*) image "$1" "$2" "$3" "$4" "$5" ;;
|
||||
video/*) video "$1" "$2" "$3" "$4" "$5" ;;
|
||||
*opendocument*) odt2txt "$1" ;;
|
||||
text/*|*/xml|application/json) batorcat "$1" ;;
|
||||
*/pdf) [ ! -f "${CACHE}.jpg" ] && pdftoppm -jpeg -f 1 -singlefile "$1" "$CACHE"; image "${CACHE}.jpg" "$2" "$3" "$4" "$5" ;;
|
||||
*) mediainfo "$1" || exit 1 ;;
|
||||
*opendocument*) odt2txt "$1" && exit 0 || echo -e "\e[31modt2txt not installed\e[0m" && exit 1;;
|
||||
*/markdown) lowdown -Tterm "$1" && exit 0 || echo -e "\e[31mlowdown not installed \e[0m" && exit 1;;
|
||||
*/html) lynx -dump "$1" && exit 0 || w3m -dump "$1" && exit 0 || echo -e "\e[31neither lynx nor w3m installed\e[0m" && exit 1;;
|
||||
text/*|*/json|*/xml) batorcat "$1" "$2" ;;
|
||||
*/pdf) [ ! -f "${CACHE}.jpg" ] && pdftoppm -jpeg -f 1 -singlefile "$1" "$CACHE"; image "${CACHE}.jpg" "$2" "$3" "$4" "$5" && exit 0 || echo -e "\e[31mpoppler-utils/poppler not installed\e[0m" && exit 1;;
|
||||
esac
|
||||
exit 0
|
||||
case "$(file -bL --mime-type "$1")" in
|
||||
text/*) batorcat "$1" "$2" ;;
|
||||
esac
|
||||
xdg-mime query filetype "$1"
|
||||
mediainfo "$1"
|
||||
exit 1
|
||||
|
||||
|
|
|
@ -1,28 +1,5 @@
|
|||
map Cch cd "/home/luca/.cache"
|
||||
map Ccf cd "/home/luca/.config"
|
||||
map Cdt cd "/home/luca/.local/share"
|
||||
map Crr cd "/home/luca/.local/src"
|
||||
map Csc cd "/home/luca/.local/bin"
|
||||
map Cmn cd "/mnt"
|
||||
map Cdl cd "/home/luca/Downloads"
|
||||
map Cdm cd "/home/luca/Documents"
|
||||
map Cms cd "/home/luca/Music"
|
||||
map Cpc cd "/home/luca/Pictures"
|
||||
map Cvd cd "/home/luca/Videos"
|
||||
map Cdot cd "/home/luca/.local/share/dotfiles"
|
||||
map Ebf $$EDITOR "/home/luca/.config/shell/bm-files"
|
||||
map Ebd $$EDITOR "/home/luca/.config/shell/bm-dirs"
|
||||
map Ecfx $$EDITOR "/home/luca/.config/x11/xresources"
|
||||
map Ecfb $$EDITOR "/home/luca/.local/src/dwmblocks/config.h"
|
||||
map Ecfv $$EDITOR "/home/luca/.config/nvim/init.vim"
|
||||
map Ecfz $$EDITOR "/.zshrc"
|
||||
map Ecfa $$EDITOR "/home/luca/.config/shell/aliasrc"
|
||||
map Ecfp $$EDITOR "/home/luca/.config/shell/profile"
|
||||
map Ecfm $$EDITOR "/home/luca/.config/mutt/muttrc"
|
||||
map Ecfn $$EDITOR "/home/luca/.config/newsboat/config"
|
||||
map Ecfu $$EDITOR "/home/luca/.config/newsboat/urls"
|
||||
map Ecfmb $$EDITOR "/home/luca/.config/ncmpcpp/bindings"
|
||||
map Ecfmc $$EDITOR "/home/luca/.config/ncmpcpp/config"
|
||||
map Ecfl $$EDITOR "/home/luca/.config/lf/lfrc"
|
||||
map EcfL $$EDITOR "/home/luca/.config/lf/scope"
|
||||
map EcfX $$EDITOR "/home/luca/.config/sxiv/exec/key-handler"
|
||||
map gh cd "/home/luca"
|
||||
map gmn cd "/mnt"
|
||||
map g/ cd "/"
|
||||
map go cd "/opt"
|
||||
map ge cd "/etc"
|
||||
|
|
|
@ -1,32 +1,42 @@
|
|||
#!/bin/sh
|
||||
|
||||
for command in apt su pkill ; do
|
||||
for command in apt su ; do
|
||||
alias $command="sudo $command"
|
||||
done; unset command
|
||||
|
||||
# Verbosity and settings that you pretty much just always are going to want.
|
||||
alias \
|
||||
cp="cp -iv" \
|
||||
mv="mv -iv" \
|
||||
rm="rm -vI" \
|
||||
mkd="mkdir -pv" \
|
||||
exa="exa -abghHliS" \
|
||||
duf="duf -all" \
|
||||
ls="ls -hN --color=auto --group-directories-first" \
|
||||
grep="grep --color=auto" \
|
||||
diff="diff --color=auto" \
|
||||
ccat="highlight --out-format=ansi" \
|
||||
ip="ip -color=auto"
|
||||
cp="cp -iv" \
|
||||
mv="mv -iv" \
|
||||
rm="rm -vI" \
|
||||
bc="bc -ql" \
|
||||
mkd="mkdir -pv" \
|
||||
ffmpeg="ffmpeg -hide_banner" \
|
||||
exa="exa -abghHliS" \
|
||||
duf="duf -all" \
|
||||
ls="ls -hN --color=auto --group-directories-first" \
|
||||
grep="grep --color=auto" \
|
||||
diff="diff --color=auto" \
|
||||
|
||||
# Colorize commands when possible.
|
||||
alias \
|
||||
ls="ls -hN --color=auto --group-directories-first" \
|
||||
grep="grep --color=auto" \
|
||||
diff="diff --color=auto" \
|
||||
ccat="highlight --out-format=ansi" \
|
||||
ip="ip -color=auto"
|
||||
|
||||
# These common commands are just too long! Abbreviate them.
|
||||
alias \
|
||||
ka="killall" \
|
||||
e="$EDITOR" \
|
||||
au="apt uninstall" \
|
||||
ar="apt reinstall" \
|
||||
ai="apt install" \
|
||||
aur="apt autoremove" \
|
||||
ka="killall" \
|
||||
e="$EDITOR" \
|
||||
ar="apt remove" \
|
||||
are="apt reinstall" \
|
||||
ai="apt install" \
|
||||
aur="apt autoremove" \
|
||||
au="apt upgrade" \
|
||||
|
||||
# Misc.
|
||||
alias \
|
||||
vim="nvim" \
|
||||
ref="shortcuts >/dev/null; source ${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutrc ; source ${XDG_CONFIG_HOME:-$HOME/.config}/shell/zshnameddirrc" \
|
||||
vim="nvim" \
|
||||
|
|
|
@ -8,6 +8,8 @@ export PATH="$PATH:${$(find -L ~/.local/bin -type d -printf %p:)%%:}"
|
|||
# Adds `~/.local/share/npm-global` to $PATH
|
||||
export PATH=~/.npm-global/bin:$PATH
|
||||
|
||||
unsetopt PROMPT_SP
|
||||
|
||||
# Default programs:
|
||||
export EDITOR="nvim"
|
||||
|
||||
|
@ -22,7 +24,6 @@ export INPUTRC="${XDG_CONFIG_HOME:-$HOME/.config}/shell/inputrc"
|
|||
export ZDOTDIR="${XDG_CONFIG_HOME:-$HOME/.config}/zsh"
|
||||
export ZSH_COMPDUMP="${XDG_CACHE_HOME:-$HOME/.cache}/zcompdump"
|
||||
export GNUPGHOME="${XDG_CONFIG_HOME:-$HOME/.config}/gnupg"
|
||||
export PASSWORD_STORE_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/password-store"
|
||||
export TMUX_TMPDIR="$XDG_RUNTIME_DIR"
|
||||
export CARGO_HOME="${XDG_DATA_HOME:-$HOME/.local/share}/cargo"
|
||||
export GOPATH="${XDG_DATA_HOME:-$HOME/.local/share}/go"
|
||||
|
@ -39,7 +40,7 @@ export LESS_TERMCAP_se="$(printf '%b' '[0m')"
|
|||
export LESS_TERMCAP_us="$(printf '%b' '[1;32m')"
|
||||
export LESS_TERMCAP_ue="$(printf '%b' '[0m')"
|
||||
export LESSOPEN="| /usr/bin/highlight -O ansi %s 2>/dev/null"
|
||||
export VIRTUAL_ENV_DISABLE_PROMPT=1
|
||||
# export VIRTUAL_ENV_DISABLE_PROMPT=1
|
||||
export PYENV_PROMPT=" %F{yellow\}%F{reset\} "
|
||||
|
||||
# This is the list for lf icons:
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
# Enable colors and change prompt:
|
||||
autoload -U colors && colors # Load colors
|
||||
autoload -U colors && colors
|
||||
autoload edit-command-line && zle -N edit-command-line
|
||||
autoload -U add-zsh-hook
|
||||
autoload -U compinit
|
||||
autoload -Uz edit-command-line
|
||||
PS1="%B%F{blue}%n%F{cyan}@%F{blue}%m %F{magenta}[%f%3~%F{magenta}] %(?.%F{green}.%F{red})»%f%b "
|
||||
RPS1="%(?..%F{red}%?)"
|
||||
stty stop undef # Disable ctrl-s to freeze terminal.
|
||||
|
@ -8,19 +11,20 @@ setopt HIST_IGNORE_ALL_DUPS HIST_REDUCE_BLANKS HIST_VERIFY BANG_HIST interactive
|
|||
# History in cache directory:
|
||||
HISTSIZE=10000000
|
||||
SAVEHIST=10000000
|
||||
HISTFILE="${XDG_CACHE_HOME:-$HOME/.cache}/zsh/history"
|
||||
|
||||
# Load aliases if existent.
|
||||
# Load aliases and shortcuts if existent.
|
||||
[ -f "${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutrc" ] && source "${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutrc"
|
||||
[ -f "${XDG_CONFIG_HOME:-$HOME/.config}/shell/aliasrc" ] && source "${XDG_CONFIG_HOME:-$HOME/.config}/shell/aliasrc"
|
||||
[ -f "${XDG_CONFIG_HOME:-$HOME/.config}/shell/zshnameddirrc" ] && source "${XDG_CONFIG_HOME:-$HOME/.config}/shell/zshnameddirrc"
|
||||
|
||||
# Basic auto/tab complete:
|
||||
autoload -U compinit
|
||||
zstyle ':completion:*' menu select
|
||||
zmodload zsh/complist
|
||||
compinit
|
||||
_comp_options+=(globdots) # Include hidden files.
|
||||
|
||||
# vi mode
|
||||
autoload -Uz edit-command-line
|
||||
zle -N edit-command-line
|
||||
bindkey -M vicmd v edit-command-line
|
||||
bindkey -v
|
||||
|
@ -80,17 +84,12 @@ bindkey '^o' _lfcd
|
|||
|
||||
# bind lazygit to ctrl-g
|
||||
lg () {
|
||||
lazygit
|
||||
tput cuu1;tput el
|
||||
[ ! -d "$(pwd)/.git" ] && [[ $(read -ek "?Not in a git repository. Create a new git repository? (y/n): ") =~ ^[Yy]$ ]] && git init
|
||||
[ -d "$(pwd)/.git" ] && lazygit -p $(pwd)
|
||||
zle reset-prompt
|
||||
}
|
||||
|
||||
_lazygit () {
|
||||
BUFFER="lg"
|
||||
zle accept-line
|
||||
}
|
||||
|
||||
zle -N _lazygit
|
||||
bindkey '^g' _lazygit
|
||||
zle -N lg{,}
|
||||
bindkey '^g' lg
|
||||
|
||||
# Edit line in vim with ctrl-e:
|
||||
autoload edit-command-line; zle -N edit-command-line
|
||||
|
@ -104,7 +103,8 @@ bindkey '^[[F' end-of-line
|
|||
bindkey '^[[1;5C' forward-word
|
||||
bindkey '^[[1;5D' backward-word
|
||||
|
||||
|
||||
[ -f "${XDG_DATA_HOME:-$HOME/.local/share}/zsh/plugins/fzf/key-bindings.zsh" ] && source "${XDG_DATA_HOME:-$HOME/.local/share}/zsh/plugins/fzf/key-bindings.zsh"
|
||||
[ -f "${XDG_DATA_HOME:-$HOME/.local/share}/zsh/plugins/autopyenv/autopyenv.plugin.zsh" ] && source "${XDG_DATA_HOME:-$HOME/.local/share}/zsh/plugins/autopyenv/autopyenv.plugin.zsh"
|
||||
|
||||
# plugins
|
||||
PLUGINS_HOME="${XDG_DATA_HOME:-$HOME/.local/share}/zsh/plugins"
|
||||
[ -f "$PLUGINS_HOME/fzf/key-bindings.zsh" ] && source "$PLUGINS_HOME/fzf/key-bindings.zsh"
|
||||
[ -f "$PLUGINS_HOME/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh" ] && source "$PLUGINS_HOME/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh"
|
||||
[ -f "$PLUGINS_HOME/autopyenv/autopyenv.plugin.zsh" ] && source "$PLUGINS_HOME/autopyenv/autopyenv.plugin.zsh"
|
||||
|
|
28
.local/bin/trash-put
Executable file
28
.local/bin/trash-put
Executable file
|
@ -0,0 +1,28 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
[ -e "$1" ] || exit 1
|
||||
getfsroot() {
|
||||
printf "%s" "$(df "$1" --output=target | tail -1)"
|
||||
}
|
||||
|
||||
filepath="$(realpath "$1")"
|
||||
filename="$(basename "$1")"
|
||||
fsroot="$(getfsroot "$1")"
|
||||
[ "$fsroot" = "$(getfsroot "${XDG_DATA_HOME:-$HOME/.local/share}")" ] \
|
||||
&& basedir="${XDG_DATA_HOME:-$HOME/.local/share}/Trash" \
|
||||
|| basedir="${fsroot}/.Trash"
|
||||
infodir="$basedir/info"
|
||||
filedir="$basedir/files"
|
||||
|
||||
mkdir -p "$infodir" 1>/dev/null 2>&1
|
||||
mkdir -p "$filedir" 1>/dev/null 2>&1
|
||||
find "$filedir" -regex ".*$filename.*" | grep -oP '(?<=.\.~)\d+(?=~$)' | sort -n | tail -1 | (
|
||||
ext=$(($(cat /dev/stdin)+1))
|
||||
filedest="$filedir/$filename.~$ext~"
|
||||
command mv -f "$filepath" "$filedest"
|
||||
cat <<EOF > "$infodir/$(basename "$filedest")"
|
||||
[Trash Info]
|
||||
Path=$filepath
|
||||
DeletionDate=$(date +%Y%m%dT%T)
|
||||
EOF
|
||||
)
|
31
.local/bin/trash-restore
Executable file
31
.local/bin/trash-restore
Executable file
|
@ -0,0 +1,31 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
getfsroot() {
|
||||
printf "%s" "$(df "$1" --output=target | tail -1)"
|
||||
}
|
||||
list() {
|
||||
# 1st arg is trash files directory
|
||||
# 2nd arg is directory to match trash files for
|
||||
[ ! "$(ls -A "$1")" ] && exit 1
|
||||
for file in "$1"/* ; do
|
||||
[ "$(head -1 "$file")" = "[Trash Info]" ] && \
|
||||
fpath=$(grep Path "$file" | cut -d '=' -f2) && \
|
||||
echo "$fpath" | grep -qP "^$2/[^/]+$" && \
|
||||
printf "%s %s %s\n" \
|
||||
"$(basename "$file")" \
|
||||
"$fpath" \
|
||||
"$(date -d "$(grep Date "$file" | cut -d '=' -f2)" +'%x %X')"
|
||||
done
|
||||
}
|
||||
|
||||
[ -n "$1" ] && dir="$(realpath "$1")" || dir="$(getfsroot "$PWD")"
|
||||
fsroot="$(getfsroot "$dir")"
|
||||
[ "$fsroot" = "$(getfsroot "${XDG_DATA_HOME:-$HOME/.local/share}")" ] \
|
||||
&& basedir="${XDG_DATA_HOME:-$HOME/.local/share}/Trash" \
|
||||
|| basedir="${fsroot}/.Trash"
|
||||
|
||||
sel="$(list "$basedir/info" "$dir" | fzf)"
|
||||
file="$basedir/files/$(echo "$sel" | cut -d ' ' -f1)"
|
||||
dest="$(echo "$sel" | cut -d ' ' -f2)"
|
||||
command mv -ib "$file" "$dest"
|
||||
command rm "$basedir/info/$(echo "$sel" | cut -d ' ' -f1)"
|
Loading…
Add table
Add a link
Reference in a new issue