2022-04-03 22:31:19 +02:00
|
|
|
transfer() { if [ $# -eq 0 ]; then echo -e "No arguments specified. Usage:\necho transfer /tmp/test.md\ncat /tmp/test.md | transfer test.md"; return 1; fi;tmpfile=$( mktemp -t transferXXX ); if tty -s; then basefile=$(basename "$1" | sed -e 's/[^a-zA-Z0-9._-]/-/g'); curl --progress-bar --upload-file "$1" "https://transfer.sh/$basefile" >> $tmpfile; else curl --progress-bar --upload-file "-" "https://transfer.sh/$1" >> $tmpfile ; fi; cat $tmpfile; rm -f $tmpfile; }
|
|
|
|
|
|
|
|
|
|
|
|
info() { printf "\n%s %s\n\n" "$( date )" "$*" >&2; }
|
|
|
|
|
|
|
|
|
|
|
|
ix () { curl -n -F 'f:1=<-' http://ix.io 2>/dev/null ;}
|
|
|
|
|
|
|
|
|
|
|
|
viman() { text=$(man "$@") && echo "$text" | vim -R +":set ft=man nomod nonu noma nolist colorcolumn=" - ; }
|
|
|
|
|
|
|
|
|
|
|
|
upload() {
|
|
|
|
# inspired by https://www.alexander-pluhar.de/paste-file-host.html
|
|
|
|
# make eternity the default lifespan
|
|
|
|
FILE_LIFESPAN=${2:-e}
|
|
|
|
FILE_ID=$(base64 /dev/urandom | tr -d '/+' | dd bs=16 count=1 2>/dev/null)
|
2022-10-18 13:48:43 +02:00
|
|
|
FILENAME=$(basename $1)
|
2022-04-03 22:31:19 +02:00
|
|
|
|
2022-10-18 13:48:43 +02:00
|
|
|
rsync -auvP -4 $1 "nebula:/var/www/htdocs/dotya.ml/files/$FILE_LIFESPAN/$FILE_ID-$FILENAME"
|
2022-04-03 22:31:19 +02:00
|
|
|
|
2022-10-18 13:48:43 +02:00
|
|
|
FILE_URL="https://dotya.ml/files/$FILE_LIFESPAN/$FILE_ID-$FILENAME"
|
2022-04-03 22:31:19 +02:00
|
|
|
|
|
|
|
if [[ -z "$WAYLAND_DISPLAY" ]]; then
|
|
|
|
echo $FILE_URL | xclip -selection clipboard
|
|
|
|
echo $FILE_URL | xsel --clipboard --input
|
|
|
|
else
|
2022-10-18 13:48:43 +02:00
|
|
|
wl-copy --trim-newline $FILE_URL
|
2022-04-03 22:31:19 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo $FILE_URL
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
timesh() {
|
2022-10-18 13:53:01 +02:00
|
|
|
shell=${1:-$SHELL}
|
2023-08-18 16:25:20 +02:00
|
|
|
for i in $(seq 1 10); do time $shell -i -c exit; done
|
2022-04-03 22:31:19 +02:00
|
|
|
}
|
|
|
|
|
2023-08-18 16:25:33 +02:00
|
|
|
timeplugins() {
|
|
|
|
for plugin ($plugins); do
|
|
|
|
timer=$(($(date +%s%N)/1000000))
|
|
|
|
if [ -f $ZSH/plugins/$plugin/$plugin.plugin.zsh ]; then
|
|
|
|
source $ZSH/plugins/$plugin/$plugin.plugin.zsh
|
|
|
|
fi
|
|
|
|
now=$(($(date +%s%N)/1000000))
|
|
|
|
elapsed=$(($now-$timer))
|
|
|
|
echo $elapsed":" $plugin;
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2022-04-03 22:31:19 +02:00
|
|
|
|
|
|
|
delete-branches() {
|
|
|
|
git branch |
|
|
|
|
grep --invert-match '\*' |
|
|
|
|
cut -c 3- |
|
|
|
|
fzf --multi --preview="git log {} --" |
|
|
|
|
xargs --no-run-if-empty git branch --delete --force
|
|
|
|
}
|
2022-07-03 12:04:48 +02:00
|
|
|
|
|
|
|
fzf-open() {
|
|
|
|
local output
|
|
|
|
output=$(fzf </dev/tty)
|
2023-09-08 14:29:15 +02:00
|
|
|
if [ $output != "" ]; then
|
|
|
|
vim --not-a-term ${output}
|
|
|
|
fi
|
|
|
|
zle .reset-prompt
|
2022-07-03 12:04:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
zle -N fzf-open
|