first commit

This commit is contained in:
bzoicas
2026-03-13 11:09:33 +02:00
commit 255fd3c079
170 changed files with 8640 additions and 0 deletions

View File

@@ -0,0 +1,75 @@
# Command aliases
alias ..='cd ..'
alias ...='cd ../../../'
alias ....='cd ../../../../'
alias back='cd $OLDPWD'
alias c='clear'
alias cd..='cd ..'
alias cp='cp -iv'
alias chmod="chmod -c"
alias chown="chown -c"
alias df='df -h -x squashfs -x tmpfs -x devtmpfs'
alias e="vim -O "
alias E="vim -o "
alias egrep='egrep --colour=auto'
alias extip='curl icanhazip.com'
alias grep='grep --color=auto'
alias l.='ls -lhFa --time-style=long-iso --color=auto'
alias ll='ls'
alias ln='ln -iv'
alias ls=' ls -lhF --color=auto --human-readable --time-style=long-iso --classify'
alias lsmount='mount |column -t'
alias mkdir='mkdir -pv'
alias mv='mv -iv'
alias ports='netstat -tulanp'
alias h='history -i 1'
alias history='history 1'
alias j='jobs -l'
alias rm='rm -iv'
alias rmdir='rmdir -v'
alias speedtest='curl -s https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | python -'
alias ssha='eval $(ssh-agent) && ssh-add'
alias svim='sudo vim'
alias tn='tmux new -s'
alias watch='watch -d'
alias weather='curl wttr.in'
alias wget='wget -c'
if command -v colordiff > /dev/null 2>&1; then
alias diff="colordiff -Nuar"
else
alias diff="diff -Nuar"
fi
## get top process eating memory
alias mem5='ps auxf | sort -nr -k 4 | head -5'
alias mem10='ps auxf | sort -nr -k 4 | head -10'
## get top process eating cpu ##
alias cpu5='ps auxf | sort -nr -k 3 | head -5'
alias cpu10='ps auxf | sort -nr -k 3 | head -10'
## list largest directories (aka "ducks")
alias dir5='du -cksh * | sort -hr | head -n 5'
alias dir10='du -cksh * | sort -hr | head -n 10'
# Safetynets
# do not delete / or prompt if deleting more than 3 files at a time #
alias rm='rm -I --preserve-root'
# Parenting changing perms on / #
alias chown='chown --preserve-root'
alias chmod='chmod --preserve-root'
alias chgrp='chgrp --preserve-root'
# Package management
if [ -f /usr/bin/apt ]; then
alias update='sudo apt update'
alias upgrade='sudo apt update && sudo apt dist-upgrade && sudo apt autoremove && sudo apt clean'
alias install='sudo apt install'
fi
if [ -f /usr/bin/pacman ]; then
alias update='sudo pacman -Syyy'
alias upgrade='sudo pacman -Syu'
alias install='sudo pacman -S'
fi

View File

@@ -0,0 +1,33 @@
# Set bindkey to emacs mode
bindkey -e
# Restore history searching with ^r
bindkey '^r' history-incremental-search-backward
# Use alt and arrow keys for moving directories
cdUndoKey() {
popd > /dev/null
zle reset-prompt
echo
ls
echo
}
cdParentKey() {
pushd .. > /dev/null
zle reset-prompt
echo
ls
echo
}
zle -N cdParentKey
zle -N cdUndoKey
bindkey '^[[1;3A' cdParentKey
bindkey '^[[1;3D' cdUndoKey
# Control-x-e to open current line in $EDITOR, awesome when writting functions or editing multiline commands.
autoload -U edit-command-line
zle -N edit-command-line
bindkey '^x^e' edit-command-line

View File

