From 3ac8e0f994839f3c972033bcb12421081ebeb683 Mon Sep 17 00:00:00 2001 From: David Runge Date: Tue, 28 Sep 2021 22:50:56 +0200 Subject: zsh: move includes to XDG compliant locations .config/zsh/{functions,includes}/*: Move functions and includes to XDG compliant locations. .zshrc: Include functions and other includes from XDG compliant locations. Remove use of prepend-sudo function. --- .config/zsh/functions/01_editor.zsh | 124 +++++++++++ .config/zsh/functions/02_utility.zsh | 75 +++++++ .config/zsh/functions/0_terminal.zsh | 74 +++++++ .config/zsh/functions/overrides.zsh | 4 + .config/zsh/functions/packaging.zsh | 133 ++++++++++++ .config/zsh/includes/aliases.zsh | 276 +++++++++++++++++++++++ .config/zsh/includes/apt | 37 ++++ .config/zsh/includes/export.zsh | 102 +++++++++ .config/zsh/includes/frqrec | 0 .config/zsh/includes/functions.zsh | 398 ++++++++++++++++++++++++++++++++++ .config/zsh/includes/hostspecific.zsh | 6 + .config/zsh/includes/key-bindings.zsh | 22 ++ .config/zsh/includes/path.zsh | 19 ++ .config/zsh/includes/udisks.zsh | 245 +++++++++++++++++++++ .config/zsh/includes/unixpool | 125 +++++++++++ .zsh.after/aliases.zsh | 276 ----------------------- .zsh.after/apt | 37 ---- .zsh.after/export.zsh | 102 --------- .zsh.after/frqrec | 0 .zsh.after/functions.zsh | 398 ---------------------------------- .zsh.after/hostspecific.zsh | 6 - .zsh.after/key-bindings.zsh | 22 -- .zsh.after/path.zsh | 19 -- .zsh.after/udisks.zsh | 245 --------------------- .zsh.after/unixpool | 125 ----------- .zsh.functions/01_editor.zsh | 124 ----------- .zsh.functions/02_utility.zsh | 75 ------- .zsh.functions/0_terminal.zsh | 74 ------- .zsh.functions/overrides.zsh | 4 - .zsh.functions/packaging.zsh | 133 ------------ .zshrc | 13 +- 31 files changed, 1644 insertions(+), 1649 deletions(-) create mode 100644 .config/zsh/functions/01_editor.zsh create mode 100644 .config/zsh/functions/02_utility.zsh create mode 100644 .config/zsh/functions/0_terminal.zsh create mode 100644 .config/zsh/functions/overrides.zsh create mode 100644 .config/zsh/functions/packaging.zsh create mode 100644 .config/zsh/includes/aliases.zsh create mode 100644 .config/zsh/includes/apt create mode 100644 .config/zsh/includes/export.zsh create mode 100644 .config/zsh/includes/frqrec create mode 100644 .config/zsh/includes/functions.zsh create mode 100644 .config/zsh/includes/hostspecific.zsh create mode 100644 .config/zsh/includes/key-bindings.zsh create mode 100644 .config/zsh/includes/path.zsh create mode 100644 .config/zsh/includes/udisks.zsh create mode 100644 .config/zsh/includes/unixpool delete mode 100644 .zsh.after/aliases.zsh delete mode 100644 .zsh.after/apt delete mode 100644 .zsh.after/export.zsh delete mode 100644 .zsh.after/frqrec delete mode 100644 .zsh.after/functions.zsh delete mode 100644 .zsh.after/hostspecific.zsh delete mode 100644 .zsh.after/key-bindings.zsh delete mode 100644 .zsh.after/path.zsh delete mode 100644 .zsh.after/udisks.zsh delete mode 100644 .zsh.after/unixpool delete mode 100644 .zsh.functions/01_editor.zsh delete mode 100644 .zsh.functions/02_utility.zsh delete mode 100644 .zsh.functions/0_terminal.zsh delete mode 100644 .zsh.functions/overrides.zsh delete mode 100644 .zsh.functions/packaging.zsh diff --git a/.config/zsh/functions/01_editor.zsh b/.config/zsh/functions/01_editor.zsh new file mode 100644 index 0000000..1484a92 --- /dev/null +++ b/.config/zsh/functions/01_editor.zsh @@ -0,0 +1,124 @@ +# Exposes information about the Zsh Line Editor via the $editor_info associative +# array. +function editor-info { + # Clean up previous $editor_info. + unset editor_info + typeset -gA editor_info + + if [[ "$KEYMAP" == 'vicmd' ]]; then + zstyle -s ':editor:info:keymap:alternate' format 'REPLY' + editor_info[keymap]="$REPLY" + else + zstyle -s ':editor:info:keymap:primary' format 'REPLY' + editor_info[keymap]="$REPLY" + + if [[ "$ZLE_STATE" == *overwrite* ]]; then + zstyle -s ':editor:info:keymap:primary:overwrite' format 'REPLY' + editor_info[overwrite]="$REPLY" + else + zstyle -s ':editor:info:keymap:primary:insert' format 'REPLY' + editor_info[overwrite]="$REPLY" + fi + fi + + unset REPLY + + zle reset-prompt + zle -R +} +zle -N editor-info + +# Updates editor information when the keymap changes. +function zle-keymap-select { + zle editor-info +} +zle -N zle-keymap-select + +# Enables terminal application mode and updates editor information. +function zle-line-init { + # The terminal must be in application mode when ZLE is active for $terminfo + # values to be valid. + if (( $+terminfo[smkx] )); then + # Enable terminal application mode. + echoti smkx + fi + + # Update editor information. + zle editor-info +} +zle -N zle-line-init + +# Disables terminal application mode and updates editor information. +function zle-line-finish { + # The terminal must be in application mode when ZLE is active for $terminfo + # values to be valid. + if (( $+terminfo[rmkx] )); then + # Disable terminal application mode. + echoti rmkx + fi + + # Update editor information. + zle editor-info +} +zle -N zle-line-finish + +# Toggles emacs overwrite mode and updates editor information. +function overwrite-mode { + zle .overwrite-mode + zle editor-info +} +zle -N overwrite-mode + +# Enters vi insert mode and updates editor information. +function vi-insert { + zle .vi-insert + zle editor-info +} +zle -N vi-insert + +# Moves to the first non-blank character then enters vi insert mode and updates +# editor information. +function vi-insert-bol { + zle .vi-insert-bol + zle editor-info +} +zle -N vi-insert-bol + +# Enters vi replace mode and updates editor information. +function vi-replace { + zle .vi-replace + zle editor-info +} +zle -N vi-replace + +# Expands .... to ../.. +function expand-dot-to-parent-directory-path { + if [[ $LBUFFER = *.. ]]; then + LBUFFER+='/..' + else + LBUFFER+='.' + fi +} +zle -N expand-dot-to-parent-directory-path + +# Displays an indicator when completing. +function expand-or-complete-with-indicator { + local indicator + zstyle -s ':editor:info:completing' format 'indicator' + print -Pn "$indicator" + zle expand-or-complete + zle redisplay +} +zle -N expand-or-complete-with-indicator + +# Inserts 'sudo ' at the beginning of the line. +function prepend-sudo { + if [[ "$BUFFER" != su(do|)\ * ]]; then + BUFFER="sudo $BUFFER" + (( CURSOR += 5 )) + fi +} +zle -N prepend-sudo + +# Reset to default key bindings. +bindkey -d diff --git a/.config/zsh/functions/02_utility.zsh b/.config/zsh/functions/02_utility.zsh new file mode 100644 index 0000000..05b77bc --- /dev/null +++ b/.config/zsh/functions/02_utility.zsh @@ -0,0 +1,75 @@ +# Makes a directory and changes to it. +function mkdcd { + [[ -n "$1" ]] && mkdir -p "$1" && builtin cd "$1" +} + +# Changes to a directory and lists its contents. +function cdls { + builtin cd "$argv[-1]" && ls "${(@)argv[1,-2]}" +} + +# Pushes an entry onto the directory stack and lists its contents. +function pushdls { + builtin pushd "$argv[-1]" && ls "${(@)argv[1,-2]}" +} + +# Pops an entry off the directory stack and lists its contents. +function popdls { + builtin popd "$argv[-1]" && ls "${(@)argv[1,-2]}" +} + +# Prints columns 1 2 3 ... n. +function slit { + awk "{ print ${(j:,:):-\$${^@}} }" +} + +# Finds files and executes a command on them. +function find-exec { + find . -type f -iname "*${1:-}*" -exec "${2:-file}" '{}' \; +} + +# Displays user owned processes status. +function psu { + ps -U "${1:-$LOGNAME}" -o 'pid,%cpu,%mem,command' "${(@)argv[2,-1]}" +} + +# Highlights make output. +function make { + if (( $+commands[colormake] )); then + colormake "$@" + else + command make "$@" + fi +} + +# Lists the contents of archives. +function lsarchive { + while (( $# > 0 )); do + if [[ ! -s "$1" ]]; then + print "$0: file not valid: $1" >&2 + shift + continue + fi + case "$1:l" in + (*.tar.gz|*.tgz) tar t${verbose:+v}vzf "$1" ;; + (*.tar.bz2|*.tbz|*.tbz2) tar t${verbose:+v}jf "$1" ;; + (*.tar.xz|*.txz) tar --xz --help &> /dev/null \ + && tar --xz -t${verbose:+v}f "$1" \ + || xzcat "$1" | tar t${verbose:+v}f - ;; + (*.tar.zma|*.tlz) tar --lzma --help &> /dev/null \ + && tar --lzma -t${verbose:+v}f "$1" \ + || lzcat "$1" | tar x${verbose:+v}f - ;; + (*.tar) tar t${verbose:+v}f "$1" ;; + (*.zip) unzip -l${verbose:+v} "$1" ;; + (*.rar) unrar &> /dev/null \ + && unrar ${${verbose:+v}:-l} "$1" \ + || rar ${${verbose:+v}:-l} "$1" ;; + (*.7z) 7za l "$1" ;; + (*) + print "$0: cannot list: $1" >&2 + success=1 + ;; + esac + shift + done +} diff --git a/.config/zsh/functions/0_terminal.zsh b/.config/zsh/functions/0_terminal.zsh new file mode 100644 index 0000000..85be89a --- /dev/null +++ b/.config/zsh/functions/0_terminal.zsh @@ -0,0 +1,74 @@ +# Terminal functions +# + +# Sets the terminal or terminal multiplexer window title. +function set-window-title { + local title_format{,ted} + title_format='%s' + zformat -f title_formatted "$title_format" "s:$argv" + + if [[ "$TERM" == screen* ]]; then + title_format="\ek%s\e\\" + else + title_format="\e]2;%s\a" + fi + + printf "$title_format" "${(V%)title_formatted}" +} + +# Sets the terminal tab title. +function set-tab-title { + local title_format{,ted} + title_format='%s' + zformat -f title_formatted "$title_format" "s:$argv" + + printf "\e]1;%s\a" ${(V%)title_formatted} +} + + +# Sets the tab and window titles with a given command. +function _terminal-set-titles-with-command { + emulate -L zsh + setopt EXTENDED_GLOB + + # Get the command name that is under job control. + if [[ "${2[(w)1]}" == (fg|%*)(\;|) ]]; then + # Get the job name, and, if missing, set it to the default %+. + local job_name="${${2[(wr)%*(\;|)]}:-%+}" + + # Make a local copy for use in the subshell. + local -A jobtexts_from_parent_shell + jobtexts_from_parent_shell=(${(kv)jobtexts}) + + jobs "$job_name" 2>/dev/null > >( + read index discarded + # The index is already surrounded by brackets: [1]. + _terminal-set-titles-with-command "${(e):-\$jobtexts_from_parent_shell$index}" + ) + else + # Set the command name, or in the case of sudo or ssh, the next command. + local cmd="${${2[(wr)^(*=*|sudo|ssh|-*)]}:t}" + local truncated_cmd="${cmd/(#m)?(#c15,)/${MATCH[1,12]}...}" + unset MATCH + + set-window-title "$cmd" + set-tab-title "$truncated_cmd" + fi +} + + +# Sets the tab and window titles with a given path. +function _terminal-set-titles-with-path { + emulate -L zsh + setopt EXTENDED_GLOB + + local absolute_path="${${1:a}:-$PWD}" + local abbreviated_path="${absolute_path/#$HOME/~}" + local truncated_path="${abbreviated_path/(#m)?(#c15,)/...${MATCH[-12,-1]}}" + unset MATCH + + set-window-title "$abbreviated_path" + set-tab-title "$truncated_path" +} + + diff --git a/.config/zsh/functions/overrides.zsh b/.config/zsh/functions/overrides.zsh new file mode 100644 index 0000000..b320671 --- /dev/null +++ b/.config/zsh/functions/overrides.zsh @@ -0,0 +1,4 @@ +# make git auto completion faster by favoring local files +__git_files () { + _wanted files expl 'local files' _files +} diff --git a/.config/zsh/functions/packaging.zsh b/.config/zsh/functions/packaging.zsh new file mode 100644 index 0000000..69d6df4 --- /dev/null +++ b/.config/zsh/functions/packaging.zsh @@ -0,0 +1,133 @@ +#!/usr/bin/env zsh + +pkg_sign() { + # sign one or more packages with the key setup in makepkg.conf + local _pkg_list=() + local _arg _pkg + + # get GPGKEY from makepkg.conf + if [[ -f /etc/makepkg.conf ]]; then + source /etc/makepkg.conf 2>/dev/null 1>&2 + fi + if [[ -f "${HOME}/.makepkg.conf" ]]; then + source "${HOME}/.makepkg.conf" 2>/dev/null 1>&2 + fi + if [[ -z "${GPGKEY}" ]]; then + 1>&2 printf "No GPGKEY is setup in makepkg.conf!\n" + return 1 + fi + + # check whether file(s) exists or globs exist + for _arg in "$@"; do + if [[ -f "${_arg}" ]] && [[ "${_arg}" == *.pkg.tar.zst ]]; then + _pkg_list+=( "${_arg}" ) + fi + if [[ -n *"${_arg}"*.pkg.tar.zst(#qN) ]]; then + _pkg_list+=( *"${_arg}"*.pkg.tar.zst ) + fi + done + + # sign package(s) + if (( ${#_pkg_list} > 0 )); then + for _pkg in "${_pkg_list[@]}"; do + gpg --detach-sign --local-user "${GPGKEY}" "$_pkg" + done + return 0 + else + 1>&2 printf "No package can be found for signing!\n" + return 1 + fi +} + +pkg_add() { + # sign one or more packages with the key setup in makepkg.conf + local _pkg_list=() + local _arg + + # get GPGKEY from makepkg.conf + if [[ -f /etc/makepkg.conf ]]; then + source /etc/makepkg.conf 2>/dev/null 1>&2 + fi + if [[ -f "${HOME}/.makepkg.conf" ]]; then + source "${HOME}/.makepkg.conf" 2>/dev/null 1>&2 + fi + if [[ -z "${GPGKEY}" ]]; then + 1>&2 printf "No GPGKEY is setup in makepkg.conf!\n" + return 1 + fi + + # check whether file(s) exists or globs exist + for _arg in "$@"; do + if [[ -f "${_arg}" ]] && [[ "$_arg" == *.pkg.tar.zst ]]; then + _pkg_list+=( "${_arg}" ) + fi + if [[ -n *"${_arg}"*.pkg.tar.zst(#qN) ]]; then + _pkg_list+=( *"${_arg}"*.pkg.tar.zst ) + fi + done + + # add package(s) to repo database + if (( ${#_pkg_list} > 0 )); then + repo-add -R -s -k "${GPGKEY}" "$(dirname "${_pkg_list[1]}")"/*.db.tar.gz "${_pkg_list[@]}" + return 0 + else + 1>&2 printf "No packages to add can be found!\n" + return 1 + fi +} + +sshfs_mount() { + mkdir -p "${HOME}/mounts/$1" + sshfs -C -F "${HOME}/.ssh/config" "$1": "${HOME}/mounts/$1" +} + +sshfs_umount() { + fusermount3 -u "${HOME}/mounts/$1" +} + +nvc() { + local config + if [[ -z "$1" ]]; then + 1>&2 printf "A repository name needs to be specified as the first argument.\n" + return 1 + fi + config="${HOME}/.config/nvchecker/$1.toml" + if [[ ! -f "${config}" ]]; then + 1>&2 printf "The configuration does not exist: %s\n" "${config}" + return 1 + fi + if ! command -v nvchecker > /dev/null; then + 1>&2 printf "The required application 'nvchecker' can not be found.\n" + return 1 + fi + nvchecker -c "${config}" +} + +nvt() { + local config package + if [[ -z "$1" ]]; then + 1>&2 printf "A repository name needs to be specified as the first argument.\n" + return 1 + fi + config="${HOME}/.config/nvchecker/$1.toml" + if [[ ! -f "${config}" ]]; then + 1>&2 printf "The configuration does not exist: %s\n" "${config}" + return 1 + fi + + if [[ -z "$2" ]]; then + 1>&2 printf "A package name needs to be specified as the second argument.\n" + return 1 + fi + package="${2}" + if ! grep "${package}" "${config}" > /dev/null; then + 1>&2 printf "The package %s can not be found in the configuration: %s\n" "${package}" "${config}" + return 1 + fi + + if ! command -v nvtake > /dev/null; then + 1>&2 printf "The required application 'nvtake' can not be found.\n" + return 1 + fi + nvtake -c "${config}" "${package}" +} diff --git a/.config/zsh/includes/aliases.zsh b/.config/zsh/includes/aliases.zsh new file mode 100644 index 0000000..20a055f --- /dev/null +++ b/.config/zsh/includes/aliases.zsh @@ -0,0 +1,276 @@ +# < ZSH ALIASES +# suffix aliases +alias -s pdf='mupdf' +alias -s ps='mupdf' +alias -s jpg='feh' +alias -s png='feh' +alias -s gif='viewnior' +alias -s gz='tar xvfz' +alias -s tgz='tar xvfz' +alias -s bz2='tar xvfj' +alias -s tbz='tar xvfj' +alias -s tlz='tar --lzma -xvf' +alias -s rar='unrar x' +alias -s tex='mkpdf' + +# global aliases +alias -g ...='../..' +alias -g ....='../../..' +alias -g .....='../../../..' +alias -g C='| wc -l' +alias -g H='| head' +alias -g L="| less" +alias -g N="| /dev/null" +alias -g S='| sort' +alias -g G='| grep' + +# ls +alias ls='ls --group-directories-first --color=auto' +alias ll="ls -lh" +alias la="ls -a" +alias lal="ls -alhv" +alias lt='ls -tr' +alias ll='ls -l' +alias llh='ls -lh' +alias llt='ls -ltr' +alias la='ls -A' +alias lla='ls -lA' +alias lsfw='ls -lah /dev|grep fw' +alias lsvid='ls -lah /dev|grep video' + +#zsh + +# Lists the ten most used commands. +alias history-stat="history 0 | awk '{print \$2}' | sort | uniq -c | sort -n -r | head" + +alias d='dirs -v' +for index ({1..9}) alias "$index"="cd +${index}"; unset index + +#MPLAYER +alias mplayer='mplayer -ao jack,pulse,alsa' +if pgrep Xwayland > /dev/null; then + alias mpv='mpv --audio-channels=stereo --gpu-context=wayland -ao=jack,pulse,alsa --sub-auto=fuzzy --jack-port="minimixer:in1_*"' +else + alias mpv='mpv --audio-channels=stereo -ao=jack,pulse,alsa --sub-auto=fuzzy --jack-port="minimixer:in1_*"' +fi +if [[ "$VENDOR" == "apple" ]]; then + alias mpv='mpv --sub-auto=fuzzy' +fi +##DU +alias du1='du -hd1' + +##FEH +alias feh='feh -Z -g 1920x1200 -b "black" -S "filename"' + +##GIT +alias gsi='git submodule update --init --recursive' +alias gsu='git submodule update --recursive' + +##TREE +alias tree='tree -aC' +#grep aliases (with excluded directories) +alias grepdot='grep -rI --exclude-dir=".steam" --exclude-dir=".local" --exclude-dir=".thunderbird" --exclude-dir=".mozilla" --exclude-dir="git" --exclude-dir=".rvm" --exclude-dir=".log" --exclude-dir=".dropbox-dist" --exclude-dir=".config" ' + + +##SYSTEMD +#tree +alias psc='ps xawf -eo pid,user,cgroup,args' +alias treeg='tree -d /cgroup/systemd/' +alias sdptree='tree -aC /usr/lib/systemd/' +alias sdstree='tree -aC /etc/systemd/' +alias sdutree='tree -aC $HOME/.config/systemd/' +#journalctl +alias sdsj='sudo journalctl --system -a' #show the entire system journal +alias sdsjf='sudo journalctl --system -af' #follow all system messages +alias sdsjb='sudo journalctl --system -ab' #Show system messages from specific boot +alias sdsjbf='sudo journalctl --system -ab -f' #follow only messages from this boot +alias sdsju='sudo journalctl --system -af -u' #follow messages of only the specified unit +alias sdsjk='journalctl -k' #show dmesg +alias sdsjkb='journalctl -kb' #show dmesg from specific boot +alias sdsjkf='journalctl -kf' #follow current dmesg +alias sdsjlb='journalctl --list-boots' #list all boots +alias sdsjp='sudo journalctl --system _PID=' #show all messages of specified system process (PID) +alias sdjgrep='sudo journalctl -an1000 |grep ' #Use a grep command to search through journal +alias sduj='journalctl --user -a' +alias sdujf='journalctl --user -af' +alias sdujb='journalctl --user -ab' +alias sdujbf='journalctl --user -afb' +alias sdujb='journalctl --user -ab' +alias sdujp='journalctl --user _PID=' #show all messages of specified user process (PID) +#systemd system services +alias sdsedit='sudo systemctl edit' +alias sdsstart='sudo systemctl start' +alias sdsstop='sudo systemctl stop' +alias sdsrestart='sudo systemctl restart' +alias sdsreload='sudo systemctl reload' +alias sdsenable='sudo systemctl enable' +alias sdsdisable='sudo systemctl disable' +alias sdsreenable='sudo systemctl reenable' +alias sdsisactive='sudo systemctl is-active' +alias sdsisenabled='sudo systemctl is-enabled' +alias sdsstat='sudo systemctl status -a -l' +alias sdswants='sudo systemctl show -p "Wants"' +alias sdswantedby='sudo systemctl show -p "WantedBy"' +alias sdsrequires='sudo systemctl show -p "Requires"' +alias sdsrequiredby='sudo systemctl show -p "RequiredBy"' +alias sdsconflicts='sudo systemctl show -p "Conflicts"' +alias sdsconflictedby='sudo systemctl show -p "ConflictedBy"' +alias sdsbefore='sudo systemctl show -p "Before"' +alias sdsafter='sudo systemctl show -p "After"' +alias sdst='sudo systemctl --system list-timers' +alias sdss='sudo systemctl --system list-sockets' +alias sdsu='sudo systemctl --system list-units' +alias sdsuf='sudo systemctl --system list-unit-files' +alias sdsdep='sudo systemctl --system list-dependencies' +alias sdscat='systemctl --system cat' +alias sdsreload='sudo systemctl daemon-reload' +alias sds='sudo systemctl -a' +alias sdsfail='sudo systemctl -a -l --no-legend --state=failed' +alias sdsmask='sudo systemctl mask' +alias sdsunmask='sudo systemctl unmask' +#systemd user services +alias sduedit='systemctl --user edit' +alias sdustart='systemctl --user start' +alias sdustop='systemctl --user stop' +alias sdurestart='systemctl --user restart' +alias sdureload='systemctl --user reload' +alias sduenable='systemctl --user enable' +alias sdudisable='systemctl --user disable' +alias sdureenable='systemctl --user reenable' +alias sduisactive='systemctl --user is-active' +alias sduisenabled='systemctl --user is-enabled' +alias sdustat='systemctl --user status -a -l' +alias sduwants='systemctl --user show -p "Wants"' +alias sduwantedby='systemctl --user show -p "WantedBy"' +alias sdurequires='systemctl --user show -p "Requires"' +alias sdurequiredby='systemctl --user show -p "RequiredBy"' +alias sduconflicts='systemctl --user show -p "Conflicts"' +alias sduconflictedby='systemctl --user show -p "ConflictedBy"' +alias sdubefore='systemctl --user show -p "Before"' +alias sduafter='systemctl --user show -p "After"' +alias sdut='systemctl --user list-timers' +alias sdus='systemctl --user list-sockets' +alias sduu='systemctl --user list-units' +alias sdudep='systemctl --user list-dependencies' +alias sducat='systemctl --user cat' +alias sdureload='systemctl --user daemon-reload' +#alias sdu='systemctl --user' +alias sdufail='systemctl --user -a -l --no-legend --state=failed' +alias sdumask='systemctl --user mask' +alias sduunmask='systemctl --user unmask' +#poweroff/reboot/isolate +alias sdiso='sudo systemctl isolate ' +alias sdreboot='sudo systemctl reboot' +alias sdpoweroff='sudo systemctl poweroff' +alias sdsuspend='sudo systemctl suspend' +#systemd bootchart +alias sda='systemd-analyze' +alias sdab='systemd-analyze blame' +if [ -x /usr/bin/xsvg ]; then + alias sdap='xsvg $HOME/cloud/photos/systemd/sdap-$HOST.svg' +fi + +##PACMAN +alias paclid="sudo pacman -Qi | sed '/^Depends On/,/^Required By/{ s/^Required By.*$//; H; d }; /^Name/!d; /^Name/{ n;x;}'| sed '/^$/s//==================================================================================/'" +alias pacsize="pacman -Qi | awk '/^Name/ {pkg=\$3} /Size/ {print \$4\$5,pkg}' | sort -n" #Show all packages by size +alias pacall="sudo pacman -Qi | awk '/^Name/ {pkg=\$3} /Version/ {ver=\$3} /Size/ {size=\$4\$5} {print pkg,ver,size}' | uniq" #All packages uniquely with name, version, size +alias pacup='sudo pacman -Syu' #Synchronize with repositories before upgrading packages that are out of date on the local system. +alias pac='sudo pacman -S' #Install specific package(s) from the repositories +alias pacu='sudo pacman -U' #Install specific package not from the repositories but from a file +alias pacre='sudo pacman -R' #Remove the specified package(s), retaining its configuration(s) and required dependencies +alias pacrem='sudo pacman -Rns' #Remove specified package(s), its configuration(s) and unneeded depends +alias pacname="sudo pacman -Qi|grep Name|grep " #Search through names of packages by string +alias pacri='pacman -Si' #Display information about a given package in the repositories +alias pacrs='pacman -Ss' #Search for package(s) in the repositories +alias pacli='pacman -Qi' #Display information about a given package in the local database +alias pacls='pacman -Qs' #Search for package(s) in the local database +alias pacorph='sudo pacman -Qdt' #Search for orphan packages +alias paclal='pacman -Ql' #List installed files of a given package +alias pacg='pacman -Sg' #List all groups or all packages in specified group +alias pacclean='sudo pacman -Sc' #Remove all packages from local repository, not installed atm, remove all unused repos +alias pacconf='sudo find /etc -type f \( -name "*.pacsave" -o -name "*.pacnew" \)' #Search for .pacnew and .pacsave files +alias pacown='sudo pacman -Qo' # Find out what package a give file belongs to +alias pacupd='sudo pacman -Sy && sudo abs' #Update and refresh the local package and ABS databases against repositories +alias pacdep='sudo pacman -S --asdeps' #Install given package(s) as dependencies of another package +alias pacmir='sudo pacman -Syy' #Force refresh of all package lists after updating /etc/pacman.d/mirrorlist +alias packup='comm -23 <(pacman -Qeq|sort) <(pacman -Qmq|sort) > $HOME/Dropbox/sync/archlinux/pkglist-$HOST' #Backup the current list of non-local packages +alias pacret='sudo pacman -S $(< $HOME/Dropbox/sync/archlinux/pkglist-$HOST)' #Install from the backup list +alias pacredown='sudo pacman -S $(comm -23 <(pacman -Qeq) <(pacman -Qmq))' #Redownload all installed packages (minus AUR) +alias pacdis='sudo pacman-disowned > /tmp/$USERNAME/non-pkg-$HOST' #Getting a list of files not owned by any package +alias packimp='sudo pacman-key -r ' #Import a key ID to the pacman keyring +alias packsign='sudo pacman-key --lsign-key ' #Sign a key ID after importing it to the keyring +alias packref='sudo pacman-key --refresh-keys' #Refresh the list of master keys + +##YAOURT +alias yaup='yaourt -Syu --devel --aur' #Updates all locally installed repository, AUR and git packages +alias yadb='yaourt -B $HOME/ownCloud/backup/settings/' #Backs up the yaourt database + +##XCLIP +alias cpx="xclip -selection clipboard -display :0" + +##CD +alias cd.sds="cd /etc/systemd/system" +alias cd.sdp="cd /usr/lib/systemd/system" +alias cd.courses="cd $HOME/ownCloud/documents/university/tu-berlin/courses" +alias cd.backup="cd $HOME/ownCloud/backup" +alias cd.scpref="cd $HOME/.config/SuperCollider" + +##OCTAVE +#alias octave="octave --silent --braindead --force-gui" +alias octave="octave --force-gui" + +##MATLAB +alias matlabc="matlab -nodesktop -nosplash" + +##NMCLI +alias nmup="sudo nmcli con up id" +alias nmdown="sudo nmcli con down id" +alias nmstat="sudo nmcli con show --active" +alias nmlist="sudo nmcli con list" +alias nmdev="sudo nmcli dev" + +#SSH +alias ssh.add="ssh-add $HOME/.ssh/id_{rsa{,_tu},ed25519{,_aur,_github,_holoplot}}" +alias ssh.new='ssh-keygen -t ed25519 -C "$(whoami)@$(hostname)-$(date -I)"' +if [ $VENDOR = "apple" ]; then + # apple's date is broken + alias ssh.new='ssh-keygen -t ed25519 -C "$(whoami)@$(hostname)-$(date +%Y-%m-%d)"' +fi +alias pool='ssh pool -Y' +alias sshtunnel="ssh -ND 44350 -v -p 46399 dave@frqb.zapto.org" # tunnel through home +alias frqtun="ssh -ND 44350 -v frq" +alias scp=scp + +#KEYCHAIN +alias keyflush="keychain --clear && keychain -k mine" + +#PULSEAUDIO +alias pak='pulseaudio --kill' +alias pas='pulseaudio --start' +alias paflush='pax11publish -r' +alias bthp="pactl load-module module-bluetooth-device address='00:1B:66:01:6C:D1'" #load bluetooth headphone module for pulseaudio + +#PYTHON +alias pyserv='python -m http.server' # start a python http server + +# VDIRSYNCER +alias vsync="vdirsyncer sync" + +#WOL +alias woldave_in='wol -i homey 00:15:f2:e0:e0:c6' #wake up homey +alias woldave_ex='wol -p X -i frqb.zapto.org 00:15:f2:e0:e0:c6' #wake up homey via + +## OVERRIDES +# Colorize grep output +alias grep='grep --color=auto --exclude-dir=.git' +alias psgrep='ps aux | grep -v "grep"| grep $1' +alias greptodo='grep -R "TODO" .' +alias exit="clear; exit" +alias du='du -h' +alias .='source' + + +## HELP +alias helpdd='echo dd if=bla | pv -s 10M | dd of=blob' + +# ZSH ALIASES > diff --git a/.config/zsh/includes/apt b/.config/zsh/includes/apt new file mode 100644 index 0000000..e1942cf --- /dev/null +++ b/.config/zsh/includes/apt @@ -0,0 +1,37 @@ +#TODO: add pacman to apt-get conversion for all pacman aliases +alias paclid="sudo pacman -Qi | sed '/^Depends On/,/^Required By/{ s/^Required By.*$//; H; d }; /^Name/!d; /^Name/{ n;x;}'| sed '/^$/s//==================================================================================/'" +alias pacsize="pacman -Qi | awk '/^Name/ {pkg=\$3} /Size/ {print \$4\$5,pkg}' | sort -n" #All packages by size +alias pacall="sudo pacman -Qi | awk '/^Name/ {pkg=\$3} /Version/ {ver=\$3} /Size/ {size=\$4\$5} {print pkg,ver,size}' | uniq" #All packages uniquely with name, version, size +#alias pacremorph='sudo pacman -Rs $(pacman -Qtdq)' #Remove all orphaned packages +alias pacup='sudo apt-get update && sudo apt-get upgrade' #'sudo pacman -Syu' # Synchronize with repositories before upgrading packages that are out of date on the local system. +alias pac='sudo apt-get install ' #'sudo pacman -S' # Install specific package(s) from the repositories +alias pacu='sudo pacman -U' # Install specific package not from the repositories but from a file +alias pacre='sudo apt-get remove ' #'sudo pacman -R' # Remove the specified package(s), retaining its configuration(s) and required ##dependencies +alias pacrem='sudo apt-get purge ' #'sudo pacman -Rns' # Remove specified package(s), its configuration(s) and unneeded depends +alias pacsearch="pacman -Sl | cut -d' ' -f2 | grep " # Search through all available packages in repo +#alias pacname='dpkg -l|grep Name|grep ' #'sudo pacman -Qi|grep Name|grep ' #Search through names of packages by string +alias pacri='sudo apt-get update && sudo apt-cache show ' #'pacman -Si' # Display information about a given package in the repositories +alias pacrs='sudo apt-get update && sudo apt-cache search ' #'pacman -Ss' # Search for package(s) in the repositories +alias pacli='dpkg -l ' #'pacman -Qi' # Display information about a given package in the local database +alias pacls='dpkg -l|grep ' #'pacman -Qs' # Search for package(s) in the local database +alias pacorph='sudo pacman -Qdt' # Search for orphan packages +alias paclal='dpkg -L' #'sudo pacman -Ql' # List installed files of a given package +alias pacg='pacman -Sg' #List all groups or all packages in specified group +alias pacclean='sudo pacman -Sc' # Remove all packages from local repository, not installed atm, remove all unused repos +alias pacconf='sudo find /etc -name "*.pac*" -type f -print' # Search for .pacnew and .pacsave files +alias pacfile='dpkg -S ' #'sudo pacman -Qo' # Find out what package a give file belongs to +alias pacupd='sudo apt-get update' #'sudo pacman -Sy && sudo abs' # Update and refresh the local package and ABS databases against repositories +alias pacdep='sudo pacman -S --asdeps' # Install given package(s) as dependencies of another package +alias pacmir='sudo pacman -Syy' # Force refresh of all package lists after updating /etc/pacman.d/mirrorlist +alias packup='comm -23 <(pacman -Qeq|sort) <(pacman -Qmq|sort) > $HOME/Dropbox/sync/archlinux/pkglist-$HOST' # Backup the current list of non-local packages +alias pacret='sudo pacman -S $(< $HOME/Dropbox/sync/archlinux/pkglist-$HOST)' # Install from the backup list +alias pacredown='sudo pacman -S $(comm -23 <(pacman -Qeq) <(pacman -Qmq))' # Redownload all installed packages (minus AUR) +alias pacdis='rm -f $HOME/Dropbox/sync/archlinux/non-pkg-$HOST; sudo pacman-disowned > $HOME/Dropbox/sync/archlinux/non-pkg-$HOST' # Getting a list of files not owned by any package +alias packimp='sudo pacman-key -r ' #Import a key ID to the pacman keyring +alias packsign='sudo pacman-key --lsign-key ' #Sign a key ID after importing it to the keyring +alias packref='sudo pacman-key --refresh-keys' #Refresh the list of master keys + +##Yaourt aliases +alias yaup='yaourt -Syu --devel --aur' # Updates all locally installed repository, AUR and git packages +alias yadb='yaourt -B $HOME/Dropbox/sync/archlinux' # Backs up the yaourt database +alias ya='sudo apt-get -t testing install ' # Install packages from AUR/Testing diff --git a/.config/zsh/includes/export.zsh b/.config/zsh/includes/export.zsh new file mode 100644 index 0000000..59eb186 --- /dev/null +++ b/.config/zsh/includes/export.zsh @@ -0,0 +1,102 @@ +if [[ -n $TMUX ]] && [[ $VENDOR != "apple" ]] && [[ ! -e /etc/debian_version ]]; then + export TERM="screen-256color" +elif [[ -n $STY ]];then + export TERM="screen-256color" +else + export TERM="xterm-256color" +fi + + +available_locale=$(locale -a|tr '\n' ' ') +if [ "${available_locale#*en_DK.utf8}" != "$available_locale" ]; then + export LC_TIME="en_DK.UTF-8" +elif [ "${available_locale#*en_DK.UTF-8}" != "$available_locale" ]; then + export LC_TIME="en_DK.UTF-8" +fi +if [ "${available_locale#*de_DE.utf8}" != "$available_locale" ]; then + export LC_MONETARY="de_DE.UTF-8" +elif [ "${available_locale#*de_DE.UTF-8}" != "$available_locale" ]; then + export LC_MONETARY="de_DE.UTF-8" +fi +if [ "${available_locale#*en_US.utf8}" != "$available_locale" ]; then + export LANG="en_US.UTF-8" +elif [ "${available_locale#*en_US.UTF-8}" != "$available_locale" ]; then + export LANG="en_US.UTF-8" +fi +if [ "${available_locale#*en_US.utf8}" != "$available_locale" ] ; then + export LC_CTYPE="en_US.UTF-8" +elif [ "${available_locale#*en_US.UTF-8}" != "$available_locale" ]; then + export LC_CTYPE="en_US.UTF-8" +fi + +# keyboard exports for sway +export XKB_DEFAULT_LAYOUT=de + +# browser +export BROWSER=firefox +export REPORTTIME=5 + +# systemd +export SYSTEMD_EDITOR=vim + +# editor +export EDITOR=vim +export VISUAL=vim + +# if vimpager is installed, use it instead of less +if [[ -x /usr/bin/vimpager ]];then + export PAGER="vimpager" +else + export PAGER="less -j4" +fi + +export GREP_COLOR="1;33" + +# let RVM ignore global ruby +export rvm_ignore_gemrc_issues=1 + +# Java +# font settings/ renderings +export _JAVA_OPTIONS='-Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true' +# non-reparenting windows +export _JAVA_AWT_WM_NONREPARENTING=1 + +# pipenv environment variables: +# - disabling fancy shell stuff +# - creating virtualenv within each project +# - moving cache dir to build volume +export PIPENV_NOSPIN="true" +export PIPENV_COLORBLIND="true" +export PIPENV_HIDE_EMOJIS="true" +export PIPENV_VENV_IN_PROJECT="true" +#export PIPENV_CACHE_DIR="$HOME/.cache/pipenv" + +# brew +if command -v brew > /dev/null; then + export HOMEBREW_NO_ANALYTICS="true" + export HOMEBREW_NO_AUTO_UPDATE="true" + export HOMEBREW_NO_EMOJI="true" +fi + +# GnuPG +export GPG_TTY=$TTY +export GPG_AGENT_INFO="" + +# ssh-agent +if [[ $UID -ne 0 ]] && [[ $VENDOR != "apple" ]];then + export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.socket" +fi + +# tmux +if [[ $UID -ne 0 ]] && [[ $VENDOR != "apple" ]]; then + export TMUX_TMPDIR="$XDG_RUNTIME_DIR/" +else + export TMUX_TMPDIR="/tmp" +fi + +# zsh +if [[ $UID -eq 0 ]]; then + export TMOUT=360 + readonly TMOUT + export TMOUT +fi diff --git a/.config/zsh/includes/frqrec b/.config/zsh/includes/frqrec new file mode 100644 index 0000000..e69de29 diff --git a/.config/zsh/includes/functions.zsh b/.config/zsh/includes/functions.zsh new file mode 100644 index 0000000..7a87bee --- /dev/null +++ b/.config/zsh/includes/functions.zsh @@ -0,0 +1,398 @@ +# < FUNCTIONS + +## PDF/LATEX + function mkpdf() + { + pdflatex -shell-escape $1 + # latex --output-format=pdf $1 + name=`echo $1 | sed 's/.tex//'` + EXT=(aux log) + for i in $EXT; + do + rm -v $name.$i + done + } + + function gsmerge() + { + target=$1 + echo "target: $target" + sleep 1 + shift + + /usr/bin/gs \ + -sDEVICE=pdfwrite \ + -dCompatibilityLevel=1.4 \ + -dNOPAUSE \ + -dBATCH \ + -sPAPERSIZE=a4 \ + -sOUTPUTFILE=$target $* + } + + function gsmerge_medium() + { + target=$1 + echo "target: $target" + sleep 1 + shift + + /usr/bin/gs \ + -sDEVICE=pdfwrite \ + -dPDFSETTINGS=/ebook \ + -dCompatibilityLevel=1.4 \ + -dNOPAUSE \ + -dBATCH \ + -sPAPERSIZE=a4 \ + -sOutputFile=$target $* + } + +## USABILITY + function lvim() + { + noglob vim $(echo $1 | awk -F":" '{ print $1" +"$2 }' ) + } + + function mkcd() + { + mkdir $1 + cd $1 + } + + function cpwd() + { + pwd >! /tmp/pwd + } + + function ppwd() + { + cd "`cat /tmp/pwd`" + } + + function cp2wd() + { + cp $@ "`cat /tmp/pwd`" + } + function cpmk() { + DIR=${*: -1} + [ ! -d $DIR ] && mkdir -p $DIR + cp $* + + } + + cpmd5(){ + md5sum $1|cut -d ' ' -f 1|cpx + } + + +function publish() { + [ -f $1 ] || return + + DIR=`dirname $1` + FILE=`basename $1` + mute pushd $DIR + scp $FILE pool:public_html/ + echo "http://www-pool.math.tu-berlin.de/~runge/$FILE" + echo "http://www-pool.math.tu-berlin.de/~runge/$FILE"|cpx + mute popd +} + +function incognichrome { + chromium --incognito +} + +function inproxychrome { + chromium --incognito --proxy-server=apu-serve:8123 --user-data-dir="$HOME/.config/chromium-proxy" +} + +## ZSH +refresh() { + source $HOME/.zshrc +} + + +## compress stuff +tar_tgz() { + tar cvfz $1.tgz $1 +} +tar_tbz() { + tar cvfj $1.tbz $1 +} +tar_tlz() { + tar --lzma -cvf $1.tlz $1 +} +tar_xz() { + tar cvfJ $1.tar.xz $1 +} + +#Decompress any given compressed file +ex() { + if [ -f $1 ] ; then + case $1 in + *.tar.bz2) + tar xvjf $1 + ;; + *.tar.gz) + tar xvzf $1 + ;; + *.tar.lz) + tar xvf $1 + ;; + *.bz2) + bunzip2 $1 + ;; + *.deb) + ar vx $1 + ;; + *.rar) + unrar x $1 + ;; + *.pgp) + gpg -o ${1%".pgp"} -d $1 + ;; + *.gpg) + gpg -o ${1%".gpg"} -d $1 + ;; + *.asc) + gpg -o ${1%".asc"} -d $1 + ;; + *.gz) + gunzip $1 + ;; + *.tar) + tar xvf $1 + ;; + *.tbz2) + tar xvjf $1 + ;; + *.tgz) + tar xvzf $1 + ;; + *.whl) + unzip "$1" + ;; + *.xz) + tar xvJf $1 + ;; + *.zip) + unzip $1 + ;; + *.zst) + tar --zstd -xvf $1 --force-local + ;; + *.Z) + uncompress $1 + ;; + *.7z) + 7z x $1 + ;; + *) + echo "Don't know how to extract '$1'..." + ;; + esac + else + echo "'$1' is not a valid file to extract!" + fi +} + +ex2() { + if [ -f $2 ] ;then + echo "Extracting to '$2'" + local out = $2 + else + echo "Extracting to '$( pwd )'" + local out = $( pwd ) + fi + if [ -f $1 ] ;then + echo "'$1'" + else + echo "'$1' is not a valid file!" + fi +} + +lstar() { + if [ -f "$1" ] ; then + case "$1" in + *.deb) + ar -tv "$1" + ;; + *.bz2) + tar -tvf "$1" --force-local + ;; + *.gz) + tar -tvf "$1" --force-local + ;; + *.lz) + tar -tvf "$1" --force-local + ;; + *.rar) + unrar lb "$1" + ;; + *.tar) + tar -tvf "$1" --force-local + ;; + *.tbz2) + tar -tvf "$1" --force-local + ;; + *.tgz) + tar -tvf "$1" --force-local + ;; + *.whl) + unzip -l "$1" + ;; + *.xz) + tar -Jtvf "$1" --force-local + ;; + *.zip) + unzip -l "$1" + ;; + *.Z) + uncompress $1 + ;; + *.7z) + 7z l "$1" + ;; + *.zst) + tar --zstd -tvf "$1" --force-local + ;; + *) + echo "Don't know how to look into $1" + exit 1 + ;; + esac + else + echo "'$1' is not a file!" + exit 1 + fi +} + +## RSYNC + +backupinfo() { + rsync\ + -r\ + -n\ + -t\ + -p\ + -o\ + -h\ + -g\ + -v\ + --progress\ + --delete\ + --ignore-existing\ + --size-only\ + -s\ + --exclude 'lost+found'\ + --exclude '.Trash-1000'\ + --exclude '$RECYCLEBIN'\ + --exclude 'System Volume Information'\ + --exclude '.thumbs'\ + $1 $2 + echo "backupfolder path/to/folder/ /path/to/other/folder" +} + +backupfolder() { + rsync \ + -r\ + -t\ + -p\ + -o\ + -h\ + -g\ + -v\ + --progress\ + --delete --ignore-existing --size-only -s --exclude 'lost+found' --exclude '.Trash-1000' --exclude '$RECYCLEBIN' --exclude 'System Volume Information' --exclude '.thumbs' $1 $2 +} + +# journalctl + +# show messages of specified system units +function sdsjfu(){ + local journal_cmd="sudo journalctl --system -a" + eval ${journal_cmd} $(echo $@ | sed 's/\ /\ -u\ /g; s/^/\ -u\ /') +} + +# follow messages of specified system units +function sdsjfu(){ + local journal_cmd="sudo journalctl --system -af" + eval ${journal_cmd} $(echo $@ | sed 's/\ /\ -u\ /g; s/^/\ -u\ /') +} + +# follow messages of specified system units for this boot +function sdsjbfu(){ + local journal_cmd="sudo journalctl --system -b -af" + eval ${journal_cmd} $(echo $@ | sed 's/\ /\ -u\ /g; s/^/\ -u\ /') +} + +# follow messages of specified user units +function sdujfu(){ + local journal_cmd="journalctl --user -af" + eval ${journal_cmd} $(echo $@ | sed 's/\ /\ --user-unit\ /g; s/^/\ --user-unit\ /') +} + +# follow messages of specified user units for this boot +function sdujbu(){ + local journal_cmd="journalctl --user -a -b" + #TODO: Check if first argument is a number, then use it for -b + eval ${journal_cmd} $(echo $@ | sed 's/\ /\ --user-unit\ /g') +} + +# show messages of specified system units since and until a specified time +function sdsjSUu(){ + local journal_cmd="sudo journalctl --system -a -S" + local args=(${@}) + journal_cmd="$journal_cmd $args[1] -U $args[2]" + args=(${args:2}) + eval ${journal_cmd} $(echo $args | sed 's/\ /\ -u\ /g; s/^/\ -u\ /') +} + +# show messages of specified system units since a specified time +function sdsjSu(){ + local journal_cmd="sudo journalctl --system -a -S" + local args=(${@}) + journal_cmd="$journal_cmd $args[1]" + args=(${args:1}) + eval ${journal_cmd} $(echo $args | sed 's/\ /\ -u\ /g; s/^/\ -u\ /') +} + +# show messages of specified user units since and until a specified time +function sdujSUu(){ + local journal_cmd="journalctl --user -a -S" + local args=(${@}) + journal_cmd="$journal_cmd $args[1] -U $args[2]" + args=(${args:2}) + eval ${journal_cmd} $(echo $args | sed 's/\ /\ --user-unit\ /g; s/^/\ --user-unit\ /') +} + +# show messages of specified user units since a specified time +function sdujSu(){ + local journal_cmd="journalctl --user -a -S" + local args=(${@}) + journal_cmd="$journal_cmd $args[1]" + args=(${args:1}) + eval ${journal_cmd} $(echo $args | sed 's/\ /\ --user-unit\ /g; s/^/\ --user-unit\ /') +} + +# show kernel messages since and until a specified time +function sdsjkSU(){ + local journal_cmd="sudo journalctl --system -a -k -S" + local args=(${@}) + journal_cmd="$journal_cmd $args[1] -U $args[2]" + eval ${journal_cmd} +} + +# show kernel messages since a specified time +function sdsjkS(){ + local journal_cmd="sudo journalctl --system -a -k -S" + local args=(${@}) + journal_cmd="$journal_cmd $args[1]" + eval ${journal_cmd} +} + + +function pasters() { + local file="${1:-/dev/stdin}" + curl --data-binary @"${file}" https://paste.rs +} + +# FUNCTIONS > diff --git a/.config/zsh/includes/hostspecific.zsh b/.config/zsh/includes/hostspecific.zsh new file mode 100644 index 0000000..20d569b --- /dev/null +++ b/.config/zsh/includes/hostspecific.zsh @@ -0,0 +1,6 @@ +case "${HOST}" in + s4|s5|c{1,2}*) + . $HOME/.zsh.after/apt + . $HOME/.zsh.after/unixpool + ;; +esac diff --git a/.config/zsh/includes/key-bindings.zsh b/.config/zsh/includes/key-bindings.zsh new file mode 100644 index 0000000..300b3c7 --- /dev/null +++ b/.config/zsh/includes/key-bindings.zsh @@ -0,0 +1,22 @@ +## OVERRIDE KEY-BINDINGS +bindkey -s '\e,' '..\n' # [Esc-,] - run command: .. (up directory) +bindkey '\e.' insert-last-word # [Esc-.] - insert last word +#bindkey '^[Oc' forward-word # [Ctrl-RightArrow] - move forward one word +#bindkey '^[OC' forward-word # [Ctrl-RightArrow] - move forward one word +#bindkey '^[Od' backward-word # [Ctrl-LeftArrow] - move backward one word +#bindkey '^[OD' backward-word # [Ctrl-LeftArrow] - move backward one word + +## URXVT & TMUX +case $TERM in + rxvt-unicode-256color) + bindkey '^[Oc' forward-word # [Ctrl-RightArrow] - move forward one word + bindkey '^[Od' backward-word # [Ctrl-LeftArrow] - move backward one word + ;; + screen-256color) + bindkey '^[[1;5C' forward-word # [Ctrl-RightArrow] - tmux: move forward one word + bindkey '^[[1;5D' backward-word # [Ctrl-LeftArrow] - tmux: move backward one word + ;; +esac + +## NEW KEY-BINDINGS +bindkey '^K' kill-line diff --git a/.config/zsh/includes/path.zsh b/.config/zsh/includes/path.zsh new file mode 100644 index 0000000..21e36e6 --- /dev/null +++ b/.config/zsh/includes/path.zsh @@ -0,0 +1,19 @@ +# cargo +[ -d "${HOME}/.cargo/bin" ] && PATH="${HOME}/.cargo/bin:${PATH}" +# pyenv +[ -d "${HOME}/.local/bin" ] && PATH="${HOME}/.local/bin:${PATH}" +[ -d "${HOME}/.pyenv/shims" ] && PATH="${HOME}/.pyenv/shims:${PATH}" +# RPi +[ -d "/opt/vc/bin" ] && PATH="${PATH}:/opt/vc/bin" +[ -d "/opt/vc/sbin" ] && PATH="${PATH}:/opt/vc/sbin" +# user bin +[ -d "${HOME}/bin" ] && PATH="${HOME}/bin:${PATH}" +# Debilian +[ -d "/usr/sbin" ] && [ ! -L "/usr/sbin" ] && PATH="${PATH}:/usr/sbin" +# whackOS +[ -d "/usr/local/opt/coreutils/libexec/gnubin" ] && PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH" +[ -d "/usr/local/opt/gnu-sed/libexec/gnubin" ] && PATH="/usr/local/opt/gnu-sed/libexec/gnubin:$PATH" +[ -d "/usr/local/opt/gnu-tar/libexec/gnubin" ] && PATH="/usr/local/opt/gnu-tar/libexec/gnubin:$PATH" +[ -d "/usr/local/opt/gnu-which/libexec/gnubin" ] && PATH="/usr/local/opt/gnu-which/libexec/gnubin:$PATH" +[ -d "/usr/local/opt/findutils/libexec/gnubin" ] && PATH="/usr/local/opt/findutils/libexec/gnubin:$PATH" +[ -d "/usr/local/opt/grep/libexec/gnubin" ] && PATH="/usr/local/opt/grep/libexec/gnubin:$PATH" diff --git a/.config/zsh/includes/udisks.zsh b/.config/zsh/includes/udisks.zsh new file mode 100644 index 0000000..3478aea --- /dev/null +++ b/.config/zsh/includes/udisks.zsh @@ -0,0 +1,245 @@ +# EXAMPLES: +# - mounting devices +# sdm sdb1 // mount first partition on sdb +# sdm sdb 1 // mount first partition on sdb +# sdm sdb // mount all available partitions on sdb +# sdm // mount all available devices +# mcm mmcblk0p1 // mount first partition on mmcblk0 +# mcm mmcblk0 1 // mount first partition on mmcblk0 +# mcm mmcblk0 // mount all partitions on mmcblk0 +# mcm // mount all partitions on all mmcblk devices +# srm 0 // mount first optical drive +# srm // mount all optical drives +# +# - unmounting devices +# sdu sdb1 // unmount first partition on sdb +# sdu sdb 1 // unmount first partition on sdb +# sdu sdb // unmount all available partitions on sdb +# sdu // unmount all available devices +# mcu mmcblk0p1 // unmount first partition on mmcblk0 +# mcu mmcblk0 1 // unmount first partition on mmcblk0 +# mcu mmcblk0 // unmount all partitions on mmcblk0 +# mcu // unmount all partitions on all mmcblk devices +# sru 0 // unmount first optical drive +# sru // unmount all optical drives +# + +# mount commands: +mount="udisksctl mount -b" +unmount="udisksctl unmount -b" + +# Path to all devices +folder="/dev/" + +# Devices of the form /dev/sd{b,c,d,e,f,g,h,i,j,k,l,m,n} +# path +dev="/dev/sd" +# Device numbers/names +devices=( b c d e f g h i j k l m n ) +# Partition numbers +device_partitions=( 1 2 3 4 5 6 7 8 9 ) + +# Devices of the form /dev/mmcblk{0,1,2,3,4,5,6,7,8,9}p{1,2,3,4,5,6,7,8,9} +# path +mmc="/dev/mmcblk" +# Device numbers/names +mmc_devices=( 0 ) +# Partition numbers +mmc_partitions=( p1 p2 p3 p4 p5 p6 p7 p8 p9 ) + +# Devices of the form /dev/sr{0,1,2} +# path +optical="/dev/sr" +# Device numbers/names +optical_devices=( 0 1 2 ) + +# device functions: +sdm() { + if [[ -n "$2" ]]; then # if 2nd argument is set + if [[ "$1" = ?d* ]]; then # check if 1st argument features the letter d + if [[ -b $folder$1$2 ]]; then # check if block device $1$2 is available + $=mount $folder$1$2 + fi + fi + elif [[ -n "$1" ]]; then # if 1st argument is set + if [[ "$1" = ?d* ]]; then # check if 1st argument featurs a letter d + if [[ -b $folder$1"1" ]]; then #check if first device is available + for a in $device_partitions; do # loop through device partitions of first argument + echo "$folder$1$a" + if [[ -b $folder$1$a ]]; then # checking for each device if available and block device + $=mount "$folder$1$a" + fi + done + else + echo "Trying to mount: $folder$1" + if [[ -b $folder$1 ]]; then # check if 1st argument already is the block device to mount + $=mount $folder$1 + fi + fi + fi + else # here we loop all available block devices and mount them + # TODO: check with df if the device is already mounted + for a in $devices; do # loop through the list of all devices + if [[ -b $dev$a ]]; then # check if first partition of block device is available + for b in $device_partitions; do # loop through the list of all partitions + if [[ -b $dev$a$b ]]; then # if it's a block device + echo "Trying to mount: $dev$a$b" + $=mount "$dev$a$b" + fi + done + fi + done + fi +} + +sdu() { + if [[ -n "$2" ]]; then + if [[ "$1" = ?d* ]]; then + if [[ -b $folder$1$2 ]]; then + echo "Trying to unmount: $folder$1$2" + $=unmount $folder$1$2 + fi + fi + elif [[ -n "$1" ]]; then + if [[ "$1" = ?d* ]]; then + if [[ -b $folder$1"1" ]]; then + for a in $device_partitions; do + if [[ -b $folder$1$a ]]; then # checking for each device if available and block device + echo "Trying to unmount: $folder$1$a" + $=unmount $folder$1$a + fi + done + else + if [[ -b $folder$1 ]]; then + echo "Trying to unmount: $folder$1" + $=unmount $folder$1 + fi + fi + fi + else # unmount all devices mounted + for a in $devices; do + if [[ -b $dev$a ]]; then + for b in $device_partitions; do + if [[ -b $dev$a$b ]]; then # if it's a block device + echo "Trying to unmount: $dev$a$b" + $=unmount $dev$a$b + fi + done + fi + done + fi +} + +# mmc functions: +mcm() { + if [[ -n "$2" ]]; then + if [[ "$1" = mmcblk* ]]; then + if [[ -b $folder$1"p"$2 ]]; then + echo "Trying to mount: $folder$1"p"$2" + $=mount $folder$1"p"$2 + fi + fi + elif [[ -n "$1" ]]; then + if [[ "$1" = mmcblk* ]]; then + if [[ -b $folder$1"p1" ]]; then + for a in $mmc_partitions; do + if [[ -b $folder$1$a ]]; then + echo "Trying to mount: $folder$1$a" + $=mount $folder$1$a + fi + done + else + if [[ -b $folder$1 ]]; then + echo "Trying to mount: $folder$1" + $=mount $folder$1 + fi + fi + fi + else + for a in $mmc_devices; do + if [[ -b $mmc$a"p1" ]]; then + for b in $mmc_partitions; do + if [[ -b $mmc$a$b ]]; then # if it's a block device + echo "Trying to mount: $mmc$a$b" + $=mount $mmc$a$b + fi + done + fi + done + fi +} + +mcu() { + if [[ -n "$2" ]]; then + if [[ "$1" = mmcblk* ]]; then + if [[ -b $folder$1"p"$2 ]]; then + echo "Trying to unmount: $folder$1"p"$2" + $=unmount $folder$1"p"$2 + fi + fi + elif [[ -n "$1" ]]; then + if [[ "$1" = mmcblk* ]]; then + if [[ -b $folder$1"p1" ]]; then + for a in $mmc_partitions; do + echo "Trying to unmount: $folder$1$a" + $=unmount $folder$1$a + done + else + if [[ -b $folder$1 ]]; then + echo "Trying to unmount: $folder$1" + $=unmount $folder$1 + fi + fi + fi + else + for a in $mmc_devices; do + if [[ -b "$mmc$a${mmc_partitions[0]}" ]]; then + echo $mmc$a${mmc_partitions[0]} + for b in $mmc_partitions; do + if [[ -b $mmc$a$b ]]; then # if it's a block device + echo "Trying to unmount: $mmc$a$b" + $=unmount $mmc$a$b + fi + done + fi + done + fi +} + +# sr functions: +srm() { + if [[ -n "$1" ]]; then + if [[ "$1" = ? ]]; then + if [[ -b $optical$1 ]]; then + echo "Trying to mount: $optical$1" + $=mount $optical$1 + fi + fi + else + for a in $optical_devices; do + if [[ -b $optical$a ]]; then + echo "Trying to mount: $optical$a" + $=mount $optical$a + fi + done + fi +} + +sru() { + if [[ -n "$1" ]]; then + if [[ "$1" = ? ]]; then + if [[ -b $optical$1 ]]; then + echo "Trying to unmount: $optical$1" + $=unmount $optical$1 + fi + fi + else + for a in $optical_devices; do + if [[ -b $optical$a ]]; then + echo "Trying to unmount: $optical$a" + $=unmount $optical$a + fi + done + fi +} + diff --git a/.config/zsh/includes/unixpool b/.config/zsh/includes/unixpool new file mode 100644 index 0000000..e2edade --- /dev/null +++ b/.config/zsh/includes/unixpool @@ -0,0 +1,125 @@ +# host based zshrc +# unixpool + +HISTFILE=$HOME/.zhistory +unset MAILCHECK + +## PATH and exports +PATH=${PATH}:/net/local64/bin +PATH=${PATH}:/net/adm/bin +PATH=${PATH}:/net/adm/scripts +PATH=${PATH}:/net/adm/xadm +PATH=${PATH}:/homes/wheel/wheel/bin +PATH=${PATH}:/sbin +PATH=${PATH}:/usr/sbin +#PATH=/store/s4/android/android-sdk-linux_86/tools:$PATH +#PATH=/store/s4/android/android-sdk-linux_86/platform-tools:$PATH + +#Remove /usr/bin/X11: if it shows up in $PATH +autoload -U regexp-replace +regexp-replace PATH '/usr/bin/X11:' '' + +export MATLAB_JAVA=/usr/lib/jvm/java-6-sun-1.6.0.26/jre + +## aliases +alias lp_ps1_100='lp -q 100 -d ps1' +alias lp_ps2_100='lp -q 100 -d ps2' +alias QW='xterm -geometry 84x41-0+0 -T '\''QWatch'\'' -fn 5x8 -e /homes/misc/lpviewer/lpdisp' +alias QWbig='xterm -geometry 84x41-0+0 -T '\''QWatch'\'' -e /homes/misc/lpviewer/lpdisp' +alias QWbighere='/homes/misc/lpviewer/lpdisp' +alias QWdisplay="watch 'for n in {1..3}; do scli -c \"show printer display\" ps\$n-pool; done'" +#alias pyadm="/net/adm/pyadm-64ready/start.py" +alias synergys='synergys -c .config/synergy-$HOST.conf' + +# set pulseaudio server to s4 +if [ -f "`which pax11publish`" ]; +then + if [ ! $SSH_CLIENT ]; + then + if [ `pax11publish | grep -c s4` -eq 0 ]; + then + echo pulseaudio server set + pax11publish -S s4 -e + else + echo pulseaudio active + fi + fi +fi + + +## FUNCTIONS +function music_update() { + echo "updating zip files" + for i in */*; + do + name=`echo $i | sed 's/\ /_/g' | sed 's/\//-/g'` + if [ ! -e $name.zip ]; + then + echo "packing $i as $name.zip" + zip -r $name.zip $i + fi + done + echo "done" +} + +function makantine() { + wget http://personalkantine.personalabteilung.tu-berlin.de/pdf/MA-aktuell.pdf -O /tmp/makantine.$$.pdf >&/dev/null + xpdf -cont -z page /tmp/makantine.$$.pdf + rm -f /tmp/makantine.$$.pdf +} + +function pxeln() { + local instmode host oldumask bopts="" isrc="" + while [ -n "$1" ]; do + if [[ "$1" == -o* ]]; then + [ -z "$bopts" ] && bopts="bootopts=${1:2}" || bopts="${bopts},${1:2}"; + else + if [ -z "$instmode" ]; then instmode="$1"; + elif [ -z "$host" ]; then host="$1"; + else echo "Ignoring superfluous argument \"$1\"."; + fi + fi + + shift + done + if [[ -z "$instmode" || -z "$host" ]]; then + echo -e "Missing argument!\nSyntax: pxeln {mode} {host}\n(use tab completion for available modes)" >/dev/stderr + return 1 + fi + local IP=$(egrep "^[^,]*,${host}," /net/adm/access/HWlist |cut -d, -f1|cut -d. -f4) + local M="01-$(egrep " $IP " /net/adm/access/MAClist 2>/dev/null|sed -e "s/^|[^|]*| \([0-9a-f:]*\) |/\1/" -e "y/:/-/")" + if [[ ${#M} -ne 20 ]]; then + echo "Unknown host." >/dev/stderr + return 1 + fi + shift 2 + oldumask=$(umask -p) + umask 0022 + local instmodetl=$(tr [:upper:] [:lower:]<<<$instmode) + if [ -s /homes/ext15a/tftpboot/pxelinux.cfg/${instmode}.sed ]; then + if [ -e /homes/ext15a/tftpboot/pxelinux.cfg/$M ]; then + rm -f /homes/ext15a/tftpboot/pxelinux.cfg/$M + echo "$host: former PXE diversion removed." + fi + sed /homes/ext15a/tftpboot/pxelinux.cfg/_template \ + -f /homes/ext15a/tftpboot/pxelinux.cfg/${instmode}.sed \ + > /homes/ext15a/tftpboot/pxelinux.cfg/$M + echo -n "$host: elected for ${instmode}" + if [ -n "$bopts" ]; then + sed -i -e "/bootmode=${instmodetl}/ s/$/ ${bopts}/" /homes/ext15a/tftpboot/pxelinux.cfg/$M + echo -n " (with extra boot options: \"$bopts\")" + fi + echo "." + elif [ "$instmode" == "remove" ]; then + rm -f /homes/ext15a/tftpboot/pxelinux.cfg/$M + echo "$host: PXE diversion removed." + else + echo "Unknown PXE mode." >/dev/stderr + fi + $oldumask + return 0 +} + +function mailhighscore() { + for i in /homes/wheel/*; do n=`basename $i`; echo `grep $n /var/spool/mail/runge | grep -c From` $n; done | sort -nr +} diff --git a/.zsh.after/aliases.zsh b/.zsh.after/aliases.zsh deleted file mode 100644 index 20a055f..0000000 --- a/.zsh.after/aliases.zsh +++ /dev/null @@ -1,276 +0,0 @@ -# < ZSH ALIASES -# suffix aliases -alias -s pdf='mupdf' -alias -s ps='mupdf' -alias -s jpg='feh' -alias -s png='feh' -alias -s gif='viewnior' -alias -s gz='tar xvfz' -alias -s tgz='tar xvfz' -alias -s bz2='tar xvfj' -alias -s tbz='tar xvfj' -alias -s tlz='tar --lzma -xvf' -alias -s rar='unrar x' -alias -s tex='mkpdf' - -# global aliases -alias -g ...='../..' -alias -g ....='../../..' -alias -g .....='../../../..' -alias -g C='| wc -l' -alias -g H='| head' -alias -g L="| less" -alias -g N="| /dev/null" -alias -g S='| sort' -alias -g G='| grep' - -# ls -alias ls='ls --group-directories-first --color=auto' -alias ll="ls -lh" -alias la="ls -a" -alias lal="ls -alhv" -alias lt='ls -tr' -alias ll='ls -l' -alias llh='ls -lh' -alias llt='ls -ltr' -alias la='ls -A' -alias lla='ls -lA' -alias lsfw='ls -lah /dev|grep fw' -alias lsvid='ls -lah /dev|grep video' - -#zsh - -# Lists the ten most used commands. -alias history-stat="history 0 | awk '{print \$2}' | sort | uniq -c | sort -n -r | head" - -alias d='dirs -v' -for index ({1..9}) alias "$index"="cd +${index}"; unset index - -#MPLAYER -alias mplayer='mplayer -ao jack,pulse,alsa' -if pgrep Xwayland > /dev/null; then - alias mpv='mpv --audio-channels=stereo --gpu-context=wayland -ao=jack,pulse,alsa --sub-auto=fuzzy --jack-port="minimixer:in1_*"' -else - alias mpv='mpv --audio-channels=stereo -ao=jack,pulse,alsa --sub-auto=fuzzy --jack-port="minimixer:in1_*"' -fi -if [[ "$VENDOR" == "apple" ]]; then - alias mpv='mpv --sub-auto=fuzzy' -fi -##DU -alias du1='du -hd1' - -##FEH -alias feh='feh -Z -g 1920x1200 -b "black" -S "filename"' - -##GIT -alias gsi='git submodule update --init --recursive' -alias gsu='git submodule update --recursive' - -##TREE -alias tree='tree -aC' -#grep aliases (with excluded directories) -alias grepdot='grep -rI --exclude-dir=".steam" --exclude-dir=".local" --exclude-dir=".thunderbird" --exclude-dir=".mozilla" --exclude-dir="git" --exclude-dir=".rvm" --exclude-dir=".log" --exclude-dir=".dropbox-dist" --exclude-dir=".config" ' - - -##SYSTEMD -#tree -alias psc='ps xawf -eo pid,user,cgroup,args' -alias treeg='tree -d /cgroup/systemd/' -alias sdptree='tree -aC /usr/lib/systemd/' -alias sdstree='tree -aC /etc/systemd/' -alias sdutree='tree -aC $HOME/.config/systemd/' -#journalctl -alias sdsj='sudo journalctl --system -a' #show the entire system journal -alias sdsjf='sudo journalctl --system -af' #follow all system messages -alias sdsjb='sudo journalctl --system -ab' #Show system messages from specific boot -alias sdsjbf='sudo journalctl --system -ab -f' #follow only messages from this boot -alias sdsju='sudo journalctl --system -af -u' #follow messages of only the specified unit -alias sdsjk='journalctl -k' #show dmesg -alias sdsjkb='journalctl -kb' #show dmesg from specific boot -alias sdsjkf='journalctl -kf' #follow current dmesg -alias sdsjlb='journalctl --list-boots' #list all boots -alias sdsjp='sudo journalctl --system _PID=' #show all messages of specified system process (PID) -alias sdjgrep='sudo journalctl -an1000 |grep ' #Use a grep command to search through journal -alias sduj='journalctl --user -a' -alias sdujf='journalctl --user -af' -alias sdujb='journalctl --user -ab' -alias sdujbf='journalctl --user -afb' -alias sdujb='journalctl --user -ab' -alias sdujp='journalctl --user _PID=' #show all messages of specified user process (PID) -#systemd system services -alias sdsedit='sudo systemctl edit' -alias sdsstart='sudo systemctl start' -alias sdsstop='sudo systemctl stop' -alias sdsrestart='sudo systemctl restart' -alias sdsreload='sudo systemctl reload' -alias sdsenable='sudo systemctl enable' -alias sdsdisable='sudo systemctl disable' -alias sdsreenable='sudo systemctl reenable' -alias sdsisactive='sudo systemctl is-active' -alias sdsisenabled='sudo systemctl is-enabled' -alias sdsstat='sudo systemctl status -a -l' -alias sdswants='sudo systemctl show -p "Wants"' -alias sdswantedby='sudo systemctl show -p "WantedBy"' -alias sdsrequires='sudo systemctl show -p "Requires"' -alias sdsrequiredby='sudo systemctl show -p "RequiredBy"' -alias sdsconflicts='sudo systemctl show -p "Conflicts"' -alias sdsconflictedby='sudo systemctl show -p "ConflictedBy"' -alias sdsbefore='sudo systemctl show -p "Before"' -alias sdsafter='sudo systemctl show -p "After"' -alias sdst='sudo systemctl --system list-timers' -alias sdss='sudo systemctl --system list-sockets' -alias sdsu='sudo systemctl --system list-units' -alias sdsuf='sudo systemctl --system list-unit-files' -alias sdsdep='sudo systemctl --system list-dependencies' -alias sdscat='systemctl --system cat' -alias sdsreload='sudo systemctl daemon-reload' -alias sds='sudo systemctl -a' -alias sdsfail='sudo systemctl -a -l --no-legend --state=failed' -alias sdsmask='sudo systemctl mask' -alias sdsunmask='sudo systemctl unmask' -#systemd user services -alias sduedit='systemctl --user edit' -alias sdustart='systemctl --user start' -alias sdustop='systemctl --user stop' -alias sdurestart='systemctl --user restart' -alias sdureload='systemctl --user reload' -alias sduenable='systemctl --user enable' -alias sdudisable='systemctl --user disable' -alias sdureenable='systemctl --user reenable' -alias sduisactive='systemctl --user is-active' -alias sduisenabled='systemctl --user is-enabled' -alias sdustat='systemctl --user status -a -l' -alias sduwants='systemctl --user show -p "Wants"' -alias sduwantedby='systemctl --user show -p "WantedBy"' -alias sdurequires='systemctl --user show -p "Requires"' -alias sdurequiredby='systemctl --user show -p "RequiredBy"' -alias sduconflicts='systemctl --user show -p "Conflicts"' -alias sduconflictedby='systemctl --user show -p "ConflictedBy"' -alias sdubefore='systemctl --user show -p "Before"' -alias sduafter='systemctl --user show -p "After"' -alias sdut='systemctl --user list-timers' -alias sdus='systemctl --user list-sockets' -alias sduu='systemctl --user list-units' -alias sdudep='systemctl --user list-dependencies' -alias sducat='systemctl --user cat' -alias sdureload='systemctl --user daemon-reload' -#alias sdu='systemctl --user' -alias sdufail='systemctl --user -a -l --no-legend --state=failed' -alias sdumask='systemctl --user mask' -alias sduunmask='systemctl --user unmask' -#poweroff/reboot/isolate -alias sdiso='sudo systemctl isolate ' -alias sdreboot='sudo systemctl reboot' -alias sdpoweroff='sudo systemctl poweroff' -alias sdsuspend='sudo systemctl suspend' -#systemd bootchart -alias sda='systemd-analyze' -alias sdab='systemd-analyze blame' -if [ -x /usr/bin/xsvg ]; then - alias sdap='xsvg $HOME/cloud/photos/systemd/sdap-$HOST.svg' -fi - -##PACMAN -alias paclid="sudo pacman -Qi | sed '/^Depends On/,/^Required By/{ s/^Required By.*$//; H; d }; /^Name/!d; /^Name/{ n;x;}'| sed '/^$/s//==================================================================================/'" -alias pacsize="pacman -Qi | awk '/^Name/ {pkg=\$3} /Size/ {print \$4\$5,pkg}' | sort -n" #Show all packages by size -alias pacall="sudo pacman -Qi | awk '/^Name/ {pkg=\$3} /Version/ {ver=\$3} /Size/ {size=\$4\$5} {print pkg,ver,size}' | uniq" #All packages uniquely with name, version, size -alias pacup='sudo pacman -Syu' #Synchronize with repositories before upgrading packages that are out of date on the local system. -alias pac='sudo pacman -S' #Install specific package(s) from the repositories -alias pacu='sudo pacman -U' #Install specific package not from the repositories but from a file -alias pacre='sudo pacman -R' #Remove the specified package(s), retaining its configuration(s) and required dependencies -alias pacrem='sudo pacman -Rns' #Remove specified package(s), its configuration(s) and unneeded depends -alias pacname="sudo pacman -Qi|grep Name|grep " #Search through names of packages by string -alias pacri='pacman -Si' #Display information about a given package in the repositories -alias pacrs='pacman -Ss' #Search for package(s) in the repositories -alias pacli='pacman -Qi' #Display information about a given package in the local database -alias pacls='pacman -Qs' #Search for package(s) in the local database -alias pacorph='sudo pacman -Qdt' #Search for orphan packages -alias paclal='pacman -Ql' #List installed files of a given package -alias pacg='pacman -Sg' #List all groups or all packages in specified group -alias pacclean='sudo pacman -Sc' #Remove all packages from local repository, not installed atm, remove all unused repos -alias pacconf='sudo find /etc -type f \( -name "*.pacsave" -o -name "*.pacnew" \)' #Search for .pacnew and .pacsave files -alias pacown='sudo pacman -Qo' # Find out what package a give file belongs to -alias pacupd='sudo pacman -Sy && sudo abs' #Update and refresh the local package and ABS databases against repositories -alias pacdep='sudo pacman -S --asdeps' #Install given package(s) as dependencies of another package -alias pacmir='sudo pacman -Syy' #Force refresh of all package lists after updating /etc/pacman.d/mirrorlist -alias packup='comm -23 <(pacman -Qeq|sort) <(pacman -Qmq|sort) > $HOME/Dropbox/sync/archlinux/pkglist-$HOST' #Backup the current list of non-local packages -alias pacret='sudo pacman -S $(< $HOME/Dropbox/sync/archlinux/pkglist-$HOST)' #Install from the backup list -alias pacredown='sudo pacman -S $(comm -23 <(pacman -Qeq) <(pacman -Qmq))' #Redownload all installed packages (minus AUR) -alias pacdis='sudo pacman-disowned > /tmp/$USERNAME/non-pkg-$HOST' #Getting a list of files not owned by any package -alias packimp='sudo pacman-key -r ' #Import a key ID to the pacman keyring -alias packsign='sudo pacman-key --lsign-key ' #Sign a key ID after importing it to the keyring -alias packref='sudo pacman-key --refresh-keys' #Refresh the list of master keys - -##YAOURT -alias yaup='yaourt -Syu --devel --aur' #Updates all locally installed repository, AUR and git packages -alias yadb='yaourt -B $HOME/ownCloud/backup/settings/' #Backs up the yaourt database - -##XCLIP -alias cpx="xclip -selection clipboard -display :0" - -##CD -alias cd.sds="cd /etc/systemd/system" -alias cd.sdp="cd /usr/lib/systemd/system" -alias cd.courses="cd $HOME/ownCloud/documents/university/tu-berlin/courses" -alias cd.backup="cd $HOME/ownCloud/backup" -alias cd.scpref="cd $HOME/.config/SuperCollider" - -##OCTAVE -#alias octave="octave --silent --braindead --force-gui" -alias octave="octave --force-gui" - -##MATLAB -alias matlabc="matlab -nodesktop -nosplash" - -##NMCLI -alias nmup="sudo nmcli con up id" -alias nmdown="sudo nmcli con down id" -alias nmstat="sudo nmcli con show --active" -alias nmlist="sudo nmcli con list" -alias nmdev="sudo nmcli dev" - -#SSH -alias ssh.add="ssh-add $HOME/.ssh/id_{rsa{,_tu},ed25519{,_aur,_github,_holoplot}}" -alias ssh.new='ssh-keygen -t ed25519 -C "$(whoami)@$(hostname)-$(date -I)"' -if [ $VENDOR = "apple" ]; then - # apple's date is broken - alias ssh.new='ssh-keygen -t ed25519 -C "$(whoami)@$(hostname)-$(date +%Y-%m-%d)"' -fi -alias pool='ssh pool -Y' -alias sshtunnel="ssh -ND 44350 -v -p 46399 dave@frqb.zapto.org" # tunnel through home -alias frqtun="ssh -ND 44350 -v frq" -alias scp=scp - -#KEYCHAIN -alias keyflush="keychain --clear && keychain -k mine" - -#PULSEAUDIO -alias pak='pulseaudio --kill' -alias pas='pulseaudio --start' -alias paflush='pax11publish -r' -alias bthp="pactl load-module module-bluetooth-device address='00:1B:66:01:6C:D1'" #load bluetooth headphone module for pulseaudio - -#PYTHON -alias pyserv='python -m http.server' # start a python http server - -# VDIRSYNCER -alias vsync="vdirsyncer sync" - -#WOL -alias woldave_in='wol -i homey 00:15:f2:e0:e0:c6' #wake up homey -alias woldave_ex='wol -p X -i frqb.zapto.org 00:15:f2:e0:e0:c6' #wake up homey via - -## OVERRIDES -# Colorize grep output -alias grep='grep --color=auto --exclude-dir=.git' -alias psgrep='ps aux | grep -v "grep"| grep $1' -alias greptodo='grep -R "TODO" .' -alias exit="clear; exit" -alias du='du -h' -alias .='source' - - -## HELP -alias helpdd='echo dd if=bla | pv -s 10M | dd of=blob' - -# ZSH ALIASES > diff --git a/.zsh.after/apt b/.zsh.after/apt deleted file mode 100644 index e1942cf..0000000 --- a/.zsh.after/apt +++ /dev/null @@ -1,37 +0,0 @@ -#TODO: add pacman to apt-get conversion for all pacman aliases -alias paclid="sudo pacman -Qi | sed '/^Depends On/,/^Required By/{ s/^Required By.*$//; H; d }; /^Name/!d; /^Name/{ n;x;}'| sed '/^$/s//==================================================================================/'" -alias pacsize="pacman -Qi | awk '/^Name/ {pkg=\$3} /Size/ {print \$4\$5,pkg}' | sort -n" #All packages by size -alias pacall="sudo pacman -Qi | awk '/^Name/ {pkg=\$3} /Version/ {ver=\$3} /Size/ {size=\$4\$5} {print pkg,ver,size}' | uniq" #All packages uniquely with name, version, size -#alias pacremorph='sudo pacman -Rs $(pacman -Qtdq)' #Remove all orphaned packages -alias pacup='sudo apt-get update && sudo apt-get upgrade' #'sudo pacman -Syu' # Synchronize with repositories before upgrading packages that are out of date on the local system. -alias pac='sudo apt-get install ' #'sudo pacman -S' # Install specific package(s) from the repositories -alias pacu='sudo pacman -U' # Install specific package not from the repositories but from a file -alias pacre='sudo apt-get remove ' #'sudo pacman -R' # Remove the specified package(s), retaining its configuration(s) and required ##dependencies -alias pacrem='sudo apt-get purge ' #'sudo pacman -Rns' # Remove specified package(s), its configuration(s) and unneeded depends -alias pacsearch="pacman -Sl | cut -d' ' -f2 | grep " # Search through all available packages in repo -#alias pacname='dpkg -l|grep Name|grep ' #'sudo pacman -Qi|grep Name|grep ' #Search through names of packages by string -alias pacri='sudo apt-get update && sudo apt-cache show ' #'pacman -Si' # Display information about a given package in the repositories -alias pacrs='sudo apt-get update && sudo apt-cache search ' #'pacman -Ss' # Search for package(s) in the repositories -alias pacli='dpkg -l ' #'pacman -Qi' # Display information about a given package in the local database -alias pacls='dpkg -l|grep ' #'pacman -Qs' # Search for package(s) in the local database -alias pacorph='sudo pacman -Qdt' # Search for orphan packages -alias paclal='dpkg -L' #'sudo pacman -Ql' # List installed files of a given package -alias pacg='pacman -Sg' #List all groups or all packages in specified group -alias pacclean='sudo pacman -Sc' # Remove all packages from local repository, not installed atm, remove all unused repos -alias pacconf='sudo find /etc -name "*.pac*" -type f -print' # Search for .pacnew and .pacsave files -alias pacfile='dpkg -S ' #'sudo pacman -Qo' # Find out what package a give file belongs to -alias pacupd='sudo apt-get update' #'sudo pacman -Sy && sudo abs' # Update and refresh the local package and ABS databases against repositories -alias pacdep='sudo pacman -S --asdeps' # Install given package(s) as dependencies of another package -alias pacmir='sudo pacman -Syy' # Force refresh of all package lists after updating /etc/pacman.d/mirrorlist -alias packup='comm -23 <(pacman -Qeq|sort) <(pacman -Qmq|sort) > $HOME/Dropbox/sync/archlinux/pkglist-$HOST' # Backup the current list of non-local packages -alias pacret='sudo pacman -S $(< $HOME/Dropbox/sync/archlinux/pkglist-$HOST)' # Install from the backup list -alias pacredown='sudo pacman -S $(comm -23 <(pacman -Qeq) <(pacman -Qmq))' # Redownload all installed packages (minus AUR) -alias pacdis='rm -f $HOME/Dropbox/sync/archlinux/non-pkg-$HOST; sudo pacman-disowned > $HOME/Dropbox/sync/archlinux/non-pkg-$HOST' # Getting a list of files not owned by any package -alias packimp='sudo pacman-key -r ' #Import a key ID to the pacman keyring -alias packsign='sudo pacman-key --lsign-key ' #Sign a key ID after importing it to the keyring -alias packref='sudo pacman-key --refresh-keys' #Refresh the list of master keys - -##Yaourt aliases -alias yaup='yaourt -Syu --devel --aur' # Updates all locally installed repository, AUR and git packages -alias yadb='yaourt -B $HOME/Dropbox/sync/archlinux' # Backs up the yaourt database -alias ya='sudo apt-get -t testing install ' # Install packages from AUR/Testing diff --git a/.zsh.after/export.zsh b/.zsh.after/export.zsh deleted file mode 100644 index 59eb186..0000000 --- a/.zsh.after/export.zsh +++ /dev/null @@ -1,102 +0,0 @@ -if [[ -n $TMUX ]] && [[ $VENDOR != "apple" ]] && [[ ! -e /etc/debian_version ]]; then - export TERM="screen-256color" -elif [[ -n $STY ]];then - export TERM="screen-256color" -else - export TERM="xterm-256color" -fi - - -available_locale=$(locale -a|tr '\n' ' ') -if [ "${available_locale#*en_DK.utf8}" != "$available_locale" ]; then - export LC_TIME="en_DK.UTF-8" -elif [ "${available_locale#*en_DK.UTF-8}" != "$available_locale" ]; then - export LC_TIME="en_DK.UTF-8" -fi -if [ "${available_locale#*de_DE.utf8}" != "$available_locale" ]; then - export LC_MONETARY="de_DE.UTF-8" -elif [ "${available_locale#*de_DE.UTF-8}" != "$available_locale" ]; then - export LC_MONETARY="de_DE.UTF-8" -fi -if [ "${available_locale#*en_US.utf8}" != "$available_locale" ]; then - export LANG="en_US.UTF-8" -elif [ "${available_locale#*en_US.UTF-8}" != "$available_locale" ]; then - export LANG="en_US.UTF-8" -fi -if [ "${available_locale#*en_US.utf8}" != "$available_locale" ] ; then - export LC_CTYPE="en_US.UTF-8" -elif [ "${available_locale#*en_US.UTF-8}" != "$available_locale" ]; then - export LC_CTYPE="en_US.UTF-8" -fi - -# keyboard exports for sway -export XKB_DEFAULT_LAYOUT=de - -# browser -export BROWSER=firefox -export REPORTTIME=5 - -# systemd -export SYSTEMD_EDITOR=vim - -# editor -export EDITOR=vim -export VISUAL=vim - -# if vimpager is installed, use it instead of less -if [[ -x /usr/bin/vimpager ]];then - export PAGER="vimpager" -else - export PAGER="less -j4" -fi - -export GREP_COLOR="1;33" - -# let RVM ignore global ruby -export rvm_ignore_gemrc_issues=1 - -# Java -# font settings/ renderings -export _JAVA_OPTIONS='-Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true' -# non-reparenting windows -export _JAVA_AWT_WM_NONREPARENTING=1 - -# pipenv environment variables: -# - disabling fancy shell stuff -# - creating virtualenv within each project -# - moving cache dir to build volume -export PIPENV_NOSPIN="true" -export PIPENV_COLORBLIND="true" -export PIPENV_HIDE_EMOJIS="true" -export PIPENV_VENV_IN_PROJECT="true" -#export PIPENV_CACHE_DIR="$HOME/.cache/pipenv" - -# brew -if command -v brew > /dev/null; then - export HOMEBREW_NO_ANALYTICS="true" - export HOMEBREW_NO_AUTO_UPDATE="true" - export HOMEBREW_NO_EMOJI="true" -fi - -# GnuPG -export GPG_TTY=$TTY -export GPG_AGENT_INFO="" - -# ssh-agent -if [[ $UID -ne 0 ]] && [[ $VENDOR != "apple" ]];then - export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.socket" -fi - -# tmux -if [[ $UID -ne 0 ]] && [[ $VENDOR != "apple" ]]; then - export TMUX_TMPDIR="$XDG_RUNTIME_DIR/" -else - export TMUX_TMPDIR="/tmp" -fi - -# zsh -if [[ $UID -eq 0 ]]; then - export TMOUT=360 - readonly TMOUT - export TMOUT -fi diff --git a/.zsh.after/frqrec b/.zsh.after/frqrec deleted file mode 100644 index e69de29..0000000 diff --git a/.zsh.after/functions.zsh b/.zsh.after/functions.zsh deleted file mode 100644 index 7a87bee..0000000 --- a/.zsh.after/functions.zsh +++ /dev/null @@ -1,398 +0,0 @@ -# < FUNCTIONS - -## PDF/LATEX - function mkpdf() - { - pdflatex -shell-escape $1 - # latex --output-format=pdf $1 - name=`echo $1 | sed 's/.tex//'` - EXT=(aux log) - for i in $EXT; - do - rm -v $name.$i - done - } - - function gsmerge() - { - target=$1 - echo "target: $target" - sleep 1 - shift - - /usr/bin/gs \ - -sDEVICE=pdfwrite \ - -dCompatibilityLevel=1.4 \ - -dNOPAUSE \ - -dBATCH \ - -sPAPERSIZE=a4 \ - -sOUTPUTFILE=$target $* - } - - function gsmerge_medium() - { - target=$1 - echo "target: $target" - sleep 1 - shift - - /usr/bin/gs \ - -sDEVICE=pdfwrite \ - -dPDFSETTINGS=/ebook \ - -dCompatibilityLevel=1.4 \ - -dNOPAUSE \ - -dBATCH \ - -sPAPERSIZE=a4 \ - -sOutputFile=$target $* - } - -## USABILITY - function lvim() - { - noglob vim $(echo $1 | awk -F":" '{ print $1" +"$2 }' ) - } - - function mkcd() - { - mkdir $1 - cd $1 - } - - function cpwd() - { - pwd >! /tmp/pwd - } - - function ppwd() - { - cd "`cat /tmp/pwd`" - } - - function cp2wd() - { - cp $@ "`cat /tmp/pwd`" - } - function cpmk() { - DIR=${*: -1} - [ ! -d $DIR ] && mkdir -p $DIR - cp $* - - } - - cpmd5(){ - md5sum $1|cut -d ' ' -f 1|cpx - } - - -function publish() { - [ -f $1 ] || return - - DIR=`dirname $1` - FILE=`basename $1` - mute pushd $DIR - scp $FILE pool:public_html/ - echo "http://www-pool.math.tu-berlin.de/~runge/$FILE" - echo "http://www-pool.math.tu-berlin.de/~runge/$FILE"|cpx - mute popd -} - -function incognichrome { - chromium --incognito -} - -function inproxychrome { - chromium --incognito --proxy-server=apu-serve:8123 --user-data-dir="$HOME/.config/chromium-proxy" -} - -## ZSH -refresh() { - source $HOME/.zshrc -} - - -## compress stuff -tar_tgz() { - tar cvfz $1.tgz $1 -} -tar_tbz() { - tar cvfj $1.tbz $1 -} -tar_tlz() { - tar --lzma -cvf $1.tlz $1 -} -tar_xz() { - tar cvfJ $1.tar.xz $1 -} - -#Decompress any given compressed file -ex() { - if [ -f $1 ] ; then - case $1 in - *.tar.bz2) - tar xvjf $1 - ;; - *.tar.gz) - tar xvzf $1 - ;; - *.tar.lz) - tar xvf $1 - ;; - *.bz2) - bunzip2 $1 - ;; - *.deb) - ar vx $1 - ;; - *.rar) - unrar x $1 - ;; - *.pgp) - gpg -o ${1%".pgp"} -d $1 - ;; - *.gpg) - gpg -o ${1%".gpg"} -d $1 - ;; - *.asc) - gpg -o ${1%".asc"} -d $1 - ;; - *.gz) - gunzip $1 - ;; - *.tar) - tar xvf $1 - ;; - *.tbz2) - tar xvjf $1 - ;; - *.tgz) - tar xvzf $1 - ;; - *.whl) - unzip "$1" - ;; - *.xz) - tar xvJf $1 - ;; - *.zip) - unzip $1 - ;; - *.zst) - tar --zstd -xvf $1 --force-local - ;; - *.Z) - uncompress $1 - ;; - *.7z) - 7z x $1 - ;; - *) - echo "Don't know how to extract '$1'..." - ;; - esac - else - echo "'$1' is not a valid file to extract!" - fi -} - -ex2() { - if [ -f $2 ] ;then - echo "Extracting to '$2'" - local out = $2 - else - echo "Extracting to '$( pwd )'" - local out = $( pwd ) - fi - if [ -f $1 ] ;then - echo "'$1'" - else - echo "'$1' is not a valid file!" - fi -} - -lstar() { - if [ -f "$1" ] ; then - case "$1" in - *.deb) - ar -tv "$1" - ;; - *.bz2) - tar -tvf "$1" --force-local - ;; - *.gz) - tar -tvf "$1" --force-local - ;; - *.lz) - tar -tvf "$1" --force-local - ;; - *.rar) - unrar lb "$1" - ;; - *.tar) - tar -tvf "$1" --force-local - ;; - *.tbz2) - tar -tvf "$1" --force-local - ;; - *.tgz) - tar -tvf "$1" --force-local - ;; - *.whl) - unzip -l "$1" - ;; - *.xz) - tar -Jtvf "$1" --force-local - ;; - *.zip) - unzip -l "$1" - ;; - *.Z) - uncompress $1 - ;; - *.7z) - 7z l "$1" - ;; - *.zst) - tar --zstd -tvf "$1" --force-local - ;; - *) - echo "Don't know how to look into $1" - exit 1 - ;; - esac - else - echo "'$1' is not a file!" - exit 1 - fi -} - -## RSYNC - -backupinfo() { - rsync\ - -r\ - -n\ - -t\ - -p\ - -o\ - -h\ - -g\ - -v\ - --progress\ - --delete\ - --ignore-existing\ - --size-only\ - -s\ - --exclude 'lost+found'\ - --exclude '.Trash-1000'\ - --exclude '$RECYCLEBIN'\ - --exclude 'System Volume Information'\ - --exclude '.thumbs'\ - $1 $2 - echo "backupfolder path/to/folder/ /path/to/other/folder" -} - -backupfolder() { - rsync \ - -r\ - -t\ - -p\ - -o\ - -h\ - -g\ - -v\ - --progress\ - --delete --ignore-existing --size-only -s --exclude 'lost+found' --exclude '.Trash-1000' --exclude '$RECYCLEBIN' --exclude 'System Volume Information' --exclude '.thumbs' $1 $2 -} - -# journalctl - -# show messages of specified system units -function sdsjfu(){ - local journal_cmd="sudo journalctl --system -a" - eval ${journal_cmd} $(echo $@ | sed 's/\ /\ -u\ /g; s/^/\ -u\ /') -} - -# follow messages of specified system units -function sdsjfu(){ - local journal_cmd="sudo journalctl --system -af" - eval ${journal_cmd} $(echo $@ | sed 's/\ /\ -u\ /g; s/^/\ -u\ /') -} - -# follow messages of specified system units for this boot -function sdsjbfu(){ - local journal_cmd="sudo journalctl --system -b -af" - eval ${journal_cmd} $(echo $@ | sed 's/\ /\ -u\ /g; s/^/\ -u\ /') -} - -# follow messages of specified user units -function sdujfu(){ - local journal_cmd="journalctl --user -af" - eval ${journal_cmd} $(echo $@ | sed 's/\ /\ --user-unit\ /g; s/^/\ --user-unit\ /') -} - -# follow messages of specified user units for this boot -function sdujbu(){ - local journal_cmd="journalctl --user -a -b" - #TODO: Check if first argument is a number, then use it for -b - eval ${journal_cmd} $(echo $@ | sed 's/\ /\ --user-unit\ /g') -} - -# show messages of specified system units since and until a specified time -function sdsjSUu(){ - local journal_cmd="sudo journalctl --system -a -S" - local args=(${@}) - journal_cmd="$journal_cmd $args[1] -U $args[2]" - args=(${args:2}) - eval ${journal_cmd} $(echo $args | sed 's/\ /\ -u\ /g; s/^/\ -u\ /') -} - -# show messages of specified system units since a specified time -function sdsjSu(){ - local journal_cmd="sudo journalctl --system -a -S" - local args=(${@}) - journal_cmd="$journal_cmd $args[1]" - args=(${args:1}) - eval ${journal_cmd} $(echo $args | sed 's/\ /\ -u\ /g; s/^/\ -u\ /') -} - -# show messages of specified user units since and until a specified time -function sdujSUu(){ - local journal_cmd="journalctl --user -a -S" - local args=(${@}) - journal_cmd="$journal_cmd $args[1] -U $args[2]" - args=(${args:2}) - eval ${journal_cmd} $(echo $args | sed 's/\ /\ --user-unit\ /g; s/^/\ --user-unit\ /') -} - -# show messages of specified user units since a specified time -function sdujSu(){ - local journal_cmd="journalctl --user -a -S" - local args=(${@}) - journal_cmd="$journal_cmd $args[1]" - args=(${args:1}) - eval ${journal_cmd} $(echo $args | sed 's/\ /\ --user-unit\ /g; s/^/\ --user-unit\ /') -} - -# show kernel messages since and until a specified time -function sdsjkSU(){ - local journal_cmd="sudo journalctl --system -a -k -S" - local args=(${@}) - journal_cmd="$journal_cmd $args[1] -U $args[2]" - eval ${journal_cmd} -} - -# show kernel messages since a specified time -function sdsjkS(){ - local journal_cmd="sudo journalctl --system -a -k -S" - local args=(${@}) - journal_cmd="$journal_cmd $args[1]" - eval ${journal_cmd} -} - - -function pasters() { - local file="${1:-/dev/stdin}" - curl --data-binary @"${file}" https://paste.rs -} - -# FUNCTIONS > diff --git a/.zsh.after/hostspecific.zsh b/.zsh.after/hostspecific.zsh deleted file mode 100644 index 20d569b..0000000 --- a/.zsh.after/hostspecific.zsh +++ /dev/null @@ -1,6 +0,0 @@ -case "${HOST}" in - s4|s5|c{1,2}*) - . $HOME/.zsh.after/apt - . $HOME/.zsh.after/unixpool - ;; -esac diff --git a/.zsh.after/key-bindings.zsh b/.zsh.after/key-bindings.zsh deleted file mode 100644 index 300b3c7..0000000 --- a/.zsh.after/key-bindings.zsh +++ /dev/null @@ -1,22 +0,0 @@ -## OVERRIDE KEY-BINDINGS -bindkey -s '\e,' '..\n' # [Esc-,] - run command: .. (up directory) -bindkey '\e.' insert-last-word # [Esc-.] - insert last word -#bindkey '^[Oc' forward-word # [Ctrl-RightArrow] - move forward one word -#bindkey '^[OC' forward-word # [Ctrl-RightArrow] - move forward one word -#bindkey '^[Od' backward-word # [Ctrl-LeftArrow] - move backward one word -#bindkey '^[OD' backward-word # [Ctrl-LeftArrow] - move backward one word - -## URXVT & TMUX -case $TERM in - rxvt-unicode-256color) - bindkey '^[Oc' forward-word # [Ctrl-RightArrow] - move forward one word - bindkey '^[Od' backward-word # [Ctrl-LeftArrow] - move backward one word - ;; - screen-256color) - bindkey '^[[1;5C' forward-word # [Ctrl-RightArrow] - tmux: move forward one word - bindkey '^[[1;5D' backward-word # [Ctrl-LeftArrow] - tmux: move backward one word - ;; -esac - -## NEW KEY-BINDINGS -bindkey '^K' kill-line diff --git a/.zsh.after/path.zsh b/.zsh.after/path.zsh deleted file mode 100644 index 21e36e6..0000000 --- a/.zsh.after/path.zsh +++ /dev/null @@ -1,19 +0,0 @@ -# cargo -[ -d "${HOME}/.cargo/bin" ] && PATH="${HOME}/.cargo/bin:${PATH}" -# pyenv -[ -d "${HOME}/.local/bin" ] && PATH="${HOME}/.local/bin:${PATH}" -[ -d "${HOME}/.pyenv/shims" ] && PATH="${HOME}/.pyenv/shims:${PATH}" -# RPi -[ -d "/opt/vc/bin" ] && PATH="${PATH}:/opt/vc/bin" -[ -d "/opt/vc/sbin" ] && PATH="${PATH}:/opt/vc/sbin" -# user bin -[ -d "${HOME}/bin" ] && PATH="${HOME}/bin:${PATH}" -# Debilian -[ -d "/usr/sbin" ] && [ ! -L "/usr/sbin" ] && PATH="${PATH}:/usr/sbin" -# whackOS -[ -d "/usr/local/opt/coreutils/libexec/gnubin" ] && PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH" -[ -d "/usr/local/opt/gnu-sed/libexec/gnubin" ] && PATH="/usr/local/opt/gnu-sed/libexec/gnubin:$PATH" -[ -d "/usr/local/opt/gnu-tar/libexec/gnubin" ] && PATH="/usr/local/opt/gnu-tar/libexec/gnubin:$PATH" -[ -d "/usr/local/opt/gnu-which/libexec/gnubin" ] && PATH="/usr/local/opt/gnu-which/libexec/gnubin:$PATH" -[ -d "/usr/local/opt/findutils/libexec/gnubin" ] && PATH="/usr/local/opt/findutils/libexec/gnubin:$PATH" -[ -d "/usr/local/opt/grep/libexec/gnubin" ] && PATH="/usr/local/opt/grep/libexec/gnubin:$PATH" diff --git a/.zsh.after/udisks.zsh b/.zsh.after/udisks.zsh deleted file mode 100644 index 3478aea..0000000 --- a/.zsh.after/udisks.zsh +++ /dev/null @@ -1,245 +0,0 @@ -# EXAMPLES: -# - mounting devices -# sdm sdb1 // mount first partition on sdb -# sdm sdb 1 // mount first partition on sdb -# sdm sdb // mount all available partitions on sdb -# sdm // mount all available devices -# mcm mmcblk0p1 // mount first partition on mmcblk0 -# mcm mmcblk0 1 // mount first partition on mmcblk0 -# mcm mmcblk0 // mount all partitions on mmcblk0 -# mcm // mount all partitions on all mmcblk devices -# srm 0 // mount first optical drive -# srm // mount all optical drives -# -# - unmounting devices -# sdu sdb1 // unmount first partition on sdb -# sdu sdb 1 // unmount first partition on sdb -# sdu sdb // unmount all available partitions on sdb -# sdu // unmount all available devices -# mcu mmcblk0p1 // unmount first partition on mmcblk0 -# mcu mmcblk0 1 // unmount first partition on mmcblk0 -# mcu mmcblk0 // unmount all partitions on mmcblk0 -# mcu // unmount all partitions on all mmcblk devices -# sru 0 // unmount first optical drive -# sru // unmount all optical drives -# - -# mount commands: -mount="udisksctl mount -b" -unmount="udisksctl unmount -b" - -# Path to all devices -folder="/dev/" - -# Devices of the form /dev/sd{b,c,d,e,f,g,h,i,j,k,l,m,n} -# path -dev="/dev/sd" -# Device numbers/names -devices=( b c d e f g h i j k l m n ) -# Partition numbers -device_partitions=( 1 2 3 4 5 6 7 8 9 ) - -# Devices of the form /dev/mmcblk{0,1,2,3,4,5,6,7,8,9}p{1,2,3,4,5,6,7,8,9} -# path -mmc="/dev/mmcblk" -# Device numbers/names -mmc_devices=( 0 ) -# Partition numbers -mmc_partitions=( p1 p2 p3 p4 p5 p6 p7 p8 p9 ) - -# Devices of the form /dev/sr{0,1,2} -# path -optical="/dev/sr" -# Device numbers/names -optical_devices=( 0 1 2 ) - -# device functions: -sdm() { - if [[ -n "$2" ]]; then # if 2nd argument is set - if [[ "$1" = ?d* ]]; then # check if 1st argument features the letter d - if [[ -b $folder$1$2 ]]; then # check if block device $1$2 is available - $=mount $folder$1$2 - fi - fi - elif [[ -n "$1" ]]; then # if 1st argument is set - if [[ "$1" = ?d* ]]; then # check if 1st argument featurs a letter d - if [[ -b $folder$1"1" ]]; then #check if first device is available - for a in $device_partitions; do # loop through device partitions of first argument - echo "$folder$1$a" - if [[ -b $folder$1$a ]]; then # checking for each device if available and block device - $=mount "$folder$1$a" - fi - done - else - echo "Trying to mount: $folder$1" - if [[ -b $folder$1 ]]; then # check if 1st argument already is the block device to mount - $=mount $folder$1 - fi - fi - fi - else # here we loop all available block devices and mount them - # TODO: check with df if the device is already mounted - for a in $devices; do # loop through the list of all devices - if [[ -b $dev$a ]]; then # check if first partition of block device is available - for b in $device_partitions; do # loop through the list of all partitions - if [[ -b $dev$a$b ]]; then # if it's a block device - echo "Trying to mount: $dev$a$b" - $=mount "$dev$a$b" - fi - done - fi - done - fi -} - -sdu() { - if [[ -n "$2" ]]; then - if [[ "$1" = ?d* ]]; then - if [[ -b $folder$1$2 ]]; then - echo "Trying to unmount: $folder$1$2" - $=unmount $folder$1$2 - fi - fi - elif [[ -n "$1" ]]; then - if [[ "$1" = ?d* ]]; then - if [[ -b $folder$1"1" ]]; then - for a in $device_partitions; do - if [[ -b $folder$1$a ]]; then # checking for each device if available and block device - echo "Trying to unmount: $folder$1$a" - $=unmount $folder$1$a - fi - done - else - if [[ -b $folder$1 ]]; then - echo "Trying to unmount: $folder$1" - $=unmount $folder$1 - fi - fi - fi - else # unmount all devices mounted - for a in $devices; do - if [[ -b $dev$a ]]; then - for b in $device_partitions; do - if [[ -b $dev$a$b ]]; then # if it's a block device - echo "Trying to unmount: $dev$a$b" - $=unmount $dev$a$b - fi - done - fi - done - fi -} - -# mmc functions: -mcm() { - if [[ -n "$2" ]]; then - if [[ "$1" = mmcblk* ]]; then - if [[ -b $folder$1"p"$2 ]]; then - echo "Trying to mount: $folder$1"p"$2" - $=mount $folder$1"p"$2 - fi - fi - elif [[ -n "$1" ]]; then - if [[ "$1" = mmcblk* ]]; then - if [[ -b $folder$1"p1" ]]; then - for a in $mmc_partitions; do - if [[ -b $folder$1$a ]]; then - echo "Trying to mount: $folder$1$a" - $=mount $folder$1$a - fi - done - else - if [[ -b $folder$1 ]]; then - echo "Trying to mount: $folder$1" - $=mount $folder$1 - fi - fi - fi - else - for a in $mmc_devices; do - if [[ -b $mmc$a"p1" ]]; then - for b in $mmc_partitions; do - if [[ -b $mmc$a$b ]]; then # if it's a block device - echo "Trying to mount: $mmc$a$b" - $=mount $mmc$a$b - fi - done - fi - done - fi -} - -mcu() { - if [[ -n "$2" ]]; then - if [[ "$1" = mmcblk* ]]; then - if [[ -b $folder$1"p"$2 ]]; then - echo "Trying to unmount: $folder$1"p"$2" - $=unmount $folder$1"p"$2 - fi - fi - elif [[ -n "$1" ]]; then - if [[ "$1" = mmcblk* ]]; then - if [[ -b $folder$1"p1" ]]; then - for a in $mmc_partitions; do - echo "Trying to unmount: $folder$1$a" - $=unmount $folder$1$a - done - else - if [[ -b $folder$1 ]]; then - echo "Trying to unmount: $folder$1" - $=unmount $folder$1 - fi - fi - fi - else - for a in $mmc_devices; do - if [[ -b "$mmc$a${mmc_partitions[0]}" ]]; then - echo $mmc$a${mmc_partitions[0]} - for b in $mmc_partitions; do - if [[ -b $mmc$a$b ]]; then # if it's a block device - echo "Trying to unmount: $mmc$a$b" - $=unmount $mmc$a$b - fi - done - fi - done - fi -} - -# sr functions: -srm() { - if [[ -n "$1" ]]; then - if [[ "$1" = ? ]]; then - if [[ -b $optical$1 ]]; then - echo "Trying to mount: $optical$1" - $=mount $optical$1 - fi - fi - else - for a in $optical_devices; do - if [[ -b $optical$a ]]; then - echo "Trying to mount: $optical$a" - $=mount $optical$a - fi - done - fi -} - -sru() { - if [[ -n "$1" ]]; then - if [[ "$1" = ? ]]; then - if [[ -b $optical$1 ]]; then - echo "Trying to unmount: $optical$1" - $=unmount $optical$1 - fi - fi - else - for a in $optical_devices; do - if [[ -b $optical$a ]]; then - echo "Trying to unmount: $optical$a" - $=unmount $optical$a - fi - done - fi -} - diff --git a/.zsh.after/unixpool b/.zsh.after/unixpool deleted file mode 100644 index e2edade..0000000 --- a/.zsh.after/unixpool +++ /dev/null @@ -1,125 +0,0 @@ -# host based zshrc -# unixpool - -HISTFILE=$HOME/.zhistory -unset MAILCHECK - -## PATH and exports -PATH=${PATH}:/net/local64/bin -PATH=${PATH}:/net/adm/bin -PATH=${PATH}:/net/adm/scripts -PATH=${PATH}:/net/adm/xadm -PATH=${PATH}:/homes/wheel/wheel/bin -PATH=${PATH}:/sbin -PATH=${PATH}:/usr/sbin -#PATH=/store/s4/android/android-sdk-linux_86/tools:$PATH -#PATH=/store/s4/android/android-sdk-linux_86/platform-tools:$PATH - -#Remove /usr/bin/X11: if it shows up in $PATH -autoload -U regexp-replace -regexp-replace PATH '/usr/bin/X11:' '' - -export MATLAB_JAVA=/usr/lib/jvm/java-6-sun-1.6.0.26/jre - -## aliases -alias lp_ps1_100='lp -q 100 -d ps1' -alias lp_ps2_100='lp -q 100 -d ps2' -alias QW='xterm -geometry 84x41-0+0 -T '\''QWatch'\'' -fn 5x8 -e /homes/misc/lpviewer/lpdisp' -alias QWbig='xterm -geometry 84x41-0+0 -T '\''QWatch'\'' -e /homes/misc/lpviewer/lpdisp' -alias QWbighere='/homes/misc/lpviewer/lpdisp' -alias QWdisplay="watch 'for n in {1..3}; do scli -c \"show printer display\" ps\$n-pool; done'" -#alias pyadm="/net/adm/pyadm-64ready/start.py" -alias synergys='synergys -c .config/synergy-$HOST.conf' - -# set pulseaudio server to s4 -if [ -f "`which pax11publish`" ]; -then - if [ ! $SSH_CLIENT ]; - then - if [ `pax11publish | grep -c s4` -eq 0 ]; - then - echo pulseaudio server set - pax11publish -S s4 -e - else - echo pulseaudio active - fi - fi -fi - - -## FUNCTIONS -function music_update() { - echo "updating zip files" - for i in */*; - do - name=`echo $i | sed 's/\ /_/g' | sed 's/\//-/g'` - if [ ! -e $name.zip ]; - then - echo "packing $i as $name.zip" - zip -r $name.zip $i - fi - done - echo "done" -} - -function makantine() { - wget http://personalkantine.personalabteilung.tu-berlin.de/pdf/MA-aktuell.pdf -O /tmp/makantine.$$.pdf >&/dev/null - xpdf -cont -z page /tmp/makantine.$$.pdf - rm -f /tmp/makantine.$$.pdf -} - -function pxeln() { - local instmode host oldumask bopts="" isrc="" - while [ -n "$1" ]; do - if [[ "$1" == -o* ]]; then - [ -z "$bopts" ] && bopts="bootopts=${1:2}" || bopts="${bopts},${1:2}"; - else - if [ -z "$instmode" ]; then instmode="$1"; - elif [ -z "$host" ]; then host="$1"; - else echo "Ignoring superfluous argument \"$1\"."; - fi - fi - - shift - done - if [[ -z "$instmode" || -z "$host" ]]; then - echo -e "Missing argument!\nSyntax: pxeln {mode} {host}\n(use tab completion for available modes)" >/dev/stderr - return 1 - fi - local IP=$(egrep "^[^,]*,${host}," /net/adm/access/HWlist |cut -d, -f1|cut -d. -f4) - local M="01-$(egrep " $IP " /net/adm/access/MAClist 2>/dev/null|sed -e "s/^|[^|]*| \([0-9a-f:]*\) |/\1/" -e "y/:/-/")" - if [[ ${#M} -ne 20 ]]; then - echo "Unknown host." >/dev/stderr - return 1 - fi - shift 2 - oldumask=$(umask -p) - umask 0022 - local instmodetl=$(tr [:upper:] [:lower:]<<<$instmode) - if [ -s /homes/ext15a/tftpboot/pxelinux.cfg/${instmode}.sed ]; then - if [ -e /homes/ext15a/tftpboot/pxelinux.cfg/$M ]; then - rm -f /homes/ext15a/tftpboot/pxelinux.cfg/$M - echo "$host: former PXE diversion removed." - fi - sed /homes/ext15a/tftpboot/pxelinux.cfg/_template \ - -f /homes/ext15a/tftpboot/pxelinux.cfg/${instmode}.sed \ - > /homes/ext15a/tftpboot/pxelinux.cfg/$M - echo -n "$host: elected for ${instmode}" - if [ -n "$bopts" ]; then - sed -i -e "/bootmode=${instmodetl}/ s/$/ ${bopts}/" /homes/ext15a/tftpboot/pxelinux.cfg/$M - echo -n " (with extra boot options: \"$bopts\")" - fi - echo "." - elif [ "$instmode" == "remove" ]; then - rm -f /homes/ext15a/tftpboot/pxelinux.cfg/$M - echo "$host: PXE diversion removed." - else - echo "Unknown PXE mode." >/dev/stderr - fi - $oldumask - return 0 -} - -function mailhighscore() { - for i in /homes/wheel/*; do n=`basename $i`; echo `grep $n /var/spool/mail/runge | grep -c From` $n; done | sort -nr -} diff --git a/.zsh.functions/01_editor.zsh b/.zsh.functions/01_editor.zsh deleted file mode 100644 index 1484a92..0000000 --- a/.zsh.functions/01_editor.zsh +++ /dev/null @@ -1,124 +0,0 @@ -# Exposes information about the Zsh Line Editor via the $editor_info associative -# array. -function editor-info { - # Clean up previous $editor_info. - unset editor_info - typeset -gA editor_info - - if [[ "$KEYMAP" == 'vicmd' ]]; then - zstyle -s ':editor:info:keymap:alternate' format 'REPLY' - editor_info[keymap]="$REPLY" - else - zstyle -s ':editor:info:keymap:primary' format 'REPLY' - editor_info[keymap]="$REPLY" - - if [[ "$ZLE_STATE" == *overwrite* ]]; then - zstyle -s ':editor:info:keymap:primary:overwrite' format 'REPLY' - editor_info[overwrite]="$REPLY" - else - zstyle -s ':editor:info:keymap:primary:insert' format 'REPLY' - editor_info[overwrite]="$REPLY" - fi - fi - - unset REPLY - - zle reset-prompt - zle -R -} -zle -N editor-info - -# Updates editor information when the keymap changes. -function zle-keymap-select { - zle editor-info -} -zle -N zle-keymap-select - -# Enables terminal application mode and updates editor information. -function zle-line-init { - # The terminal must be in application mode when ZLE is active for $terminfo - # values to be valid. - if (( $+terminfo[smkx] )); then - # Enable terminal application mode. - echoti smkx - fi - - # Update editor information. - zle editor-info -} -zle -N zle-line-init - -# Disables terminal application mode and updates editor information. -function zle-line-finish { - # The terminal must be in application mode when ZLE is active for $terminfo - # values to be valid. - if (( $+terminfo[rmkx] )); then - # Disable terminal application mode. - echoti rmkx - fi - - # Update editor information. - zle editor-info -} -zle -N zle-line-finish - -# Toggles emacs overwrite mode and updates editor information. -function overwrite-mode { - zle .overwrite-mode - zle editor-info -} -zle -N overwrite-mode - -# Enters vi insert mode and updates editor information. -function vi-insert { - zle .vi-insert - zle editor-info -} -zle -N vi-insert - -# Moves to the first non-blank character then enters vi insert mode and updates -# editor information. -function vi-insert-bol { - zle .vi-insert-bol - zle editor-info -} -zle -N vi-insert-bol - -# Enters vi replace mode and updates editor information. -function vi-replace { - zle .vi-replace - zle editor-info -} -zle -N vi-replace - -# Expands .... to ../.. -function expand-dot-to-parent-directory-path { - if [[ $LBUFFER = *.. ]]; then - LBUFFER+='/..' - else - LBUFFER+='.' - fi -} -zle -N expand-dot-to-parent-directory-path - -# Displays an indicator when completing. -function expand-or-complete-with-indicator { - local indicator - zstyle -s ':editor:info:completing' format 'indicator' - print -Pn "$indicator" - zle expand-or-complete - zle redisplay -} -zle -N expand-or-complete-with-indicator - -# Inserts 'sudo ' at the beginning of the line. -function prepend-sudo { - if [[ "$BUFFER" != su(do|)\ * ]]; then - BUFFER="sudo $BUFFER" - (( CURSOR += 5 )) - fi -} -zle -N prepend-sudo - -# Reset to default key bindings. -bindkey -d diff --git a/.zsh.functions/02_utility.zsh b/.zsh.functions/02_utility.zsh deleted file mode 100644 index 05b77bc..0000000 --- a/.zsh.functions/02_utility.zsh +++ /dev/null @@ -1,75 +0,0 @@ -# Makes a directory and changes to it. -function mkdcd { - [[ -n "$1" ]] && mkdir -p "$1" && builtin cd "$1" -} - -# Changes to a directory and lists its contents. -function cdls { - builtin cd "$argv[-1]" && ls "${(@)argv[1,-2]}" -} - -# Pushes an entry onto the directory stack and lists its contents. -function pushdls { - builtin pushd "$argv[-1]" && ls "${(@)argv[1,-2]}" -} - -# Pops an entry off the directory stack and lists its contents. -function popdls { - builtin popd "$argv[-1]" && ls "${(@)argv[1,-2]}" -} - -# Prints columns 1 2 3 ... n. -function slit { - awk "{ print ${(j:,:):-\$${^@}} }" -} - -# Finds files and executes a command on them. -function find-exec { - find . -type f -iname "*${1:-}*" -exec "${2:-file}" '{}' \; -} - -# Displays user owned processes status. -function psu { - ps -U "${1:-$LOGNAME}" -o 'pid,%cpu,%mem,command' "${(@)argv[2,-1]}" -} - -# Highlights make output. -function make { - if (( $+commands[colormake] )); then - colormake "$@" - else - command make "$@" - fi -} - -# Lists the contents of archives. -function lsarchive { - while (( $# > 0 )); do - if [[ ! -s "$1" ]]; then - print "$0: file not valid: $1" >&2 - shift - continue - fi - case "$1:l" in - (*.tar.gz|*.tgz) tar t${verbose:+v}vzf "$1" ;; - (*.tar.bz2|*.tbz|*.tbz2) tar t${verbose:+v}jf "$1" ;; - (*.tar.xz|*.txz) tar --xz --help &> /dev/null \ - && tar --xz -t${verbose:+v}f "$1" \ - || xzcat "$1" | tar t${verbose:+v}f - ;; - (*.tar.zma|*.tlz) tar --lzma --help &> /dev/null \ - && tar --lzma -t${verbose:+v}f "$1" \ - || lzcat "$1" | tar x${verbose:+v}f - ;; - (*.tar) tar t${verbose:+v}f "$1" ;; - (*.zip) unzip -l${verbose:+v} "$1" ;; - (*.rar) unrar &> /dev/null \ - && unrar ${${verbose:+v}:-l} "$1" \ - || rar ${${verbose:+v}:-l} "$1" ;; - (*.7z) 7za l "$1" ;; - (*) - print "$0: cannot list: $1" >&2 - success=1 - ;; - esac - shift - done -} diff --git a/.zsh.functions/0_terminal.zsh b/.zsh.functions/0_terminal.zsh deleted file mode 100644 index 85be89a..0000000 --- a/.zsh.functions/0_terminal.zsh +++ /dev/null @@ -1,74 +0,0 @@ -# Terminal functions -# - -# Sets the terminal or terminal multiplexer window title. -function set-window-title { - local title_format{,ted} - title_format='%s' - zformat -f title_formatted "$title_format" "s:$argv" - - if [[ "$TERM" == screen* ]]; then - title_format="\ek%s\e\\" - else - title_format="\e]2;%s\a" - fi - - printf "$title_format" "${(V%)title_formatted}" -} - -# Sets the terminal tab title. -function set-tab-title { - local title_format{,ted} - title_format='%s' - zformat -f title_formatted "$title_format" "s:$argv" - - printf "\e]1;%s\a" ${(V%)title_formatted} -} - - -# Sets the tab and window titles with a given command. -function _terminal-set-titles-with-command { - emulate -L zsh - setopt EXTENDED_GLOB - - # Get the command name that is under job control. - if [[ "${2[(w)1]}" == (fg|%*)(\;|) ]]; then - # Get the job name, and, if missing, set it to the default %+. - local job_name="${${2[(wr)%*(\;|)]}:-%+}" - - # Make a local copy for use in the subshell. - local -A jobtexts_from_parent_shell - jobtexts_from_parent_shell=(${(kv)jobtexts}) - - jobs "$job_name" 2>/dev/null > >( - read index discarded - # The index is already surrounded by brackets: [1]. - _terminal-set-titles-with-command "${(e):-\$jobtexts_from_parent_shell$index}" - ) - else - # Set the command name, or in the case of sudo or ssh, the next command. - local cmd="${${2[(wr)^(*=*|sudo|ssh|-*)]}:t}" - local truncated_cmd="${cmd/(#m)?(#c15,)/${MATCH[1,12]}...}" - unset MATCH - - set-window-title "$cmd" - set-tab-title "$truncated_cmd" - fi -} - - -# Sets the tab and window titles with a given path. -function _terminal-set-titles-with-path { - emulate -L zsh - setopt EXTENDED_GLOB - - local absolute_path="${${1:a}:-$PWD}" - local abbreviated_path="${absolute_path/#$HOME/~}" - local truncated_path="${abbreviated_path/(#m)?(#c15,)/...${MATCH[-12,-1]}}" - unset MATCH - - set-window-title "$abbreviated_path" - set-tab-title "$truncated_path" -} - - diff --git a/.zsh.functions/overrides.zsh b/.zsh.functions/overrides.zsh deleted file mode 100644 index b320671..0000000 --- a/.zsh.functions/overrides.zsh +++ /dev/null @@ -1,4 +0,0 @@ -# make git auto completion faster by favoring local files -__git_files () { - _wanted files expl 'local files' _files -} diff --git a/.zsh.functions/packaging.zsh b/.zsh.functions/packaging.zsh deleted file mode 100644 index 69d6df4..0000000 --- a/.zsh.functions/packaging.zsh +++ /dev/null @@ -1,133 +0,0 @@ -#!/usr/bin/env zsh - -pkg_sign() { - # sign one or more packages with the key setup in makepkg.conf - local _pkg_list=() - local _arg _pkg - - # get GPGKEY from makepkg.conf - if [[ -f /etc/makepkg.conf ]]; then - source /etc/makepkg.conf 2>/dev/null 1>&2 - fi - if [[ -f "${HOME}/.makepkg.conf" ]]; then - source "${HOME}/.makepkg.conf" 2>/dev/null 1>&2 - fi - if [[ -z "${GPGKEY}" ]]; then - 1>&2 printf "No GPGKEY is setup in makepkg.conf!\n" - return 1 - fi - - # check whether file(s) exists or globs exist - for _arg in "$@"; do - if [[ -f "${_arg}" ]] && [[ "${_arg}" == *.pkg.tar.zst ]]; then - _pkg_list+=( "${_arg}" ) - fi - if [[ -n *"${_arg}"*.pkg.tar.zst(#qN) ]]; then - _pkg_list+=( *"${_arg}"*.pkg.tar.zst ) - fi - done - - # sign package(s) - if (( ${#_pkg_list} > 0 )); then - for _pkg in "${_pkg_list[@]}"; do - gpg --detach-sign --local-user "${GPGKEY}" "$_pkg" - done - return 0 - else - 1>&2 printf "No package can be found for signing!\n" - return 1 - fi -} - -pkg_add() { - # sign one or more packages with the key setup in makepkg.conf - local _pkg_list=() - local _arg - - # get GPGKEY from makepkg.conf - if [[ -f /etc/makepkg.conf ]]; then - source /etc/makepkg.conf 2>/dev/null 1>&2 - fi - if [[ -f "${HOME}/.makepkg.conf" ]]; then - source "${HOME}/.makepkg.conf" 2>/dev/null 1>&2 - fi - if [[ -z "${GPGKEY}" ]]; then - 1>&2 printf "No GPGKEY is setup in makepkg.conf!\n" - return 1 - fi - - # check whether file(s) exists or globs exist - for _arg in "$@"; do - if [[ -f "${_arg}" ]] && [[ "$_arg" == *.pkg.tar.zst ]]; then - _pkg_list+=( "${_arg}" ) - fi - if [[ -n *"${_arg}"*.pkg.tar.zst(#qN) ]]; then - _pkg_list+=( *"${_arg}"*.pkg.tar.zst ) - fi - done - - # add package(s) to repo database - if (( ${#_pkg_list} > 0 )); then - repo-add -R -s -k "${GPGKEY}" "$(dirname "${_pkg_list[1]}")"/*.db.tar.gz "${_pkg_list[@]}" - return 0 - else - 1>&2 printf "No packages to add can be found!\n" - return 1 - fi -} - -sshfs_mount() { - mkdir -p "${HOME}/mounts/$1" - sshfs -C -F "${HOME}/.ssh/config" "$1": "${HOME}/mounts/$1" -} - -sshfs_umount() { - fusermount3 -u "${HOME}/mounts/$1" -} - -nvc() { - local config - if [[ -z "$1" ]]; then - 1>&2 printf "A repository name needs to be specified as the first argument.\n" - return 1 - fi - config="${HOME}/.config/nvchecker/$1.toml" - if [[ ! -f "${config}" ]]; then - 1>&2 printf "The configuration does not exist: %s\n" "${config}" - return 1 - fi - if ! command -v nvchecker > /dev/null; then - 1>&2 printf "The required application 'nvchecker' can not be found.\n" - return 1 - fi - nvchecker -c "${config}" -} - -nvt() { - local config package - if [[ -z "$1" ]]; then - 1>&2 printf "A repository name needs to be specified as the first argument.\n" - return 1 - fi - config="${HOME}/.config/nvchecker/$1.toml" - if [[ ! -f "${config}" ]]; then - 1>&2 printf "The configuration does not exist: %s\n" "${config}" - return 1 - fi - - if [[ -z "$2" ]]; then - 1>&2 printf "A package name needs to be specified as the second argument.\n" - return 1 - fi - package="${2}" - if ! grep "${package}" "${config}" > /dev/null; then - 1>&2 printf "The package %s can not be found in the configuration: %s\n" "${package}" "${config}" - return 1 - fi - - if ! command -v nvtake > /dev/null; then - 1>&2 printf "The required application 'nvtake' can not be found.\n" - return 1 - fi - nvtake -c "${config}" "${package}" -} diff --git a/.zshrc b/.zshrc index d2ea153..082c2d3 100644 --- a/.zshrc +++ b/.zshrc @@ -1,7 +1,4 @@ -# zsh.functions -for config_file ($HOME/.zsh.functions/*.zsh) source $config_file - # dircolors # Set colors for ls output eval $(dircolors ~/.dircolors) @@ -173,9 +170,6 @@ for keymap in 'emacs' 'viins'; do # Complete in the middle of word. bindkey -M "$keymap" "$key_info[Control]I" expand-or-complete - - # Insert 'sudo ' at the beginning of the line. - bindkey -M "$keymap" "$key_info[Control]X$key_info[Control]S" prepend-sudo done # Set the key layout to vi mode @@ -436,9 +430,10 @@ for p in ${history_substring}; do fi done -# zsh.after -# -for config_file ($HOME/.zsh.after/*.zsh) source $config_file +# functions +for config_file ($HOME/.config/zsh/functions/*.zsh) source $config_file +# includes +for config_file ($HOME/.config/zsh/includes/*.zsh) source $config_file # use starship for prompt if it exists (( ${+commands[starship]} )) && eval "$(starship init zsh)" -- cgit v1.2.3-70-g09d2