2023-05-09 16:37:01 +02:00
|
|
|
autoload -U promptinit; promptinit;
|
|
|
|
autoload -U compinit bashcompinit
|
|
|
|
compinit
|
|
|
|
bashcompinit
|
|
|
|
zstyle ':completion:*' menu yes select
|
|
|
|
zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}'
|
|
|
|
zstyle ':completion:*' rehash true
|
|
|
|
|
|
|
|
autoload -U select-word-style
|
|
|
|
select-word-style bash
|
|
|
|
|
|
|
|
setopt auto_cd
|
|
|
|
setopt HIST_IGNORE_SPACE
|
|
|
|
setopt interactive_comments
|
|
|
|
setopt inc_append_history
|
|
|
|
setopt share_history
|
|
|
|
setopt AUTO_PUSHD
|
|
|
|
setopt PUSHD_IGNORE_DUPS
|
|
|
|
setopt PUSHD_SILENT
|
|
|
|
|
|
|
|
if [[ -t 0 && $- = *i* ]]
|
|
|
|
then
|
|
|
|
stty -ixon
|
|
|
|
fi
|
|
|
|
|
|
|
|
unset histchars
|
|
|
|
|
|
|
|
for index ({1..9}) alias "$index"="cd +${index}"; unset index
|
|
|
|
|
|
|
|
HISTFILE=~/.zsh_history
|
|
|
|
HISTSIZE=10000000
|
|
|
|
SAVEHIST=10000000
|
|
|
|
|
|
|
|
bindkey '^[.' insert-last-word
|
|
|
|
bindkey "^[[H" beginning-of-line # HOME
|
|
|
|
bindkey "^[[F" end-of-line # END
|
|
|
|
bindkey "^[OH" beginning-of-line # HOME
|
|
|
|
bindkey "^[OF" end-of-line # END
|
|
|
|
bindkey "^[[3~" delete-char # DEL
|
|
|
|
bindkey -M emacs '\e#' pound-insert # ALT+#
|
|
|
|
bindkey '^R' history-incremental-pattern-search-backward
|
|
|
|
bindkey '^S' history-incremental-pattern-search-forward
|
|
|
|
bindkey '^[[1;3C' forward-word
|
|
|
|
bindkey '^[[1;3D' backward-word
|
|
|
|
|
|
|
|
mem() {
|
|
|
|
echo $(echo $(smem -t -P $1 | tail -n 1 | rev | cut -d ' ' -f 2 | rev) / 1024 | bc) MB
|
|
|
|
}
|
|
|
|
|
|
|
|
alias eZ="vim ~/.zshrc"
|
|
|
|
alias eI="vim ~/.config/sway/config"
|
|
|
|
alias eW="vim ~/.config/wezterm/wezterm.lua"
|
|
|
|
alias eI="vim ~/.config/sway/config"
|
|
|
|
alias eV="vim ~/.vimrc"
|
|
|
|
alias eS="vim ~/.config/starship.toml"
|
|
|
|
alias wetter="curl http://v3.wttr.in/Niedersachsen.sxl; sleep 5; curl http://v1.wttr.in/Hildesheim"
|
|
|
|
alias history="history 0"
|
|
|
|
alias etcher="usbimager"
|
|
|
|
alias ls='ls --color=auto'
|
|
|
|
|
2023-08-23 17:13:40 +02:00
|
|
|
function keytype() {
|
|
|
|
echo "Eingabe wird in 5 Sekunden ausgegeben!"
|
|
|
|
sleep 5 && { echo typedelay 100; echo type $1; } | DOTOOL_XKB_LAYOUT=de dotool && notify-send done
|
|
|
|
}
|
|
|
|
|
2023-05-09 16:37:01 +02:00
|
|
|
alias k="kubectl"
|
|
|
|
alias serve="python -m http.server 8000"
|
|
|
|
|
|
|
|
function imgcat()
|
|
|
|
{
|
|
|
|
local CNT=0
|
|
|
|
local IFS=$'\n'
|
|
|
|
local posY=$(($(echo -e "cols" | tput -S) / 2))
|
|
|
|
local posX=$(($(echo -e "lines" | tput -S) / 4))
|
|
|
|
|
|
|
|
for i in $(find $1 -type f -exec file --mime-type {} \+ | awk -F: '{if ($2 ~/image\//) print $1}'); do
|
|
|
|
CNT=$((CNT+1))
|
|
|
|
if test $(($CNT % 2)) -eq 0 && test "$2" != "-1"; then
|
|
|
|
printf "\033[${posX}A"
|
|
|
|
printf "\033[${posY}C"
|
|
|
|
echo -e "==== $(basename $i) ===="
|
|
|
|
printf "\033[${posY}C"
|
|
|
|
else
|
|
|
|
echo -e "==== $(basename $i) ===="
|
|
|
|
fi
|
|
|
|
|
|
|
|
if echo "$i" | grep -e ".svg$" &> /dev/null; then
|
|
|
|
ffmpeg -i "$i" -vf scale=640:-1 -f image2pipe -vcodec png - 2> /dev/null | wezterm imgcat --height 20%
|
|
|
|
else
|
|
|
|
wezterm imgcat --height 20% "$i";
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
function fixvmware() {
|
|
|
|
sudo systemctl restart docker
|
|
|
|
virsh --connect qemu:///system net-destroy default
|
|
|
|
virsh --connect qemu:///system net-start --network default
|
|
|
|
}
|
|
|
|
|
|
|
|
## colored prompt
|
2023-05-09 15:17:29 +02:00
|
|
|
autoload -U colors && colors
|
|
|
|
PS1="%{$fg[red]%}%n%{$reset_color%}@%{$fg[blue]%}%m %{$fg[yellow]%}%/ %{$reset_color%}% "
|
2023-05-09 16:37:01 +02:00
|
|
|
## called when executing a command
|
2023-05-09 15:17:29 +02:00
|
|
|
function preexec {
|
|
|
|
print -Pn "\e]0;${(q)1}\e\\"
|
2023-02-17 16:41:55 +01:00
|
|
|
}
|
|
|
|
|
2025-01-24 19:23:38 +01:00
|
|
|
transfer()
|
|
|
|
{
|
|
|
|
local file
|
|
|
|
declare -a file_array
|
|
|
|
file_array=("${@}")
|
|
|
|
|
|
|
|
if [[ "${file_array[@]}" == "" || "${1}" == "--help" || "${1}" == "-h" ]]
|
|
|
|
then
|
|
|
|
echo "${0} - Upload arbitrary files to \"transfer.sh\"."
|
|
|
|
echo ""
|
|
|
|
echo "Usage: ${0} [options] [<file>]..."
|
|
|
|
echo ""
|
|
|
|
echo "OPTIONS:"
|
|
|
|
echo " -h, --help"
|
|
|
|
echo " show this message"
|
|
|
|
echo ""
|
|
|
|
echo "EXAMPLES:"
|
|
|
|
echo " Upload a single file from the current working directory:"
|
|
|
|
echo " ${0} \"image.img\""
|
|
|
|
echo ""
|
|
|
|
echo " Upload multiple files from the current working directory:"
|
|
|
|
echo " ${0} \"image.img\" \"image2.img\""
|
|
|
|
echo ""
|
|
|
|
echo " Upload a file from a different directory:"
|
|
|
|
echo " ${0} \"/tmp/some_file\""
|
|
|
|
echo ""
|
|
|
|
echo " Upload all files from the current working directory. Be aware of the webserver's rate limiting!:"
|
|
|
|
echo " ${0} *"
|
|
|
|
echo ""
|
|
|
|
echo " Upload a single file from the current working directory and filter out the delete token and download link:"
|
|
|
|
echo " ${0} \"image.img\" | awk --field-separator=\": \" '/Delete token:/ { print \$2 } /Download link:/ { print \$2 }'"
|
|
|
|
echo ""
|
|
|
|
echo " Show help text from \"transfer.sh\":"
|
|
|
|
echo " curl --request GET \"https://transfer.sh\""
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
for file in "${file_array[@]}"
|
|
|
|
do
|
|
|
|
if [[ ! -f "${file}" ]]
|
|
|
|
then
|
|
|
|
echo -e "\e[01;31m'${file}' could not be found or is not a file.\e[0m" >&2
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
unset file
|
|
|
|
fi
|
|
|
|
|
|
|
|
local upload_files
|
|
|
|
local curl_output
|
|
|
|
local awk_output
|
|
|
|
|
|
|
|
du -c -k -L "${file_array[@]}" >&2
|
|
|
|
# be compatible with "bash"
|
|
|
|
if [[ "${ZSH_NAME}" == "zsh" ]]
|
|
|
|
then
|
|
|
|
read $'upload_files?\e[01;31mDo you really want to upload the above files ('"${#file_array[@]}"$') to "transfer.sh"? (Y/n): \e[0m'
|
|
|
|
elif [[ "${BASH}" == *"bash"* ]]
|
|
|
|
then
|
|
|
|
read -p $'\e[01;31mDo you really want to upload the above files ('"${#file_array[@]}"$') to "transfer.sh"? (Y/n): \e[0m' upload_files
|
|
|
|
fi
|
|
|
|
|
|
|
|
case "${upload_files:-y}" in
|
|
|
|
"y"|"Y")
|
|
|
|
# for the sake of the progress bar, execute "curl" for each file.
|
|
|
|
# the parameters "--include" and "--form" will suppress the progress bar.
|
|
|
|
for file in "${file_array[@]}"
|
|
|
|
do
|
|
|
|
# show delete link and filter out the delete token from the response header after upload.
|
|
|
|
# it is important to save "curl's" "stdout" via a subshell to a variable or redirect it to another command,
|
|
|
|
# which just redirects to "stdout" in order to have a sane output afterwards.
|
|
|
|
# the progress bar is redirected to "stderr" and is only displayed,
|
|
|
|
# if "stdout" is redirected to something; e.g. ">/dev/null", "tee /dev/null" or "| <some_command>".
|
|
|
|
# the response header is redirected to "stdout", so redirecting "stdout" to "/dev/null" does not make any sense.
|
|
|
|
# redirecting "curl's" "stderr" to "stdout" ("2>&1") will suppress the progress bar.
|
|
|
|
curl_output=$(curl --request PUT --progress-bar --dump-header - --upload-file "${file}" "https://transfer.sh/")
|
|
|
|
awk_output=$(awk \
|
|
|
|
'gsub("\r", "", $0) && tolower($1) ~ /x-url-delete/ \
|
|
|
|
{
|
|
|
|
delete_link=$2;
|
|
|
|
print "Delete command: curl --request DELETE " "\""delete_link"\"";
|
|
|
|
|
|
|
|
gsub(".*/", "", delete_link);
|
|
|
|
delete_token=delete_link;
|
|
|
|
print "Delete token: " delete_token;
|
|
|
|
}
|
|
|
|
|
|
|
|
END{
|
|
|
|
print "Download link: " $0;
|
|
|
|
}' <<< "${curl_output}")
|
|
|
|
|
|
|
|
# return the results via "stdout", "awk" does not do this for some reason.
|
|
|
|
echo -e "${awk_output}\n"
|
|
|
|
|
|
|
|
# avoid rate limiting as much as possible; nginx: too many requests.
|
|
|
|
if (( ${#file_array[@]} > 4 ))
|
|
|
|
then
|
|
|
|
sleep 5
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
;;
|
|
|
|
|
|
|
|
"n"|"N")
|
|
|
|
return 1
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
echo -e "\e[01;31mWrong input: '${upload_files}'.\e[0m" >&2
|
|
|
|
return 1
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2023-05-09 16:37:01 +02:00
|
|
|
export PNPM_HOME="$HOME/.local/share/pnpm"
|
2023-09-12 14:02:22 +02:00
|
|
|
export PATH="$PATH:$HOME/bin:$HOME/.local/bin"
|
2024-12-09 16:48:29 +01:00
|
|
|
export PATH=$PATH:/usr/local/go/bin
|
2025-01-24 13:01:11 +01:00
|
|
|
export PATH=$PATH:$HOME/minio-binaries/
|
2023-05-09 16:37:01 +02:00
|
|
|
|
2023-12-18 00:20:02 +01:00
|
|
|
source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh
|
|
|
|
source ~/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
|
2025-01-19 18:07:41 +01:00
|
|
|
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
|
2023-02-17 16:41:55 +01:00
|
|
|
|
2023-08-22 20:01:49 +02:00
|
|
|
export EDITOR=vim
|
|
|
|
|
2023-12-07 08:46:00 +01:00
|
|
|
alias wezterm='flatpak run org.wezfurlong.wezterm'
|
|
|
|
|
2024-06-03 01:56:37 +02:00
|
|
|
fpath=(~/.zsh/completion $fpath)
|
2024-06-26 22:33:49 +02:00
|
|
|
autoload -Uz compinit
|
|
|
|
compinit
|
2024-06-03 01:56:37 +02:00
|
|
|
|
2023-02-17 16:41:55 +01:00
|
|
|
eval "$(starship init zsh)"
|
2023-11-11 18:51:55 +01:00
|
|
|
|
2023-11-11 18:53:15 +01:00
|
|
|
test -e "$HOME/.shellfishrc" && source "$HOME/.shellfishrc"
|
2023-11-13 13:48:17 +01:00
|
|
|
|
2024-02-16 12:13:29 +01:00
|
|
|
if [ -x "$(command -v tmux)" ] && [ -n "${DISPLAY}" ] && [ -z "${TMUX}" ] && [ -n "${WEZTERM_UNIX_SOCKET}" ]; then
|
2023-11-13 13:48:17 +01:00
|
|
|
exec tmux new-session -A -s ${USER} >/dev/null 2>&1
|
|
|
|
fi
|