@@ -0,0 +1,54 @@
autoload -U compinit && compinit
zmodload -i zsh/complist
# man zshcontrib
zstyle ':vcs_info:*' actionformats '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{3}|%F{1}%a%F{5}]%f '
zstyle ':vcs_info:*' formats '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{5}]%f '
zstyle ':vcs_info:*' enable git #svn cvs
# Enable completion caching, use rehash to clear
zstyle ':completion::complete:*' use-cache on
zstyle ':completion::complete:*' cache-path ~/.zsh/cache/$HOST
# Make directories blue when autocompleting
zstyle ':completion:*' list-colors 'di=34:ln=35:so=32:pi=33:ex=31:bd=46;34:cd=43;34:su=41;30:sg=46;30:tw=42;30:ow=43;30'
# Make the list prompt friendly
zstyle ':completion:*' list-prompt '%SAt %p: Hit TAB for more, or the character to insert%s'
# Make the selection prompt friendly when there are a lot of choices
zstyle ':completion:*' select-prompt '%SScrolling active: current selection at %p%s'
# Add simple colors to kill
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01'
# list of completers to use
zstyle ':completion:*::::' completer _expand _complete _ignored _approximate
# Use menu, also llows you to use arrow keys
zstyle ':completion:*' menu select=2 _complete _ignored _approximate
# insert all expansions for expand completer
zstyle ':completion:*:expand:*' tag-order all-expansions
# match uppercase from lowercase
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
# offer indexes before parameters in subscripts
zstyle ':completion:*:*:-subscript-:*' tag-order indexes parameters
# formatting and messages
zstyle ':completion:*' verbose yes
zstyle ':completion:*:descriptions' format '%B%d%b'
zstyle ':completion:*:messages' format '%d'
zstyle ':completion:*:warnings' format 'No matches for: %d'
zstyle ':completion:*:corrections' format '%B%d (errors: %e)%b'
zstyle ':completion:*' group-name ''
# ignore completion functions (until the _ignored completer)
zstyle ':completion:*:functions' ignored-patterns '_*'
zstyle ':completion:*:scp:*' tag-order files users 'hosts:-host hosts:-domain:domain hosts:-ipaddr"IP\ Address *'
zstyle ':completion:*:scp:*' group-order files all-files users hosts-domain hosts-host hosts-ipaddr
zstyle ':completion:*:ssh:*' tag-order users 'hosts:-host hosts:-domain:domain hosts:-ipaddr"IP\ Address *'
zstyle ':completion:*:ssh:*' group-order hosts-domain hosts-host users hosts-ipaddr
zstyle '*' single-ignored show

View File

@@ -0,0 +1,8 @@
export TERM=xterm-256color
export EDITOR="/usr/bin/vim"
export GREP_COLOR='3;33'
# Not all servers have terminfo for rxvt-256color. :<
#if [ "${TERM}" = 'rxvt-256color' ] && ! [ -f '/usr/share/terminfo/r/rxvt-256color' ] && ! [ -f '/lib/terminfo/r/rxvt-256color' ] && ! [ -f "${HOME}/.terminfo/r/rxvt-256color" ]; #then
# export TERM='rxvt-unicode'
#fi

View File

