dotfiles-desktop/.zshrc

352 lines
13 KiB
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# ~/.zshrc file for zsh interactive shells.
# see /usr/share/doc/zsh/examples/zshrc for examples
export ZSH="$HOME/.oh-my-zsh"
ZSH_THEME="jonathan"
plugins=(git)
source $ZSH/oh-my-zsh.sh
setopt autocd # change directory just by typing its name
#setopt correct # auto correct mistakes
setopt interactivecomments # allow comments in interactive mode
setopt magicequalsubst # enable filename expansion for arguments of the form anything=expression
setopt nonomatch # hide error message if there is no match for the pattern
setopt notify # report the status of background jobs immediately
setopt numericglobsort # sort filenames numerically when it makes sense
setopt promptsubst # enable command substitution in prompt
WORDCHARS=${WORDCHARS//\/} # Don't consider certain characters part of the word
# hide EOL sign ('%')
PROMPT_EOL_MARK=""
# configure key keybindings
bindkey -e # emacs key bindings
bindkey ' ' magic-space # do history expansion on space
bindkey '^U' backward-kill-line # ctrl + U
bindkey '^[[3;5~' kill-word # ctrl + Supr
bindkey '^[[3~' delete-char # delete
bindkey '^[[1;5C' forward-word # ctrl + ->
bindkey '^[[1;5D' backward-word # ctrl + <-
bindkey '^[[5~' beginning-of-buffer-or-history # page up
bindkey '^[[6~' end-of-buffer-or-history # page down
bindkey '^[[H' beginning-of-line # home
bindkey '^[[F' end-of-line # end
bindkey '^[[Z' undo # shift + tab undo last action
# enable completion features
autoload -Uz compinit
compinit -d ~/.cache/zcompdump
zstyle ':completion:*:*:*:*:*' menu select
zstyle ':completion:*' auto-description 'specify: %d'
zstyle ':completion:*' completer _expand _complete
zstyle ':completion:*' format 'Completing %d'
zstyle ':completion:*' group-name ''
zstyle ':completion:*' list-colors ''
zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}'
zstyle ':completion:*' rehash true
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
zstyle ':completion:*' use-compctl false
zstyle ':completion:*' verbose true
zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd'
# History configurations
HISTFILE=~/.zsh_history
HISTSIZE=2000
SAVEHIST=4000
setopt hist_expire_dups_first # delete duplicates first when HISTFILE size exceeds HISTSIZE
setopt hist_ignore_dups # ignore duplicated commands history list
setopt hist_ignore_space # ignore commands that start with space
setopt hist_verify # show command with history expansion to user before running it
#setopt share_history # share command history data
# force zsh to show the complete history
alias history="history 0"
# configure `time` format
TIMEFMT=$'\nreal\t%E\nuser\t%U\nsys\t%S\ncpu\t%P'
# make less more friendly for non-text input files, see lesspipe(1)
#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color|*-256color) color_prompt=yes;;
esac
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
configure_prompt() {
prompt_symbol=
# Skull emoji for root terminal
#[ "$EUID" -eq 0 ] && prompt_symbol=💀
case "$PROMPT_ALTERNATIVE" in
twoline)
PROMPT=$'%F{%(#.red.green)}┌──${debian_chroot:+($debian_chroot)─}${VIRTUAL_ENV:+($(basename $VIRTUAL_ENV))─}(%B%F{%(#.red.red)}%n'$prompt_symbol$'%m%b%F{%(#.red.green)})-[%B%F{reset}%(6~.%-1~/…/%4~.%5~)%b%F{%(#.red.green)}]\n└─%B%(#.%F{red}#.%F{red}$)%b%F{reset} '
# Right-side prompt with exit codes and background processes
#RPROMPT=$'%(?.. %? %F{red}%B%b%F{reset})%(1j. %j %F{yellow}%B⚙%b%F{reset}.)'
;;
oneline)
PROMPT=$'${debian_chroot:+($debian_chroot)}${VIRTUAL_ENV:+($(basename $VIRTUAL_ENV))}%B%F{%(#.red.red)}%n@%m%b%F{reset}:%B%F{%(#.red.green)}%~%b%F{reset}%(#.#.$) '
RPROMPT=
;;
backtrack)
PROMPT=$'${debian_chroot:+($debian_chroot)}${VIRTUAL_ENV:+($(basename $VIRTUAL_ENV))}%B%F{red}%n@%m%b%F{reset}:%B%F{red}%~%b%F{reset}%(#.#.$) '
RPROMPT=
;;
esac
unset prompt_symbol
}
# The following block is surrounded by two delimiters.
# These delimiters must not be modified. Thanks.
# START KALI CONFIG VARIABLES
PROMPT_ALTERNATIVE=twoline
NEWLINE_BEFORE_PROMPT=yes
unset color_prompt force_color_prompt
toggle_oneline_prompt(){
if [ "$PROMPT_ALTERNATIVE" = oneline ]; then
PROMPT_ALTERNATIVE=twoline
else
PROMPT_ALTERNATIVE=oneline
fi
configure_prompt
zle reset-prompt
}
zle -N toggle_oneline_prompt
bindkey ^P toggle_oneline_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*|Eterm|aterm|kterm|gnome*|alacritty)
TERM_TITLE=$'\e]0;${debian_chroot:+($debian_chroot)}${VIRTUAL_ENV:+($(basename $VIRTUAL_ENV))}%n@%m: %~\a'
;;
*)
;;
esac
precmd() {
# Print the previously configured title
print -Pnr -- "$TERM_TITLE"
# Print a new line before the prompt, but only if it is not the first line
if [ "$NEWLINE_BEFORE_PROMPT" = yes ]; then
if [ -z "$_NEW_LINE_BEFORE_PROMPT" ]; then
_NEW_LINE_BEFORE_PROMPT=1
else
print ""
fi
fi
}
# enable color support of ls, less and man, and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
export LS_COLORS="$LS_COLORS:ow=30;44:" # fix ls color for folders with 777 permissions
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
alias diff='diff --color=auto'
alias ip='ip --color=auto'
export LESS_TERMCAP_mb=$'\E[1;31m' # begin blink
export LESS_TERMCAP_md=$'\E[1;36m' # begin bold
export LESS_TERMCAP_me=$'\E[0m' # reset bold/blink
export LESS_TERMCAP_so=$'\E[01;33m' # begin reverse video
export LESS_TERMCAP_se=$'\E[0m' # reset reverse video
export LESS_TERMCAP_us=$'\E[1;32m' # begin underline
export LESS_TERMCAP_ue=$'\E[0m' # reset underline
# Take advantage of $LS_COLORS for completion as well
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
fi
# Aliases
# Aliases
# RSS Feeds
alias rss="newsboat"
# Change OpenBSDs Soundlevel
alias audio-ext="sysctl hw.snd.default_unit=4"
alias audio-int="sysctl hw.snd.default_unit=0"
# List files and Folders
alias ll="ls -lah"
# Mount with SSH
alias nasm="sudo sshfs -o uid=1000 -o gid=1000 -o allow_other root@192.168.178.200:/hdds/ /media/anon/nas "
# Torrent via CLI - no seed
alias torrent="aria2c --follow-torrent=mem --seed-time=0 -j 10"
# Neofetch with Picture
alias fetch="neofetch --backend w3m --source ~/Bilder/tiger.png"
# Listen German Radio
alias radio-berliner-rundfunk-91-4="mpv http://stream.berliner-rundfunk.de/brf/mp3-128/internetradio"
# Listen German techno Radio
alias technobase="mpv http://listen.technobase.fm/tunein-mp3"
# Listen anonradio
alias anonradio="mpv http://anonradio.net:8000/anonradio"
# Backup Home Folder
alias backup="~/Software/git/rsync-time-backup/rsync_tmbackup.sh ~/ /media/anon/8TB-int/backup/"
# enter Nanochan with w3m
alias nanochan="torsocks w3m -o auto_image=FALSE https://nanochanqzaytwlydykbg5nxkgyjxk3zsrctxuoxdmbx5jbh2ydyprid.onion/"
# Spinnig ASCII Globe
alias download-world="curl -s http://artscene.textfiles\.com/vt100/globe.vt | pv -L9600 -q"
# Open Darknet Bookmarks
alias darknet="torsocks w3m -o auto_image=FALSE .w3m/bookmark.html"
# Open Weechat that runs on Server
alias reechat="ssh chrissly@vps -t screen -rd weechat"
# Openvpn
alias cast-home="sudo openvpn ~/Seafile/Crypt/zuhause.ovpn"
alias cast-vps="openvpn ~/Seafile/Crypt/vps.ovpn"
# webserver statistics
alias goaccess="ssh tay -t goaccess -c /var/log/nginx/access.log"
# Dotfiles in Git
alias config="git --git-dir=$HOME/.cfg/ --work-tree=$HOME"
# Tempary Upload from cli
alias drop="~/Software/bin/plik"
# Displays when Filesystem was created
alias installation-age="stat -c %w / | cut -d\ -f1"
# launch Stable Diffusion
alias stable-diffusion="bash ~/Software/scripts/stable-diffusion.sh"
# Launch Youtube-dl with Brave Cookies and twitter fix
alias youtube-dl="yt-dlp --cookies-from-browser Brave -o '%(title).100B [%(id)s].%(ext)s'"
# Run a simple webserver in current dir
alias webserver="python3 -m http.server"
#Spotify cli
alias ncspot="flatpak run io.github.hrkfdn.ncspot"
# Launch Matrix Client
alias matrix="gomuks"
# Mound NAS
alias nasm="sudo mount -t nfs4 192.168.178.254:/media/user/raid /media/anon/raid"
# Show Hardware Infos
alias hardware="inxi -Fnxxz"
# start i2p
alias i2p-start="i2p/i2prouter start"
# stop i2p
alias i2p-stop="i2p/i2prouter stop"
# wifite2
alias wifi="sudo wifite -mac --wps --dict ~/Dokumente/rockyou.txt --new-hs"
alias wget-fullpage="wget -mkEpnp -e robots=off --convert-links"
# alias ai-dophin-mixtral="ollama run dolphin-mixtral"
alias lama="ollama run llama3:8b"
alias wireguard-up="sudo wg-quick up vps"
alias wireguard-up"sudo wg-quick down vps"
alias spotify-dl="spotdl"
alias timer="termdown"
# some more ls aliases
alias ll='ls -l'
alias la='ls -A'
alias l='ls -CF'
alias xfix="./xfix.sh"
# functions
# Functions
record-small-screen() {
filename="cast-$(date +"%Y-%m-%d_%H_%M")-$(uname -s)-$(uname -m)"
ffmpeg -f alsa -ac 2 -f x11grab -r 25 -s 1366x768 -i :0.0 -vcodec libx264 -pix_fmt yuv420p -preset ultrafast -crf 0 -threads 0 -acodec pcm_s16le -y ~/$filename.mkv
}
record-big-screen(){
filename="cast-$(date +"%Y-%m-%d_%H_%M")-$(uname -s)-$(uname -m)"
ffmpeg -f alsa -ac 2 -f x11grab -r 25 -s 1920x1080 -i :0.0 -vcodec libx264 -pix_fmt yuv420p -preset ultrafast -crf 0 -threads 0 -acodec pcm_s16le -y ~/$filename.mkv
}
wetter() { curl wttr.in/$1; }
ytdl() {
torsocks mpv ytdl://$@
}
news() {
NNTPSERVER='nntp.aioe.org' && export NNTPSERVER
slrn -f ~/.jnewsrc --create
}
# Download Plemora emojis; requires curl and jq
pleroma-emoji-dl() {
server=$1
curl $server/api/v1/custom_emojis | jq -r 'map(.url)|join("\n")|@text' | xargs wget --random-wait --wait=1
}
# NOTES FILE(S)
notes() {
VAR=$1
if [ -z $VAR ]; then
/usr/local/bin/vim sftp://chrissly@goliath.tinfoil-hat.net/notes/default.txt
elif [ "$VAR" == "-h" ]; then
printf "Usage: notes [-l] [file]\n";
printf " notes Open/Create \"default.txt\" file\n"
printf " notes <file> Open/Create \"<file>.txt\" file\n"
printf " notes -l Show available note files\n"
printf " notes -h Show this help\n"
elif [ "$VAR" == "-l" ]; then
printf "List of notes:\n"
ssh chrissly@sina.tinfoil-hat.net "ls -1 \$HOME/notes/*.txt | sed 's,.*/\(.*\)\.txt, - \1,g'"
else
vim sftp://chrissly@goliath.tinfoil-hat.net/notes/$1.txt
fi
}
# Dotfiles - Autocommit
function dotfiles-autoupdate {
config add -u && \
config commit -m "Update $(date +"%Y-%m-%d %H:%M") $(uname -s)/$(uname -m)" && \
config push origin master
}
# vars
GPG_TTY=$(tty)
NNTPSERVER='news.tilde.club'
TERMINAL='/usr/local/bin/urxvt'
# exports
export GPG_TTY
export LC_ALL=de_DE.UTF-8
export NNTPSERVER
export PATH=$HOME/.local/bin:$PATH
export EDITOR=vim
# enable auto-suggestions based on the history
if [ -f /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh ]; then
. /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh
# change suggestion color
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=#999'
fi
# PS1="%{$(tput setaf 34)%}%n%{$(tput setaf 244)%}@%{$(tput setaf 34)%}%m %{$(tput setaf 178)%}%1~ %{$(tput sgr0)%}$ "
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
# Install Ruby Gems to ~/gems
export GEM_HOME="$HOME/gems"
export PATH="$HOME/gems/bin:$PATH"