zshrc: move functions to .zsh/functions.zsh
This commit is contained in:
parent
10f2143d21
commit
bf51cf8f8b
46
.zsh/functions.zsh
Normal file
46
.zsh/functions.zsh
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
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)
|
||||||
|
|
||||||
|
rsync -auvP -4 $1 nebula:/var/www/htdocs/dotya.ml/files/$FILE_LIFESPAN/$FILE_ID-$1
|
||||||
|
|
||||||
|
FILE_URL="https://dotya.ml/files/$FILE_LIFESPAN/$FILE_ID-$1"
|
||||||
|
|
||||||
|
if [[ -z "$WAYLAND_DISPLAY" ]]; then
|
||||||
|
echo $FILE_URL | xclip -selection clipboard
|
||||||
|
echo $FILE_URL | xsel --clipboard --input
|
||||||
|
else
|
||||||
|
echo $FILE_URL | wl-copy
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo $FILE_URL
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
timesh() {
|
||||||
|
shell=${1-$SHELL}
|
||||||
|
for i in $(seq 1 10); do /usr/bin/time $shell -i -c exit; done
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
delete-branches() {
|
||||||
|
git branch |
|
||||||
|
grep --invert-match '\*' |
|
||||||
|
cut -c 3- |
|
||||||
|
fzf --multi --preview="git log {} --" |
|
||||||
|
xargs --no-run-if-empty git branch --delete --force
|
||||||
|
}
|
29
.zshrc
29
.zshrc
@ -110,6 +110,7 @@
|
|||||||
|
|
||||||
# User configuration
|
# User configuration
|
||||||
source ~/.dotenv
|
source ~/.dotenv
|
||||||
|
source ~/.zsh/functions.zsh
|
||||||
|
|
||||||
# You may need to manually set your language environment
|
# You may need to manually set your language environment
|
||||||
LANG=en_GB.UTF-8
|
LANG=en_GB.UTF-8
|
||||||
@ -142,34 +143,6 @@
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
rsync -auvP -4 $1 nebula:/var/www/htdocs/dotya.ml/files/$FILE_LIFESPAN/$FILE_ID-$1
|
|
||||||
|
|
||||||
FILE_URL="https://dotya.ml/files/$FILE_LIFESPAN/$FILE_ID-$1"
|
|
||||||
|
|
||||||
if [[ -z "$WAYLAND_DISPLAY" ]]; then
|
|
||||||
echo $FILE_URL | xclip -selection clipboard
|
|
||||||
echo $FILE_URL | xsel --clipboard --input
|
|
||||||
else
|
|
||||||
echo $FILE_URL | wl-copy
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo $FILE_URL
|
|
||||||
}
|
|
||||||
timesh() {
|
|
||||||
shell=${1-$SHELL}
|
|
||||||
for i in $(seq 1 10); do /usr/bin/time $shell -i -c exit; done
|
|
||||||
}
|
|
||||||
|
|
||||||
eval "$(starship init zsh)"
|
eval "$(starship init zsh)"
|
||||||
|
|
||||||
if [ -e ~/.nix-profile/etc/profile.d/nix.sh ]; then . ~/.nix-profile/etc/profile.d/nix.sh; fi # added by Nix installer...and kept by me
|
if [ -e ~/.nix-profile/etc/profile.d/nix.sh ]; then . ~/.nix-profile/etc/profile.d/nix.sh; fi # added by Nix installer...and kept by me
|
||||||
|
Loading…
Reference in New Issue
Block a user