@@ -0,0 +1,157 @@
# Easily extract archives
extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjvf $1 ;;
*.tar.gz) tar xzvf $1 ;;
*.tar.xz) tar xvf $1 ;;
*.bz2) bzip2 -d $1 ;;
*.rar) unrar2dir $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip2dir $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*.ace) unace x $1 ;;
*) echo "'$1' cannot be extracted via extract()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
run_under_tmux() {
# Run $1 under session or attach if such session already exist.
# $2 is optional path, if no specified, will use $1 from $PATH.
# If you need to pass extra variables, use $2 for it as in example below..
# Example usage:
# torrent() { run_under_tmux 'rtorrent' '/usr/local/rtorrent-git/bin/rtorrent'; }
# mutt() { run_under_tmux 'mutt'; }
# irc() { run_under_tmux 'irssi' "TERM='screen' command irssi"; }
# There is a bug in linux's libevent...
# export EVENT_NOEPOLL=1
command -v tmux >/dev/null 2>&1 || return 1
if [ -z "$1" ]; then return 1; fi
local name="$1"
if [ -n "$2" ]; then
local execute="$2"
else
local execute="command ${name}"
fi
if tmux has-session -t "${name}" 2>/dev/null; then
tmux attach -d -t "${name}"
else
tmux new-session -s "${name}" "${execute}" \; set-option status \; set set-titles-string "${name} (tmux@${HOST})"
fi
}
reload () {
exec "${SHELL}" "$@"
}
confirm() {
local answer
echo -ne "zsh: sure you want to run '${YELLOW}$*${NC}' [yN]? "
read -q answer
echo
if [[ "${answer}" =~ ^[Yy]$ ]]; then
command "${@}"
else
return 1
fi
}
confirm_wrapper() {
if [ "$1" = '--root' ]; then
local as_root='true'
shift
fi
local prefix=''
if [ "${as_root}" = 'true' ] && [ "${USER}" != 'root' ]; then
prefix="sudo"
fi
confirm ${prefix} "$@"
}
poweroff() { confirm_wrapper --root $0 "$@"; }
reboot() { confirm_wrapper --root $0 "$@"; }
hibernate() { confirm_wrapper --root $0 "$@"; }
startx() {
exec =startx
}
begin_with() {
local string="${1}"
shift
local element=''
for element in "$@"; do
if [[ "${string}" =~ "^${element}" ]]; then
return 0
fi
done
return 1
}
termtitle() {
case "$TERM" in
rxvt*|xterm*|nxterm|gnome|screen|screen-*)
local prompt_host="${(%):-%m}"
local prompt_user="${(%):-%n}"
local prompt_char="${(%):-%~}"
case "$1" in
precmd)
printf '\e]0;%s@%s: %s\a' "${prompt_user}" "${prompt_host}" "${prompt_char}"
;;
preexec)
printf '\e]0;%s [%s@%s: %s]\a' "$2" "${prompt_user}" "${prompt_host}" "${prompt_char}"
;;
esac
;;
esac
}
dot_progress() {
# Fancy progress function from Landley's Aboriginal Linux.
# Useful for long rm, tar and such.
# Usage:
# rm -rfv /foo | dot_progress
local i='0'
local line=''
while read line; do
i="$((i+1))"
if [ "${i}" = '25' ]; then
printf '.'
i='0'
fi
done
printf '\n'
}
# Fix backgrounding of GUI apps
precmd_disown() {
emulate -L zsh
setopt extendedglob
local job match mbegin mend
jobs | while read job; do
if [[ $job = \[(#b)([[:digit:]]##)\]*running* ]]; then
disown %$match[1]
fi
done
}
autoload -U add-zsh-hook
add-zsh-hook precmd precmd_disown

View File

@@ -0,0 +1,38 @@
# Set history file
HISTFILE=~/.zhistory
# Set history size
HISTSIZE=1000
# Set the number of lines in $HISTFILE
SAVEHIST="${HISTSIZE}"
# Enable history search with up and down arrows
autoload -Uz up-line-or-beginning-search down-line-or-beginning-search
zle -N up-line-or-beginning-search
zle -N down-line-or-beginning-search
[[ -n "$key[Up]" ]] && bindkey -- "$key[Up]" up-line-or-beginning-search
[[ -n "$key[Down]" ]] && bindkey -- "$key[Down]" down-line-or-beginning-search
# All terminal sessions append to the history file immediately as commands are entered
setopt inc_append_history
# save timestamp of command and duration
setopt extended_history
# when trimming history, lose oldest duplicates first
setopt hist_expire_dups_first
# When a duplicate command is entered, remove the oldest duplicate
setopt hist_ignore_all_dups
# remove command line from history list when first character on the line is a space
setopt hist_ignore_space
# Remove extra blanks from each command line being added to history
setopt hist_reduce_blanks
# Reads the history file every time history is called
# This means that the history command will show recent entries, even between terminal sessions
setopt share_history

View File

@@ -0,0 +1,2 @@
path+=/home/super_user
/.local/bin

View File

@@ -0,0 +1,2 @@
# Load plugins
plugins=(git)

View File

@@ -0,0 +1,3 @@
# Set the prompt
newline=$'\n'
prompt='%F{35}%* [%j]${git_prompt} [%m:%F{75}%f%F{69}%c%f%F{35}] %#%f ${newline}🦄 '

View File

@@ -0,0 +1,38 @@
# Don't beep on error
setopt no_beep
# Allow comments even in interactive shells (especially for Muness)
setopt interactive_comments
# If you type foo, and it isn't a command, and it is a directory in your cdpath, go there
setopt auto_cd
# don't push multiple copies of the same directory onto the directory stack
setopt pushd_ignore_dups
# When completing from the middle of a word, move the cursor to the end of the word
setopt always_to_end
# show completion menu on successive tab press. needs unsetop menu_complete to work
setopt auto_menu
# any parameter that is set to the absolute name of a directory immediately becomes a name for that directory
setopt auto_name_dirs
# Allow completion from within a word/phrase
setopt complete_in_word
# do not autoselect the first completion entry
unsetopt menu_complete
# spelling correction for commands
setopt correct
# Stop annoying error when using asterisk in shell commands (i.e. scp server:*.txt .)
setopt nonomatch
# extended globbing, awesome!
setopt extendedGlob
# Turn on command substitution in the prompt (and parameter expansion and arithmetic expansion).
setopt promptsubst

View File

@@ -0,0 +1,14 @@
# Colors.
red='\e[0;31m'
RED='\e[1;31m'
green='\e[0;32m'
GREEN='\e[1;32m'
yellow='\e[0;33m'
YELLOW='\e[1;33m'
blue='\e[0;34m'
BLUE='\e[1;34m'
purple='\e[0;35m'
PURPLE='\e[1;35m'
cyan='\e[0;36m'
CYAN='\e[1;36m'
NC='\e[0m'

View File

@@ -0,0 +1,11 @@
source ~/.zsh/aliases.zsh
source ~/.zsh/bindkey.zsh
source ~/.zsh/completion.zsh
source ~/.zsh/exports.zsh
source ~/.zsh/functions.zsh
source ~/.zsh/history.zsh
source ~/.zsh/path.zsh
source ~/.zsh/plugins.zsh
source ~/.zsh/prompt.zsh
source ~/.zsh/setopt.zsh
source ~/.zsh/theming.zsh