diff --git a/CHANGELOG b/CHANGELOG index 5947e3e..2082b36 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,3 @@ -eeleater, 22.02.2017, Cleaned up a bit - eeleater, 06.10.2015, Stuff (look at commits) eeleater, 22.09.2015, removed Ansible Completion (again...) diff --git a/README.md b/README.md index c63b0a3..8d4cd85 100644 --- a/README.md +++ b/README.md @@ -5,5 +5,3 @@ This Repo contains my dotfiles Install with the ```./install``` script. - -Also need to install xmlstarlet, use ```yaourt -S xmlstarlet``` diff --git a/bin/is b/bin/is deleted file mode 100755 index 965d7c9..0000000 --- a/bin/is +++ /dev/null @@ -1,127 +0,0 @@ -#!/bin/bash -# -# Copyright (c) 2016 Józef Sokołowski -# Distributed under the MIT License -# -# For most current version checkout repository: -# https://github.com/qzb/is.sh -# - -is() { - if [ "$1" == "--help" ]; then - cat << EOF -Conditions: - is equal VALUE_A VALUE_B - is matching REGEXP VALUE - is substring VALUE_A VALUE_B - is empty VALUE - is number VALUE - is gt NUMBER_A NUMBER_B - is lt NUMBER_A NUMBER_B - is ge NUMBER_A NUMBER_B - is le NUMBER_A NUMBER_B - is file PATH - is dir PATH - is link PATH - is existing PATH - is readable PATH - is writeable PATH - is executable PATH - is available COMMAND - is older PATH_A PATH_B - is newer PATH_A PATH_B - is true VALUE - is false VALUE - -Negation: - is not equal VALUE_A VALUE_B -EOF - exit - fi - - if [ "$1" == "--version" ]; then - echo "is.sh 1.1.0" - exit - fi - - local condition="$1" - local value_a="$2" - local value_b="$3" - - if [ "$condition" == "not" ]; then - shift 1 - ! is "${@}" - return $? - fi - - if [ "$condition" == "a" ] || [ "$condition" == "an" ] || [ "$condition" == "the" ]; then - shift 1 - is "${@}" - return $? - fi - - case "$condition" in - file) - [ -f "$value_a" ]; return $?;; - dir|directory) - [ -d "$value_a" ]; return $?;; - link|symlink) - [ -L "$value_a" ]; return $?;; - existent|existing|exist|exists) - [ -e "$value_a" ]; return $?;; - readable) - [ -r "$value_a" ]; return $?;; - writeable) - [ -w "$value_a" ]; return $?;; - executable) - [ -x "$value_a" ]; return $?;; - available|installed) - which "$value_a"; return $?;; - empty) - [ -z "$value_a" ]; return $?;; - number) - echo "$value_a" | grep -E '^[0-9]+(\.[0-9]+)?$'; return $?;; - older) - [ "$value_a" -ot "$value_b" ]; return $?;; - newer) - [ "$value_a" -nt "$value_b" ]; return $?;; - gt) - is not a number "$value_a" && return 1; - is not a number "$value_b" && return 1; - awk "BEGIN {exit $value_a > $value_b ? 0 : 1}"; return $?;; - lt) - is not a number "$value_a" && return 1; - is not a number "$value_b" && return 1; - awk "BEGIN {exit $value_a < $value_b ? 0 : 1}"; return $?;; - ge) - is not a number "$value_a" && return 1; - is not a number "$value_b" && return 1; - awk "BEGIN {exit $value_a >= $value_b ? 0 : 1}"; return $?;; - le) - is not a number "$value_a" && return 1; - is not a number "$value_b" && return 1; - awk "BEGIN {exit $value_a <= $value_b ? 0 : 1}"; return $?;; - eq|equal) - [ "$value_a" = "$value_b" ] && return 0; - is not a number "$value_a" && return 1; - is not a number "$value_b" && return 1; - awk "BEGIN {exit $value_a == $value_b ? 0 : 1}"; return $?;; - match|matching) - echo "$value_b" | grep -xE "$value_a"; return $?;; - substr|substring) - echo "$value_b" | grep -F "$value_a"; return $?;; - true) - [ "$value_a" == true ] || [ "$value_a" == 0 ]; return $?;; - false) - [ "$value_a" != true ] && [ "$value_a" != 0 ]; return $?;; - esac > /dev/null - - return 1 -} - -if is not equal "${BASH_SOURCE[0]}" "$0"; then - export -f is -else - is "${@}" - exit $? -fi diff --git a/bin/nma b/bin/nma deleted file mode 100755 index 8b6bf7b..0000000 --- a/bin/nma +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -out=$(mktemp /tmp/nma.XXXXXXXX) - -curl --silent --data-ascii "apikey=1e9cfe3bddab21f271b742eb04f9918a76ad0ef0333be7d3" \ - --data-ascii "application=Server" --data-ascii "event=megumi.eeleater.org" \ - --data-asci "description=$1" --data-asci "priority=0" \ - "https://www.notifymyandroid.com/publicapi/notify" -o "$out" - -if test $(xml sel -t -m "nma/success" -v "@code" "$out") == "200"; then - echo "Sent" - exit 0 -else - echo "Not sent: $(xml sel -t -m "nma/error" -v "." "$out")" - exit 1 -fi diff --git a/dotbot b/dotbot index fe9ca6f..847cb10 160000 --- a/dotbot +++ b/dotbot @@ -1 +1 @@ -Subproject commit fe9ca6f5ede35d16f28e0c5db781fb39437fd171 +Subproject commit 847cb101d486319da882f958b1cb58b515cc6db2 diff --git a/install_zulu.zsh b/install_zulu.zsh deleted file mode 100644 index b60166e..0000000 --- a/install_zulu.zsh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/zsh -pathfile="${ZUC}/path" -fpathfile="${ZUC}/fpath" -cdpathfile="${ZUC}/cdpath" -manpathfile="${ZUC}/manpath" -aliasfile="${ZUC}/alias" - -echo "${ZUL}/bin" > $pathfile -echo "${ZUL}/share" > $fpathfile -echo "" > $cdpathfile -echo "" > $manpathfile -echo "" > $aliasfile - -for p in "${path[@]}"; do echo "$p" >> $pathfile; done -for p in "${fpath[@]}"; do echo "$p" >> $fpathfile; done -for p in "${cdpath[@]}"; do echo "$p" >> $cdpathfile; done -for p in "${manpath[@]}"; do echo "$p" >> $manpathfile; done - -# Fix for alias -unalias -- - &>/dev/null - -IFS=$'\n'; for a in `alias`; do echo "alias $a\n" >> $aliasfile; done - -cd ${ZUL}/core/ -./build.zsh - -if test ! -e ${ZUL}/share/_zulu; then ln -s ${ZUL}/core/zulu.zsh-completion ${ZUL}/share/_zulu; fi diff --git a/lib/nano/syntax b/lib/nano/syntax index 43dd59a..ee137a1 160000 --- a/lib/nano/syntax +++ b/lib/nano/syntax @@ -1 +1 @@ -Subproject commit 43dd59ad3677b9e1ddd0e2b81000312fa5d7356b +Subproject commit ee137a16bfc8e4e928215968616a104027f0253a diff --git a/lib/zulu/core b/lib/zulu/core deleted file mode 160000 index 4c5db4e..0000000 --- a/lib/zulu/core +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 4c5db4e6be08ef8b3466298b9e40e52d940adfed diff --git a/lib/zulu/index b/lib/zulu/index deleted file mode 160000 index aad6ee4..0000000 --- a/lib/zulu/index +++ /dev/null @@ -1 +0,0 @@ -Subproject commit aad6ee4f1c4a50964556664de6dd359dd425905c diff --git a/zsh/files.d/aliases.zsh b/zsh/files.d/aliases.zsh deleted file mode 100644 index 9870538..0000000 --- a/zsh/files.d/aliases.zsh +++ /dev/null @@ -1,36 +0,0 @@ -# Changing/making/removing directory -setopt auto_pushd -setopt pushd_ignore_dups -setopt pushdminus - -# Command Line Foo -alias clf='clf --color' - -# The Fuck -TF_ALIAS=fuck alias fuck='eval $(thefuck $(fc -ln -1 | tail -n 1)); fc -R' - -# PClear -pclear () { - clear - printf '\033[3J' -} - -# Termbin -alias tb='nc termbin.com 9999' - -# Make Dir and enter it -mkcd() { - mkdir $1 &>/dev/null - [ -e $1 ] && cd $1 -} - -# Listing -alias la='ls -lah' -alias ls='ls -lah' - -# Interactive -alias rm='rm -i' -alias cp='cp -i' -alias mv='mv -i' - -alias psgrep='ps aux | grep -v grep | grep' diff --git a/zsh/files.d/os/arch-aliases.zsh b/zsh/files.d/os/arch-aliases.zsh deleted file mode 100644 index 5eda274..0000000 --- a/zsh/files.d/os/arch-aliases.zsh +++ /dev/null @@ -1,54 +0,0 @@ -if (( $+commands[yaourt] )); then - alias yaupg='yaourt -Syua' - alias yain='yaourt -S' - alias yains='yaourt -U' - alias yare='yaourt -R' - alias yarem='yaourt -Rns' -fi - -alias pacupg='sudo pacman -Syu' -alias pacin='sudo pacman -S' -alias pacins='sudo pacman -U' -alias pacre='sudo pacman -R' -alias pacrem='sudo pacman -Rns' - -paclist() { - # Source: https://bbs.archlinux.org/viewtopic.php?id=93683 - LC_ALL=C pacman -Qei $(pacman -Qu | cut -d " " -f 1) | \ - awk 'BEGIN {FS=":"} /^Name/{printf("\033[1;36m%s\033[1;37m", $2)} /^Description/{print $2}' -} - -pacdisowned() { - emulate -L zsh - - tmp=${TMPDIR-/tmp}/pacman-disowned-$UID-$$ - db=$tmp/db - fs=$tmp/fs - - mkdir "$tmp" - trap 'rm -rf "$tmp"' EXIT - - pacman -Qlq | sort -u > "$db" - - find /bin /etc /lib /sbin /usr ! -name lost+found \ - \( -type d -printf '%p/\n' -o -print \) | sort > "$fs" - - comm -23 "$fs" "$db" -} - -pacmanallkeys() { - emulate -L zsh - curl -s https://www.archlinux.org/people/{developers,trustedusers}/ | \ - awk -F\" '(/pgp.mit.edu/) { sub(/.*search=0x/,""); print $1}' | \ - xargs sudo pacman-key --recv-keys -} - -pacmansignkeys() { - emulate -L zsh - for key in $*; do - sudo pacman-key --recv-keys $key - sudo pacman-key --lsign-key $key - printf 'trust\n3\n' | sudo gpg --homedir /etc/pacman.d/gnupg \ - --no-permission-warning --command-fd 0 --edit-key $key - done -} diff --git a/zsh/files.d/os/deb-aliases.zsh b/zsh/files.d/os/deb-aliases.zsh deleted file mode 100644 index 0f99d0c..0000000 --- a/zsh/files.d/os/deb-aliases.zsh +++ /dev/null @@ -1,219 +0,0 @@ -# Use aptitude if installed, or apt-get if not. -# You can just set apt_pref='apt-get' to override it. -if [[ -e $( which -p aptitude 2>&1 ) ]]; then - apt_pref='aptitude' - apt_upgr='safe-upgrade' -else - apt_pref='apt-get' - apt_upgr='upgrade' -fi - -# Use sudo by default if it's installed -if [[ -e $( which -p sudo 2>&1 ) ]]; then - use_sudo=1 -fi - -# Aliases ################################################################### -# These are for more obscure uses of apt-get and aptitude that aren't covered -# below. -alias age='apt-get' -alias api='aptitude' - -# Some self-explanatory aliases -alias acs="apt-cache search" -alias aps='aptitude search' -alias as="aptitude -F \"* %p -> %d \n(%v/%V)\" \ - --no-gui --disable-columns search" # search package - -# apt-file -alias afs='apt-file search --regexp' - - -# These are apt-get only -alias asrc='apt-get source' -alias app='apt-cache policy' - -# superuser operations ###################################################### -if [[ $use_sudo -eq 1 ]]; then -# commands using sudo ####### - alias aac='sudo $apt_pref autoclean' - alias abd='sudo $apt_pref build-dep' - alias ac='sudo $apt_pref clean' - alias ad='sudo $apt_pref update' - alias adg='sudo $apt_pref update && sudo $apt_pref $apt_upgr' - alias adu='sudo $apt_pref update && sudo $apt_pref dist-upgrade' - alias afu='sudo apt-file update' - alias ag='sudo $apt_pref $apt_upgr' - alias ai='sudo $apt_pref install' - # Install all packages given on the command line while using only the first word of each line: - # acs ... | ail - alias ail="sed -e 's/ */ /g' -e 's/ *//' | cut -s -d ' ' -f 1 | "' xargs sudo $apt_pref install' - alias ap='sudo $apt_pref purge' - alias ar='sudo $apt_pref remove' - - # apt-get only - alias ads='sudo apt-get dselect-upgrade' - - # Install all .deb files in the current directory. - # Warning: you will need to put the glob in single quotes if you use: - # glob_subst - alias dia='sudo dpkg -i ./*.deb' - alias di='sudo dpkg -i' - - # Remove ALL kernel images and headers EXCEPT the one in use - alias kclean='sudo aptitude remove -P ?and(~i~nlinux-(ima|hea) \ - ?not(~n`uname -r`))' - - -# commands using su ######### -else - alias aac='su -ls \'$apt_pref autoclean\' root' - abd() { - cmd="su -lc '$apt_pref build-dep $@' root" - print "$cmd" - eval "$cmd" - } - alias ac='su -ls \'$apt_pref clean\' root' - alias ad='su -lc \'$apt_pref update\' root' - alias adg='su -lc \'$apt_pref update && aptitude $apt_upgr\' root' - alias adu='su -lc \'$apt_pref update && aptitude dist-upgrade\' root' - alias afu='su -lc "apt-file update"' - alias ag='su -lc \'$apt_pref $apt_upgr\' root' - ai() { - cmd="su -lc 'aptitude -P install $@' root" - print "$cmd" - eval "$cmd" - } - ap() { - cmd="su -lc '$apt_pref -P purge $@' root" - print "$cmd" - eval "$cmd" - } - ar() { - cmd="su -lc '$apt_pref -P remove $@' root" - print "$cmd" - eval "$cmd" - } - # Install all .deb files in the current directory - # Assumes glob_subst is off - alias dia='su -lc "dpkg -i ./*.deb" root' - alias di='su -lc "dpkg -i" root' - # Remove ALL kernel images and headers EXCEPT the one in use - alias kclean='su -lc '\''aptitude remove -P ?and(~i~nlinux-(ima|hea) \ - ?not(~n`uname -r`))'\'' root' -fi - -# Completion ################################################################ - -# -# Registers a compdef for $1 that calls $apt_pref with the commands $2 -# To do that it creates a new completion function called _apt_pref_$2 -# -apt_pref_compdef() { - local f fb - f="_apt_pref_${2}" - - eval "function ${f}() { - shift words; - service=\"\$apt_pref\"; - words=(\"\$apt_pref\" '$2' \$words); - ((CURRENT++)) - test \"\${apt_pref}\" = 'aptitude' && _aptitude || _apt - }" - - compdef "$f" "$1" -} - -apt_pref_compdef aac "autoclean" -apt_pref_compdef abd "build-dep" -apt_pref_compdef ac "clean" -apt_pref_compdef ad "update" -apt_pref_compdef afu "update" -apt_pref_compdef ag "$apt_upgr" -apt_pref_compdef ai "install" -apt_pref_compdef ail "install" -apt_pref_compdef ap "purge" -apt_pref_compdef ar "remove" -apt_pref_compdef ads "dselect-upgrade" - -# Misc. ##################################################################### -# print all installed packages -alias allpkgs='aptitude search -F "%p" --disable-columns ~i' - -# Create a basic .deb package -alias mydeb='time dpkg-buildpackage -rfakeroot -us -uc' - - -# Functions ################################################################# -# create a simple script that can be used to 'duplicate' a system -apt-copy() { - print '#!/bin/sh'"\n" > apt-copy.sh - - cmd='$apt_pref install' - - for p in ${(f)"$(aptitude search -F "%p" --disable-columns \~i)"}; { - cmd="${cmd} ${p}" - } - - print $cmd "\n" >> apt-copy.sh - - chmod +x apt-copy.sh -} - -# Prints apt history -# Usage: -# apt-history install -# apt-history upgrade -# apt-history remove -# apt-history rollback -# apt-history list -# Based On: http://linuxcommando.blogspot.com/2008/08/how-to-show-apt-log-history.html -apt-history () { - case "$1" in - install) - zgrep --no-filename 'install ' $(ls -rt /var/log/dpkg*) - ;; - upgrade|remove) - zgrep --no-filename $1 $(ls -rt /var/log/dpkg*) - ;; - rollback) - zgrep --no-filename upgrade $(ls -rt /var/log/dpkg*) | \ - grep "$2" -A10000000 | \ - grep "$3" -B10000000 | \ - awk '{print $4"="$5}' - ;; - list) - zgrep --no-filename '' $(ls -rt /var/log/dpkg*) - ;; - *) - echo "Parameters:" - echo " install - Lists all packages that have been installed." - echo " upgrade - Lists all packages that have been upgraded." - echo " remove - Lists all packages that have been removed." - echo " rollback - Lists rollback information." - echo " list - Lists all contains of dpkg logs." - ;; - esac -} - -# Kernel-package building shortcut -kerndeb () { - # temporarily unset MAKEFLAGS ( '-j3' will fail ) - MAKEFLAGS=$( print - $MAKEFLAGS | perl -pe 's/-j\s*[\d]+//g' ) - print '$MAKEFLAGS set to '"'$MAKEFLAGS'" - appendage='-custom' # this shows up in $ (uname -r ) - revision=$(date +"%Y%m%d") # this shows up in the .deb file name - - make-kpkg clean - - time fakeroot make-kpkg --append-to-version "$appendage" --revision \ - "$revision" kernel_image kernel_headers -} - -# List packages by size -function apt-list-packages { - dpkg-query -W --showformat='${Installed-Size} ${Package} ${Status}\n' | \ - grep -v deinstall | \ - sort -n | \ - awk '{print $1" "$2}' -} diff --git a/zsh/files.d/systemd.zsh b/zsh/files.d/systemd.zsh deleted file mode 100644 index 299ac6b..0000000 --- a/zsh/files.d/systemd.zsh +++ /dev/null @@ -1,12 +0,0 @@ -user_commands=( - list-units is-active status show help list-unit-files - is-enabled list-jobs show-environment cat list-timers) - -sudo_commands=( - start stop reload restart try-restart isolate kill - reset-failed enable disable reenable preset mask unmask - link load cancel set-environment unset-environment - edit daemon-reload) - -for c in $user_commands; do; alias sc-$c="systemctl $c"; done -for c in $sudo_commands; do; alias sc-$c="sudo systemctl $c"; done diff --git a/zsh/single-files/command-history.zsh b/zsh/single-files/command-history.zsh deleted file mode 100644 index c61c420..0000000 --- a/zsh/single-files/command-history.zsh +++ /dev/null @@ -1,759 +0,0 @@ -#!/usr/bin/env zsh -############################################################################## -# -# Copyright (c) 2009 Peter Stephenson -# Copyright (c) 2011 Guido van Steen -# Copyright (c) 2011 Suraj N. Kurapati -# Copyright (c) 2011 Sorin Ionescu -# Copyright (c) 2011 Vincent Guerci -# Copyright (c) 2016 Geza Lore -# Copyright (c) 2017 Bengt Brodersen -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials provided -# with the distribution. -# -# * Neither the name of the FIZSH nor the names of its contributors -# may be used to endorse or promote products derived from this -# software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################## - -#----------------------------------------------------------------------------- -# declare global configuration variables -#----------------------------------------------------------------------------- - -typeset -g HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND='bg=magenta,fg=white,bold' -typeset -g HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND='bg=red,fg=white,bold' -typeset -g HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS='i' -typeset -g HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE='' -typeset -g HISTORY_SUBSTRING_SEARCH_FUZZY='' - -#----------------------------------------------------------------------------- -# declare internal global variables -#----------------------------------------------------------------------------- - -typeset -g BUFFER MATCH MBEGIN MEND CURSOR -typeset -g _history_substring_search_refresh_display -typeset -g _history_substring_search_query_highlight -typeset -g _history_substring_search_result -typeset -g _history_substring_search_query -typeset -g -a _history_substring_search_query_parts -typeset -g -a _history_substring_search_raw_matches -typeset -g -i _history_substring_search_raw_match_index -typeset -g -a _history_substring_search_matches -typeset -g -i _history_substring_search_match_index -typeset -g -A _history_substring_search_unique_filter - -#----------------------------------------------------------------------------- -# the main ZLE widgets -#----------------------------------------------------------------------------- - -history-substring-search-up() { - _history-substring-search-begin - - _history-substring-search-up-history || - _history-substring-search-up-buffer || - _history-substring-search-up-search - - _history-substring-search-end -} - -history-substring-search-down() { - _history-substring-search-begin - - _history-substring-search-down-history || - _history-substring-search-down-buffer || - _history-substring-search-down-search - - _history-substring-search-end -} - -zle -N history-substring-search-up -zle -N history-substring-search-down - -#----------------------------------------------------------------------------- -# implementation details -#----------------------------------------------------------------------------- - -zmodload -F zsh/parameter - -# -# We have to "override" some keys and widgets if the -# zsh-syntax-highlighting plugin has not been loaded: -# -# https://github.com/nicoulaj/zsh-syntax-highlighting -# -if [[ $+functions[_zsh_highlight] -eq 0 ]]; then - # - # Dummy implementation of _zsh_highlight() that - # simply removes any existing highlights when the - # user inserts printable characters into $BUFFER. - # - _zsh_highlight() { - if [[ $KEYS == [[:print:]] ]]; then - region_highlight=() - fi - } - - # - # The following snippet was taken from the zsh-syntax-highlighting project: - # - # https://github.com/zsh-users/zsh-syntax-highlighting/blob/56b134f5d62ae3d4e66c7f52bd0cc2595f9b305b/zsh-syntax-highlighting.zsh#L126-161 - # - # Copyright (c) 2010-2011 zsh-syntax-highlighting contributors - # All rights reserved. - # - # Redistribution and use in source and binary forms, with or without - # modification, are permitted provided that the following conditions are - # met: - # - # * Redistributions of source code must retain the above copyright - # notice, this list of conditions and the following disclaimer. - # - # * Redistributions in binary form must reproduce the above copyright - # notice, this list of conditions and the following disclaimer in the - # documentation and/or other materials provided with the distribution. - # - # * Neither the name of the zsh-syntax-highlighting contributors nor the - # names of its contributors may be used to endorse or promote products - # derived from this software without specific prior written permission. - # - # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - # IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - # - #--------------8<-------------------8<-------------------8<----------------- - # Rebind all ZLE widgets to make them invoke _zsh_highlights. - _zsh_highlight_bind_widgets() - { - # Load ZSH module zsh/zleparameter, needed to override user defined widgets. - zmodload zsh/zleparameter 2>/dev/null || { - echo 'zsh-syntax-highlighting: failed loading zsh/zleparameter.' >&2 - return 1 - } - - # Override ZLE widgets to make them invoke _zsh_highlight. - local cur_widget - for cur_widget in ${${(f)"$(builtin zle -la)"}:#(.*|_*|orig-*|run-help|which-command|beep|yank*)}; do - case $widgets[$cur_widget] in - - # Already rebound event: do nothing. - user:$cur_widget|user:_zsh_highlight_widget_*);; - - # User defined widget: override and rebind old one with prefix "orig-". - user:*) eval "zle -N orig-$cur_widget ${widgets[$cur_widget]#*:}; \ - _zsh_highlight_widget_$cur_widget() { builtin zle orig-$cur_widget -- \"\$@\" && _zsh_highlight }; \ - zle -N $cur_widget _zsh_highlight_widget_$cur_widget";; - - # Completion widget: override and rebind old one with prefix "orig-". - completion:*) eval "zle -C orig-$cur_widget ${${widgets[$cur_widget]#*:}/:/ }; \ - _zsh_highlight_widget_$cur_widget() { builtin zle orig-$cur_widget -- \"\$@\" && _zsh_highlight }; \ - zle -N $cur_widget _zsh_highlight_widget_$cur_widget";; - - # Builtin widget: override and make it call the builtin ".widget". - builtin) eval "_zsh_highlight_widget_$cur_widget() { builtin zle .$cur_widget -- \"\$@\" && _zsh_highlight }; \ - zle -N $cur_widget _zsh_highlight_widget_$cur_widget";; - - # Default: unhandled case. - *) echo "zsh-syntax-highlighting: unhandled ZLE widget '$cur_widget'" >&2 ;; - esac - done - } - #-------------->8------------------->8------------------->8----------------- - - _zsh_highlight_bind_widgets -fi - -_history-substring-search-begin() { - setopt localoptions extendedglob - - _history_substring_search_refresh_display= - _history_substring_search_query_highlight= - - # - # If the buffer is the same as the previously displayed history substring - # search result, then just keep stepping through the match list. Otherwise - # start a new search. - # - if [[ -n $BUFFER && $BUFFER == ${_history_substring_search_result:-} ]]; then - return; - fi - - # - # Clear the previous result. - # - _history_substring_search_result='' - - if [[ -z $BUFFER ]]; then - # - # If the buffer is empty, we will just act like up-history/down-history - # in ZSH, so we do not need to actually search the history. This should - # speed things up a little. - # - _history_substring_search_query= - _history_substring_search_query_parts=() - _history_substring_search_raw_matches=() - - else - # - # For the purpose of highlighting we keep a copy of the original - # query string. - # - _history_substring_search_query=$BUFFER - - # - # compose search pattern - # - if [[ -n $HISTORY_SUBSTRING_SEARCH_FUZZY ]]; then - # - # `=` split string in arguments - # - _history_substring_search_query_parts=(${=_history_substring_search_query}) - else - _history_substring_search_query_parts=(${_history_substring_search_query}) - fi - - # - # Escape and join query parts with wildcard character '*' as seperator - # `(j:CHAR:)` join array to string with CHAR as seperator - # - local search_pattern="*${(j:*:)_history_substring_search_query_parts[@]//(#m)[\][()|\\*?#<>~^]/\\$MATCH}*" - - # - # Find all occurrences of the search pattern in the history file. - # - # (k) returns the "keys" (history index numbers) instead of the values - # (R) returns values in reverse older, so the index of the youngest - # matching history entry is at the head of the list. - # - _history_substring_search_raw_matches=(${(k)history[(R)(#$HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS)${search_pattern}]}) - fi - - # - # In order to stay as responsive as possible, we will process the raw - # matches lazily (when the user requests the next match) to choose items - # that need to be displayed to the user. - # _history_substring_search_raw_match_index holds the index of the last - # unprocessed entry in _history_substring_search_raw_matches. Any items - # that need to be displayed will be added to - # _history_substring_search_matches. - # - # We use an associative array (_history_substring_search_unique_filter) as - # a 'set' data structure to ensure uniqueness of the results if desired. - # If an entry (key) is in the set (non-empty value), then we have already - # added that entry to _history_substring_search_matches. - # - _history_substring_search_raw_match_index=0 - _history_substring_search_matches=() - _history_substring_search_unique_filter=() - - # - # If $_history_substring_search_match_index is equal to - # $#_history_substring_search_matches + 1, this indicates that we - # are beyond the end of $_history_substring_search_matches and that we - # have also processed all entries in - # _history_substring_search_raw_matches. - # - # If $#_history_substring_search_match_index is equal to 0, this indicates - # that we are beyond the beginning of $_history_substring_search_matches. - # - # If we have initially pressed "up" we have to initialize - # $_history_substring_search_match_index to 0 so that it will be - # incremented to 1. - # - # If we have initially pressed "down" we have to initialize - # $_history_substring_search_match_index to 1 so that it will be - # decremented to 0. - # - if [[ $WIDGET == history-substring-search-down ]]; then - _history_substring_search_match_index=1 - else - _history_substring_search_match_index=0 - fi -} - -_history-substring-search-end() { - setopt localoptions extendedglob - - _history_substring_search_result=$BUFFER - - # the search was successful so display the result properly by clearing away - # existing highlights and moving the cursor to the end of the result buffer - if [[ $_history_substring_search_refresh_display -eq 1 ]]; then - region_highlight=() - CURSOR=${#BUFFER} - fi - - # highlight command line using zsh-syntax-highlighting - _zsh_highlight - - # highlight the search query inside the command line - if [[ -n $_history_substring_search_query_highlight ]]; then - # highlight first matching query parts - local highlight_start_index=0 - local highlight_end_index=0 - for query_part in $_history_substring_search_query_parts; do - local escaped_query_part=${query_part//(#m)[\][()|\\*?#<>~^]/\\$MATCH} - # (i) get index of pattern - local query_part_match_index=${${BUFFER:$highlight_start_index}[(i)(#$HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS)${escaped_query_part}]} - if [[ $query_part_match_index -le ${#BUFFER:$highlight_start_index} ]]; then - highlight_start_index=$(( $highlight_start_index + $query_part_match_index )) - highlight_end_index=$(( $highlight_start_index + ${#query_part} )) - region_highlight+=("$(($highlight_start_index - 1)) $(($highlight_end_index - 1)) $_history_substring_search_query_highlight") - fi - done - fi - - # For debugging purposes: - # zle -R "mn: "$_history_substring_search_match_index" m#: "${#_history_substring_search_matches} - # read -k -t 200 && zle -U $REPLY - - # Exit successfully from the history-substring-search-* widgets. - return 0 -} - -_history-substring-search-up-buffer() { - # - # Check if the UP arrow was pressed to move the cursor within a multi-line - # buffer. This amounts to three tests: - # - # 1. $#buflines -gt 1. - # - # 2. $CURSOR -ne $#BUFFER. - # - # 3. Check if we are on the first line of the current multi-line buffer. - # If so, pressing UP would amount to leaving the multi-line buffer. - # - # We check this by adding an extra "x" to $LBUFFER, which makes - # sure that xlbuflines is always equal to the number of lines - # until $CURSOR (including the line with the cursor on it). - # - local buflines XLBUFFER xlbuflines - buflines=(${(f)BUFFER}) - XLBUFFER=$LBUFFER"x" - xlbuflines=(${(f)XLBUFFER}) - - if [[ $#buflines -gt 1 && $CURSOR -ne $#BUFFER && $#xlbuflines -ne 1 ]]; then - zle up-line-or-history - return 0 - fi - - return 1 -} - -_history-substring-search-down-buffer() { - # - # Check if the DOWN arrow was pressed to move the cursor within a multi-line - # buffer. This amounts to three tests: - # - # 1. $#buflines -gt 1. - # - # 2. $CURSOR -ne $#BUFFER. - # - # 3. Check if we are on the last line of the current multi-line buffer. - # If so, pressing DOWN would amount to leaving the multi-line buffer. - # - # We check this by adding an extra "x" to $RBUFFER, which makes - # sure that xrbuflines is always equal to the number of lines - # from $CURSOR (including the line with the cursor on it). - # - local buflines XRBUFFER xrbuflines - buflines=(${(f)BUFFER}) - XRBUFFER="x"$RBUFFER - xrbuflines=(${(f)XRBUFFER}) - - if [[ $#buflines -gt 1 && $CURSOR -ne $#BUFFER && $#xrbuflines -ne 1 ]]; then - zle down-line-or-history - return 0 - fi - - return 1 -} - -_history-substring-search-up-history() { - # - # Behave like up in ZSH, except clear the $BUFFER - # when beginning of history is reached like in Fish. - # - if [[ -z $_history_substring_search_query ]]; then - - # we have reached the absolute top of history - if [[ $HISTNO -eq 1 ]]; then - BUFFER= - - # going up from somewhere below the top of history - else - zle up-line-or-history - fi - - return 0 - fi - - return 1 -} - -_history-substring-search-down-history() { - # - # Behave like down-history in ZSH, except clear the - # $BUFFER when end of history is reached like in Fish. - # - if [[ -z $_history_substring_search_query ]]; then - - # going down from the absolute top of history - if [[ $HISTNO -eq 1 && -z $BUFFER ]]; then - BUFFER=${history[1]} - _history_substring_search_refresh_display=1 - - # going down from somewhere above the bottom of history - else - zle down-line-or-history - fi - - return 0 - fi - - return 1 -} - -_history_substring_search_process_raw_matches() { - # - # Process more outstanding raw matches and append any matches that need to - # be displayed to the user to _history_substring_search_matches. - # Return whether there were any more results appended. - # - - # - # While we have more raw matches. Process them to see if there are any more - # matches that need to be displayed to the user. - # - while [[ $_history_substring_search_raw_match_index -lt $#_history_substring_search_raw_matches ]]; do - # - # Move on to the next raw entry and get its history index. - # - _history_substring_search_raw_match_index+=1 - local index=${_history_substring_search_raw_matches[$_history_substring_search_raw_match_index]} - - # - # If HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE is set to a non-empty value, - # then ensure that only unique matches are presented to the user. - # When HIST_IGNORE_ALL_DUPS is set, ZSH already ensures a unique history, - # so in this case we do not need to do anything. - # - if [[ ! -o HIST_IGNORE_ALL_DUPS && -n $HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE ]]; then - # - # Get the actual history entry at the new index, and check if we have - # already added it to _history_substring_search_matches. - # - local entry=${history[$index]} - - if [[ -z ${_history_substring_search_unique_filter[$entry]} ]]; then - # - # This is a new unique entry. Add it to the filter and append the - # index to _history_substring_search_matches. - # - _history_substring_search_unique_filter[$entry]=1 - _history_substring_search_matches+=($index) - - # - # Indicate that we did find a match. - # - return 0 - fi - - else - # - # Just append the new history index to the processed matches. - # - _history_substring_search_matches+=($index) - - # - # Indicate that we did find a match. - # - return 0 - fi - - done - - # - # We are beyond the end of the list of raw matches. Indicate that no - # more matches are available. - # - return 1 -} - -_history-substring-search-has-next() { - # - # Predicate function that returns whether any more older matches are - # available. - # - - if [[ $_history_substring_search_match_index -lt $#_history_substring_search_matches ]]; then - # - # We did not reach the end of the processed list, so we do have further - # matches. - # - return 0 - - else - # - # We are at the end of the processed list. Try to process further - # unprocessed matches. _history_substring_search_process_raw_matches - # returns whether any more matches were available, so just return - # that result. - # - _history_substring_search_process_raw_matches - return $? - fi -} - -_history-substring-search-has-prev() { - # - # Predicate function that returns whether any more younger matches are - # available. - # - - if [[ $_history_substring_search_match_index -gt 1 ]]; then - # - # We did not reach the beginning of the processed list, so we do have - # further matches. - # - return 0 - - else - # - # We are at the beginning of the processed list. We do not have any more - # matches. - # - return 1 - fi -} - -_history-substring-search-found() { - # - # A match is available. The index of the match is held in - # $_history_substring_search_match_index - # - # 1. Make $BUFFER equal to the matching history entry. - # - # 2. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND - # to highlight the current buffer. - # - BUFFER=$history[$_history_substring_search_matches[$_history_substring_search_match_index]] - _history_substring_search_query_highlight=$HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND -} - -_history-substring-search-not-found() { - # - # No more matches are available. - # - # 1. Make $BUFFER equal to $_history_substring_search_query so the user can - # revise it and search again. - # - # 2. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND - # to highlight the current buffer. - # - BUFFER=$_history_substring_search_query - _history_substring_search_query_highlight=$HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND -} - -_history-substring-search-up-search() { - _history_substring_search_refresh_display=1 - - # - # Select history entry during history-substring-down-search: - # - # The following variables have been initialized in - # _history-substring-search-up/down-search(): - # - # $_history_substring_search_matches is the current list of matches that - # need to be displayed to the user. - # $_history_substring_search_match_index is the index of the current match - # that is being displayed to the user. - # - # The range of values that $_history_substring_search_match_index can take - # is: [0, $#_history_substring_search_matches + 1]. A value of 0 - # indicates that we are beyond the beginning of - # $_history_substring_search_matches. A value of - # $#_history_substring_search_matches + 1 indicates that we are beyond - # the end of $_history_substring_search_matches and that we have also - # processed all entries in _history_substring_search_raw_matches. - # - # If $_history_substring_search_match_index equals - # $#_history_substring_search_matches and - # $_history_substring_search_raw_match_index is not greater than - # $#_history_substring_search_raw_matches, then we need to further process - # $_history_substring_search_raw_matches to see if there are any more - # entries that need to be displayed to the user. - # - # In _history-substring-search-up-search() the initial value of - # $_history_substring_search_match_index is 0. This value is set in - # _history-substring-search-begin(). _history-substring-search-up-search() - # will initially increment it to 1. - # - - if [[ $_history_substring_search_match_index -gt $#_history_substring_search_matches ]]; then - # - # We are beyond the end of $_history_substring_search_matches. This - # can only happen if we have also exhausted the unprocessed matches in - # _history_substring_search_raw_matches. - # - # 1. Update display to indicate search not found. - # - _history-substring-search-not-found - return - fi - - if _history-substring-search-has-next; then - # - # We do have older matches. - # - # 1. Move index to point to the next match. - # 2. Update display to indicate search found. - # - _history_substring_search_match_index+=1 - _history-substring-search-found - - else - # - # We do not have older matches. - # - # 1. Move the index beyond the end of - # _history_substring_search_matches. - # 2. Update display to indicate search not found. - # - _history_substring_search_match_index+=1 - _history-substring-search-not-found - fi - - # - # When HIST_FIND_NO_DUPS is set, meaning that only unique command lines from - # history should be matched, make sure the new and old results are different. - # - # However, if the HIST_IGNORE_ALL_DUPS shell option, or - # HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE is set, then we already have a - # unique history, so in this case we do not need to do anything. - # - if [[ -o HIST_IGNORE_ALL_DUPS || -n $HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE ]]; then - return - fi - - if [[ -o HIST_FIND_NO_DUPS && $BUFFER == $_history_substring_search_result ]]; then - # - # Repeat the current search so that a different (unique) match is found. - # - _history-substring-search-up-search - fi -} - -_history-substring-search-down-search() { - _history_substring_search_refresh_display=1 - - # - # Select history entry during history-substring-down-search: - # - # The following variables have been initialized in - # _history-substring-search-up/down-search(): - # - # $_history_substring_search_matches is the current list of matches that - # need to be displayed to the user. - # $_history_substring_search_match_index is the index of the current match - # that is being displayed to the user. - # - # The range of values that $_history_substring_search_match_index can take - # is: [0, $#_history_substring_search_matches + 1]. A value of 0 - # indicates that we are beyond the beginning of - # $_history_substring_search_matches. A value of - # $#_history_substring_search_matches + 1 indicates that we are beyond - # the end of $_history_substring_search_matches and that we have also - # processed all entries in _history_substring_search_raw_matches. - # - # In _history-substring-search-down-search() the initial value of - # $_history_substring_search_match_index is 1. This value is set in - # _history-substring-search-begin(). _history-substring-search-down-search() - # will initially decrement it to 0. - # - - if [[ $_history_substring_search_match_index -lt 1 ]]; then - # - # We are beyond the beginning of $_history_substring_search_matches. - # - # 1. Update display to indicate search not found. - # - _history-substring-search-not-found - return - fi - - if _history-substring-search-has-prev; then - # - # We do have younger matches. - # - # 1. Move index to point to the previous match. - # 2. Update display to indicate search found. - # - _history_substring_search_match_index+=-1 - _history-substring-search-found - - else - # - # We do not have younger matches. - # - # 1. Move the index beyond the beginning of - # _history_substring_search_matches. - # 2. Update display to indicate search not found. - # - _history_substring_search_match_index+=-1 - _history-substring-search-not-found - fi - - # - # When HIST_FIND_NO_DUPS is set, meaning that only unique command lines from - # history should be matched, make sure the new and old results are different. - # - # However, if the HIST_IGNORE_ALL_DUPS shell option, or - # HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE is set, then we already have a - # unique history, so in this case we do not need to do anything. - # - if [[ -o HIST_IGNORE_ALL_DUPS || -n $HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE ]]; then - return - fi - - if [[ -o HIST_FIND_NO_DUPS && $BUFFER == $_history_substring_search_result ]]; then - # - # Repeat the current search so that a different (unique) match is found. - # - _history-substring-search-down-search - fi -} - -# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- -# vim: ft=zsh sw=2 ts=2 et - diff --git a/zsh/zshrc b/zsh/zshrc index 350d2ac..92aebda 100644 --- a/zsh/zshrc +++ b/zsh/zshrc @@ -1,35 +1,61 @@ -# Exports & Completionpath -export DOT=${HOME}/dotfiles -export OWN=${DOT}/zsh -export LIB=${DOT}/lib -export ZUL=${LIB}/zulu -export ZULU_DIR=${ZUL} -export ZUC=${ZUL}/config -export ZULU_CONFIG_DIR=${ZUC} -export PATH="${HOME}/dotfiles/bin:/opt/android-sdk/build-tools/26.0.0/:${PATH}" -export EDITOR='nano' -export TERM=xterm-256color +# Oh My ZSH Path +export ZSH=${HOME}/dotfiles/lib/ohmyzsh -# Fix MobaXterm Home/End key with ZSH -bindkey '^[[H' beginning-of-line -bindkey '^[[F' end-of-line +# Oh My ZSH Theme +ZSH_THEME="mortalscumbag" -# Settings & Dircolors -ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets) -eval `dircolors ${OWN}/dircolors` +# Disable Auto Update of Oh My ZSH +DISABLE_AUTO_UPDATE="true" -# Install Zulu if needed -if [[ ! -e ${ZUC}/ZULU_INSTALLED ]]; then - source ${DOT}/install_zulu.zsh - touch ${ZUC}/ZULU_INSTALLED +# Go Path +export GOPATH=${HOME}/go + +# Path +export PATH="${GOPATH}/bin:${HOME}/.gem/ruby/2.2.0/bin:${HOME}/dotfiles/lib/util:${HOME}/dotfiles/lib/dasht/bin:${PATH}" + +# Dasht +export DASHT_DOCSETS_DIR=$HOME/.local/share/Zeal/Zeal/docsets + +# Plugins +plugins=(gem bundler composer git vagrant docker python) +plugins+=(npm systemd systemadmin gitignore tmux extract) +plugins+=(command-not-found colored-man-pages fabric ansible) + +if [ $(uname -n) = "megumi" -o $(uname -n) = "kimari" -o $(uname -n) = "sayaka" ]; then + plugins+=(archlinux) +fi +if [ $(uname -n) = "mx" -o $(uname -n) = "git" ]; then + plugins+=(debian) fi +# Preferred editor for local and remote sessions +export EDITOR='nano' -for file in ${OWN}/files.d/*.zsh; do source $file; done # Aliases -source ${ZUL}/core/zulu # Zulu +# Load Oh My ZSH +source ${ZSH}/oh-my-zsh.sh -# Init Zulu -zulu init +# Fix home/end key at work +bindkey "^[[1~" beginning-of-line +bindkey "^[[4~" end-of-line -source "/usr/share/fzf/completion.zsh" -source "/usr/share/fzf/key-bindings.zsh" +# Source k.sh +source ${HOME}/dotfiles/lib/k/k.sh + +# Shell Syntax Highlighter +source ${HOME}/dotfiles/lib/highlighting/zsh-syntax-highlighting.zsh +ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets) + +# Dircolors +eval `dircolors ${HOME}/dotfiles/zsh/dircolors` + +# Source Aliases +source ${HOME}/dotfiles/zsh/aliases.zsh + +# Source FZF +[ -f ${HOME}/.fzf.zsh ] && source ${HOME}/.fzf.zsh + +# Completions Path +fpath=(${HOME}/dotfiles/lib/completions/src $fpath) + +# Source local zshrc +[ -f ${HOME}/local.zshrc ] && source ${HOME}/local.zshrc