├── .github ├── FUNDING.yml └── workflows │ └── test-build.yml ├── .gitignore ├── README.md ├── debian ├── NEWS ├── changelog ├── conffiles ├── control ├── copyright ├── gbp.conf ├── grml-etc-core.lintian-overrides ├── install ├── manpages ├── postrm ├── preinst ├── rules └── source │ └── format ├── doc ├── Makefile └── grmlzshrc.adoc ├── etc ├── apt │ └── grml │ │ └── listbugs ├── grml │ ├── lsb-functions │ ├── screen_multisession │ ├── screenrc │ ├── screenrc_acpi │ ├── screenrc_generic │ ├── script-functions │ └── sysexits-sh ├── grml_colors ├── grml_nocolors ├── minimal-shellrc ├── network │ └── interfaces.examples ├── skel │ ├── .emacs │ ├── .gitconfig │ ├── .hgrc │ ├── .vim │ │ ├── ftplugin │ │ │ └── c.vim │ │ ├── klammerpaare.vim │ │ ├── plugin │ │ │ └── DirDiff.vim │ │ └── spellfile.add │ └── .zshrc ├── tmux.conf ├── vim │ └── vimrc └── zsh │ ├── keephack │ ├── zlogin │ ├── zprofile │ ├── zshenv │ └── zshrc └── usr_share_grml └── zsh ├── completion ├── debian │ └── _debian_rules ├── grml │ ├── _grml-lang │ ├── _grml-tips │ └── _grml-wallpaper ├── linux │ ├── _fbset │ └── _iwconfig └── unix │ ├── _hl_complete │ └── _lookup └── functions ├── Lookup ├── Backends │ ├── LOOKUP_be_cpan │ ├── LOOKUP_be_deb_bts │ ├── LOOKUP_be_deb_msgid │ ├── LOOKUP_be_deb_patchtrack │ ├── LOOKUP_be_deb_pts │ ├── LOOKUP_be_dsc │ ├── LOOKUP_be_filewatcher │ ├── LOOKUP_be_freshmeat │ ├── LOOKUP_be_gmane │ ├── LOOKUP_be_google │ ├── LOOKUP_be_grml_bts │ ├── LOOKUP_be_koders │ ├── LOOKUP_be_leo │ ├── LOOKUP_be_letssingit │ ├── LOOKUP_be_rfc │ ├── LOOKUP_be_sourceforge │ ├── LOOKUP_be_usenet │ ├── LOOKUP_be_wikipedia │ └── LOOKUP_be_zsh_mla ├── LOOKUP_browser ├── LOOKUP_context ├── LOOKUP_encode ├── LOOKUP_guard ├── LOOKUP_help ├── LOOKUP_hook ├── LOOKUP_parseopts ├── LOOKUP_query_handler └── lookupinit ├── exirename ├── grml └── grml-wallpaper ├── hl ├── ipv6-tunnel ├── linenr ├── lsdisk ├── minimal-shell ├── purge ├── readme ├── urldecode └── weather /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: grml 2 | -------------------------------------------------------------------------------- /.github/workflows/test-build.yml: -------------------------------------------------------------------------------- 1 | name: test-build 2 | on: 3 | pull_request: 4 | push: 5 | 6 | concurrency: 7 | group: "${{ github.ref }}" 8 | cancel-in-progress: true 9 | jobs: 10 | build-debian: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v4 14 | - name: "Update changelog" 15 | run: | 16 | set -ex 17 | OLD_VERSION=$(dpkg-parsechangelog -SVersion) 18 | SOURCE=$(dpkg-parsechangelog -SSource) 19 | cat > debian/changelog < $(date -R) 25 | EOT 26 | - uses: jtdor/build-deb-action@v1 27 | - name: Archive build result 28 | uses: actions/upload-artifact@v4 29 | with: 30 | name: deb 31 | if-no-files-found: error 32 | path: | 33 | debian/artifacts/* 34 | 35 | zsh-refcard: 36 | runs-on: ubuntu-latest 37 | steps: 38 | - uses: actions/checkout@v4 39 | - name: Install texlive 40 | run: | 41 | set -ex 42 | sudo apt update 43 | sudo apt install -y texlive-fonts-recommended texlive-latex-recommended 44 | - name: Build grml-zsh-refcard 45 | run: | 46 | set -ex 47 | git clone --depth 1 https://github.com/grml/grml-gen-zshrefcard 48 | cd grml-gen-zshrefcard 49 | ./genrefcard.pl < ../etc/zsh/zshrc > grml-zsh-refcard.tex 50 | pdflatex grml-zsh-refcard.tex 51 | - name: Archive build result 52 | uses: actions/upload-artifact@v4 53 | with: 54 | name: zsh-refcard 55 | if-no-files-found: error 56 | path: | 57 | grml-gen-zshrefcard/grml-zsh-refcard.tex 58 | grml-gen-zshrefcard/grml-zsh-refcard.pdf 59 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build-stamp 2 | debian/files 3 | debian/*.log 4 | debian/*.substvars 5 | debian/grml-etc-core 6 | doc/*.[1-8] 7 | doc/*.html 8 | *.zwc 9 | *~ 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | grml-etc-core 2 | ============= 3 | 4 | This repository contains the core /etc files for the Grml system. 5 | 6 | Documentation 7 | ------------- 8 | 9 | * [blog post describing the setup](https://grml.org/console/) 10 | * [zshrc manual page](./doc/grmlzshrc.adoc) 11 | 12 | Installation on non-Debian systems 13 | ---------------------------------- 14 | 15 | While generally these files are distributed as a Debian package, named 16 | "grml-etc-core", they are also useful on other systems. 17 | 18 | To use the most important files for your user, use the following commands: 19 | 20 | # IMPORTANT: please note that you might overwrite existing 21 | # configuration files in the current working directory! 22 | wget -O .screenrc https://grml.org/console/screenrc 23 | wget -O .tmux.conf https://grml.org/console/tmux.conf 24 | wget -O .vimrc https://grml.org/console/vimrc 25 | wget -O .zshrc https://grml.org/console/zshrc 26 | # optional: 27 | # wget -O .zshrc.local https://grml.org/console/zshrc.local 28 | 29 | Or, on operating systems without wget: 30 | 31 | # IMPORTANT: please note that you might overwrite existing 32 | # configuration files in the current working directory! 33 | curl -L -o .screenrc https://grml.org/console/screenrc 34 | curl -L -o .tmux.conf https://grml.org/console/tmux.conf 35 | curl -L -o .vimrc https://grml.org/console/vimrc 36 | curl -L -o .zshrc https://grml.org/console/zshrc 37 | # optional: 38 | # wget -O .zshrc.local https://grml.org/console/zshrc.local 39 | -------------------------------------------------------------------------------- /debian/NEWS: -------------------------------------------------------------------------------- 1 | grml-etc-core (0.9.0) grml-testing; urgency=low 2 | 3 | zshrc: use "ctrl-x ." instead ",." to enable power completion / 4 | abbreviation expansion: 5 | 6 | The use of ",." for enabling the power completion / 7 | abbreviation expansion / buffer expansion was a bad idea 8 | because you'll get either a delay or even missing characters, 9 | e.g. when ",." is part of a copy/paste action. So we decided to 10 | switch to a safer approach by using "ctrl-x ." instead. 11 | 12 | -- Michael Prokop Wed, 04 Sep 2013 17:06:45 +0200 13 | 14 | grml-etc-core (0.8.0) unstable; urgency=low 15 | 16 | * zshrc: Prompt converted to zsh's prompt theme system: 17 | 18 | This version of the included zsh setup features a prompt theme based 19 | on the old statically set prompt, that we shipped. The prompt is very 20 | much customisable. Changing colours or removing and adding information 21 | used in the prompt is easily possible via zsh's zstyle mechanism. For 22 | more details call this: 23 | 24 | prompt -h grml 25 | 26 | However, if you used to discard our old prompt and used an own static 27 | prompt, you need to disable the prompt system so your changes stick, 28 | because when a prompt theme is active it takes over control of prompt 29 | variables, which will undo your changes again. So your customisation 30 | now has to look like this: 31 | 32 | prompt off 33 | PS1='%~ %# ' 34 | 35 | Our prompt is also quite extensible: For example, if you use 36 | Virtualenv, and would like integration in our prompt, this is how it 37 | can be done (the default way Virtualenv tries to do this is by 38 | statically extending $PS1, which doesn't work with zsh themes, as 39 | discussed above): 40 | 41 | function virtual_env_prompt () { 42 | REPLY=${VIRTUAL_ENV+(${VIRTUAL_ENV:t}) } 43 | } 44 | grml_theme_add_token \ 45 | virtual-env -f virtual_env_prompt '%F{magenta}' '%f' 46 | zstyle ':prompt:grml:left:setup' items \ 47 | rc virtual-env change-root user at host path vcs percent 48 | 49 | * zshrc: Keyboard setup changed to terminfo data 50 | 51 | This setup had a mixture of hard-coded escape sequences and a broken 52 | terminfo data extraction scheme. 53 | 54 | Starting with this release, escape sequences are extracted from 55 | terminfo exclusively (except for a handful of combinations, that are 56 | commonly not found in terminfo databases). For this to work properly, 57 | the terminal needs to be switched to "keyboard transmit mode" via the 58 | `smkx' escape sequence (if a terminal's terminfo entry does not 59 | support this key, keyboard transmit-mode is active all the time). To 60 | enable this feature when zsh's line editor (zle) is active, this setup 61 | now uses the `zle-line-init' and `zle-line-finish' hooks. The former 62 | invokes the `smkx' sequence and the latter invokes the `rmkx' 63 | sequence. 64 | 65 | If you override these hooks in your setup, make sure you include the 66 | following function calls in your own hooks: 67 | 68 | zle-line-init: zle-smkx 69 | zle-line-finish: zle-rmkx 70 | 71 | Unless your system does not have support for terminfo, the new setup 72 | should work a lot more robust across a much larger number of terminals 73 | and terminal/terminal-multiplexer combinations. 74 | 75 | -- Frank Terbeck Mon, 01 Apr 2013 16:53:31 +0200 76 | 77 | grml-etc-core (0.3.62) unstable; urgency=low 78 | 79 | * Merged /etc/skel/.zshrc into /etc/zsh/zshrc: 80 | 81 | Starting with grml-etc-core 0.3.62 grml's zsh setup lives only in 82 | *one* zshrc file - that is the global one: /etc/zsh/zshrc 83 | /etc/skel/.zshrc still exists but provides commented examples only. 84 | It is best to leave the /etc/skel/.zshrc file untouched and do 85 | personal changes to the setup via ${HOME}/.zshrc.local (as before) 86 | which is loaded at the end of the global zshrc. 87 | 88 | That way, we enable people on other operating systems to use our 89 | setup, too, just by copying our global zshrc to their ${HOME}/.zshrc. 90 | Adjustments would still go to the .zshrc.local file. 91 | Further information is available in the grml-zsh-refcard, available 92 | at http://grml.org/zsh/ 93 | 94 | If you explore *any* problems please let us know: 95 | http://grml.org/bugs/ 96 | 97 | -- Michael Prokop Fri, 13 Feb 2009 12:40:28 +0100 98 | 99 | grml-etc-core (0.3.5) unstable; urgency=low 100 | 101 | * Please note, that the setup of zsh's completion functions has 102 | been changed. The setup has been cleaned up but as a sideeffect 103 | you might notice a problem like: 104 | 105 | "_tags:comptags:67: can only be called from completion function" 106 | 107 | when starting zsh. The reason for this change is because the files 108 | inside /etc/zsh/completion.d/ have been renamed from 'foo' to 109 | '_foo' and their content has been adjusted according to the new 110 | setup too. If you added functions to completion.d yourself, please 111 | consider moving them to /etc/zsh/functions.d/. Files in that 112 | directory, not starting with an underscore are marked for 113 | automatic loading by default (so that is quite convenient). 114 | 115 | So to avoid above error message make sure you don't have any 116 | dpkg-files *not* starting with a '_' in /etc/zsh/completion.d/ 117 | laying around. If there are files *not* starting with an 118 | underscore from an older grml-etc-core in completion.d, you may 119 | safely remove them. 120 | 121 | Information regarding upgrading can be found also at: 122 | 123 | http://wiki.grml.org/doku.php?id=upgrading 124 | 125 | Information regarding (changing) zsh setup can be found at: 126 | 127 | http://grml.org/zsh/#grmlzshrefcard 128 | 129 | -- Michael Prokop Fri, 25 May 2007 01:32:27 +0200 130 | 131 | grml-etc-core (0.1-31) unstable; urgency=low 132 | 133 | * Please note, that the behaviour of global aliases in /etc/skel/.zshrc 134 | has been changed. Now global aliases won't be expanded automatically 135 | anymore. You can still use them (and even some more now as well), 136 | just type the abbreviation/global alias and expand it via pressing 137 | the key sequence ',.'. Usage example: 138 | 139 | % ls G 140 | 141 | expands to: 142 | 143 | % ls |& grep --color=auto 144 | 145 | Thanks for the contribution, Matthias Kopfermann! 146 | 147 | -- Michael Prokop Sun, 12 Nov 2006 12:27:02 +0100 148 | -------------------------------------------------------------------------------- /debian/conffiles: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grml/grml-etc-core/4802508f32e118b54128d72a59be062c48d18d9c/debian/conffiles -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: grml-etc-core 2 | Section: grml 3 | Priority: optional 4 | Maintainer: Michael Prokop 5 | Build-Depends: 6 | asciidoctor, 7 | debhelper-compat (= 12), 8 | Standards-Version: 4.6.2 9 | Rules-Requires-Root: no 10 | Homepage: https://github.com/grml/grml-etc-core 11 | Vcs-Git: https://github.com/grml/grml-etc-core.git 12 | Vcs-Browser: https://github.com/grml/grml-etc-core 13 | Origin: Grml 14 | Bugs: mailto:bugs@grml.org 15 | 16 | Package: grml-etc-core 17 | Architecture: all 18 | Conflicts: 19 | grml-autoconfig (<< 0.5-7), 20 | grml-etc (<< 0.8-11), 21 | grml-scripts (<< 0.8-27), 22 | Replaces: 23 | vim-common, 24 | Depends: 25 | ${misc:Depends}, 26 | vim | nvi | editor, 27 | Recommends: 28 | grml-scripts-core, 29 | Pre-Depends: 30 | ${misc:Pre-Depends}, 31 | zsh, 32 | Description: core etcetera files for the Grml system 33 | This package includes some /etc files for the 34 | Grml system. Whereas the main grml-etc package is 35 | meant for use on Grml systems this package can be 36 | used on plain Debian (stable/testing/unstable) 37 | systems as well. 38 | -------------------------------------------------------------------------------- /debian/copyright: -------------------------------------------------------------------------------- 1 | This package was debianized by Michael Prokop on 2 | Tue, 12 Sep 2006 15:45:23 +0200. 3 | 4 | It was downloaded from http://grml.org/ 5 | 6 | Copyright Holder: Michael Prokop 7 | 8 | Copyright: 9 | 10 | This software is copyright (c) 2004-2009 by Michael Prokop. 11 | 12 | This package is free software; you can redistribute it and/or modify 13 | it under the terms of the GNU General Public License as published by 14 | the Free Software Foundation; version 2 dated June, 1991. 15 | 16 | This package is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this package; if not, write to the Free Software 23 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 24 | 02110-1301, USA. 25 | 26 | On Debian GNU/Linux systems, the complete text of the GNU General 27 | Public License can be found in `/usr/share/common-licenses/GPL-2'. 28 | 29 | 30 | The zsh-lookup sub-system (`/usr/share/grml/zsh/functions/Lookup' and 31 | `/usr/share/grml/zsh/completion/unix/_lookup') is subject to the same 32 | copyright terms as zsh itself: 33 | 34 | Copyright (c) 2009-2010 Frank Terbeck 35 | All rights reserved. 36 | 37 | Permission is hereby granted, without written agreement and without 38 | license or royalty fees, to use, copy, modify, and distribute this 39 | software and to distribute modified versions of this software for any 40 | purpose, provided that the above copyright notice and the following 41 | two paragraphs appear in all copies of this software. 42 | 43 | In no event shall Frank Terbeck or the Zsh Development Group be liable 44 | to any party for direct, indirect, special, incidental, or consequential 45 | damages arising out of the use of this software and its documentation, 46 | even if Frank Terbeck and the Zsh Development Group have been advised of 47 | the possibility of such damage. 48 | 49 | Frank Terbeck and the Zsh Development Group specifically disclaim any 50 | warranties, including, but not limited to, the implied warranties of 51 | merchantability and fitness for a particular purpose. The software 52 | provided hereunder is on an "as is" basis, and Frank Terbeck and the 53 | Zsh Development Group have no obligation to provide maintenance, 54 | support, updates, enhancements, or modifications. 55 | -------------------------------------------------------------------------------- /debian/gbp.conf: -------------------------------------------------------------------------------- 1 | [DEFAULT] 2 | debian-tag = v%(version)s 3 | 4 | # Options only affecting "gbp dch" 5 | [dch] 6 | id-length = 7 7 | meta = True 8 | multimaint-merge = True 9 | -------------------------------------------------------------------------------- /debian/grml-etc-core.lintian-overrides: -------------------------------------------------------------------------------- 1 | grml-etc-core: unknown-section grml 2 | grml-etc-core: diversion-for-unknown-file 3 | grml-etc-core: orphaned-diversion 4 | grml-etc-core: package-contains-file-in-etc-skel 5 | grml-etc-core: bugs-field-does-not-refer-to-debian-infrastructure mailto:bugs@grml.org 6 | -------------------------------------------------------------------------------- /debian/install: -------------------------------------------------------------------------------- 1 | etc 2 | usr_share_grml/* usr/share/grml/ 3 | -------------------------------------------------------------------------------- /debian/manpages: -------------------------------------------------------------------------------- 1 | doc/grmlzshrc.5 2 | -------------------------------------------------------------------------------- /debian/postrm: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Filename: postrm 3 | # Purpose: postrm script for package grml-etc-core 4 | # Authors: grml-team (grml.org), (c) Michael Prokop 5 | # Bug-Reports: see http://grml.org/bugs/ 6 | # License: This file is licensed under the GPL v2. 7 | ################################################################################ 8 | 9 | set -e 10 | 11 | TO_UNDIVERT1="zlogin zprofile zshenv zshrc" 12 | TO_UNDIVERT2=".zshrc" 13 | TO_UNDIVERT3="vimrc" 14 | 15 | undivert_gen() { 16 | if [ -f "$2/$1" -o "$2/$1".original ] ; then 17 | DEXT=${3:-original} 18 | dpkg-divert --remove --rename --package grml-etc-core \ 19 | --divert $2/$1.$DEXT $2/$1 #> /dev/null 20 | fi 21 | } 22 | 23 | case "$1" in 24 | purge) 25 | for cmd in $TO_UNDIVERT1; do 26 | undivert_gen $cmd /etc/zsh 27 | done 28 | for cmd in $TO_UNDIVERT2; do 29 | undivert_gen $cmd /etc/skel 30 | done 31 | for cmd in $TO_UNDIVERT3; do 32 | undivert_gen $cmd /etc/vim 33 | done 34 | ;; 35 | remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) 36 | ;; 37 | *) 38 | echo "postrm called with unknown argument $1" >&2 39 | exit 1 40 | esac 41 | 42 | #DEBHELPER# 43 | 44 | exit 0 45 | 46 | ## END OF FILE ################################################################# 47 | -------------------------------------------------------------------------------- /debian/preinst: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Filename: preinst 3 | # Purpose: preinst script for package grml-etc-core 4 | # Authors: grml-team (grml.org), (c) Michael Prokop 5 | # Bug-Reports: see http://grml.org/bugs/ 6 | # License: This file is licensed under the GPL v2. 7 | ################################################################################ 8 | 9 | set -e 10 | 11 | case "$1" in 12 | install|upgrade|configure) 13 | TMP=$$ 14 | for file in /etc/zsh/zlogin /etc/zsh/zprofile /etc/zsh/zshenv /etc/zsh/zshrc \ 15 | /etc/vim/vimrc /etc/tmux.conf; do 16 | # make sure we don't lose anything 17 | # yes this is ugly :( 18 | [ -e "$file".original ] || cp -f "$file" "${file}.tmp.$TMP" 2>/dev/null || true 19 | [ -e "$file" ] && cp -f "$file" "$file".grml-etc-core && \ 20 | [ -f "$file" ] && rm "$file" && \ 21 | dpkg-divert --quiet --add --rename --package grml-etc-core --divert "$file".original $file && \ 22 | [ -f "$file".grml-etc-core ] && mv -f "$file".grml-etc-core "$file" 23 | [ -e "${file}.tmp.$TMP" ] && mv -f "${file}.tmp.$TMP" "$file.original" 24 | done 25 | 26 | # we stopped shipping /etc/zsh/zlogout with v0.20.0, 27 | # make sure we don't leave it behind on updated systems 28 | if dpkg-divert --list grml-etc-core 2>/dev/null | grep -q '/etc/zsh/zlogout' ; then 29 | mv -f /etc/zsh/zlogout /etc/zsh/zlogout.old && \ 30 | dpkg-divert --remove --rename --package grml-etc-core /etc/zsh/zlogout 31 | fi 32 | ;; 33 | *) 34 | echo "preinst called with unknown argument $1" >&2 35 | exit 1 36 | esac 37 | 38 | #DEBHELPER# 39 | 40 | exit 0 41 | 42 | ## END OF FILE ################################################################# 43 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | # -*- makefile -*- 3 | 4 | %: 5 | dh $@ 6 | 7 | 8 | after_dh_auto_clean: 9 | $(MAKE) -C doc clean 10 | 11 | override_dh_auto_build: 12 | $(MAKE) -C doc all 13 | 14 | -------------------------------------------------------------------------------- /debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (native) 2 | -------------------------------------------------------------------------------- /doc/Makefile: -------------------------------------------------------------------------------- 1 | MANPAGES = grmlzshrc.5 2 | HTMLPAGES = grmlzshrc.html 3 | 4 | all: $(MANPAGES) $(HTMLPAGES) 5 | 6 | .SUFFIXES: 7 | .SUFFIXES: .adoc .5 .html 8 | 9 | .adoc.5: 10 | @printf 'ASCIIDOCTOR %s\n' "$@" 11 | @asciidoctor -b manpage -o$@ $< 12 | 13 | .adoc.html: 14 | @printf 'ASCIIDOCTOR %s\n' "$@" 15 | @asciidoctor -b html5 -o$@ $< 16 | 17 | clean: 18 | rm -f *.5 *.html *.gz *~ 19 | 20 | .PHONY: all clean 21 | -------------------------------------------------------------------------------- /etc/apt/grml/listbugs: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Filename: /etc/apt/listbugs 3 | # Purpose: display bugs of currently running system (used inside grml-live) 4 | # Authors: grml-team (grml.org), (c) Michael Prokop 5 | # Bug-Reports: see http://grml.org/bugs/ 6 | # License: This file is licensed under the GPL v2 or any later version. 7 | ################################################################################ 8 | 9 | [ -n "$SEVERITY" ] || SEVERITY="critical,grave,serious" 10 | 11 | if ! [ -x /usr/sbin/apt-listbugs ] ; then 12 | echo "Error: /usr/sbin/apt-listbugs not available. Exiting." 13 | exit 1 14 | fi 15 | 16 | if ! [ -x /usr/bin/apt-show-source ] ; then 17 | echo "Error: /usr/bin/apt-show-source not available. Exiting." 18 | exit 1 19 | fi 20 | 21 | if ! [ -x /usr/bin/dpkg-query ] ; then 22 | echo "Error: /usr/bin/dpkg-query not available. Exiting." 23 | exit 1 24 | fi 25 | 26 | if apt-show-source 1>/dev/null 2>&1 ; then 27 | apt-listbugs -q -n -s $SEVERITY list \ 28 | $(apt-show-source | grep -v -e 'not installed' -e '--------------' -e \ 29 | 'Version' | awk '{print $4;}' | grep -v '^[() ]*$'| sort | uniq) 30 | else 31 | apt-listbugs -q -n -s $SEVERITY list $(dpkg-query -W --showformat='${Package}\n') 32 | fi 33 | 34 | # $ROOTCMD apt-listbugs -s $SEVERITY list \ 35 | # $(dpkg --get-selections| grep ' install' | awk '{print $1}) 36 | 37 | ## END OF FILE ################################################################# 38 | -------------------------------------------------------------------------------- /etc/grml/lsb-functions: -------------------------------------------------------------------------------- 1 | # lsb init-functions 2 | # 3 | # based on: 4 | # /lib/lsb/init-functions for Debian -*- shell-script -*- 5 | # 6 | # Copyright (c) 2002-03 Chris Lawrence 7 | # All rights reserved. 8 | # 9 | # Redistribution and use in source and binary forms, with or without 10 | # modification, are permitted provided that the following conditions 11 | # are met: 12 | # 1. Redistributions of source code must retain the above copyright 13 | # notice, this list of conditions and the following disclaimer. 14 | # 2. Redistributions in binary form must reproduce the above copyright 15 | # notice, this list of conditions and the following disclaimer in the 16 | # documentation and/or other materials provided with the distribution. 17 | # 3. Neither the name of the author nor the names of other contributors 18 | # may be used to endorse or promote products derived from this software 19 | # without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | # ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | # SUCH DAMAGE. 32 | 33 | # log_*() functions {{{ 34 | TPUT="${TPUT:-"/usr/bin/tput"}" 35 | 36 | _have_tput() { 37 | [ -x "$TPUT" ] && "$TPUT" hpa 60 >/dev/null 2>&1 \ 38 | && return 0 \ 39 | || return 1 40 | } 41 | 42 | log_success_msg() { 43 | printf " * $@\n" 44 | } 45 | 46 | log_failure_msg() { 47 | if _have_tput ; then 48 | RED="$("$TPUT" setaf 1)" 49 | #NORMAL="$("$TPUT" op)" 50 | printf " ${RED}*${NORMAL} $@\n" 51 | else 52 | printf " * $@\n" 53 | fi 54 | } 55 | 56 | log_warning_msg() { 57 | if _have_tput ; then 58 | YELLOW="$("$TPUT" setaf 3)" 59 | #NORMAL="$("$TPUT" op")" 60 | # printf " *${NORMAL} $@\n" 61 | printf " ${BLUE}*${NORMAL} $@\n" 62 | else 63 | printf " * $@\n" 64 | fi 65 | } 66 | 67 | log_warning_msg_nn() { 68 | if _have_tput ; then 69 | YELLOW="$("$TPUT" setaf 3)" 70 | printf " ${BLUE}*${NORMAL} $@" 71 | else 72 | printf " * $@" 73 | fi 74 | } 75 | 76 | # int log_begin_message (char *message) 77 | log_begin_msg() { 78 | if [ "$#" -eq 0 ]; then 79 | return 1 80 | fi 81 | printf " ${GREEN}*${NORMAL} $@\n" 82 | } 83 | 84 | log_begin_msg_nn() { 85 | if [ "$#" -eq 0 ]; then 86 | return 1 87 | fi 88 | printf " ${GREEN}*${NORMAL} $@" 89 | } 90 | 91 | 92 | SUBMSG=" ${GREEN}-${NORMAL} " 93 | 94 | # int log_end_message (int exitstatus) 95 | log_end_msg() { 96 | 97 | # If no arguments were passed, return 98 | [ "$#" -eq 0 ] && return 1 99 | 100 | # Only do the fancy stuff if we have an appropriate terminal 101 | # and if /usr is already mounted 102 | if _have_tput ; then 103 | COLS="$("$TPUT" cols)" 104 | if [ -n "$COLS" ]; then 105 | COL=$(( $COLS - 7 )) 106 | else 107 | COL=73 108 | fi 109 | UP="$("$TPUT" cuu1)" 110 | END="$("$TPUT" hpa "$COL")" 111 | START="$("$TPUT" hpa 0)" 112 | #RED="$("$TPUT" setaf 1)" 113 | #NORMAL="$("$TPUT" op)" 114 | if [ "$1" -eq 0 ]; then 115 | printf "${UP}${END}${BLUE}[ ${GREEN}ok ${BLUE}]${NORMAL}\n" 116 | else 117 | printf "${UP}${START} ${RED}*${NORMAL}${END}[${RED}fail${NORMAL}]\n" 118 | fi 119 | else 120 | if [ "$1" -eq 0 ]; then 121 | printf " ...done.\n" 122 | else 123 | printf " ...fail!\n" 124 | fi 125 | fi 126 | return "$1" 127 | } 128 | # }}} 129 | 130 | # e*() output functions {{{ 131 | # heavily based on gentoo's functions.sh; stripped down and modified 132 | # to match our needs. 133 | # 134 | # defined functions: 135 | # ebegin() 136 | # eend() 137 | # eerror() 138 | # eindent() 139 | # einfo() 140 | # einfon() 141 | # eoutdent() 142 | # esetdent() 143 | # esyslog() 144 | # ewarn() 145 | # ewend() 146 | # 147 | # copyright 1999-2005 gentoo foundation 148 | # distributed under the terms of the gnu general public license v2 149 | # $header: /var/cvsroot/gentoo-src/rc-scripts/sbin/functions.sh,v 1.81.2.6 2005/05/15 20:00:31 vapier exp $ 150 | 151 | # initialisation {{{ 152 | # internal variables 153 | 154 | # Don't output to stdout? 155 | RC_QUIET_STDOUT="no" 156 | 157 | # Default values for e-message indentation and dots 158 | RC_INDENTATION='' 159 | RC_DEFAULT_INDENT=2 160 | #RC_DOT_PATTERN=' .' 161 | RC_DOT_PATTERN='' 162 | # don't output to stdout? 163 | rc_quiet_stdout="no" 164 | 165 | # default values for e-message indentation and dots 166 | rc_indentation='' 167 | rc_default_indent=2 168 | #rc_dot_pattern=' .' 169 | rc_dot_pattern='' 170 | 171 | # should we use color? 172 | if [ -r /proc/cmdline ] ; then 173 | grep -q ' nocolor' /proc/cmdline && RC_NOCOLOR='yes' 174 | fi 175 | [ -n "$NOCOLORS" ] && RC_NOCOLOR='yes' 176 | RC_NOCOLOR="${RC_NOCOLOR:-no}" 177 | if [ "$RC_NOCOLOR" = "no" ] ; then 178 | if [ -r /etc/grml_colors ] ; then 179 | . /etc/grml_colors 180 | fi 181 | fi 182 | 183 | # Can the terminal handle endcols? 184 | if [ "${RC_NOCOLOR}" = "yes" ]; then 185 | RC_ENDCOL="no" 186 | else 187 | RC_ENDCOL="yes" 188 | fi 189 | 190 | # Setup COLS and ENDCOL so eend can line up the [ ok ] 191 | # width of [ ok ] == 7 192 | COLS="$(stty size 2>/dev/null | cut -d' ' -f2)" 193 | if [ -z "${COLS}" ] || [ "${COLS}" -le 0 ] ; then 194 | COLS=80 195 | fi 196 | 197 | if [ "${RC_ENDCOL}" = "yes" ]; then 198 | ENDCOL="[$(( ${COLS} - 8 ))G" 199 | else 200 | ENDCOL='' 201 | fi 202 | 203 | # Setup the colors so our messages all look pretty 204 | if [ "${RC_NOCOLOR}" = "yes" ]; then 205 | unset GOOD WARN BAD NORMAL HILITE BRACKET 206 | else 207 | GOOD='' 208 | WARN='' 209 | BAD='' 210 | NORMAL='' 211 | HILITE='' 212 | BRACKET='' 213 | fi 214 | #}}} 215 | 216 | # void esyslog(char* priority, char* tag, char* message) 217 | # 218 | # use the system logger to log a message 219 | # 220 | esyslog() { 221 | local pri 222 | local tag 223 | 224 | [ "$#" -le 2 ] && return 0 225 | if [ -x /usr/bin/logger ] ; then 226 | pri="$1" 227 | tag="$2" 228 | shift 2 229 | 230 | /usr/bin/logger -p "${pri}" -t "${tag}" -- "$@" 231 | fi 232 | 233 | return 0 234 | } 235 | 236 | # void eindent(int num) 237 | # 238 | # increase the indent used for e-commands. 239 | # 240 | eindent() { 241 | local i="${1:-0}" 242 | [ "$i" -gt 0 ] || i="${RC_DEFAULT_INDENT}" 243 | esetdent $(( ${#RC_INDENTATION} + $i )) 244 | } 245 | 246 | # void eoutdent(int num) 247 | # 248 | # decrease the indent used for e-commands. 249 | # 250 | eoutdent() { 251 | local i="${1:-0}" 252 | [ "$i" -gt 0 ] || i="${RC_DEFAULT_INDENT}" 253 | esetdent $(( ${#RC_INDENTATION} - $i )) 254 | } 255 | 256 | # void esetdent(int num) 257 | # 258 | # hard set the indent used for e-commands. 259 | # num defaults to 0 260 | # 261 | esetdent() { 262 | local i="${1:-0}" 263 | [ "$i" -lt 0 ] && i=0 264 | RC_INDENTATION="$(printf "%${i}s" '')" 265 | } 266 | 267 | # void einfo(char* message) 268 | # 269 | # show an informative message (with a newline) 270 | # 271 | einfo() { 272 | einfon "$*\n" 273 | LAST_E_CMD=einfo 274 | return 0 275 | } 276 | 277 | # void einfon(char* message) 278 | # 279 | # show an informative message (without a newline) 280 | # 281 | einfon() { 282 | [ "${RC_QUIET_STDOUT}" = "yes" ] && return 0 283 | [ "${RC_ENDCOL}" != "yes" ] && [ "${LAST_E_CMD}" = "ebegin" ] && echo 284 | printf " ${GOOD}*${NORMAL} ${RC_INDENTATION}$*" 285 | LAST_E_CMD=einfon 286 | return 0 287 | } 288 | 289 | # void ewarn(char* message) 290 | # 291 | # show a warning message + log it 292 | # 293 | ewarn() { 294 | if [ "${RC_QUIET_STDOUT}" = "yes" ]; then 295 | printf " $*\n" 296 | else 297 | [ "${RC_ENDCOL}" != "yes" ] && [ "${LAST_E_CMD}" = "ebegin" ] && echo 298 | printf " ${WARN}*${NORMAL} ${RC_INDENTATION}$*\n" 299 | fi 300 | 301 | # Log warnings to system log 302 | esyslog "daemon.warning" "rc-scripts" "$@" 303 | 304 | LAST_E_CMD=ewarn 305 | return 0 306 | } 307 | 308 | # void eerror(char* message) 309 | # 310 | # show an error message + log it 311 | # 312 | eerror() { 313 | if [ "${RC_QUIET_STDOUT}" = "yes" ]; then 314 | printf " $*\n" >&2 315 | else 316 | [ "${RC_ENDCOL}" != "yes" ] && [ "${LAST_E_CMD}" = "ebegin" ] && echo 317 | printf " ${BAD}*${NORMAL} ${RC_INDENTATION}$*\n" 318 | fi 319 | 320 | # Log errors to system log 321 | esyslog "daemon.err" "rc-scripts" "$@" 322 | 323 | LAST_E_CMD=eerror 324 | return 0 325 | } 326 | 327 | # void ebegin(char* message) 328 | # 329 | # show a message indicating the start of a process 330 | # 331 | ebegin() { 332 | local msg="$@" dots spaces 333 | spaces="$(printf '%'"${#RC_DOT_PATTERN}"'s' '')" 334 | [ "${RC_QUIET_STDOUT}" = "yes" ] && return 0 335 | 336 | if [ -n "${RC_DOT_PATTERN}" ]; then 337 | dots="$(printf "%$(( $COLS - 3 - ${#RC_INDENTATION} - ${#msg} - 7 ))s" '')" 338 | while [ "${dots#${spaces}}" != "${dots}" ] ; do 339 | dots="${dots#${spaces}}${RC_DOT_PATTERN}" 340 | done 341 | msg="${msg}${dots}" 342 | else 343 | msg="${msg} ..." 344 | fi 345 | einfon "${msg}" 346 | [ "${RC_ENDCOL}" = "yes" ] && echo 347 | 348 | LAST_E_LEN=$(( 3 + ${#RC_INDENTATION} + ${#msg} )) 349 | LAST_E_CMD=ebegin 350 | return 0 351 | } 352 | 353 | # void _eend(int error, char *efunc, char* errstr) 354 | # 355 | # indicate the completion of process, called from eend/ewend 356 | # if error, show errstr via efunc 357 | # 358 | # This function is private to functions.sh. Do not call it from a 359 | # script. 360 | # 361 | _eend() { 362 | local retval="${1:-0}" efunc="${2:-eerror}" msg 363 | shift 2 364 | 365 | if [ "${retval}" -eq 0 ]; then 366 | [ "${RC_QUIET_STDOUT}" = "yes" ] && return 0 367 | msg="${BRACKET}[ ${GOOD}ok${BRACKET} ]${NORMAL}" 368 | else 369 | if [ "$#" -gt 0 ] ; then 370 | "${efunc}" "$@" 371 | fi 372 | msg="${BRACKET}[ ${BAD}!!${BRACKET} ]${NORMAL}" 373 | fi 374 | 375 | if [ "${RC_ENDCOL}" = "yes" ]; then 376 | printf "${ENDCOL} ${msg}\n" 377 | else 378 | [ "${LAST_E_CMD}" = "ebegin" ] || LAST_E_LEN=0 379 | printf "%$(( ${COLS} - ${LAST_E_LEN} - 6 ))s%b\n" '' "${msg}" 380 | fi 381 | 382 | return "${retval}" 383 | } 384 | 385 | # void eend(int error, char* errstr) 386 | # 387 | # indicate the completion of process 388 | # if error, show errstr via eerror 389 | # 390 | eend() { 391 | local retval="${1:-0}" 392 | shift 393 | 394 | _eend "${retval}" eerror "$@" 395 | 396 | LAST_E_CMD=eend 397 | return "$retval" 398 | } 399 | 400 | # void ewend(int error, char* errstr) 401 | # 402 | # indicate the completion of process 403 | # if error, show errstr via ewarn 404 | # 405 | ewend() { 406 | local retval="${1:-0}" 407 | shift 408 | 409 | _eend "${retval}" ewarn "$@" 410 | 411 | LAST_E_CMD=ewend 412 | return "$retval" 413 | } 414 | #}}} 415 | 416 | # if we're using systemd then redefine functions 417 | # for output in systemd style 418 | if [ "$(cat /proc/1/comm 2>/dev/null)" = "systemd" ] ; then 419 | einfo() { 420 | printf "[ ${GREEN}OK${NORMAL} ] %s\n" "$*" 421 | } 422 | 423 | ewarn() { 424 | printf "[ ${YELLOW}WARN${NORMAL} ] %s\n" "$*" 425 | } 426 | 427 | eerror() { 428 | printf "[ ${RED}FAIL${NORMAL} ] %s\n" "$*" 429 | } 430 | 431 | eend() { 432 | : 433 | } 434 | fi 435 | 436 | # vim: ft=sh tw=80 ts=4 foldmethod=marker 437 | -------------------------------------------------------------------------------- /etc/grml/screen_multisession: -------------------------------------------------------------------------------- 1 | # Filename: /etc/grml/screen_multisession 2 | # Purpose: configuration file for use in multisession mode of GNU screen 3 | # Authors: grml-team (grml.org), (c) Michael Prokop 4 | # Bug-Reports: see http://grml.org/bugs/ 5 | # License: This file is licensed under the GPL v2 or any later version. 6 | ################################################################################ 7 | 8 | # who is allowed to connect via multiuser-mode? 9 | addacl root,grml 10 | 11 | # allow multiuser-mode 12 | multiuser on 13 | 14 | # redefine C-a 15 | defescape ^Bb 16 | escape ^Bb 17 | 18 | # no nag-screen, please 19 | startup_message off 20 | 21 | ## END OF FILE ################################################################# 22 | -------------------------------------------------------------------------------- /etc/grml/screenrc: -------------------------------------------------------------------------------- 1 | # Filename: /etc/grml/screenrc 2 | # Purpose: main configuration file for GNU screen 3 | # Authors: grml-team (grml.org), (c) Michael Prokop 4 | # Bug-Reports: see http://grml.org/bugs/ 5 | # License: This file is licensed under the GPL v2. 6 | ################################################################################ 7 | 8 | backtick 1 0 60 /usr/bin/cpu-screen 9 | backtick 2 0 60 /usr/bin/ip-screen 10 | caption always "%{+b rk}$USER@%{wk}%H | %{yk}(load: %l |%{rk} cpu: %1` | %{Gk}net: %2`) %-21=%{wk}%D %Y-%m-%d %0c" 11 | hardstatus alwayslastline "%{wr}%n%f %t %{kw} | %?%-Lw%?%{wb}%n*%f %t%?(%u)%?%{kw}%?%+Lw%? %{wk}" 12 | 13 | # switch order of caption and hardstatus: 14 | # hardstatus alwayslastline "%{+b kr}$USER@%{kw}%H | %{ky}(load: %l |%{kr} cpu: %1` | %{kG}net: %2`) %-21=%{kw}%D %Y-%m-%d %0c" 15 | # caption always "%{rw}%n%f %t %{wk} | %?%-Lw%?%{bw}%n*%f %t%?(%u)%?%{wk}%?%+Lw%? %{wk}" 16 | 17 | # detach on hangup 18 | autodetach on # default: on 19 | crlf off # default: off 20 | deflogin off # default: on 21 | # defsilence off # default: off 22 | # hardcopy_append on # default: off 23 | hardcopy_append off # default: off 24 | nethack on # default: off 25 | # don't display the copyright page 26 | startup_message off # default: on 27 | # no annoying audible bell, please 28 | vbell on 29 | 30 | defscrollback 1000 # default: 100 31 | # msgminwait 3 # default: 1 32 | silencewait 15 # default: 30 33 | 34 | hardcopydir $HOME/.hardcopy 35 | 36 | # fix the "screen.linux" terminal problem (see Debian BTS #238355 + #239776) 37 | # term linux 38 | 39 | # shell /bin/zsh 40 | 41 | # "sorendition": set the colors for 42 | # the "messages" and "text marking" 43 | # (ie text you mark in copy mode): 44 | sorendition 10 99 # default! 45 | 46 | # use %n to display the window number and %t for its title: 47 | activity "activity in %n (%t) [%w:%s]~" 48 | 49 | # pass on the "beep" (CTRL-G) by adding a '~': 50 | bell "bell in %n (%t) [%w:%s]~" 51 | 52 | # pow_detach_msg: Message shown when session 53 | # gets power detached. 54 | pow_detach_msg "Screen session of \$LOGNAME \$:cr:\$:nl:ended." 55 | 56 | # vbell_msg: Message shown when the 57 | # "virtual bell" rings. 58 | vbell_msg " *beep* " 59 | 60 | # Key bindings 61 | # Remove some default key bindings by binding 62 | # them to "nothing" (empty right-hand-side): 63 | # bind . dumptermcap # default 64 | bind . 65 | # bind ^\ 66 | # bind \\ 67 | bind . 68 | bind k 69 | bind ^k 70 | bind ^h 71 | 72 | # 040126 To be able to select windows with n > 9 -> 73 | # press "C-a - #" instead of just "C-a #" 74 | bind - command -c select_1n 75 | bind -c select_1n 0 select 10 76 | bind -c select_1n 1 select 11 77 | bind -c select_1n 2 select 12 78 | bind -c select_1n 3 select 13 79 | bind -c select_1n 4 select 14 80 | bind -c select_1n 5 select 15 81 | bind -c select_1n 6 select 16 82 | bind -c select_1n 7 select 17 83 | bind -c select_1n 8 select 18 84 | bind -c select_1n 9 select 19 85 | bind -c select_1n - command -c select_2n 86 | bind -c select_2n 0 select 20 87 | bind -c select_2n 1 select 21 88 | bind -c select_2n 2 select 22 89 | bind -c select_2n 3 select 23 90 | bind -c select_2n 4 select 24 91 | bind -c select_2n 5 select 25 92 | bind -c select_2n 6 select 26 93 | bind -c select_2n 7 select 27 94 | bind -c select_2n 8 select 28 95 | bind -c select_2n 9 select 29 96 | bind -c select_2n - select - 97 | 98 | # Use the function keys F11 and F12 to cycle backwards/forwards in 99 | # the list of existing windows: 100 | # bindkey -k F1 prev 101 | # bindkey -k F2 next 102 | 103 | bind h hardcopy 104 | # make them better 105 | bind 'K' kill 106 | bind 'I' login on 107 | bind 'O' login off 108 | bind '}' history 109 | 110 | # Paste - use 'P' instead of ']': 111 | # bind P # unbound by default 112 | bind P paste . 113 | 114 | # Yet another hack: 115 | # Prepend/append register [/] to the paste if ^a^] is pressed. 116 | # This lets me have autoindent mode in vi. 117 | # register [ "\033:se noai\015a" 118 | # register ] "\033:se ai\015a" 119 | # bind ^] paste [.] 120 | 121 | # X - a fast way to lock the current screen. 122 | bind X lockscreen 123 | 124 | # 030511 Workaround for stupid machines without xmodmap ;-) 125 | bindkey -t °a stuff "ä" 126 | bindkey -t °A stuff "Ä" 127 | bindkey -t °o stuff "ö" 128 | bindkey -t °O stuff "Ö" 129 | bindkey -t °u stuff "ü" 130 | bindkey -t °U stuff "Ü" 131 | bindkey -t °s stuff "ß" 132 | 133 | msgwait 1 134 | version 135 | # change back to showing messages 136 | # for duration of two seconds: 137 | msgwait 2 138 | 139 | # To get screen to add lines to xterm's scrollback buffer, uncomment the 140 | # following termcapinfo line which tells xterm to use the normal screen buffer 141 | # (which has scrollback), not the alternate screen buffer. 142 | termcapinfo xterm|xterms|xs|rxvt ti@:te@ 143 | 144 | # Welcome the user: 145 | echo "welcome BoFH!" 146 | 147 | # vim: ft=screen 148 | ## END OF FILE ################################################################# 149 | -------------------------------------------------------------------------------- /etc/grml/screenrc_acpi: -------------------------------------------------------------------------------- 1 | # Filename: /etc/grml/screenrc_acpi 2 | # Purpose: configuration file for GNU screen providing ACPI output 3 | # Authors: grml-team (grml.org), (c) Michael Prokop 4 | # Bug-Reports: see http://grml.org/bugs/ 5 | # License: This file is licensed under the GPL v2. 6 | ################################################################################ 7 | 8 | backtick 1 60 60 /usr/bin/cpu-screen 9 | backtick 2 60 60 /usr/bin/yacpi -p 10 | caption always "%{+b rk}$USER@%{wk}%H | %{yk}(load: %l |%{rk} cpu: %1` | %{Gk}acpi: %2`) %-21=%{wk}%D %Y-%m-%d %0c" 11 | hardstatus alwayslastline "%{wr}%n%f %t %{kw} | %?%-Lw%?%{wb}%n*%f %t%?(%u)%?%{kw}%?%+Lw%? %{wk}" 12 | 13 | # switch order of caption and hardstatus: 14 | # hardstatus alwayslastline "%{+b rk}$USER@%{wk}%H | %{yk}(load: %l |%{rk} cpu: %1` | %{Gk}acpi: %2`) %-21=%{wk}%D %Y-%m-%d %0c" 15 | # caption always "%{wr}%n%f %t %{kw} | %?%-Lw%?%{wb}%n*%f %t%?(%u)%?%{kw}%?%+Lw%? %{wk}" 16 | 17 | # detach on hangup 18 | autodetach on # default: on 19 | crlf off # default: off 20 | deflogin off # default: on 21 | # defsilence off # default: off 22 | # hardcopy_append on # default: off 23 | hardcopy_append off # default: off 24 | nethack on # default: off 25 | # don't display the copyright page 26 | startup_message off # default: on 27 | # no annoying audible bell, please 28 | vbell on 29 | 30 | defscrollback 1000 # default: 100 31 | # msgminwait 3 # default: 1 32 | silencewait 15 # default: 30 33 | 34 | hardcopydir $HOME/.hardcopy 35 | 36 | # fix the "screen.linux" terminal problem (see Debian BTS #238355 + #239776) 37 | # term linux 38 | 39 | # shell /bin/zsh 40 | 41 | # "sorendition": set the colors for 42 | # the "messages" and "text marking" 43 | # (ie text you mark in copy mode): 44 | sorendition 10 99 # default! 45 | 46 | # use %n to display the window number and %t for its title: 47 | activity "activity in %n (%t) [%w:%s]~" 48 | 49 | # pass on the "beep" (CTRL-G) by adding a '~': 50 | bell "bell in %n (%t) [%w:%s]~" 51 | 52 | # pow_detach_msg: Message shown when session 53 | # gets power detached. 54 | pow_detach_msg "Screen session of \$LOGNAME \$:cr:\$:nl:ended." 55 | 56 | # vbell_msg: Message shown when the 57 | # "virtual bell" rings. 58 | vbell_msg " *beep* " 59 | 60 | # Key bindings 61 | # Remove some default key bindings by binding 62 | # them to "nothing" (empty right-hand-side): 63 | # bind . dumptermcap # default 64 | bind . 65 | bind ^\ 66 | bind \\ 67 | 68 | # 040126 To be able to select windows with n > 9 -> 69 | # press "C-a - #" instead of just "C-a #" 70 | bind - command -c select_1n 71 | bind -c select_1n 0 select 10 72 | bind -c select_1n 1 select 11 73 | bind -c select_1n 2 select 12 74 | bind -c select_1n 3 select 13 75 | bind -c select_1n 4 select 14 76 | bind -c select_1n 5 select 15 77 | bind -c select_1n 6 select 16 78 | bind -c select_1n 7 select 17 79 | bind -c select_1n 8 select 18 80 | bind -c select_1n 9 select 19 81 | bind -c select_1n - command -c select_2n 82 | bind -c select_2n 0 select 20 83 | bind -c select_2n 1 select 21 84 | bind -c select_2n 2 select 22 85 | bind -c select_2n 3 select 23 86 | bind -c select_2n 4 select 24 87 | bind -c select_2n 5 select 25 88 | bind -c select_2n 6 select 26 89 | bind -c select_2n 7 select 27 90 | bind -c select_2n 8 select 28 91 | bind -c select_2n 9 select 29 92 | bind -c select_2n - select - 93 | 94 | # Use the function keys F11 and F12 to cycle backwards/forwards in 95 | # the list of existing windows: 96 | # bindkey -k F1 prev 97 | # bindkey -k F2 next 98 | 99 | # remove some stupid / dangerous key bindings 100 | bind k 101 | bind ^k 102 | bind . 103 | bind ^\ 104 | bind \\ 105 | bind ^h 106 | bind h hardcopy 107 | # make them better 108 | bind 'K' kill 109 | bind 'I' login on 110 | bind 'O' login off 111 | bind '}' history 112 | 113 | # Paste - use 'P' instead of ']': 114 | # bind P # unbound by default 115 | bind P paste . 116 | 117 | # Yet another hack: 118 | # Prepend/append register [/] to the paste if ^a^] is pressed. 119 | # This lets me have autoindent mode in vi. 120 | register [ "\033:se noai\015a" 121 | register ] "\033:se ai\015a" 122 | bind ^] paste [.] 123 | 124 | # X - a fast way to lock the current screen. 125 | bind X lockscreen 126 | 127 | # 030511 Workaround for stupid machines without xmodmap ;-) 128 | bindkey -t °a stuff "ä" 129 | bindkey -t °A stuff "Ä" 130 | bindkey -t °o stuff "ö" 131 | bindkey -t °O stuff "Ö" 132 | bindkey -t °u stuff "ü" 133 | bindkey -t °U stuff "Ü" 134 | bindkey -t °s stuff "ß" 135 | 136 | msgwait 1 137 | version 138 | # change back to showing messages 139 | # for duration of two seconds: 140 | msgwait 2 141 | # 142 | # Welcome the user: 143 | echo "welcome BoFH!" 144 | 145 | # vim: ft=screen 146 | ## END OF FILE ################################################################# 147 | -------------------------------------------------------------------------------- /etc/grml/screenrc_generic: -------------------------------------------------------------------------------- 1 | # Filename: /etc/grml/screenrc_generic 2 | # Purpose: generic configuration file for GNU screen 3 | # Authors: grml-team (grml.org), (c) Michael Prokop 4 | # Bug-Reports: see http://grml.org/bugs/ 5 | # License: This file is licensed under the GPL v2. 6 | ################################################################################ 7 | 8 | caption always "%{+b rk}$USER@%{wk}%H | %{yk}(load: %l) %-21=%{wk}%D %Y-%m-%d %0c" 9 | hardstatus alwayslastline "%{wr}%n%f %t %{kw} | %?%-Lw%?%{wb}%n*%f %t%?(%u)%?%{kw}%?%+Lw%? %{wk}" 10 | 11 | # switch order of caption and hardstatus: 12 | # hardstatus alwayslastline "%{+b rk}$USER@%{wk}%H | %{yk}(load: %l |%{rk} cpu: %1` | %{Gk}net: %2`) %-21=%{wk}%D %Y-%m-%d %0c" 13 | # caption always "%{wr}%n%f %t %{kw} | %?%-Lw%?%{wb}%n*%f %t%?(%u)%?%{kw}%?%+Lw%? %{wk}" 14 | 15 | # detach on hangup 16 | autodetach on # default: on 17 | crlf off # default: off 18 | deflogin off # default: on 19 | # defsilence off # default: off 20 | # hardcopy_append on # default: off 21 | hardcopy_append off # default: off 22 | nethack on # default: off 23 | # don't display the copyright page 24 | startup_message off # default: on 25 | # no annoying audible bell, please 26 | vbell on 27 | 28 | defscrollback 1000 # default: 100 29 | # msgminwait 3 # default: 1 30 | silencewait 15 # default: 30 31 | 32 | hardcopydir $HOME/.hardcopy 33 | 34 | # fix the "screen.linux" terminal problem (see Debian BTS #238355 + #239776) 35 | # term linux 36 | 37 | # shell /bin/zsh 38 | 39 | # "sorendition": set the colors for 40 | # the "messages" and "text marking" 41 | # (ie text you mark in copy mode): 42 | sorendition 10 99 # default! 43 | 44 | # use %n to display the window number and %t for its title: 45 | activity "activity in %n (%t) [%w:%s]~" 46 | 47 | # pass on the "beep" (CTRL-G) by adding a '~': 48 | bell "bell in %n (%t) [%w:%s]~" 49 | 50 | # pow_detach_msg: Message shown when session 51 | # gets power detached. 52 | pow_detach_msg "Screen session of \$LOGNAME \$:cr:\$:nl:ended." 53 | 54 | # vbell_msg: Message shown when the 55 | # "virtual bell" rings. 56 | vbell_msg " *beep* " 57 | 58 | # Key bindings 59 | # Remove some default key bindings by binding 60 | # them to "nothing" (empty right-hand-side): 61 | # bind . dumptermcap # default 62 | bind . 63 | bind ^\ 64 | bind \\ 65 | 66 | # 040126 To be able to select windows with n > 9 -> 67 | # press "C-a - #" instead of just "C-a #" 68 | bind - command -c select_1n 69 | bind -c select_1n 0 select 10 70 | bind -c select_1n 1 select 11 71 | bind -c select_1n 2 select 12 72 | bind -c select_1n 3 select 13 73 | bind -c select_1n 4 select 14 74 | bind -c select_1n 5 select 15 75 | bind -c select_1n 6 select 16 76 | bind -c select_1n 7 select 17 77 | bind -c select_1n 8 select 18 78 | bind -c select_1n 9 select 19 79 | bind -c select_1n - command -c select_2n 80 | bind -c select_2n 0 select 20 81 | bind -c select_2n 1 select 21 82 | bind -c select_2n 2 select 22 83 | bind -c select_2n 3 select 23 84 | bind -c select_2n 4 select 24 85 | bind -c select_2n 5 select 25 86 | bind -c select_2n 6 select 26 87 | bind -c select_2n 7 select 27 88 | bind -c select_2n 8 select 28 89 | bind -c select_2n 9 select 29 90 | bind -c select_2n - select - 91 | 92 | # Use the function keys F11 and F12 to cycle backwards/forwards in 93 | # the list of existing windows: 94 | # bindkey -k F1 prev 95 | # bindkey -k F2 next 96 | 97 | # remove some stupid / dangerous key bindings 98 | bind k 99 | bind ^k 100 | bind . 101 | bind ^\ 102 | bind \\ 103 | bind ^h 104 | bind h hardcopy 105 | # make them better 106 | bind 'K' kill 107 | bind 'I' login on 108 | bind 'O' login off 109 | bind '}' history 110 | 111 | # Paste - use 'P' instead of ']': 112 | # bind P # unbound by default 113 | bind P paste . 114 | 115 | # Yet another hack: 116 | # Prepend/append register [/] to the paste if ^a^] is pressed. 117 | # This lets me have autoindent mode in vi. 118 | # register [ "\033:se noai\015a" 119 | # register ] "\033:se ai\015a" 120 | # bind ^] paste [.] 121 | 122 | # X - a fast way to lock the current screen. 123 | bind X lockscreen 124 | 125 | # 030511 Workaround for stupid machines without xmodmap ;-) 126 | bindkey -t °a stuff "ä" 127 | bindkey -t °A stuff "Ä" 128 | bindkey -t °o stuff "ö" 129 | bindkey -t °O stuff "Ö" 130 | bindkey -t °u stuff "ü" 131 | bindkey -t °U stuff "Ü" 132 | bindkey -t °s stuff "ß" 133 | 134 | msgwait 1 135 | version 136 | # change back to showing messages 137 | # for duration of two seconds: 138 | msgwait 2 139 | 140 | # To get screen to add lines to xterm's scrollback buffer, uncomment the 141 | # following termcapinfo line which tells xterm to use the normal screen buffer 142 | # (which has scrollback), not the alternate screen buffer. 143 | termcapinfo xterm|xterm-256color|xterms|xs|rxvt ti@:te@ 144 | 145 | # Welcome the user: 146 | echo "welcome BoFH!" 147 | 148 | # vim: ft=screen 149 | ## END OF FILE ################################################################# 150 | -------------------------------------------------------------------------------- /etc/grml/script-functions: -------------------------------------------------------------------------------- 1 | # Filename: /etc/grml/script-functions 2 | # Purpose: some often used functions for use in shellscripts 3 | # Authors: grml-team (grml.org), (c) Michael Prokop 4 | # Bug-Reports: see http://grml.org/bugs/ 5 | # License: This file is licensed under the GPL v2. 6 | ################################################################################ 7 | 8 | # {{{ set default PATH 9 | setpath(){ 10 | export PATH=${PATH:-'/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin:/usr/local/bin'} 11 | } 12 | # }}} 13 | 14 | # {{{ check for root-permissions 15 | check4root(){ 16 | if [ "$(id -u 2>/dev/null)" != 0 ] ; then 17 | echo 1>&2 "Error: please run this script with uid 0 (root)." ; return 1 18 | fi 19 | } 20 | # }}} 21 | 22 | # {{{ check for user permissions 23 | check4user(){ 24 | if [ "$(id -u 2>/dev/null)" = 0 ] ; then 25 | echo 1>&2 "Error: please do not run this script with uid 0 (root)." ; return 1 26 | fi 27 | } 28 | # }}} 29 | 30 | # {{{ check for running zsh 31 | iszsh(){ 32 | if ! [ -z "$ZSH_VERSION" ] ; then 33 | return 0 34 | else 35 | return 1 36 | fi 37 | } 38 | # }}} 39 | 40 | # {{{ check for (X)dialog 41 | setdialog(){ 42 | if [ -n "$DISPLAY" ] ; then 43 | [ -x /usr/bin/Xdialog ] && DIALOG="Xdialog" && export XDIALOG_HIGH_DIALOG_COMPAT=1 44 | else 45 | [ -x /usr/bin/dialog ] && DIALOG='dialog' || ( echo 1>&2 "dialog not available" ; return 1 ) 46 | fi 47 | } 48 | # }}} 49 | 50 | # {{{ check for availability of program(s) 51 | # usage example: 52 | # check4progs [-s,-q,--quiet,--silent] arg [arg .... argn] 53 | # 54 | # with option given either of: 55 | # -s,-q,--quiet,--silent 56 | # 57 | # check for available progs but produce no output 58 | check4progs() { 59 | [ -n "${ZSH_VERSION}" ] && emulate -L sh 60 | local RTN=0 61 | local oldifs="${IFS}" 62 | local ARG d found 63 | local VERBOSE=1 64 | 65 | case ${1} in 66 | -q | -s | --quiet | --silent) 67 | VERBOSE=0 68 | shift 1 69 | ;; 70 | 71 | *) 72 | ;; 73 | esac 74 | 75 | while [ $# -gt 0 ] 76 | do 77 | ARG="$1" 78 | shift 79 | 80 | found=0 81 | IFS=: 82 | for d in $PATH 83 | do 84 | if [ -x "${d}/${ARG}" ] 85 | then 86 | found=1 87 | break 88 | fi 89 | done 90 | IFS="${oldifs}" 91 | 92 | # check for availability 93 | if [ ${found} -eq 0 ] 94 | then 95 | if [ ${VERBOSE} -eq 1 ] 96 | then 97 | printf "%s: binary not found\n" "${ARG}" >&2 98 | fi 99 | RTN=1 100 | fi 101 | done 102 | 103 | # return non zero, if at least one prog is missing! 104 | return $RTN 105 | } 106 | # }}} 107 | 108 | # {{{ simple shell grep 109 | stringinfile(){ 110 | case "$(cat $2)" in *$1*) return 0;; esac 111 | return 1 112 | } 113 | # }}} 114 | 115 | # {{{ simple shell grep for strings 116 | stringinstring(){ 117 | case "$2" in *$1*) return 0;; esac 118 | return 1 119 | } 120 | # }}} 121 | 122 | # {{{ reread boot command line; echo last parameter's argument or return false. 123 | getbootparam(){ 124 | CMDLINE=$(cat /proc/cmdline) 125 | stringinstring " $1=" "$CMDLINE" || return 1 126 | result="${CMDLINE##*$1=}" 127 | result="${result%%[ ]*}" 128 | echo "$result" 129 | return 0 130 | } 131 | # }}} 132 | 133 | # {{{ check boot commandline for specified option 134 | checkbootparam(){ 135 | stringinfile " $1" /proc/cmdline 136 | return "$?" 137 | } 138 | # }}} 139 | 140 | # {{{ check whether $1 is yes 141 | checkvalue(){ 142 | if [ "$1" = "yes" -o "$1" = "YES" ] ; then 143 | return 0 144 | else 145 | return 1 146 | fi 147 | } 148 | # }}} 149 | 150 | # {{{ grml specific checks 151 | isgrml(){ 152 | [ -f /etc/grml_version ] && return 0 || return 1 153 | } 154 | 155 | grmlversion(){ 156 | cat /etc/grml_version 157 | } 158 | 159 | isgrmlcd(){ 160 | [ -f /etc/grml_cd ] && return 0 || return 1 161 | } 162 | 163 | isgrmlhd(){ 164 | [ -f /etc/grml_cd ] && return 1 || return 0 165 | } 166 | 167 | checkgrmlsmall(){ 168 | grep -q small /etc/grml_version 2>/dev/null && return 0 || return 1 169 | } 170 | # }}} 171 | 172 | # {{{ filesystems (proc, pts, sys) 173 | mount_proc(){ 174 | check4root || return 1 175 | [ -f /proc/version ] || mount -t proc /proc /proc 2>/dev/null 176 | } 177 | 178 | mount_pts(){ 179 | check4root || return 1 180 | stringinfile "/dev/pts" /proc/mounts || mount -t devpts /dev/pts /dev/pts 2>/dev/null 181 | } 182 | 183 | mount_sys(){ 184 | check4root || return 1 185 | [ -d /sys/devices ] || mount -t sysfs /sys /sys 2>/dev/null 186 | } 187 | # }}} 188 | 189 | # char *reverse_list(list) {{{ 190 | # 191 | # Returns the reversed order of list 192 | # 193 | reverse_list() { 194 | local ret 195 | ret='' 196 | while [ "$#" -gt 0 ] ; do 197 | if [ -z "${ret}" ] ; then 198 | ret="$1" 199 | else 200 | ret="$1 ${ret}" 201 | fi 202 | shift 203 | done 204 | printf '%s' "${ret}" 205 | } 206 | #}}} 207 | 208 | # bool is_older_than(reference, files/dirs to check) {{{ 209 | # 210 | # return 0 if any of the files/dirs are newer than 211 | # the reference file 212 | # 213 | # EXAMPLE: if is_older_than a.out *.o ; then ... 214 | is_older_than() { 215 | local x 216 | local ref="$1" 217 | shift 218 | 219 | for x in "$@" ; do 220 | [ "${x}" -nt "${ref}" ] && return 0 221 | 222 | if [ -d "${x}" ] ; then 223 | is_older_than "${ref}" "${x}"/* && return 0 224 | fi 225 | done 226 | 227 | return 1 228 | } 229 | #}}} 230 | 231 | ## END OF FILE ################################################################# 232 | # vim:foldmethod=marker tw=80 ai expandtab shiftwidth=2 tabstop=8 ft=sh 233 | -------------------------------------------------------------------------------- /etc/grml/sysexits-sh: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 1987, 1993 3 | # The Regents of the University of California. All rights reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions 7 | # are met: 8 | # 1. Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # 2. Redistributions in binary form must reproduce the above copyright 11 | # notice, this list of conditions and the following disclaimer in the 12 | # documentation and/or other materials provided with the distribution. 13 | # 4. Neither the name of the University nor the names of its contributors 14 | # may be used to endorse or promote products derived from this software 15 | # without specific prior written permission. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | # ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | # SUCH DAMAGE. 28 | # 29 | # @(#)sysexits.h 8.1 (Berkeley) 6/2/93 30 | # 31 | 32 | 33 | EX_OK=0 # successful termination 34 | 35 | EX__BASE=64 # base value for error messages 36 | 37 | EX_USAGE=64 # command line usage error 38 | EX_DATAERR=65 # data format error 39 | EX_NOINPUT=66 # cannot open input 40 | EX_NOUSER=67 # addressee unknown 41 | EX_NOHOST=68 # host name unknown 42 | EX_UNAVAILABLE=69 # service unavailable 43 | EX_SOFTWARE=70 # internal software error 44 | EX_OSERR=71 # system error (e.g., can't fork) 45 | EX_OSFILE=72 # critical OS file missing 46 | EX_CANTCREAT=73 # can't create (user) output file 47 | EX_IOERR=74 # input/output error 48 | EX_TEMPFAIL=75 # temp failure; user is invited to retry 49 | EX_PROTOCOL=76 # remote error in protocol 50 | EX_NOPERM=77 # permission denied 51 | EX_CONFIG=78 # configuration error 52 | 53 | EX__MAX=78 # maximum listed value 54 | -------------------------------------------------------------------------------- /etc/grml_colors: -------------------------------------------------------------------------------- 1 | # Filename: grml_colors 2 | # Purpose: color definition file 3 | # Authors: (c) Michael Prokop 4 | # Bug-Reports: see http://grml.org/bugs/ 5 | # License: This file is licensed under the GPL v2. 6 | ################################################################################ 7 | 8 | # don't use highlighed colors under systemd to match its style 9 | if [ "$(cat /proc/1/comm 2>/dev/null)" = "systemd" ] ; then 10 | HIGHLIGHT=0 11 | else 12 | HIGHLIGHT=1 13 | fi 14 | 15 | # ANSI COLORS 16 | CRE=" " 17 | NORMAL="" 18 | # RED: Failure or error message 19 | RED="[${HIGHLIGHT};31m" 20 | # GREEN: Success message 21 | GREEN="[${HIGHLIGHT};32m" 22 | # YELLOW: Descriptions 23 | YELLOW="[${HIGHLIGHT};33m" 24 | # BLUE: System messages 25 | BLUE="[${HIGHLIGHT};34m" 26 | # MAGENTA: Found devices or drivers 27 | MAGENTA="[${HIGHLIGHT};35m" 28 | # CYAN: Questions 29 | CYAN="[${HIGHLIGHT};36m" 30 | # BOLD WHITE: Hint 31 | WHITE="[${HIGHLIGHT};37m" 32 | 33 | # don't expose unneeded local variables 34 | unset HIGHLIGHT 35 | 36 | ## END OF FILE ################################################################# 37 | -------------------------------------------------------------------------------- /etc/grml_nocolors: -------------------------------------------------------------------------------- 1 | # Filename: grml_nocolors 2 | # Purpose: "no colors" definition file - don't use any escape sequences 3 | # Authors: (c) Michael Prokop 4 | # Bug-Reports: see http://grml.org/bugs/ 5 | # License: This file is licensed under the GPL v2. 6 | ################################################################################ 7 | # Notice: if you want to use colors in your script you probably are 8 | # searching for /etc/grml_colors. This file is meant to be used 9 | # when you don't want to get escape sequences in output. For example 10 | # this is useful when logging stuff to a file. 11 | ################################################################################ 12 | 13 | # ANSI COLORS 14 | CRE='' 15 | NORMAL='' 16 | # RED: Failure or error message 17 | RED='' 18 | # GREEN: Success message 19 | GREEN='' 20 | # YELLOW: Descriptions 21 | YELLOW='' 22 | # BLUE: System messages 23 | BLUE='' 24 | # MAGENTA: Found devices or drivers 25 | MAGENTA='' 26 | # CYAN: Questions 27 | CYAN='' 28 | # BOLD WHITE: Hint 29 | WHITE='' 30 | 31 | ## END OF FILE ################################################################# 32 | -------------------------------------------------------------------------------- /etc/minimal-shellrc: -------------------------------------------------------------------------------- 1 | # vim:ft=sh:fdm=marker 2 | # Configuration for the `minimal-shell' function of grml's zsh setup. 3 | # That function spawns a `mksh' shell with this file as its configuration. 4 | 5 | # skip this setup for non-interactive shells 6 | [[ -o interactive && -t 0 ]] || return 7 | 8 | export PATH="/bin:/sbin/:/usr/bin/:/usr/sbin:/usr/local/bin:/usr/local/sbin:${HOME}/bin:/opt/bin" 9 | export EDITOR='ed' 10 | 11 | if [[ -x $(which vim) ]] ; then 12 | export VISUAL='vim' 13 | else 14 | export VISUAL='vi' 15 | fi 16 | if [[ -x $(which less) ]] ; then 17 | export PAGER='less' 18 | else 19 | export PAGER='more' 20 | fi 21 | 22 | # some options. 23 | set -o bgnice \ 24 | -o braceexpand \ 25 | -o emacs \ 26 | -o markdirs \ 27 | -o monitor \ 28 | -o nohup \ 29 | -o trackall 30 | 31 | # aliases for various command shortcuts 32 | alias ls='command ls --color=auto' # we're on grml, so we do have GNU ls. 33 | alias ll='command ls -l --color=auto' 34 | alias la='command ls -la --color=auto' 35 | alias pu='ps -fu $USER' 36 | 37 | ## Keybindings 38 | bind '^L=clear-screen' 39 | if [[ -x $(which infocmp) ]] && [[ -x $(which sed) ]] ; then 40 | # Reading some special keys from terminfo database. If `infocmp' 41 | # cannot be found, we rely on mksh to do the right thing. 42 | infocmp -x1L | sed '/^\t[^k]/d;/^[^\t]/d;s/\t//;s/,$//' | \ 43 | while read -r line ; do 44 | key="${line%=*}" 45 | [[ "${key}" != k* ]] && continue 46 | seq="$(print -r -- "${line#*=}" | sed -e 's,\\\([1-7][0-7]*\),\\0\1,g')" 47 | seq="$(print "${seq}")" 48 | case "$key" in 49 | key_left) bind "${seq}"='backward-char' ;; 50 | key_right) bind "${seq}"='forward-char' ;; 51 | key_up) bind "${seq}"='up-history' ;; 52 | key_down) bind "${seq}"='down-history' ;; 53 | key_ppage) bind "${seq}"='search-history-up' ;; 54 | key_npage) bind "${seq}"='search-history-down' ;; 55 | key_home) bind "${seq}"='beginning-of-line' ;; 56 | key_end) bind "${seq}"='end-of-line' ;; 57 | key_backspace) bind "${seq}"='delete-char-backward' ;; 58 | key_dc) bind "${seq}"='delete-char-forward' ;; 59 | esac 60 | done 61 | fi 62 | 63 | function _lrv { 64 | local rv="$?" 65 | if [[ "${rv}" != 0 ]]; then 66 | print -- "[${rv}]-" 67 | fi 68 | return 0 69 | } 70 | # put the current directory and history number in the prompt. 71 | # use a wrapper for 'cd' to get '~' instead of /home/foo/. 72 | function _cd { 73 | "cd" "$@" 74 | [[ $PWD = $HOME* && $HOME != / ]] && _pwd=\~"${PWD#$HOME}" && return 75 | _pwd="$PWD" 76 | } 77 | alias cd=_cd 78 | _cd . 79 | PS1='$(_lrv)(!)-$_pwd' 80 | if (( USER_ID )); then 81 | PS1="$PS1"'\$ ' 82 | else 83 | PS1="$PS1"'# ' 84 | fi 85 | 86 | HISTSIZE=500 87 | HISTEDIT="$EDITOR" 88 | # This is the default in mksh, but we make sure in case people tempered 89 | # with it in their environment. 90 | unset HISTFILE 91 | true 92 | -------------------------------------------------------------------------------- /etc/network/interfaces.examples: -------------------------------------------------------------------------------- 1 | # /etc/network/interfaces -- configuration file for ifup(8), ifdown(8) 2 | # Also check out /usr/share/doc/ifupdown/examples/network-interfaces.gz 3 | 4 | # The loopback interface 5 | # automatically added when upgrading 6 | auto lo 7 | iface lo inet loopback 8 | 9 | # Sample entries: 10 | # =============== 11 | 12 | # static entry: 13 | # auto eth1 14 | # iface eth1 inet static 15 | # address 192.168.0.1 16 | # netmask 255.255.255.0 17 | # network 192.168.0.0 18 | # broadcast 192.168.0.255 19 | # gateway 192.168.0.1 20 | # dns-search foo.example 21 | # dns-nameservers 192.168.0.10 192.168.0.20 22 | # 23 | # vconfig: 24 | # auto eth0.1 25 | # iface eth0.1 inet manual 26 | # pre-up vconfig add eth0.1 27 | # up ifconfig eth0 0.0.0.0 promisc up 28 | # post-down vconfig rem eth0.1 29 | 30 | # Ad-hoc WLAN Network: 31 | # auto eth1 32 | # iface eth1 inet static 33 | # address 192.168.0.1 34 | # netmask 255.255.255.0 35 | # wireless_mode ad-hoc 36 | # wireless_essid foobar 37 | # wireless_channel 11 38 | 39 | # WLAN: 40 | # auto eth1 41 | # iface eth1 inet dhcp 42 | # wireless_essid foo 43 | # wireless_nick bar 44 | # wireless_key 11111111111111111111111111 45 | # wireless_keymode restricted 46 | # wireless_keymode open 47 | # wireless_mode managed 48 | 49 | # DSL Interface 50 | # allow-hotplug dsl 51 | # iface dsl inet manual 52 | # up ip link set $IFACE up 53 | # up ip -6 addr flush dev $IFACE || true 54 | # down ip link set $IFACE down 55 | 56 | # Mapping - bring up via e.g. 'ifup eth0=dhcp': 57 | # iface dhcp inet dhcp 58 | 59 | # Mapping - bring up via e.g. 'ifup -v eth0=home': 60 | # auto eth1 61 | # iface home inet dhcp 62 | # wireless_essid foo 63 | # wireless_nick bar 64 | # wireless_key 11111111111111111111111111 65 | # wireless_keymode restricted 66 | 67 | # More complex mapping-setup: 68 | # auto eth0 69 | # mapping eth0 70 | # script /etc/network/ping-places.sh 71 | # map 192.168.0.90/24 192.168.0.42 home 72 | # map 129.27.140.238/24 129.27.140.241 spsc 73 | # map 192.168.0.90/24 192.168.0.100 sevian7 74 | # map 192.168.0.90/24 192.168.0.1 work 75 | # map 195.177.251.50/255.255.255.224 195.177.251.33 office 76 | # 77 | # iface home inet static 78 | # address 192.168.0.90 79 | # netmask 255.255.255.0 80 | # gateway 192.168.0.42 81 | # mtu 1400 82 | # 83 | # up cp /etc/apt/sources.list.home /etc/apt/sources.list 84 | # up cp /etc/resolv.conf.home /etc/resolv.conf 85 | # 86 | # iface spsc inet static 87 | # address 129.27.140.238 88 | # netmask 255.255.255.0 89 | # gateway 129.27.140.1 90 | # 91 | # up cp /etc/apt/sources.list.spsc /etc/apt/sources.list 92 | # up cp /etc/resolv.conf.spsc /etc/resolv.conf 93 | # 94 | # iface work inet static 95 | # address 192.168.0.90 96 | # netmask 255.255.255.0 97 | # gateway 192.168.0.1 98 | # 99 | # up cp /etc/resolv.conf.work /etc/resolv.conf 100 | # 101 | # iface dhcp inet dhcp 102 | # 103 | # iface office inet dhcp 104 | # up cp /etc/apt/sources.list.office /etc/apt/sources.list 105 | # 106 | # iface realraum inet static 107 | # wireless_essid graz.funkfeuer.at 108 | # wireless_ap 08:CA:FF:EE:BA:BE 109 | # wireless-mode Ad-Hoc 110 | # address 10.13.0.13 111 | # netmask 255.255.255.224 112 | # gateway 10.13.0.1 113 | # dns-nameservers 83.64.208.23 114 | # 115 | ## Madwifi - http://madwifi.org/wiki/UserDocs/Distro/Debian/ConfiguringtheMadWifidevice 116 | # iface ath0 inet static 117 | # pre-up wlanconfig ath0 create wlandev wifi0 wlanmode ap 118 | # post-down wlanconfig ath0 destroy 119 | # wireless-essid my-essid 120 | # 121 | # iface home inet dhcp 122 | # wireless-mode Managed 123 | # wireless-essid secret 124 | # wpa-ssid secret 125 | # wpa-psk secret 126 | # 127 | # iface wpa inet dhcp 128 | # wpa-conf /etc/wpa_supplicant.conf 129 | # 130 | # iface nat inet static 131 | # address 10.23.42.1 132 | # netmask 255.255.255.0 133 | # up iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE 134 | # up echo "1" > /proc/sys/net/ipv4/ip_forward 135 | # 136 | # iface oldwpa inet dhcp 137 | # wireless-mode Managed 138 | # wireless-essid mikaasus 139 | # pre-up wpa_supplicant -Dwext -iipw -c/etc/wpa_supplicant.conf -B 140 | # down killall wpa_supplicant 141 | # 142 | # EOF 143 | -------------------------------------------------------------------------------- /etc/skel/.emacs: -------------------------------------------------------------------------------- 1 | ;; Filename: $HOME/.emacs 2 | ;; Purpose: configuration file for Emacs 3 | ;; Authors: grml-team (grml.org), (c) Michael Prokop 4 | ;; Bug-Reports: see http://grml.org/bugs/ 5 | ;; License: This file is licensed under the GPL v2. 6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 7 | 8 | ;; Activate UTF-8 mode: 9 | (setq locale-coding-system 'utf-8) 10 | (set-terminal-coding-system 'utf-8) 11 | (set-keyboard-coding-system 'utf-8) 12 | (set-selection-coding-system 'utf-8) 13 | (prefer-coding-system 'utf-8) 14 | 15 | ;; END OF FILE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 16 | -------------------------------------------------------------------------------- /etc/skel/.gitconfig: -------------------------------------------------------------------------------- 1 | # Filename: $HOME/.gitconfig 2 | # Purpose: configuration file for git(1) 3 | # Authors: grml-team (grml.org) 4 | # Bug-Reports: see http://grml.org/bugs/ 5 | # License: This file is licensed under the GPL v2 or any later version. 6 | ################################################################################ 7 | 8 | # Notice: We do not set user section by default so syncing 9 | # with this file is as easy as possible. Use 10 | # GIT_AUTHOR_NAME, GIT_COMMITTER_NAME, GIT_AUTHOR_EMAIL and 11 | # GIT_COMMITTER_EMAIL via your shell environment instead. 12 | #[user] 13 | # name = Grml User 14 | # email = git@grml.org 15 | 16 | [format] 17 | numbered = auto 18 | 19 | [color] 20 | branch = yes 21 | diff = auto 22 | pager = yes 23 | status = auto 24 | 25 | #[color "branch"] 26 | # current = green 27 | # local = yellow 28 | # remote = cyan 29 | # 30 | #[color "diff"] 31 | # meta = yellow 32 | # frag = magenta 33 | # old = red 34 | # new = green 35 | # 36 | #[color "status"] 37 | # header = magenta 38 | # added = yellow 39 | # changed = green 40 | # untracked = cyan 41 | 42 | #[gui] 43 | # fontui = -family terminus -size 9 -weight normal -slant roman -underline 0 -overstrike 0 44 | # fontdiff = -family terminus -size 9 -weight normal -slant roman -underline 0 -overstrike 0 45 | # editor = gvim 46 | 47 | [svn] 48 | rmdir = true 49 | 50 | #[http] 51 | # sslVerify=false 52 | 53 | [alias] 54 | b = branch 55 | ca = commit -a 56 | chgd = diff HEAD 57 | ci = commit 58 | co = checkout 59 | fpu = format-patch -s -p origin/master 60 | graphviz = "!f() { echo 'digraph git {' ; git log --pretty='format: %h -> { %p }' \"$@\" | sed 's/[0-9a-f]\\+/\"&\"/g' ; echo '}'; }; f" 61 | m = checkout master 62 | mnc = merge --no-commit 63 | olg = log --abbrev-commit --abbrev=6 --pretty=oneline 64 | one = "!sh -c 'git show -s --pretty=\"tformat:%h (%s, %ai\" \"$@\" | sed -e \"s/ [012][0-9]:[0-5][0-9]:[0-5][0-9] [-+][0-9][0-9][0-9][0-9]$/)/\"' -" 65 | out = !git push --dry-run 66 | purge = !git checkout $(git rev-parse --show-cdup) && git clean -xdf 67 | serve = !sh -c 'git daemon --reuseaddr --verbose \"$@\" --base-path=. --export-all ./.git' sh 68 | stgd = diff --cached 69 | st = status 70 | tagme = !sh -c '[ -z "$1" ] && exit 1 || git tag -s v\"$1\" -m \"release \"$1\"\"' sh 71 | tush = push --tags 72 | who = "!sh -c 'git log -1 --pretty=\"format:%an <%ae>\" --author=\"$1\"' -" 73 | 74 | #[sendemail] 75 | # aliasesfile = /home/grml/.gitaliases 76 | # aliasfiletype = mutt 77 | # chainreplyto = false 78 | # smtpserver = /usr/bin/msmtp 79 | 80 | ## END OF FILE ################################################################# 81 | # vim:tabstop=4 autoindent filetype=gitconfig expandtab 82 | -------------------------------------------------------------------------------- /etc/skel/.hgrc: -------------------------------------------------------------------------------- 1 | # Filename: $HOME/.hgrc 2 | # Purpose: configuration file for mercurial 3 | # Authors: grml-team (grml.org), (c) Michael Prokop 4 | # Bug-Reports: see http://grml.org/bugs/ 5 | # License: This file is licensed under the GPL v2. 6 | ################################################################################ 7 | 8 | # See 'man 5 hgrc' and http://www.selenic.com/mercurial/hgrc.5.html 9 | # for more details about possibilities for configuration of mercurial. 10 | 11 | [ui] 12 | username = grml User 13 | # debug = true 14 | # verbose = true 15 | # merge = hgmergevim 16 | 17 | # useful for patchbomb extension (e.g.: 'hg email -t grml@localhost tip') 18 | [email] 19 | from = grml User 20 | method = /usr/sbin/sendmail 21 | 22 | # Extension stuff, see /etc/mercurial/hgrc.d/hgext.rc 23 | # and http://www.selenic.com/mercurial/wiki/index.cgi/ExtensionHowto 24 | 25 | [extensions] 26 | 27 | # Hooks to control commit access to parts of a tree. 28 | # acl=/usr/share/python-support/mercurial/hgext/acl.py 29 | 30 | # Update Bugzilla bugs when changesets mention them (> 0.9-1). 31 | # bugzilla = /home/grml/mercurial-snapshot/hgext/bugzilla.py 32 | 33 | # Graph amount of code changed per author over time (> 0.9-1). 34 | # churn = /home/grml/mercurial-snapshot/contrib/churn.py 35 | # churn = 36 | 37 | # Extension for using an external program to diff repository (or 38 | # selected files). Available in 0.9.1. 39 | # extdiff=/usr/share/python-support/mercurial/hgext/extdiff.py 40 | hgext.extdiff= 41 | 42 | # Convenience wrapper for pulling and merging. 43 | # fetch = 44 | 45 | # Extension that provides commands to help working with trees 46 | # composed of many Mercurial repositories. See 47 | # http://www.terminus.org/hg/hgforest 48 | # forest = 49 | 50 | # Extension for signing and checking signatures. 51 | # gpg=/usr/share/python-support/mercurial/hgext/gpg.py 52 | # gpg= 53 | 54 | # Extension for binary searching in O(log2(n)) for the changeset 55 | # introducing a (mis)feature, see 56 | # http://www.selenic.com/mercurial/wiki/index.cgi/UsingBisect 57 | # hbisect=/usr/share/python-support/mercurial/hgext/hbisect.py 58 | 59 | # Graphical gitk-like repository browser, invoked with hg view. 60 | # hgk=/usr/share/python-support/mercurial/hgext/hgk.py 61 | 62 | # Mercurial Queue management extension - see 63 | # http://www.selenic.com/mercurial/wiki/index.cgi/MqExtension 64 | # mq=/usr/share/python-support/mercurial/hgext/mq.py 65 | 66 | # Template-driven email notifications, see 67 | # http://www.selenic.com/mercurial/wiki/index.cgi/NotifyExtension 68 | # notify=/usr/share/python-support/mercurial/hgext/notify.py 69 | # hgext.notify = 70 | 71 | # Extension providing the hg email command for sending a collection of 72 | # Mercurial changesets as a series of patch emails. 73 | # patchbomb=/usr/share/python-support/mercurial/hgext/patchbomb.py 74 | 75 | # Cherry-picking, rebasing and changeset rewriting - see 76 | # http://www.selenic.com/mercurial/wiki/index.cgi/TransplantExtension 77 | # transplant = 78 | 79 | # Extension for line ending conversion filters for the Windows platform. 80 | # win32text=/usr/share/python-support/mercurial/hgext/win32text.py 81 | 82 | [extdiff] 83 | # DirDiff script for Vim: http://www.vim.org/scripts/script.php?script_id=102 84 | # wget http://www.vim.org/scripts/download_script.php?src_id=5306 -O ~/.vim/plugin/DirDiff.vim 85 | # Notice: opts.* works only in Mercurial >0.9.1, use hgvimdiff as wrapper therefore 86 | cmd.vimdiff=/usr/bin/hgvimdiff 87 | # cmd.vimdiff=/usr/bin/vim.basic 88 | # opts.vimdiff=-f '+next' '+execute "DirDiff" argv(0) argv(1)' 89 | 90 | # vim: ft=config 91 | -------------------------------------------------------------------------------- /etc/skel/.vim/ftplugin/c.vim: -------------------------------------------------------------------------------- 1 | " Filename: c.vim 2 | " Purpose: configuration file for c programming with Vim 3 | " Authors: grml-team (grml.org), (c) Michael Prokop , Bart Trojanowski 4 | " Bug-Reports: see http://grml.org/bugs/ 5 | """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 6 | " This file is heavily based on Bart's blog entry 7 | " "vim and linux CodingStyle" => http://jukie.net/~bart/blog/20070209172606 8 | 9 | " some general options 10 | set noexpandtab " use tabse, not spaces 11 | set tabstop=8 " tabstops of 8 12 | set shiftwidth=8 " indents of 8 13 | set textwidth=78 " screen in 80 columns wide, wrap at 78 14 | set autoindent smartindent " turn on auto/smart indenting 15 | set smarttab " make and smarter 16 | set backspace=eol,start,indent " allow backspacing over indent, eol, & start 17 | set foldmethod=syntax " syntax highlighting items specify folds 18 | 19 | " keybindings 20 | nmap vip= " forces (re)indentation of a block of code 21 | " imap if( if () {}k$2hi 22 | " imap ife( :call IfElse()a 23 | " imap while( while () {}k$2hi 24 | " imap switch( switch () {default:break;}3k$2hi 25 | " imap do{ :call DoWhile()a 26 | " imap for( for (;;) {}k$3hi 27 | 28 | " Edit compile speedup (hotkeys) 29 | " --------- start info ----------------- 30 | " F2 - update file without confirmation 31 | " F3 - file open dialog 32 | " F5 - calls manual of function 33 | " F6 - list all errors 34 | " F7 - display previous error 35 | " F8 - display next error 36 | " --------- end info ------------------- 37 | map :update 38 | map :browse confirm e 39 | map :! man 40 | map :copen 41 | map :cp 42 | map :cn 43 | 44 | " abbreviations... 45 | abb #i #include 46 | abb #d #define 47 | abb #f #ifdef 48 | abb #n #endif 49 | " iab ,I if(){}kk$i 50 | " iab ,F for(;;){}kk$hhi 51 | " iab ,E else{}O 52 | 53 | " syntax highlighting 54 | syntax on 55 | syn keyword cType uint ubyte ulong uint64_t uint32_t uint16_t uint8_t boolean_t int64_t int32_t int16_t int8_t u_int64_t u_int32_t u_int16_t u_int8_t 56 | syn keyword cOperator likely unlikely 57 | syn match ErrorLeadSpace /^ \+/ " highlight any leading spaces 58 | syn match ErrorTailSpace / \+$/ " highlight any trailing spaces 59 | 60 | " C-mode formatting options 61 | " t auto-wrap comment 62 | " c allows textwidth to work on comments 63 | " q allows use of gq* for auto formatting 64 | " l don't break long lines in insert mode 65 | " r insert '*' on 66 | " o insert '*' on newline with 'o' 67 | " n recognize numbered lists 68 | set formatoptions=tcqlron 69 | 70 | " C-mode options (cinoptions==cino) 71 | " N number of spaces 72 | " Ns number of spaces * shiftwidth 73 | " >N default indent 74 | " eN extra indent if the { is at the end of a line 75 | " nN extra indent if there is no {} block 76 | " fN indent of the { of a function block 77 | " gN indent of the C++ class scope declarations (public, private, protected) 78 | " {N indent of a { on a new line after an if,while,for... 79 | " }N indent of a } in reference to a { 80 | " ^N extra indent inside a function {} 81 | " :N indent of case labels 82 | " =N indent of case body 83 | " lN align case {} on the case line 84 | " tN indent of function return type 85 | " +N indent continued algibreic expressions 86 | " cN indent of comment line after /* 87 | " )N vim searches for closing )'s at most N lines away 88 | " *N vim searches for closing */ at most N lines away 89 | set cinoptions=:0l1t0g0 90 | 91 | " folding 92 | " - reserve 4 columns on the left for folding tree 93 | " - fold by syntax, use {}'s 94 | " - start with all folds open 95 | if winwidth(0) > 80 96 | set foldcolumn=4 97 | endif 98 | 99 | " EOF 100 | -------------------------------------------------------------------------------- /etc/skel/.vim/klammerpaare.vim: -------------------------------------------------------------------------------- 1 | syn region klammer10a matchgroup=KLAMMER10a start='\[' end='\]' contained 2 | syn region klammer10b matchgroup=KLAMMER10a start='{' end='}' contained 3 | syn region klammer9a matchgroup=KLAMMER9a start='\[' end='\]' contained contains=klammer10a,klammer10b 4 | syn region klammer9b matchgroup=KLAMMER9a start='{' end='}' contained contains=klammer10a,klammer10b 5 | syn region klammer8a matchgroup=KLAMMER8a start='\[' end='\]' contained contains=klammer9a,klammer9b 6 | syn region klammer8b matchgroup=KLAMMER8a start='{' end='}' contained contains=klammer9a,klammer9b 7 | syn region klammer7a matchgroup=KLAMMER7a start='\[' end='\]' contained contains=klammer8a,klammer8b 8 | syn region klammer7b matchgroup=KLAMMER7a start='{' end='}' contained contains=klammer8a,klammer8b 9 | syn region klammer6a matchgroup=KLAMMER6a start='\[' end='\]' contained contains=klammer7a,klammer7b 10 | syn region klammer6b matchgroup=KLAMMER6a start='{' end='}' contained contains=klammer7a,klammer7b 11 | syn region klammer5a matchgroup=KLAMMER5a start='\[' end='\]' contained contains=klammer6a,klammer6b 12 | syn region klammer5b matchgroup=KLAMMER5a start='{' end='}' contained contains=klammer6a,klammer6b 13 | syn region klammer4a matchgroup=KLAMMER4a start='\[' end='\]' contained contains=klammer5a,klammer5b 14 | syn region klammer4b matchgroup=KLAMMER4a start='{' end='}' contained contains=klammer5a,klammer5b 15 | syn region klammer3a matchgroup=KLAMMER3a start='\[' end='\]' contained contains=klammer4a,klammer4b 16 | syn region klammer3b matchgroup=KLAMMER3a start='{' end='}' contained contains=klammer4a,klammer4b 17 | syn region klammer2a matchgroup=KLAMMER2a start='\[' end='\]' contained contains=klammer3a,klammer3b 18 | syn region klammer2b matchgroup=KLAMMER2a start='{' end='}' contained contains=klammer3a,klammer3b 19 | syn region klammer1a matchgroup=KLAMMER1a start='\[' end='\]' contains=klammer2a,klammer2b 20 | syn region klammer1b matchgroup=KLAMMER1a start='{' end='}' contains=klammer2a,klammer2b 21 | 22 | hi klammer1a ctermfg=Red ctermbg=Black guifg=Red guibg=Black 23 | hi klammer1b ctermfg=Red ctermbg=Black guifg=Red guibg=Black 24 | hi KLAMMER1b ctermfg=Red ctermbg=Black guifg=Red guibg=Black 25 | 26 | hi klammer2a ctermfg=Green ctermbg=Black guifg=Green guibg=Black 27 | hi klammer2b ctermfg=Green ctermbg=Black guifg=Green guibg=Black 28 | hi KLAMMER2b ctermfg=Green ctermbg=Black guifg=Green guibg=Black 29 | 30 | hi klammer3a ctermfg=Cyan ctermbg=Black guifg=Cyan guibg=Black 31 | hi klammer3b ctermfg=Cyan ctermbg=Black guifg=Cyan guibg=Black 32 | hi KLAMMER3b ctermfg=Cyan ctermbg=Black guifg=Cyan guibg=Black 33 | 34 | hi klammer4a ctermfg=Yellow ctermbg=Black guifg=Yellow guibg=Black 35 | hi klammer4b ctermfg=Yellow ctermbg=Black guifg=Yellow guibg=Black 36 | hi KLAMMER4b ctermfg=Yellow ctermbg=Black guifg=Yellow guibg=Black 37 | 38 | hi klammer5a ctermfg=Magenta ctermbg=Black guifg=Magenta guibg=Black 39 | hi klammer5b ctermfg=Magenta ctermbg=Black guifg=Magenta guibg=Black 40 | hi KLAMMER5b ctermfg=Magenta ctermbg=Black guifg=Magenta guibg=Black 41 | 42 | hi klammer6a ctermfg=Darkred ctermbg=Black guifg=Darkred guibg=Black 43 | hi klammer6b ctermfg=Darkred ctermbg=Black guifg=Darkred guibg=Black 44 | hi KLAMMER6b ctermfg=Darkred ctermbg=Black guifg=Darkred guibg=Black 45 | 46 | hi klammer7a ctermfg=Darkgreen ctermbg=Black guifg=Darkgreen guibg=Black 47 | hi klammer7b ctermfg=Darkgreen ctermbg=Black guifg=Darkgreen guibg=Black 48 | hi KLAMMER7b ctermfg=Darkgreen ctermbg=Black guifg=Darkgreen guibg=Black 49 | 50 | hi klammer8a ctermfg=Darkcyan ctermbg=Black guifg=Darkcyan guibg=Black 51 | hi klammer8b ctermfg=Darkcyan ctermbg=Black guifg=Darkcyan guibg=Black 52 | hi KLAMMER8b ctermfg=Darkcyan ctermbg=Black guifg=Darkcyan guibg=Black 53 | 54 | hi klammer9a ctermfg=Darkyellow ctermbg=Black guifg=Darkyellow guibg=Black 55 | hi klammer9b ctermfg=Darkyellow ctermbg=Black guifg=Darkyellow guibg=Black 56 | hi KLAMMER9b ctermfg=Darkyellow ctermbg=Black guifg=Darkyellow guibg=Black 57 | 58 | hi klammer10a ctermfg=Darkmagenta ctermbg=Black guifg=Darkmagenta guibg=Black 59 | hi klammer10b ctermfg=Darkmagenta ctermbg=Black guifg=Darkmagenta guibg=Black 60 | hi KLAMMER10b ctermfg=Darkmagenta ctermbg=Black guifg=Darkmagenta guibg=Black 61 | 62 | syn sync minlines=300 63 | -------------------------------------------------------------------------------- /etc/skel/.vim/spellfile.add: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grml/grml-etc-core/4802508f32e118b54128d72a59be062c48d18d9c/etc/skel/.vim/spellfile.add -------------------------------------------------------------------------------- /etc/skel/.zshrc: -------------------------------------------------------------------------------- 1 | # Filename: /etc/skel/.zshrc 2 | # Purpose: config file for zsh (z shell) 3 | # Authors: (c) grml-team (grml.org) 4 | # Bug-Reports: see http://grml.org/bugs/ 5 | # License: This file is licensed under the GPL v2 or any later version. 6 | ################################################################################ 7 | # Nowadays, grml's zsh setup lives in only *one* zshrc file. 8 | # That is the global one: /etc/zsh/zshrc (from grml-etc-core). 9 | # It is best to leave *this* file untouched and do personal changes to 10 | # your zsh setup via ${HOME}/.zshrc.local which is loaded at the end of 11 | # the global zshrc. 12 | # 13 | # That way, we enable people on other operating systems to use our 14 | # setup, too, just by copying our global zshrc to their ${HOME}/.zshrc. 15 | # Adjustments would still go to the .zshrc.local file. 16 | ################################################################################ 17 | 18 | ## Inform users about upgrade path for grml's old zshrc layout, assuming that: 19 | ## /etc/skel/.zshrc was installed as ~/.zshrc, 20 | ## /etc/zsh/zshrc was installed as ~/.zshrc.global and 21 | ## ~/.zshrc.local does not exist yet. 22 | if [ -r ~/.zshrc -a -r ~/.zshrc.global -a ! -r ~/.zshrc.local ] ; then 23 | printf '-!-\n' 24 | printf '-!- Looks like you are using the old zshrc layout of grml.\n' 25 | printf '-!- Please read the notes in the grml-zsh-refcard, being' 26 | printf '-!- available at: http://grml.org/zsh/\n' 27 | printf '-!-\n' 28 | printf '-!- If you just want to get rid of this warning message execute:\n' 29 | printf '-!- touch ~/.zshrc.local\n' 30 | printf '-!-\n' 31 | fi 32 | 33 | ## Settings for umask 34 | #if (( EUID == 0 )); then 35 | # umask 002 36 | #else 37 | # umask 022 38 | #fi 39 | 40 | ## Now, we'll give a few examples of what you might want to use in your 41 | ## .zshrc.local file (just copy'n'paste and uncomment it there): 42 | 43 | ## Prompt theme extension ## 44 | 45 | # Virtualenv support 46 | 47 | #function virtual_env_prompt () { 48 | # REPLY=${VIRTUAL_ENV+(${VIRTUAL_ENV:t}) } 49 | #} 50 | #grml_theme_add_token virtual-env -f virtual_env_prompt '%F{magenta}' '%f' 51 | #zstyle ':prompt:grml:left:setup' items rc virtual-env change-root user at host path vcs percent 52 | 53 | ## ZLE tweaks ## 54 | 55 | ## use the vi navigation keys (hjkl) besides cursor keys in menu completion 56 | #bindkey -M menuselect 'h' vi-backward-char # left 57 | #bindkey -M menuselect 'k' vi-up-line-or-history # up 58 | #bindkey -M menuselect 'l' vi-forward-char # right 59 | #bindkey -M menuselect 'j' vi-down-line-or-history # bottom 60 | 61 | ## set command prediction from history, see 'man 1 zshcontrib' 62 | #is4 && zrcautoload predict-on && \ 63 | #zle -N predict-on && \ 64 | #zle -N predict-off && \ 65 | #bindkey "^X^Z" predict-on && \ 66 | #bindkey "^Z" predict-off 67 | 68 | ## press ctrl-q to quote line: 69 | #mquote () { 70 | # zle beginning-of-line 71 | # zle forward-word 72 | # # RBUFFER="'$RBUFFER'" 73 | # RBUFFER=${(q)RBUFFER} 74 | # zle end-of-line 75 | #} 76 | #zle -N mquote && bindkey '^q' mquote 77 | 78 | ## define word separators (for stuff like backward-word, forward-word, backward-kill-word,..) 79 | #WORDCHARS='*?_-.[]~=/&;!#$%^(){}<>' # the default 80 | #WORDCHARS=. 81 | #WORDCHARS='*?_[]~=&;!#$%^(){}' 82 | #WORDCHARS='${WORDCHARS:s@/@}' 83 | 84 | # just type '...' to get '../..' 85 | #rationalise-dot() { 86 | #local MATCH 87 | #if [[ $LBUFFER =~ '(^|/| | |'$'\n''|\||;|&)\.\.$' ]]; then 88 | # LBUFFER+=/ 89 | # zle self-insert 90 | # zle self-insert 91 | #else 92 | # zle self-insert 93 | #fi 94 | #} 95 | #zle -N rationalise-dot 96 | #bindkey . rationalise-dot 97 | ## without this, typing a . aborts incremental history search 98 | #bindkey -M isearch . self-insert 99 | 100 | #bindkey '\eq' push-line-or-edit 101 | 102 | ## some popular options ## 103 | 104 | ## add `|' to output redirections in the history 105 | #setopt histallowclobber 106 | 107 | ## try to avoid the 'zsh: no matches found...' 108 | #setopt nonomatch 109 | 110 | ## warning if file exists ('cat /dev/null > ~/.zshrc') 111 | #setopt NO_clobber 112 | 113 | ## don't warn me about bg processes when exiting 114 | #setopt nocheckjobs 115 | 116 | ## alert me if something failed 117 | #setopt printexitvalue 118 | 119 | ## with spelling correction, assume dvorak kb 120 | #setopt dvorak 121 | 122 | ## Allow comments even in interactive shells 123 | #setopt interactivecomments 124 | 125 | ## if a new command line being added to the history list duplicates an older 126 | ## one, the older command is removed from the list 127 | #is4 && setopt histignorealldups 128 | 129 | ## compsys related snippets ## 130 | 131 | ## changed completer settings 132 | #zstyle ':completion:*' completer _complete _correct _approximate 133 | #zstyle ':completion:*' expand prefix suffix 134 | 135 | ## another different completer setting: expand shell aliases 136 | #zstyle ':completion:*' completer _expand_alias _complete _approximate 137 | 138 | ## to have more convenient account completion, specify your logins: 139 | #my_accounts=( 140 | # {grml,grml1}@foo.invalid 141 | # grml-devel@bar.invalid 142 | #) 143 | #other_accounts=( 144 | # {fred,root}@foo.invalid 145 | # vera@bar.invalid 146 | #) 147 | #zstyle ':completion:*:my-accounts' users-hosts $my_accounts 148 | #zstyle ':completion:*:other-accounts' users-hosts $other_accounts 149 | 150 | ## add grml.org to your list of hosts 151 | #hosts+=(grml.org) 152 | #zstyle ':completion:*:hosts' hosts $hosts 153 | 154 | ## telnet on non-default ports? ...well: 155 | ## specify specific port/service settings: 156 | #telnet_users_hosts_ports=( 157 | # user1@host1: 158 | # user2@host2: 159 | # @mail-server:{smtp,pop3} 160 | # @news-server:nntp 161 | # @proxy-server:8000 162 | #) 163 | #zstyle ':completion:*:*:telnet:*' users-hosts-ports $telnet_users_hosts_ports 164 | 165 | ## the default grml setup provides '..' as a completion. it does not provide 166 | ## '.' though. If you want that too, use the following line: 167 | #zstyle ':completion:*' special-dirs true 168 | 169 | ## aliases ## 170 | 171 | ## translate 172 | #alias u='translate -i' 173 | 174 | ## ignore ~/.ssh/known_hosts entries 175 | #alias insecssh='ssh -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null" -o "PreferredAuthentications=keyboard-interactive"' 176 | 177 | 178 | ## global aliases (for those who like them) ## 179 | 180 | #alias -g '...'='../..' 181 | #alias -g '....'='../../..' 182 | #alias -g BG='& exit' 183 | #alias -g C='|wc -l' 184 | #alias -g G='|grep' 185 | #alias -g H='|head' 186 | #alias -g Hl=' --help |& less -r' 187 | #alias -g J='|jq' 188 | #alias -g K='|keep' 189 | #alias -g L='|less' 190 | #alias -g LL='|& less -r' 191 | #alias -g M='|most' 192 | #alias -g N='&>/dev/null' 193 | #alias -g R='| tr A-z N-za-m' 194 | #alias -g SL='| sort | less' 195 | #alias -g S='| sort' 196 | #alias -g T='|tail' 197 | #alias -g TS='|ts "%F %H:%M:%.S"' 198 | #alias -g V='| vim -' 199 | 200 | ## instead of global aliase it might be better to use grmls $abk assoc array, whose contents are expanded after pressing ,. 201 | #$abk[SnL]="| sort -n | less" 202 | 203 | ## get top 10 shell commands: 204 | #alias top10='print -l ${(o)history%% *} | uniq -c | sort -nr | head -n 10' 205 | 206 | ## Execute \kbd{./configure} 207 | #alias CO="./configure" 208 | 209 | ## Execute \kbd{./configure --help} 210 | #alias CH="./configure --help" 211 | 212 | ## miscellaneous code ## 213 | 214 | ## Use a default width of 80 for manpages for more convenient reading 215 | #export MANWIDTH=${MANWIDTH:-80} 216 | 217 | ## Set a search path for the cd builtin 218 | #cdpath=(.. ~) 219 | 220 | ## variation of our manzsh() function; pick you poison: 221 | #manzsh() { /usr/bin/man zshall | most +/"$1" ; } 222 | 223 | ## Switching shell safely and efficiently? http://www.zsh.org/mla/workers/2001/msg02410.html 224 | #bash() { 225 | # NO_SWITCH="yes" command bash "$@" 226 | #} 227 | #restart () { 228 | # exec $SHELL $SHELL_ARGS "$@" 229 | #} 230 | 231 | ## Handy functions for use with the (e::) globbing qualifier (like nt) 232 | #contains() { grep -q "$*" $REPLY } 233 | #sameas() { diff -q "$*" $REPLY &>/dev/null } 234 | #ot () { [[ $REPLY -ot ${~1} ]] } 235 | 236 | ## get_ic() - queries imap servers for capabilities; real simple. no imaps 237 | #ic_get() { 238 | # emulate -L zsh 239 | # local port 240 | # if [[ ! -z $1 ]] ; then 241 | # port=${2:-143} 242 | # print "querying imap server on $1:${port}...\n"; 243 | # print "a1 capability\na2 logout\n" | nc $1 ${port} 244 | # else 245 | # print "usage:\n $0 [port]" 246 | # fi 247 | #} 248 | 249 | ## List all occurrences of programm in current PATH 250 | #plap() { 251 | # emulate -L zsh 252 | # if [[ $# = 0 ]] ; then 253 | # echo "Usage: $0 program" 254 | # echo "Example: $0 zsh" 255 | # echo "Lists all occurrences of program in the current PATH." 256 | # else 257 | # ls -l ${^path}/*$1*(*N) 258 | # fi 259 | #} 260 | 261 | ## Find out which libs define a symbol 262 | #lcheck() { 263 | # if [[ -n "$1" ]] ; then 264 | # nm -go /usr/lib/lib*.a 2>/dev/null | grep ":[[:xdigit:]]\{8\} . .*$1" 265 | # else 266 | # echo "Usage: lcheck " >&2 267 | # fi 268 | #} 269 | 270 | ## Download a file and display it locally 271 | #uopen() { 272 | # emulate -L zsh 273 | # if ! [[ -n "$1" ]] ; then 274 | # print "Usage: uopen \$URL/\$file">&2 275 | # return 1 276 | # else 277 | # FILE=$1 278 | # MIME=$(curl --head $FILE | \ 279 | # grep Content-Type | \ 280 | # cut -d ' ' -f 2 | \ 281 | # cut -d\; -f 1) 282 | # MIME=${MIME%$'\r'} 283 | # curl $FILE | see ${MIME}:- 284 | # fi 285 | #} 286 | 287 | ## Memory overview 288 | #memusage() { 289 | # ps aux | awk '{if (NR > 1) print $5; 290 | # if (NR > 2) print "+"} 291 | # END { print "p" }' | dc 292 | #} 293 | 294 | ## print hex value of a number 295 | #hex() { 296 | # emulate -L zsh 297 | # if [[ -n "$1" ]]; then 298 | # printf "%x\n" $1 299 | # else 300 | # print 'Usage: hex ' 301 | # return 1 302 | # fi 303 | #} 304 | 305 | ## log out? set timeout in seconds... 306 | ## ...and do not log out in some specific terminals: 307 | #if [[ "${TERM}" == ([Exa]term*|rxvt|dtterm|screen*) ]] ; then 308 | # unset TMOUT 309 | #else 310 | # TMOUT=1800 311 | #fi 312 | 313 | ## associate types and extensions (be aware with perl scripts and anwanted behaviour!) 314 | #check_com zsh-mime-setup || { autoload zsh-mime-setup && zsh-mime-setup } 315 | #alias -s pl='perl -S' 316 | 317 | ## ctrl-s will no longer freeze the terminal. 318 | #stty erase "^?" 319 | 320 | ## you want to automatically use a bigger font on big terminals? 321 | #if [[ "$TERM" == "xterm" ]] && [[ "$LINES" -ge 50 ]] && [[ "$COLUMNS" -ge 100 ]] && [[ -z "$SSH_CONNECTION" ]] ; then 322 | # large 323 | #fi 324 | 325 | ## Some quick Perl-hacks aka /useful/ oneliner 326 | #bew() { perl -le 'print unpack "B*","'$1'"' } 327 | #web() { perl -le 'print pack "B*","'$1'"' } 328 | #hew() { perl -le 'print unpack "H*","'$1'"' } 329 | #weh() { perl -le 'print pack "H*","'$1'"' } 330 | #pversion() { perl -M$1 -le "print $1->VERSION" } # i. e."pversion LWP -> 5.79" 331 | #getlinks () { perl -ne 'while ( m/"((www|ftp|http):\/\/.*?)"/gc ) { print $1, "\n"; }' $* } 332 | #gethrefs () { perl -ne 'while ( m/href="([^"]*)"/gc ) { print $1, "\n"; }' $* } 333 | #getanames () { perl -ne 'while ( m/a name="([^"]*)"/gc ) { print $1, "\n"; }' $* } 334 | #getforms () { perl -ne 'while ( m:(\):gic ) { print $1, "\n"; }' $* } 335 | #getstrings () { perl -ne 'while ( m/"(.*?)"/gc ) { print $1, "\n"; }' $*} 336 | #getanchors () { perl -ne 'while ( m/«([^«»\n]+)»/gc ) { print $1, "\n"; }' $* } 337 | #showINC () { perl -e 'for (@INC) { printf "%d %s\n", $i++, $_ }' } 338 | #vimpm () { vim `perldoc -l $1 | sed -e 's/pod$/pm/'` } 339 | #vimhelp () { vim -c "help $1" -c on -c "au! VimEnter *" } 340 | 341 | ## END OF FILE ################################################################# 342 | -------------------------------------------------------------------------------- /etc/tmux.conf: -------------------------------------------------------------------------------- 1 | # Filename: /etc/tmux 2 | # Purpose: configuration file for tmux 3 | # Authors: grml-team (grml.org), (c) Michael Prokop , 4 | # Sebastian Boehm 5 | # Bernhard Tittelbach 6 | # Bug-Reports: see http://grml.org/bugs/ 7 | # License: This file is licensed under the GPL v2. 8 | ################################################################################ 9 | 10 | ### screen-like keybindings 11 | unbind C-b 12 | set -g prefix C-a 13 | bind-key a send-prefix 14 | bind-key C-a last-window 15 | unbind space 16 | bind-key space next-window 17 | bind-key C-space next-window 18 | bind-key K confirm-before kill-pane 19 | bind-key '\' confirm-before kill-session 20 | #bind-key C-h previous-window 21 | 22 | ### join the last active pane to the currently active window 23 | bind-key j join-pane -s ! 24 | 25 | ### join the marked pane to the currently active window 26 | ### ('bind-key m select-pane -m' is default to mark the current pane) 27 | bind-key J join-pane 28 | 29 | ### Move current window to session named "bg" (and create session if it does not exist) 30 | bind-key B if-shell "! tmux has-session -t bg" "new-session -d -s bg" \; move-window -t bg 31 | 32 | ### Reload Config 33 | if-shell "! (env | grep -q TMUX=/tmp/tmate)" \ 34 | "bind-key R source-file ~/.tmux.conf \\; source-file -q ~/.tmux.conf.local \\; display-message '~/.tmux.conf[.local] reloaded'" 35 | 36 | ###rebind keys 37 | bind-key h next-layout 38 | bind-key BSpace previous-window 39 | 40 | bind-key tab select-pane -t :.+ 41 | ### useful custom keybindings 42 | bind-key | command-prompt -p "exec:" "split-window -h '%%'" 43 | bind-key - command-prompt -p "exec:" "split-window -v '%%'" 44 | 45 | ### misc options 46 | set -s escape-time 0 47 | set -g default-terminal "screen-256color" 48 | set -g display-panes-time 3000 49 | set -g visual-activity on 50 | set -g mode-keys vi 51 | 52 | ### set status line appearance 53 | set -g status-style fg=white,bg=black 54 | 55 | set -g status-left-length 28 56 | ### status-left: @hostname:sessionname 57 | set -g status-left "#[fg=white]@#h#[fg=red]:#S#[fg=white] |" 58 | ### status-left: username@hostname:sessionname 59 | #set -g status-left "#[fg=blue]#(echo ${USER})#[fg=white]@#h#[fg=red]:#S#[fg=white] |" 60 | 61 | ### status-right: Date and Time 62 | #set -g status-right-length 16 63 | #set -g status-right '#[fg=yellow]%Y-%m-%d %H:%M' 64 | ### status-right: IPs and Date and Time 65 | if-shell "command -v hostname && hostname --help | grep -q -- -I" { set -g status-right "#[fg=green](net: #(hostname -I | sed -e 's/ [^ ]*:.*$//;s/ / | /g;s/ | $//')) #[fg=yellow]%Y-%m-%d %H:%M" } { set -g status-right '#[fg=yellow]%Y-%m-%d %H:%M' } 66 | ### status-right: Time 67 | #set -g status-right-length 6 68 | #set -g status-right "#[fg=yellow]%H:%M" 69 | 70 | set-window-option -g window-status-style fg=blue,bg=black 71 | set-window-option -g window-status-current-style bold 72 | 73 | ### source user-specific local configuration file 74 | if-shell "! (env | grep -q TMUX=/tmp/tmate)" \ 75 | "source-file -q ~/.tmux.conf.local" 76 | -------------------------------------------------------------------------------- /etc/zsh/keephack: -------------------------------------------------------------------------------- 1 | # Filename: /etc/zsh/keephack 2 | # Purpose: this file belongs to the zsh setup (see /etc/zsh/zshrc) 3 | # Authors: grml-team (grml.org), (c) Michael Prokop 4 | # Bug-Reports: see http://grml.org/bugs/ 5 | # License: This file is licensed under the GPL v2. 6 | ################################################################################ 7 | 8 | # save output in a variable for later use 9 | # Written by Bart Schaefer, for more details see: 10 | # http://www.zsh.org/cgi-bin/mla/wilma_hiliter/users/2004/msg00894.html ff. 11 | function keep { 12 | setopt localoptions nomarkdirs nonomatch nocshnullglob nullglob 13 | kept=() # Erase old value in case of error on next line 14 | kept=($~*) 15 | 16 | if [[ ! -t 0 ]] ; then 17 | local line 18 | while read line; do 19 | kept+=( $line ) # += is a zsh 4.2+ feature 20 | done 21 | fi 22 | 23 | print -Rc - ${^kept%/}(T) 24 | } 25 | # use it via: 26 | # locate -i backup | grep -i thursday | keep 27 | # echo $kept 28 | # 29 | # or: 30 | # 31 | # patch < mypatch.diff 32 | # keep **/*.(orig|rej) 33 | # vim ${${kept:#*.orig}:r} 34 | # rm $kept 35 | alias keep='noglob keep' 36 | 37 | _insert_kept() { 38 | (( $#kept )) || return 1 39 | local action 40 | zstyle -s :completion:$curcontext insert-kept action 41 | 42 | if [[ -n $action ]] ; then 43 | compstate[insert]=$action 44 | elif [[ $WIDGET == *expand* ]] ; then 45 | compstate[insert]=all 46 | fi 47 | if [[ $WIDGET == *expand* ]] ; then 48 | compadd -U ${(M)kept:#${~words[CURRENT]}} 49 | else 50 | compadd -a kept 51 | fi 52 | } 53 | 54 | # now bind it to keys and enable completion 55 | zle -C insert-kept-result complete-word _generic 56 | zle -C expand-kept-result complete-word _generic 57 | zstyle ':completion:*-kept-result:*' completer _insert_kept 58 | zstyle ':completion:insert-kept-result:*' menu yes select 59 | 60 | bindkey '^Xk' insert-kept-result 61 | bindkey '^XK' expand-kept-result # shift-K to get expansion 62 | 63 | # And the "_expand_word_and_keep" replacement for _expand_word: 64 | _expand_word_and_keep() { 65 | function compadd() { 66 | local -A args 67 | zparseopts -E -A args J: 68 | if [[ $args[-J] == all-expansions ]] ; then 69 | builtin compadd -A kept "$@" 70 | kept=( ${(Q)${(z)kept}} ) 71 | fi 72 | builtin compadd "$@" 73 | } 74 | # for older versions of zsh: 75 | local result 76 | _main_complete _expand 77 | result=$? 78 | unfunction compadd 79 | return result 80 | # versions >=4.2.1 understand this: 81 | # { _main_complete _expand } always { unfunction compadd } 82 | } 83 | 84 | # This line must come after "compinit" in startup: 85 | zle -C _expand_word complete-word _expand_word_and_keep 86 | 87 | # No bindkey needed, it's already ^Xe from _expand_word 88 | zstyle ':completion:*' insert-kept menu 89 | zmodload -i zsh/complist 90 | 91 | ## END OF FILE ################################################################# 92 | # vim:filetype=zsh foldmethod=marker autoindent expandtab shiftwidth=4 93 | -------------------------------------------------------------------------------- /etc/zsh/zlogin: -------------------------------------------------------------------------------- 1 | # Filename: zlogin 2 | # Purpose: system-wide .zlogin file for zsh(1) 3 | # Authors: grml-team (grml.org), (c) Michael Prokop 4 | # Bug-Reports: see http://grml.org/bugs/ 5 | # License: This file is licensed under the GPL v2. 6 | ################################################################################ 7 | # This file is sourced only for login shells. It 8 | # should contain commands that should be executed only 9 | # in login shells. It should be used to set the terminal 10 | # type and run a series of external commands (fortune, 11 | # msgs, from, etc.) 12 | # Note that using zprofile and zlogin, you are able to 13 | # run commands for login shells before and after zshrc. 14 | # 15 | # Global Order: zshenv, zprofile, zshrc, zlogin 16 | ################################################################################ 17 | # nothing yet. 18 | ## END OF FILE ################################################################# 19 | # vim:filetype=zsh foldmethod=marker autoindent expandtab shiftwidth=4 20 | -------------------------------------------------------------------------------- /etc/zsh/zprofile: -------------------------------------------------------------------------------- 1 | # Filename: zprofile 2 | # Purpose: system-wide .zprofile file for zsh(1) 3 | # Authors: grml-team (grml.org), (c) Michael Prokop 4 | # Bug-Reports: see http://grml.org/bugs/ 5 | # License: This file is licensed under the GPL v2. 6 | ################################################################################ 7 | # This file is sourced only for login shells (i.e. shells 8 | # invoked with "-" as the first character of argv[0], and 9 | # shells invoked with the -l flag). It's read after zshenv. 10 | # 11 | # Global Order: zshenv, zprofile, zshrc, zlogin 12 | ################################################################################ 13 | # nothing yet 14 | ## END OF FILE ################################################################# 15 | # vim:filetype=zsh foldmethod=marker autoindent expandtab shiftwidth=4 16 | -------------------------------------------------------------------------------- /etc/zsh/zshenv: -------------------------------------------------------------------------------- 1 | # Filename: zshenv 2 | # Purpose: system-wide .zshenv file for zsh(1) 3 | # Authors: grml-team (grml.org), (c) Michael Prokop 4 | # Bug-Reports: see http://grml.org/bugs/ 5 | # License: This file is licensed under the GPL v2. 6 | ################################################################################ 7 | # This file is sourced on all invocations of the shell. 8 | # It is the 1st file zsh reads; it's read for every shell, 9 | # even if started with -f (setopt NO_RCS), all other 10 | # initialization files are skipped. 11 | # 12 | # This file should contain commands to set the command 13 | # search path, plus other important environment variables. 14 | # This file should not contain commands that produce 15 | # output or assume the shell is attached to a tty. 16 | # 17 | # Notice: .zshenv is the same, execpt that it's not read 18 | # if zsh is started with -f 19 | # 20 | # Global Order: zshenv, zprofile, zshrc, zlogin 21 | ################################################################################ 22 | 23 | # language settings (read in /etc/environment before /etc/default/locale as 24 | # the latter one is the default on Debian nowadays) 25 | # no xsource() here because it's only created in zshrc! (which is good) 26 | [[ -r /etc/environment ]] && source /etc/environment 27 | 28 | ## set $PATH 29 | # gentoo users have to source /etc/profile.env 30 | if [[ -r /etc/gentoo-release ]] ; then 31 | [[ -r /etc/profile.env ]] && source /etc/profile.env 32 | fi 33 | 34 | # support extra scripts/software in special directory outside of squashfs environment in live mode 35 | if [[ -f /etc/grml_cd ]] ; then 36 | [[ -r /run/live/medium/scripts ]] && ADDONS='/run/live/medium/scripts' 37 | [[ -r /etc/grml/my_path ]] && ADDONS="$(cat /etc/grml/my_path)" 38 | fi 39 | 40 | # generic $PATH handling 41 | if (( EUID != 0 )); then 42 | path=( 43 | $HOME/bin 44 | $HOME/.local/bin 45 | /usr/local/bin 46 | /usr/bin 47 | /bin 48 | /usr/local/sbin 49 | /usr/sbin 50 | /sbin 51 | /usr/local/games 52 | /usr/games 53 | "${ADDONS}" 54 | "${path[@]}" 55 | ) 56 | else 57 | path=( 58 | $HOME/bin 59 | $HOME/.local/bin 60 | /usr/local/sbin 61 | /usr/local/bin 62 | /sbin 63 | /bin 64 | /usr/sbin 65 | /usr/bin 66 | "${ADDONS}" 67 | "${path[@]}" 68 | ) 69 | fi 70 | 71 | # remove empty components to avoid '::' ending up + resulting in './' being in $PATH 72 | path=( "${path[@]:#}" ) 73 | 74 | typeset -U path 75 | 76 | # less (:=pager) options: 77 | # export LESS=C 78 | typeset -a lp; lp=( ${^path}/lesspipe(N) ) 79 | if (( $#lp > 0 )) && [[ -x $lp[1] ]] ; then 80 | export LESSOPEN="|lesspipe %s" 81 | elif [[ -x /usr/bin/lesspipe.sh ]] ; then 82 | export LESSOPEN="|lesspipe.sh %s" 83 | fi 84 | unset lp 85 | 86 | export READNULLCMD=${PAGER:-/usr/bin/pager} 87 | 88 | ## END OF FILE ################################################################# 89 | # vim:filetype=zsh foldmethod=marker autoindent expandtab shiftwidth=4 90 | -------------------------------------------------------------------------------- /usr_share_grml/zsh/completion/debian/_debian_rules: -------------------------------------------------------------------------------- 1 | #compdef debian/rules 2 | # type debian/rules inside a source package 3 | 4 | words=(make -f debian/rules) _make 5 | -------------------------------------------------------------------------------- /usr_share_grml/zsh/completion/grml/_grml-lang: -------------------------------------------------------------------------------- 1 | #compdef grml-lang 2 | 3 | compadd at ch de dvorak es fr it jp us 4 | -------------------------------------------------------------------------------- /usr_share_grml/zsh/completion/grml/_grml-tips: -------------------------------------------------------------------------------- 1 | #compdef grml-tips 2 | 3 | local db=/usr/share/grml-tips/tags 4 | local -a args 5 | 6 | if [[ ! -e $db ]]; then 7 | _message 'Tip database not found: `'$db\' 8 | return 0 9 | fi 10 | 11 | __grml-tips-tags () { 12 | local expl 13 | local -a tags 14 | 15 | tags=( ${(f)"$(<$db)"} ) 16 | _wanted tag expl 'grml-tips tag' compadd ${expl} -- ${tags} 17 | } 18 | 19 | args=( '--help[Display help message]' 20 | '--tagsonly[Match only by tag, not by pattern]' 21 | '--tipsfile[Use non-default tips-file]:_path_files' 22 | '*::grml-tips tag:__grml-tips-tags' ) 23 | 24 | _arguments $args 25 | -------------------------------------------------------------------------------- /usr_share_grml/zsh/completion/grml/_grml-wallpaper: -------------------------------------------------------------------------------- 1 | #compdef grml-wallpaper 2 | 3 | local -a dirs 4 | 5 | dirs=(. /usr/share/grml/) 6 | _description files expl 'set desktop wallpaper on grml system' 7 | _files "$expl[@]" -W dirs -g '*.{jpg,png}(-.)' 8 | -------------------------------------------------------------------------------- /usr_share_grml/zsh/completion/linux/_fbset: -------------------------------------------------------------------------------- 1 | #compdef fbset 2 | # simple completion for fbset (switch resolution on console) 3 | 4 | fb_modes=( 5 | 640x480-60 640x480-72 640x480-75 640x480-90 640x480-100 6 | 768x576-75 7 | 800x600-48-lace 800x600-56 800x600-60 800x600-70 800x600-72 800x600-75 800x600-90 800x600-100 8 | 1024x768-43-lace 1024x768-60 1024x768-70 1024x768-72 1024x768-75 1024x768-90 1024x768-100 9 | 1152x864-43-lace 1152x864-47-lace 1152x864-60 1152x864-70 1152x864-75 1152x864-80 10 | 1280x960-75-8 1280x960-75 1280x960-75-32 11 | 1280x1024-43-lace 1280x1024-47-lace 1280x1024-60 1280x1024-70 1280x1024-74 1280x1024-75 12 | 1600x1200-60 1600x1200-66 1600x1200-76 13 | ) 14 | 15 | compadd ${fb_modes} 16 | -------------------------------------------------------------------------------- /usr_share_grml/zsh/completion/linux/_iwconfig: -------------------------------------------------------------------------------- 1 | #compdef iwconfig 2 | 3 | _wlan_interfaces() { 4 | local intf 5 | intf=$(iwconfig |& grep -E 'IEEE 802.11[abg]' | cut -d' ' -f1 | tr ' ' \\n ) 6 | # intf=$( grep -F ': ' < /proc/net/wireless | cut -d: -f1 | tr \\n ' ' | tr -s " \t" ) 7 | _wanted interfaces expl 'wireless network interface' \ 8 | compadd ${intf} 9 | } 10 | 11 | _wlan_networks() { 12 | networks=() 13 | while read LINE 14 | do 15 | networks+=$LINE 16 | done <<(iwlist scanning 2>/dev/null | grep ESSID | sed -e s/'.*"\(.*\)"'/'\1'/ ) 17 | _wanted -x names expl 'network name' \ 18 | compadd off any on ${networks} 19 | } 20 | 21 | local curcontext="$curcontext" state line expl ret=1 22 | 23 | _arguments -C \ 24 | '(1 * -)--help[display help information]' \ 25 | '(1 * -)--version[display version information]' \ 26 | '1:network interface:_wlan_interfaces' \ 27 | '*:parameter:->parameters' && ret=0 28 | 29 | if [[ -n "$state" ]]; then 30 | local -a arg 31 | 32 | case $words[CURRENT-1] in 33 | essid) _wlan_networks;; 34 | nwid|domain) _message -e ids 'network id' ;; 35 | freq|channel) _message -e channels 'channel or frequency' ;; 36 | sens) _message -e levels 'signal level' ;; 37 | mode) 38 | _wanted modes expl 'operating mode' compadd \ 39 | Ad-Hoc Managed Master Repeater Secondary Monitor Auto 40 | ;; 41 | ap) _message -e access-points 'access point' ;; 42 | nick*) _message -e names 'nickname' ;; 43 | rate|bit*) _message -e bit-rates 'bit rate' ;; 44 | rts*|frag*) _message -e sizes 'size' ;; 45 | key|enc*) _message -e keys 'key' ;; 46 | power) 47 | arg=( 48 | \*{min,max}'[modifier]' 49 | '*off[disable power management]' 50 | '*on[enable power management]' 51 | '*all[receive all packets]' 52 | 'unicast[receive unicast packets only]' 53 | 'multicast[receive multicast and broadcast packets only]' 54 | ) 55 | ;& 56 | min|max) 57 | _values -S ' ' -w 'parameter' \ 58 | 'period[set the period between wake ups]' \ 59 | 'timeout[set timeout before sleep]' \ 60 | $arg[@] && ret=0 61 | ;; 62 | period|timeout) _message -e timeouts 'timeout' ;; 63 | txpower) _message -e power 'transmit power' ;; 64 | retry) _message -e retries 'retries' ;; 65 | *) 66 | _values -S ' ' -w 'option' \ 67 | 'essid[set the network name]' \ 68 | '(nwid domain)'{nwid,domain}'[set the network ID]' \ 69 | '(freq channel)'{freq,channel}'[set the operating frequency or channel]' \ 70 | 'sens[set the sensitivity threhold]' \ 71 | 'mode[set operating mode]' \ 72 | 'ap[register with given access point]' \ 73 | '(nick nickname)'nick{,name}'[set the nickname]' \ 74 | '(rate bit)'{rate,bit}'[set the bitrate]' \ 75 | 'rts[set packet size threshold for sending RTS]' \ 76 | 'frag[set maximum packet fragment size]' \ 77 | \*{key,enc}'[add encryption key]' \ 78 | '*power[manipulate power management scheme parameters]' \ 79 | 'txpower[set transmit power]' \ 80 | 'retry[set number of retries]' \ 81 | 'commit[apply changes imediately]' && ret=0 82 | ;; 83 | esac 84 | fi 85 | 86 | return ret 87 | -------------------------------------------------------------------------------- /usr_share_grml/zsh/completion/unix/_hl_complete: -------------------------------------------------------------------------------- 1 | #compdef hl 2 | 3 | # Taken from: 4 | # https://dev.0x50.de/projects/ftzsh/repository/revisions/master/entry/functions/_hl_complete 5 | 6 | function _hl_themes() { 7 | local expl 8 | local -a themes 9 | themes=(${${${(f)"$(LC_ALL=C highlight --list-themes)"}/ #/}:#*(Installed|Use name)*}) 10 | _wanted -C list themes expl theme compadd ${themes} 11 | } 12 | 13 | function _hl_languages() { 14 | local dir expl curcontext="$curcontext" 15 | local -a langs 16 | zstyle -s ":completion:${curcontext}:" theme-directory dir \ 17 | || dir='/usr/share/highlight/langDefs/' 18 | langs=( $dir/*(.:t:r) ) 19 | _wanted -C list languages expl languages compadd ${langs} 20 | } 21 | 22 | function _hl_complete () { 23 | local -a args 24 | args=( 25 | '(--help -h)'{--help,-h}'[display help text]' 26 | '(-c --cat --no-pager)'{--no-pager,--cat,-c}'[do not use a pager]' 27 | '(--format -F)'{--format,-F}'[specify output format]' 28 | '(--list -l)'{--list,-l}'[list available languages]' 29 | '(--pager -P)'{--pager,-P}'[specify which pager to use]' 30 | '(--syntax -s)'{--syntax,-s}'[specify which syntax to assume]:languages:_hl_languages' 31 | '(--themes -t)'{--themes,-t}'[list available themes]' 32 | '(--theme -T)'{--theme,-T}'[specify which theme to use]:themes:_hl_themes' 33 | '*:files:_path_files' 34 | ) 35 | _arguments -s $args 36 | } 37 | 38 | _hl_complete "$@" 39 | -------------------------------------------------------------------------------- /usr_share_grml/zsh/completion/unix/_lookup: -------------------------------------------------------------------------------- 1 | #compdef lookup lu 2 | ### vim:ft=zsh:foldmethod=marker 3 | ## Copyright: 2009, Frank Terbeck 4 | 5 | function _lookup_aliases() { 6 | local al 7 | local -a aliases 8 | 9 | aliases=() 10 | for al in ${(k)LOOKUP_aliases}; do 11 | aliases+=("${al}:alias for ${LOOKUP_aliases[$al]}") 12 | done 13 | 14 | _describe -t aliases 'backend alias' aliases 15 | } 16 | 17 | function _lookup_backends() { 18 | local be 19 | local -i hidealiased 20 | local -a backends 21 | local -x lookup_describe 22 | lookup_describe='yes' 23 | 24 | if [[ -z ${lookup_nohide} ]] && 25 | zstyle -t ":completion:${curcontext}" hide-aliased-backends ; then 26 | hidealiased=1 27 | else 28 | hidealiased=0 29 | fi 30 | 31 | backends=() 32 | for be in ${LOOKUP_backends}; do 33 | (( hidealiased > 0 )) && [[ -n ${(Mv)LOOKUP_aliases:#$be} ]] && continue 34 | backends+=("${be}:$(LOOKUP_be_${be})") 35 | done 36 | 37 | _describe -t backends 'backend' backends 38 | } 39 | 40 | function _lookup_backends_nohide() { 41 | local -x lookup_nohide='yes' 42 | _lookup_backends 43 | } 44 | 45 | function _lookup_backends_and_aliases() { 46 | _alternative \ 47 | 'aliases: :_lookup_aliases' \ 48 | 'commands: :_lookup_backends' 49 | } 50 | 51 | function _lookup() { 52 | local context curcontext state line ret 53 | local -a args aw 54 | local -x backend 55 | local -ix lookup_complete 56 | 57 | lookup_complete=1 58 | args=( 59 | '-a[add a backend alias]:alias definition:' 60 | '-d[remove backand alias]:alias name:_lookup_aliases' 61 | '-h[provide help]:lookup backend:_lookup_backends_nohide' 62 | '-i[(re)initialize lookup]:' 63 | '-l[list available backends]:' 64 | '-L[list defined backend aliases]:' 65 | '-Q[let a handler create the QUERY string]' 66 | '-q[let a handler create the QUERY string, with arg]:argument for query handler:' 67 | '-P[print which browser command would be used]' 68 | '-R[send url to remote browser]' 69 | '*:: :->be_or_options' 70 | ) 71 | _arguments -C -s -w ${args} && return 72 | 73 | if [[ ${state} == "be_or_options" ]]; then 74 | if (( CURRENT == 1 )) ; then 75 | _lookup_backends_and_aliases 76 | else 77 | backend="${words[1]}" 78 | if [[ -n ${LOOKUP_aliases[$backend]} ]] ; then 79 | aw=( ${(z)${LOOKUP_aliases[$backend]}} ) 80 | (( CURRENT = CURRENT + ${#aw} - 1 )) 81 | words[1]=( ${aw} ) 82 | aw=() 83 | backend="${words[1]}" 84 | fi 85 | curcontext="${curcontext%:*:*}:lookup-${backend}:" 86 | _call_function ret LOOKUP_be_${backend} 87 | fi 88 | fi 89 | } 90 | 91 | _lookup 92 | -------------------------------------------------------------------------------- /usr_share_grml/zsh/functions/Lookup/Backends/LOOKUP_be_cpan: -------------------------------------------------------------------------------- 1 | ### vim:ft=zsh:foldmethod=marker 2 | ## search.cpan.org backend for lookup 3 | ## Copyright: 2009, Frank Terbeck 4 | 5 | LOOKUP_guard || return 1 6 | [[ -n ${lookup_describe} ]] && 7 | printf '%s' 'search CPAN via search.cpan.org' && return 0 8 | 9 | LOOKUP_guard -fd LOOKUP_help_${backend} || 10 | function LOOKUP_help_${backend}() { 11 | LOOKUP_guard || return 1 12 | printf 'usage: %s \n' ${backend} 13 | printf '\n Searches CPAN via search.cpan.org.\n' 14 | printf '\nExamples:\n' 15 | printf ' %% lookup %s Audio::Scan\n' ${backend} 16 | } 17 | LOOKUP_help && return 0 18 | 19 | if [[ -n ${lookup_complete} ]] ; then 20 | _message 'search.cpan.org query' 21 | return 0 22 | fi 23 | 24 | local -x QUERY 25 | QUERY="$*" 26 | LOOKUP_query_handler || return 1 27 | if [[ -z ${QUERY} ]] ; then 28 | LOOKUP_help -f 29 | return 1 30 | fi 31 | 32 | LOOKUP_encode -q 33 | LOOKUP_browser "http://search.cpan.org/search?query=${QUERY}" 34 | return $? 35 | -------------------------------------------------------------------------------- /usr_share_grml/zsh/functions/Lookup/Backends/LOOKUP_be_deb_bts: -------------------------------------------------------------------------------- 1 | ### vim:ft=zsh:foldmethod=marker 2 | ## bugs.debian.org backend for lookup 3 | ## Copyright: 2009, Frank Terbeck 4 | 5 | LOOKUP_guard || return 1 6 | [[ -n ${lookup_describe} ]] && 7 | printf '%s' 'get information about debian bugs by #id' && 8 | return 0 9 | 10 | local -a comp_args 11 | 12 | LOOKUP_guard -fd LOOKUP_help_${backend} || 13 | function LOOKUP_help_${backend}() { 14 | LOOKUP_guard || return 1 15 | printf 'usage: %s [-p] \n' ${backend} 16 | printf ' -p go to the bts page of a given package\n' 17 | printf '\n Query Debian[1]'\''s Bug Tracking System[2].\n' 18 | printf '\n By default, this looks up bugs by bug id. In this mode, all non-digit\n' 19 | printf ' characters are automatically stripped off of the query.\n' 20 | printf '\nExamples:\n' 21 | printf ' %% lookup %s 123456\n' ${backend} 22 | printf ' %% lookup %s "#123456"\n' ${backend} 23 | printf ' %% lookup %s -p zsh\n' ${backend} 24 | printf '\n[1] \n' 25 | printf '[2] \n' 26 | } 27 | LOOKUP_help && return 0 28 | 29 | if [[ -n ${lookup_complete} ]] ; then 30 | comp_args=( 31 | '-p[go to package'\''s bts page]:package:_deb_packages avail' 32 | '*:debian bts query:true' 33 | ) 34 | 35 | _arguments -s -w -A '-*' ${comp_args} && return 0 36 | _message 'debian bts query' 37 | return 0 38 | fi 39 | 40 | local mode 41 | local -A opts 42 | local -x QUERY 43 | 44 | mode='id' 45 | lu_parseopts_args=( p bool ) 46 | LOOKUP_parseopts "$@" || return 1 47 | [[ ${opts[-p]} == 'yes' ]] && mode='package' 48 | 49 | QUERY="${args[*]}" 50 | LOOKUP_query_handler || return 1 51 | if [[ -z ${QUERY} ]] ; then 52 | LOOKUP_help -f 53 | return 1 54 | fi 55 | 56 | if [[ ${mode} == 'id' ]] ; then 57 | QUERY="${QUERY//[^0-9]/}" 58 | LOOKUP_encode -q 59 | LOOKUP_browser "http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=${QUERY}" 60 | return $? 61 | else 62 | LOOKUP_encode -q 63 | LOOKUP_browser "http://bugs.debian.org/${QUERY}" 64 | return $? 65 | fi 66 | -------------------------------------------------------------------------------- /usr_share_grml/zsh/functions/Lookup/Backends/LOOKUP_be_deb_msgid: -------------------------------------------------------------------------------- 1 | ### vim:ft=zsh:foldmethod=marker 2 | ## lists.debian.org message-id search backend for lookup 3 | ## Copyright: 2009, Frank Terbeck 4 | 5 | LOOKUP_guard || return 1 6 | [[ -n ${lookup_describe} ]] && 7 | printf '%s' 'search lists.debian.org by message-ids' && 8 | return 0 9 | 10 | local lookup_context 11 | local -a comp_args 12 | 13 | lookup_context="$(LOOKUP_context)" 14 | 15 | LOOKUP_guard -fd LOOKUP_help_${backend} || 16 | function LOOKUP_help_${backend}() { 17 | LOOKUP_guard || return 1 18 | printf 'usage: %s [-1] \n' ${backend} 19 | printf ' -1 use the search'\''s first-hit option\n' 20 | printf '\n Search Debian[1]'\''s Mailinglist Archive[2] my Message-ID: header.\n' 21 | printf ' If you always want to use the -1 option, you may set the use-first-hit\n' 22 | printf ' style in this context: %s\n' ${lookup_context} 23 | printf '\nExamples:\n' 24 | printf ' %% lookup %s 20090215095848.GA21661@schmehl.info\n' ${backend} 25 | printf ' %% lookup %s -1 20090215095848.GA21661@schmehl.info\n' ${backend} 26 | printf ' %% zstyle '\'':lookup:*:%s:*'\'' use-first-hit true\n' ${backend} 27 | printf '\n[1] \n' 28 | printf '[2] \n' 29 | } 30 | LOOKUP_help && return 0 31 | 32 | if [[ -n ${lookup_complete} ]] ; then 33 | comp_args=( 34 | '-1[use /firsthit option]' 35 | '*:message-id for l.d.o:true' 36 | ) 37 | 38 | _arguments -s -w -A '-*' ${comp_args} && return 0 39 | _message 'message-id for l.d.o' 40 | return 0 41 | fi 42 | 43 | local end 44 | local -A opts 45 | local -x QUERY 46 | 47 | lu_parseopts_args=( 1 bool ) 48 | LOOKUP_parseopts "$@" || return 1 49 | [[ ${opts[-1]} == 'yes' ]] && end='/firsthit' || end='/links' 50 | zstyle -t "${lookup_context}" use-first-hit && end='/firsthit' 51 | 52 | QUERY="${args[*]}" 53 | LOOKUP_query_handler || return 1 54 | if [[ -z ${QUERY} ]] ; then 55 | LOOKUP_help -f 56 | return 1 57 | fi 58 | 59 | LOOKUP_encode -q 60 | LOOKUP_browser "http://lists.debian.org/msgid-search/${QUERY}${end}" 61 | return $? 62 | -------------------------------------------------------------------------------- /usr_share_grml/zsh/functions/Lookup/Backends/LOOKUP_be_deb_patchtrack: -------------------------------------------------------------------------------- 1 | ### vim:ft=zsh:foldmethod=marker 2 | ## patch-tracking.debian.net backend for lookup 3 | ## Copyright: 2009, Frank Terbeck 4 | 5 | LOOKUP_guard || return 1 6 | [[ -n ${lookup_describe} ]] && 7 | printf '%s' 'check patch information of debian packages' && 8 | return 0 9 | 10 | local -a comp_args 11 | 12 | LOOKUP_guard -fd LOOKUP_help_${backend} || 13 | function LOOKUP_help_${backend}() { 14 | LOOKUP_guard || return 1 15 | printf 'usage: %s \n' ${backend} 16 | printf '\n Warps you to a package'\''s page in Debian[1]'\''s Patch Tracking System[2].\n' 17 | printf '\nExamples\n' 18 | printf ' %% lookup %s fdm\n' ${backend} 19 | printf ' %% lookup %s zsh\n' ${backend} 20 | printf '\n[1] \n' 21 | printf '[2] \n' 22 | } 23 | LOOKUP_help && return 0 24 | 25 | if [[ -n ${lookup_complete} ]] ; then 26 | _message 'debian package' 27 | _deb_packages avail 28 | return 0 29 | fi 30 | 31 | local -x QUERY 32 | 33 | QUERY="$*" 34 | LOOKUP_query_handler || return 1 35 | if [[ -z ${QUERY} ]] ; then 36 | LOOKUP_help -f 37 | return 1 38 | fi 39 | 40 | LOOKUP_encode -q 41 | LOOKUP_browser "http://patch-tracker.debian.org/package/${QUERY}" 42 | return $? 43 | -------------------------------------------------------------------------------- /usr_share_grml/zsh/functions/Lookup/Backends/LOOKUP_be_deb_pts: -------------------------------------------------------------------------------- 1 | ### vim:ft=zsh:foldmethod=marker 2 | ## packages.qa.debian.org backend for lookup 3 | ## Copyright: 2009, Frank Terbeck 4 | 5 | LOOKUP_guard || return 1 6 | [[ -n ${lookup_describe} ]] && 7 | printf '%s' 'debian PTS information about a package' && 8 | return 0 9 | 10 | local -a comp_args 11 | 12 | LOOKUP_guard -fd LOOKUP_help_${backend} || 13 | function LOOKUP_help_${backend}() { 14 | LOOKUP_guard || return 1 15 | printf 'usage: %s \n' ${backend} 16 | printf '\n Warps you to a package'\''s page in Debian[1]'\''s Package\n' 17 | printf ' Tracking System[2].\n' 18 | printf '\nExamples\n' 19 | printf ' %% lookup %s wesnoth\n' ${backend} 20 | printf ' %% lookup %s zsh\n' ${backend} 21 | printf '\n[1] \n' 22 | printf '[2] \n' 23 | } 24 | LOOKUP_help && return 0 25 | 26 | if [[ -n ${lookup_complete} ]] ; then 27 | _message 'debian package' 28 | _deb_packages avail 29 | return 0 30 | fi 31 | 32 | local -x QUERY 33 | 34 | QUERY="$*" 35 | LOOKUP_query_handler || return 1 36 | if [[ -z ${QUERY} ]] ; then 37 | LOOKUP_help -f 38 | return 1 39 | fi 40 | 41 | LOOKUP_encode -q 42 | LOOKUP_browser "http://packages.qa.debian.org/${QUERY}" 43 | return $? 44 | -------------------------------------------------------------------------------- /usr_share_grml/zsh/functions/Lookup/Backends/LOOKUP_be_dsc: -------------------------------------------------------------------------------- 1 | ### vim:ft=zsh:foldmethod=marker 2 | ## datasheetcatalog.net backend for lookup 3 | ## Copyright: 2009, Frank Terbeck 4 | 5 | LOOKUP_guard || return 1 6 | [[ -n ${lookup_describe} ]] && 7 | printf '%s' 'search for datasheets via datasheetcatalog.net' && return 0 8 | 9 | LOOKUP_guard -fd LOOKUP_help_${backend} || 10 | function LOOKUP_help_${backend}() { 11 | LOOKUP_guard || return 1 12 | printf 'usage: %s \n' ${backend} 13 | printf '\n Searches for datasheets via datasheetcatalog.net.\n' 14 | printf '\nExamples:\n' 15 | printf ' %% lookup %s 7447\n' ${backend} 16 | } 17 | LOOKUP_help && return 0 18 | 19 | if [[ -n ${lookup_complete} ]] ; then 20 | _message 'datasheetcatalog.net query' 21 | return 0 22 | fi 23 | 24 | local -x QUERY 25 | QUERY="$*" 26 | LOOKUP_query_handler || return 1 27 | if [[ -z ${QUERY} ]] ; then 28 | LOOKUP_help -f 29 | return 1 30 | fi 31 | 32 | LOOKUP_encode -q 33 | LOOKUP_browser "http://search.datasheetcatalog.net/key/${QUERY}" 34 | return $? 35 | -------------------------------------------------------------------------------- /usr_share_grml/zsh/functions/Lookup/Backends/LOOKUP_be_filewatcher: -------------------------------------------------------------------------------- 1 | ### vim:ft=zsh:foldmethod=marker 2 | ## filewatcher.com search backend for lookup 3 | ## Copyright: 2009, Frank Terbeck 4 | 5 | LOOKUP_guard || return 1 6 | [[ -n ${lookup_describe} ]] && 7 | printf '%s' 'search filewatcher.com' && 8 | return 0 9 | 10 | local -a comp_args 11 | 12 | LOOKUP_guard -fd LOOKUP_help_${backend} || 13 | function LOOKUP_help_${backend}() { 14 | LOOKUP_guard || return 1 15 | printf 'usage: %s \n' ${backend} 16 | printf '\n Use filewatcher.com to search FTP server contents.\n' 17 | printf '\nExamples:\n' 18 | printf ' %% lookup %s '\''zsh*.tar.gz'\''\n' ${backend} 19 | printf ' %% lookup %s '\''*.jpg'\''\n\n' ${backend} 20 | } 21 | LOOKUP_help && return 0 22 | 23 | if [[ -n ${lookup_complete} ]] ; then 24 | _message 'filewatcher search string' 25 | return 0 26 | fi 27 | 28 | local -x QUERY 29 | 30 | QUERY="$*" 31 | LOOKUP_query_handler || return 1 32 | if [[ -z ${QUERY} ]] ; then 33 | LOOKUP_help -f 34 | return 1 35 | fi 36 | 37 | LOOKUP_encode -s -q 38 | LOOKUP_browser "http://www.filewatcher.com/_/?q=${QUERY}" 39 | return $? 40 | -------------------------------------------------------------------------------- /usr_share_grml/zsh/functions/Lookup/Backends/LOOKUP_be_freshmeat: -------------------------------------------------------------------------------- 1 | ### vim:ft=zsh:foldmethod=marker 2 | ## freshmeat.net search backend for lookup 3 | ## Copyright: 2009, Frank Terbeck 4 | 5 | LOOKUP_guard || return 1 6 | [[ -n ${lookup_describe} ]] && 7 | printf '%s' 'search freshmeat.net' && 8 | return 0 9 | 10 | local -a comp_args 11 | 12 | LOOKUP_guard -fd LOOKUP_help_${backend} || 13 | function LOOKUP_help_${backend}() { 14 | LOOKUP_guard || return 1 15 | printf 'usage: %s \n' ${backend} 16 | printf '\n Query freshmeat.net for software projects.\n' 17 | printf '\nExamples:\n' 18 | printf ' %% lookup %s zsh\n' ${backend} 19 | printf ' %% lookup %s gnu screen\n\n' ${backend} 20 | } 21 | LOOKUP_help && return 0 22 | 23 | if [[ -n ${lookup_complete} ]] ; then 24 | _message 'freshmeat search string' 25 | return 0 26 | fi 27 | 28 | local -x QUERY 29 | 30 | QUERY="$*" 31 | LOOKUP_query_handler || return 1 32 | if [[ -z ${QUERY} ]] ; then 33 | LOOKUP_help -f 34 | return 1 35 | fi 36 | 37 | LOOKUP_encode -s -q 38 | LOOKUP_browser "http://freshmeat.net/search/?q=${QUERY}§ion=projects" 39 | return $? 40 | -------------------------------------------------------------------------------- /usr_share_grml/zsh/functions/Lookup/Backends/LOOKUP_be_gmane: -------------------------------------------------------------------------------- 1 | ### vim:ft=zsh:foldmethod=marker 2 | ## gmane.org backend for lookup 3 | ## Copyright: 2009, Frank Terbeck 4 | 5 | LOOKUP_guard || return 1 6 | [[ -n ${lookup_describe} ]] && printf '%s' 'query gmane.org' && return 0 7 | 8 | local lookup_context bookmarks 9 | local -A known_sorts known_opers 10 | lookup_context="$(LOOKUP_context)" 11 | 12 | # Set up the path name of the bookmark file. Looked up in the :lookup:* 13 | # context because it may not be limited to compsys in the future 14 | # (maybe someone will write bookmark managing via zsh/curses...). :-) 15 | zstyle -s "${lookup_context}" group-bookmarks bookmarks || 16 | bookmarks="${HOME}/.zgmane.bookmarks" 17 | 18 | known_sorts=( 19 | date 'sort by date' 20 | revdate 'sort by reverse date' 21 | relevance 'sort by relevance' 22 | ) 23 | 24 | known_opers=( 25 | and 'require all words' 26 | or 'require one word' 27 | ) 28 | 29 | LOOKUP_guard -fd LOOKUP_help_${backend} || 30 | function LOOKUP_help_${backend}() { 31 | # gmane backend help {{{ 32 | LOOKUP_guard || return 1 33 | printf 'usage: %s \n' ${backend} 34 | printf ' -G Open group (like gmane.emacs.orgmode) in gmane'\''s browser mode\n' 35 | printf ' Completion will offer bookmarked groups.\n' 36 | printf ' -l search for original list names (like zsh-workers)\n' 37 | printf ' -s match gmane group names (like comp.shell)\n' 38 | printf ' -L list-mode; do not open a browser, just print the results\n' 39 | printf ' valid with -l and -s.\n' 40 | printf ' -B browser-mode; opposite of -L\n' 41 | printf ' -m search for Message-Id: header\n' 42 | printf ' -a match messages only by a certain author\n' 43 | printf ' -g match messages only from a certain gmane group\n' 44 | printf ' -o use defined operation in search (%s)\n' "${(j:/:)${(@kon)known_opers}}" 45 | printf ' -S use given sorting method (%s)\n' "${(j:/:)${(@kon)known_sorts}}" 46 | printf '\n Search the archives of the gmane.org mail2news gateway.\n' 47 | printf '\n Default sort method: relevance\n' 48 | printf ' Default query logic: and\n' 49 | printf ' List-mode (-L and -B options) defaults to: off\n' 50 | printf ' Default group bookmark file: %s\n' "${HOME}/.zgmane.bookmarks" 51 | printf ' All defaults may be altered by the use of styles.\n' 52 | printf '\nStyles:\n' 53 | printf ' All styles are looked up in this context:\n' 54 | printf ' %s\n\n' ${lookup_context} 55 | printf ' group-bookmarks: file that contains group bookmarks (see below)\n' 56 | printf ' list-default: boolean, use list-mode by default if true\n' 57 | printf ' default-sort: change default sorting method\n' 58 | printf ' default-oper: change default query logic\n' 59 | printf '\nBookmarks:\n' 60 | printf '\n Often you will want to limit your queries to a certain gmane group.\n' 61 | printf ' Since these are lengthy at times, it is awful to type them out.\n' 62 | printf ' Therefore, this backend gives you a bookmark file. Its format is:\n' 63 | printf ' gname.group.name:description\n' 64 | printf ' The '\'':description'\'' part is optional.\n' 65 | printf ' That way you can search for group names (using -L, -l and -s) and put\n' 66 | printf ' your preferred groups into that file. That way you get rid of a lot of\n' 67 | printf ' typing by using completion: %% lu gmane -g \n' 68 | printf '\nExamples:\n' 69 | printf ' %% zstyle '\'':lookup:*:%s:*'\'' list-default true\n' ${backend} 70 | printf ' %% zstyle '\'':lookup:*:%s:*'\'' default-sort date\n' ${backend} 71 | printf ' %% zstyle '\'':lookup:*:%s:*'\'' default-oper or\n' ${backend} 72 | printf ' %% zstyle '\'':lookup:*:%s:*'\'' group-bookmarks ~/.my_gmane_bookmarks\n' ${backend} 73 | printf ' %% lookup %s zsh\n' ${backend} 74 | printf ' %% lookup %s -m 20090215095848.GA21661@schmehl.info\n' ${backend} 75 | printf ' %% lookup %s -g gmane.comp.shells.fish.user zsh\n' ${backend} 76 | printf ' %% lookup %s -L -l zsh-workers\n' ${backend} 77 | printf ' %% lookup %s -L -s openbsd\n' ${backend} 78 | printf ' %% lookup %s -G gmane.emacs.orgmode\n' ${backend} 79 | #}}} 80 | } 81 | LOOKUP_help && return 0 82 | 83 | if [[ -n ${lookup_complete} ]] ; then 84 | # gmane backend completion code {{{ 85 | local -a comp_args 86 | 87 | LOOKUP_guard -fd __lookup_${backend}_known_operations || 88 | function __lookup_${backend}_known_operations() { 89 | local o 90 | local -a os 91 | 92 | os=() 93 | for o in ${(k)known_opers}; do 94 | os+=("$o:${known_opers[$o]}") 95 | done 96 | _describe -t gmane_opers 'known operations' os 97 | } 98 | 99 | LOOKUP_guard -fd __lookup_${backend}_known_sorts || 100 | function __lookup_${backend}_known_sorts() { 101 | local s 102 | local -a as 103 | 104 | as=() 105 | for s in ${(k)known_sorts}; do 106 | as+=("$s:${known_sorts[$s]}") 107 | done 108 | _describe -t gmane_sorts 'known sorting methods' as 109 | } 110 | 111 | LOOKUP_guard -fd __lookup_${backend}_group_bookmarks || 112 | function __lookup_${backend}_group_bookmarks() { 113 | local -a bms 114 | 115 | if [[ -r ${bookmarks} ]] ; then 116 | bms=(${(f)"$(< $bookmarks)"}) 117 | fi 118 | _describe -t gmane_bookmarks 'bookmarked gmane groups' bms 119 | } 120 | 121 | comp_args=( 122 | '-G[browse gmane group]:group name:__lookup_'${backend}'_group_bookmarks' 123 | '-l[search for original list names]:list name:' 124 | '-s[match gmane group names]:group name:' 125 | '-L[switch to list-mode]' 126 | '-m[query for message ids]:Message-Id\::' 127 | '-a[author name]:author:' 128 | '-g[group name]:group:__lookup_'${backend}'_group_bookmarks' 129 | '-o[operations]:operation:__lookup_'${backend}'_known_operations' 130 | '-S[sorting method]:sorting method:__lookup_'${backend}'_known_sorts' 131 | '*:wikipedia search:true' 132 | ) 133 | 134 | _arguments -s -w -A '-*' ${comp_args} && return 0 135 | _message 'gmane query' 136 | return 0 137 | #}}} 138 | fi 139 | 140 | local author group operation sort ret list_mode 141 | local -x QUERY 142 | 143 | # set some defaults via zstyle 144 | zstyle -t "${lookup_context}" list-default && list_mode='yes' 145 | zstyle -s "${lookup_context}" default-sort sort || sort='relevance' 146 | zstyle -s "${lookup_context}" default-oper operation || operation='and' 147 | 148 | # parse options 149 | lu_parseopts_args=( 150 | G bool 151 | l bool 152 | m bool 153 | s bool 154 | B bool 155 | L bool 156 | a string 157 | g string 158 | o string 159 | S string 160 | ) 161 | LOOKUP_parseopts "$@" || return 1 162 | [[ -n ${opts[-a]} ]] && author="$(LOOKUP_encode ${opts[-a]})" 163 | [[ -n ${opts[-g]} ]] && group="$(LOOKUP_encode ${opts[-g]})" 164 | [[ -n ${opts[-o]} ]] && operation="${opts[-o]}" 165 | [[ -n ${opts[-S]} ]] && sort="${opts[-S]}" 166 | [[ -n ${opts[-L]} ]] && list_mode='yes' 167 | [[ -n ${opts[-B]} ]] && list_mode='' 168 | 169 | # set QUERY and export parameters for query handlers via $lookup_communicate[] 170 | QUERY="${args[*]}" 171 | lookup_communicate[author]="${author}" 172 | lookup_communicate[group]="${group}" 173 | lookup_communicate[operation]="${operation}" 174 | lookup_communicate[sort]="${sort}" 175 | LOOKUP_query_handler || return 1 176 | [[ ${lookup_communicate[author]} != ${author} ]] && author="${lookup_communicate[author]}" 177 | [[ ${lookup_communicate[group]} != ${group} ]] && group="${lookup_communicate[group]}" 178 | [[ ${lookup_communicate[operation]} != ${operation} ]] && operation="${lookup_communicate[operation]}" 179 | [[ ${lookup_communicate[sort]} != ${sort} ]] && sort="${lookup_communicate[sort]}" 180 | 181 | # validate arguments 182 | if [[ -z ${(Mk)known_opers:#$operation} ]] ; then 183 | printf 'Unknown operation: '\''%s'\''.\n\n' ${mode} 184 | QUERY='' 185 | elif [[ -z ${(Mk)known_sorts:#$sort} ]] ; then 186 | printf 'Unknown sorting method: '\''%s'\''.\n\n' ${mode} 187 | QUERY='' 188 | fi 189 | if [[ -z ${QUERY} ]] && 190 | ( [[ ${opts[-l]} == 'yes' ]] || [[ ${opts[-s]} == 'yes' ]] || [[ ${opts[-m]} == 'yes' ]] ) 191 | then 192 | 193 | LOOKUP_help -f 194 | return 1 195 | fi 196 | if [[ -z ${QUERY} ]] && [[ -z ${group} ]] && [[ -z ${author} ]] ; then 197 | LOOKUP_help -f 198 | return 1 199 | fi 200 | 201 | LOOKUP_guard -fd LOOKUP_beh_${backend}_list || 202 | function LOOKUP_beh_${backend}_list() { 203 | # list mode via tcp_{open,send,close} {{{ 204 | LOOKUP_guard || return 1 205 | setopt localoptions no_warncreateglobal 206 | local mode="$1" q="$2" 207 | 208 | LOOKUP_guard -fd tcp_open || autoload -Uz tcp_open 209 | LOOKUP_guard -fd tcp_send || autoload -Uz tcp_send 210 | 211 | case ${mode} in 212 | (list) 213 | tcp_open -q gmane.org 80 gmane || return 1 214 | tcp_send -s gmane -- "GET /find.php?list=${q} HTTP/1.1" 215 | tcp_send -s gmane -- 'HOST: gmane.org' 216 | ;; 217 | (match) 218 | tcp_open -q dir.gmane.org 80 gmane || return 1 219 | tcp_send -s gmane -- "GET /search.php?match=${q} HTTP/1.1" 220 | tcp_send -s gmane -- 'HOST: dir.gmane.org' 221 | ;; 222 | (*) 223 | return 1 224 | ;; 225 | esac 226 | 227 | tcp_send -s gmane -- 'Connection: close' 228 | tcp_send -s gmane -- '' 229 | 230 | TCP_SILENT='yes' 231 | tcp_read -b -d -s gmane 232 | TCP_SILENT='' 233 | 234 | tcp_close -q -s gmane 235 | 236 | results=() 237 | for line in ${tcp_lines} ; do 238 | [[ ${line} != *'dir.gmane.org'* ]] && continue 239 | line=${line//(#b)*\"(http:\/\/dir.gmane.org\/[^\"]#)\"*/${match[1]}} 240 | line=${line#http://dir.gmane.org/} 241 | [[ -z ${line} ]] && continue 242 | [[ ${line} != gmane.* ]] && continue 243 | results+=( ${line} ) 244 | done 245 | 246 | print -l ${results} 247 | return 0 248 | #}}} 249 | } 250 | 251 | # make the actual queries 252 | LOOKUP_encode -q 253 | if [[ ${opts[-G]} == 'yes' ]] ; then 254 | LOOKUP_browser "http://news.gmane.org/${QUERY}" 255 | ret="$?" 256 | elif [[ ${opts[-l]} == 'yes' ]] ; then 257 | if [[ ${list_mode} == 'yes' ]] ; then 258 | LOOKUP_beh_${backend}_list 'list' ${QUERY} 259 | ret="$?" 260 | else 261 | LOOKUP_browser "http://gmane.org/find.php?list=${QUERY}" 262 | ret="$?" 263 | fi 264 | elif [[ ${opts[-s]} == 'yes' ]] ; then 265 | if [[ ${list_mode} == 'yes' ]] ; then 266 | LOOKUP_beh_${backend}_list 'match' ${QUERY} 267 | ret="$?" 268 | else 269 | LOOKUP_browser "http://dir.gmane.org/search.php?match=${QUERY}" 270 | ret="$?" 271 | fi 272 | elif [[ ${opts[-m]} == 'yes' ]] ; then 273 | LOOKUP_browser "http://mid.gmane.org/${QUERY}" 274 | ret="$?" 275 | else 276 | LOOKUP_browser "http://search.gmane.org/?query=${QUERY}&author=${author}&group=${group}&DEFAULTOP=${operation}&sort=${sort}" 277 | ret="$?" 278 | fi 279 | return ${ret} 280 | -------------------------------------------------------------------------------- /usr_share_grml/zsh/functions/Lookup/Backends/LOOKUP_be_google: -------------------------------------------------------------------------------- 1 | ### vim:ft=zsh:foldmethod=marker 2 | ## google search backend for lookup 3 | ## Copyright: 2009, Frank Terbeck 4 | 5 | LOOKUP_guard || return 1 6 | [[ -n ${lookup_describe} ]] && printf '%s' 'google websearch' && return 0 7 | 8 | if [[ -n ${lookup_complete} ]] ; then 9 | local -a comp_args 10 | comp_args=( 11 | '-1[I'\''m Feeling Lucky!]' 12 | '*:dict.leo.org query:true' 13 | ) 14 | 15 | _arguments -s -w -A '-*' ${comp_args} && return 0 16 | _message 'google query' 17 | return 0 18 | fi 19 | 20 | local mode lookup_context 21 | local -x QUERY 22 | 23 | lookup_context="$(LOOKUP_context)" 24 | 25 | LOOKUP_guard -fd LOOKUP_help_${backend} || 26 | function LOOKUP_help_${backend}() { 27 | LOOKUP_guard || return 1 28 | printf 'usage: %s [-1] \n' ${backend} 29 | printf ' -1 Go directly to the first hit using "I'\''m Feeling Lucky"\n' 30 | printf '\n Make web searches via google.com\n' 31 | printf ' If you always want to use the -1 option, you may set the use-first-hit\n' 32 | printf ' style in this context: %s\n' ${lookup_context} 33 | printf '\nExamples:\n' 34 | printf ' %% lookup %s zsh\n' ${backend} 35 | printf ' %% lookup %s -1 openbsd\n' ${backend} 36 | printf ' %% zstyle '\'':lookup:*:%s:*'\'' use-first-hit true\n\n' ${backend} 37 | } 38 | LOOKUP_help && return 0 39 | 40 | lu_parseopts_args=( 1 bool ) 41 | LOOKUP_parseopts "$@" || return 1 42 | 43 | if [[ ${opts[-1]} == 'yes' ]] || 44 | zstyle -t "${lookup_context}" use-first-hit ; then 45 | 46 | mode='I'\''m Feeling Lucky' 47 | mode="$(LOOKUP_encode ${mode})" 48 | mode="&btnI=${mode}" 49 | else 50 | mode='' 51 | fi 52 | 53 | QUERY="${args[*]}" 54 | LOOKUP_query_handler || return 1 55 | if [[ -z ${QUERY} ]] ; then 56 | LOOKUP_help -f 57 | return 1 58 | fi 59 | 60 | LOOKUP_encode -s -q 61 | LOOKUP_browser "http://www.google.com/search?q=${QUERY}${mode}" 62 | return $? 63 | -------------------------------------------------------------------------------- /usr_share_grml/zsh/functions/Lookup/Backends/LOOKUP_be_grml_bts: -------------------------------------------------------------------------------- 1 | ### vim:ft=zsh:foldmethod=marker 2 | ## bts.grml.org backend for lookup 3 | ## Copyright: 2010, Frank Terbeck 4 | 5 | LOOKUP_guard || return 1 6 | [[ -n ${lookup_describe} ]] && 7 | printf '%s' 'bts.grml.org bug lookups' && 8 | return 0 9 | 10 | LOOKUP_guard -fd LOOKUP_help_${backend} || 11 | function LOOKUP_help_${backend}() { 12 | LOOKUP_guard || return 1 13 | printf 'usage: %s \n' ${backend} 14 | printf '\n Query grml[1]'\''s Bug Tracking System[2].\n' 15 | printf '\n This looks up bugs by bug id in grml'\''s BTS. In this mode, all\n' 16 | printf ' non-digit characters are automatically stripped off of the query.\n' 17 | printf '\nExamples:\n' 18 | printf ' %% lookup %s 123\n' ${backend} 19 | printf ' %% lookup %s "#123"\n' ${backend} 20 | printf '\n[1] \n' 21 | printf '[2] \n' 22 | } 23 | LOOKUP_help && return 0 24 | 25 | local -x QUERY 26 | local -a comp_args 27 | 28 | if [[ -n ${lookup_complete} ]] ; then 29 | comp_args=( '*:grml bts query:true' ) 30 | 31 | _arguments -s -w -A '-*' ${comp_args} && return 0 32 | _message 'grml bts query' 33 | return 0 34 | fi 35 | 36 | QUERY="$*" 37 | LOOKUP_query_handler || return 1 38 | QUERY="${QUERY//[^0-9]/}" 39 | if [[ -z ${QUERY} ]] ; then 40 | LOOKUP_help -f 41 | return 1 42 | fi 43 | 44 | LOOKUP_encode -q 45 | LOOKUP_browser "http://bts.grml.org/grml/issue${QUERY}" 46 | return $? 47 | -------------------------------------------------------------------------------- /usr_share_grml/zsh/functions/Lookup/Backends/LOOKUP_be_koders: -------------------------------------------------------------------------------- 1 | ### vim:ft=zsh:foldmethod=marker 2 | ## koders.com source code search backend for lookup 3 | ## Copyright: 2009, Frank Terbeck 4 | 5 | LOOKUP_guard || return 1 6 | [[ -n ${lookup_describe} ]] && 7 | printf '%s' 'source code search via koders.com' && 8 | return 0 9 | 10 | local lookup_context 11 | local -a comp_args known_langs 12 | local -A known_licences 13 | 14 | lookup_context="$(LOOKUP_context)" 15 | 16 | known_langs=( 17 | #{{{ 18 | "ActionScript" 19 | "Ada" 20 | "ASP" 21 | "ASP.NET" 22 | "Assembler" 23 | "C" 24 | "C#" 25 | "C++" 26 | "Cobol" 27 | "ColdFusion" 28 | "Delphi" 29 | "Eiffel" 30 | "Erlang" 31 | "Fortran" 32 | "Java" 33 | "JavaScript" 34 | "JSP" 35 | "Lisp" 36 | "Lua" 37 | "Mathematica" 38 | "Matlab" 39 | "ObjectiveC" 40 | "Perl" 41 | "PHP" 42 | "Prolog" 43 | "Python" 44 | "Ruby" 45 | "Scheme" 46 | "Smalltalk" 47 | "SQL" 48 | "Tcl" 49 | "VB" 50 | "VB.NET" 51 | "*" 52 | #}}} 53 | ) 54 | 55 | known_licences=( 56 | #{{{ 57 | AFL 'Academic Free Licence' 58 | AGPLv3 'Affero General Public Licence v3' 59 | AL20 'Apache Licence, Version 2.0' 60 | ASL 'Apache Software Licence' 61 | APSL 'Apple Public Source Licence' 62 | BSD 'Berkeley Software Distribution Licence' 63 | CPL 'Common Public Licence' 64 | EPL10 'Eclipse Public Licence v1.0' 65 | GTPL 'Globus Toolkit Public Licence' 66 | GPL 'GNU General Public Licence v1 v2 v3' 67 | LGPL 'GNU Lesser General Public Licence' 68 | IBMPL 'IBM Public Licence' 69 | IBMILA 'International Licence Agreement for Non-Warranted Programs' 70 | IOSL 'Intel Open Source Licence' 71 | MSCL 'Microsoft Community Licence' 72 | MSLCL 'Microsoft Limited Community Licence' 73 | MSPL 'Microsoft Permissive Licence' 74 | MSLPL 'Microsoft Limited Permissive Licence' 75 | MSRL 'Microsoft Reference Licence' 76 | MSVSSDK 'Microsoft Visual Studio SDK Licence' 77 | MITD 'MIT Derived Licence' 78 | MPL10 'Mozilla Public Licence Version 1.0' 79 | MPL11 'Mozilla Public Licence Version 1.1' 80 | NPL10 'Netscape Public Licence, Version 1.0' 81 | NPL11 'Netscape Public Licence, Version 1.1' 82 | OSL 'Open Software Licence' 83 | PHPL 'PHP Licence' 84 | CNRIPL 'Python Licence' 85 | PSFL 'Python Software Foundation Licence' 86 | SL 'Sleepycat Software Product Licence' 87 | SISSL 'Sun Industry Standards Source Licence' 88 | SPL 'Sun Public Licence' 89 | W3C 'W3C Software Licence' 90 | WXWLL 'wxWindows Library Licence' 91 | ZLL 'zlib/libpng Licence' 92 | ZPL 'Zope Public Licence' 93 | "*" 'Match all licences' 94 | #}}} 95 | ) 96 | 97 | LOOKUP_guard -fd LOOKUP_help_${backend} || 98 | function LOOKUP_help_${backend}() { 99 | LOOKUP_guard || return 1 100 | local l 101 | local -i i 102 | local -a ls 103 | 104 | i=8 105 | ls=(${(on)known_langs}) 106 | 107 | printf 'usage: %s \n' ${backend} 108 | printf ' -l limit search to specific language\n' 109 | printf ' -L limit search to specific licence\n' 110 | printf '\n Search source code via koders.com\n' 111 | printf '\nKnown languages:\n' 112 | while (( ${#ls} > 0 )) ; do 113 | if (( ${#ls} > i )) ; then 114 | print ' ' ${ls[1,$i]} 115 | shift $i ls 116 | else 117 | print ' ' ${ls} 118 | ls=() 119 | fi 120 | done 121 | printf '\nKnown licences:\n' 122 | for l in ${(kon)known_licences} ; do 123 | printf '%8s - %s\n' $l ${known_licences[$l]} 124 | done 125 | printf '\n Per default this backend makes unlimited searches.\n' 126 | printf ' Results include code from all languages in all licences.\n' 127 | printf '\n You may specify a default language and a default licence via\n' 128 | printf ' the default-lang and default-licence styles (both default to '\''*'\''\n' 129 | printf ' which means unlimited) in this context: %s\n' ${lookup_context} 130 | printf '\nExamples:\n' 131 | printf ' %% zstyle '\'':lookup:*:%s:*'\'' default-lang C\n' ${backend} 132 | printf ' %% zstyle '\'':lookup:*:%s:*'\'' default-licence BSD\n\n' ${backend} 133 | printf ' %% lookup %s strlcpy\n' ${backend} 134 | printf ' %% lookup %s -l C handle_keys\n' ${backend} 135 | printf ' %% lookup %s -L GPL -l C strlcpy\n\n' ${backend} 136 | } 137 | LOOKUP_help && return 0 138 | 139 | if [[ -n ${lookup_complete} ]] ; then 140 | 141 | LOOKUP_guard -fd __lookup_${backend}_langs || 142 | function __lookup_${backend}_langs() { 143 | _describe -t koders_langs 'known languages' known_langs 144 | } 145 | 146 | LOOKUP_guard -fd __lookup_${backend}_licences || 147 | function __lookup_${backend}_licences() { 148 | local l 149 | local -a ls 150 | 151 | ls=() 152 | for l in ${(k)known_licences}; do 153 | ls+=("$l:${known_licences[$l]}") 154 | done 155 | _describe -t koders_licences 'known licences' ls 156 | } 157 | 158 | comp_args=( 159 | '-l[limit search to specific language]:language:__lookup_'${backend}'_langs' 160 | '-L[limit search to specific licence]:licence:__lookup_'${backend}'_licences' 161 | '*:source code search string:true' 162 | ) 163 | 164 | _arguments -s -w -A '-*' ${comp_args} && return 0 165 | _message 'source code search string' 166 | return 0 167 | fi 168 | 169 | local lang licence 170 | local -x QUERY 171 | 172 | zstyle -s "${lookup_context}" default-lang lang || lang='*' 173 | zstyle -s "${lookup_context}" default-licence licence || licence='*' 174 | 175 | lu_parseopts_args=( l string L string ) 176 | LOOKUP_parseopts "$@" || return 1 177 | [[ -n ${opts[-l]} ]] && lang="${opts[-l]}" 178 | [[ -n ${opts[-L]} ]] && licence="${opts[-L]}" 179 | 180 | QUERY="${args[*]}" 181 | LOOKUP_query_handler || return 1 182 | if [[ -z ${QUERY} ]] ; then 183 | LOOKUP_help -f 184 | return 1 185 | fi 186 | 187 | LOOKUP_encode -s -q 188 | LOOKUP_browser "http://koders.com/default.aspx?s=${QUERY}&la=${lang}&li=${licence}" 189 | return $? 190 | -------------------------------------------------------------------------------- /usr_share_grml/zsh/functions/Lookup/Backends/LOOKUP_be_leo: -------------------------------------------------------------------------------- 1 | ### vim:ft=zsh:foldmethod=marker 2 | ## dict.leo.org search backend for lookup 3 | ## Copyright: 2009, Frank Terbeck 4 | ## 5 | ## This was the first non-trivial backend for lookup. Therefore, 6 | ## it contains some guidelines on how to write backends and what they 7 | ## are expected to do. 8 | ## 9 | ## For consistency in usage among different backends, please try 10 | ## to follow the general style of this one. 11 | ## 12 | 13 | # This should be the first thing a backend does. 14 | # It makes sure a backend function is not run directly by a user, but 15 | # only via lookup(), lu() or _lookup(). 16 | LOOKUP_guard || return 1 17 | 18 | # This check is required and it should be the second thing the backend does. 19 | # If $lookup_describe is not empty, only print a short description 20 | # of what the backend does. Without a newline at the end! 21 | [[ -n ${lookup_describe} ]] && 22 | printf '%s' 'translations via dict.leo.org' && 23 | return 0 24 | 25 | # declare variables. Assume warncreateglobal is enabled. 26 | local lang lookup_context 27 | local -a comp_args 28 | local -A opts supported_langs interface_lang 29 | 30 | # For the actual query string, always use QUERY and make it 'local -x'! 31 | # Parts of the lookup system depend on $QUERY to be declared like this! 32 | local -x QUERY 33 | 34 | supported_langs=( 35 | ende 'english german' 36 | frde 'french german' 37 | esde 'spanish german' 38 | itde 'italian german' 39 | chde 'chinese german' 40 | ) 41 | 42 | # To find out the current context string you can use the LOOKUP_context() 43 | # function like this. Please don't use $context or $curcontext to store 44 | # the result (that may clash with compsys). If you use lookup_context 45 | # you cannot go wrong. For modifying the local-part of the context, see 46 | # the comment in the LOOKUP_context file. 47 | lookup_context="$(LOOKUP_context)" 48 | 49 | # Lookup backends should be self-documenting. 50 | # You need to provide a function that prints a useful message that helps 51 | # the user use the backend. 52 | # DO NOT hardcode the name of the function. Always use LOOKUP_help_${backend} 53 | # and guard its definition by 'LOOKUP_guard -fd LOOKUP_help_${backend}' just 54 | # like it is done here. 55 | LOOKUP_guard -fd LOOKUP_help_${backend} || 56 | function LOOKUP_help_${backend}() { 57 | LOOKUP_guard || return 1 58 | #-80characters-----------------------------------------------------------------# 59 | printf 'usage: %s [-l lang] \n' ${backend} 60 | printf ' -l specify a language definition string\n' 61 | printf '\nAvailable language definition strings:\n' 62 | for lang in ${(k)supported_langs} ; do 63 | printf '%6s - %s\n' ${lang} ${supported_langs[$lang]} 64 | done 65 | printf '\n Makes dictionary lookups via dict.leo.org.\n\n' 66 | printf ' Default language code: ende (german <-> english).\n' 67 | printf ' The interface language used by the website defaults to: en\n' 68 | printf '\n These can be modified via the '\''default-lang'\'' and '\''interface-lang'\''\n' 69 | printf ' styles in this context: %s\n\n' ${lookup_context} 70 | printf 'Examples:\n' 71 | printf ' %% zstyle '\'':lookup:*:%s:*'\'' default-lang frde\n' ${backend} 72 | printf ' %% zstyle '\'':lookup:*:%s:*'\'' interface-lang de\n\n' ${backend} 73 | printf ' %% lookup %s sugar\n' ${backend} 74 | printf ' %% lookup %s -l frde Zucker\n\n' ${backend} 75 | } 76 | 77 | # This call must be here, too. Just after you defined the help function. 78 | # It handles the global -h option of lookup correctly. 79 | LOOKUP_help && return 0 80 | 81 | # This test is needed, too. 82 | # Backends are supposed to bring there own completion. 83 | if [[ -n ${lookup_complete} ]] ; then 84 | # During development, you can just put a 85 | #return 0 86 | # here. That will disable completion for the backend and 87 | # prevent breakage for other backends. 88 | 89 | # completion sub-functions should be called: 90 | # __lookup_${backend}_() 91 | # Again, DO NOT hardcode the name. Use ${backend}! 92 | # guard their definition by checking the $functions[] entry 93 | # that belongs to your sub-function. 94 | LOOKUP_guard -fd __lookup_${backend}_supported_langs || 95 | function __lookup_${backend}_supported_langs() { 96 | local l 97 | local -a ls 98 | 99 | ls=() 100 | for l in ${(k)supported_langs}; do 101 | ls+=("$l:${supported_langs[$l]}") 102 | done 103 | _describe -t leo_langs 'supported languages' ls 104 | } 105 | 106 | comp_args=( 107 | '-l[set languages]:supported languages:__lookup_'${backend}'_supported_langs' 108 | '*:dict.leo.org query:true' 109 | ) 110 | 111 | _arguments -s -w -A '-*' ${comp_args} && return 0 112 | _message 'dict.leo.org query' 113 | 114 | return 0 115 | # end of completion code # 116 | fi 117 | 118 | # parse possible options of the backend. 119 | # 'LOOKUP_parseopts' is the recommended way of doing that. 120 | # See the top of that function's file for an explained example. 121 | # Since LOOKUP_parseopts() returns its findings via $opt[] and $args[], you 122 | # should *never* use variables of those names in your backends. 123 | lu_parseopts_args=( l string ) 124 | LOOKUP_parseopts "$@" || return 1 125 | lang=${opts[-l]} 126 | 127 | # all configuration should be done via zstyle. The context should always be 128 | # the result of what LOOKUP_context() tells us (see the $lookup_context comment 129 | # earlier, too). Also set reasonable defaults. 130 | if [[ -z ${lang} ]] ; then 131 | zstyle -s "${lookup_context}" default-lang lang || lang='ende' 132 | fi 133 | 134 | zstyle -s "${lookup_context}" interface-lang interface_lang || interface_lang='en' 135 | 136 | # If applicable, use the remaining arguments as QUERY. 137 | # If the backend used LOOKUP_parseopts() before, the remaining arguments 138 | # are in $args[]. If not, they can be assigned like this: 139 | # QUERY="$*" 140 | # 141 | # Since we do use LOOKUP_parseopts(), we'll do it like this: 142 | QUERY="${args[*]}" 143 | 144 | # Call LOOKUP_query_handler() to support the -Q and -q options of lookup. 145 | # This should also be called like this in every case, as this supports 146 | # a return value from handler functions that indicates unrecoverable errors. 147 | # If you want to support return values from handlers, use the 148 | # $lookup_communicate[] hash, which is meant to be used for that. It can 149 | # also be used to get additional information into the handler. 150 | # See LOOKUP_be_letssingit for an example. 151 | LOOKUP_query_handler || return 1 152 | 153 | # Do appropriate error checking and give usage information 154 | # if the query is empty. 155 | if [[ -z ${(Mk)supported_langs:#$lang} ]] ; then 156 | printf 'Unknown language definition: '\''%s'\''.\n\n' ${lang} 157 | # Clear out $QUERY, so we get the usage message below. 158 | QUERY='' 159 | fi 160 | if [[ -z ${QUERY} ]] ; then 161 | # -f means, "display the help text, no matter what." 162 | LOOKUP_help -f 163 | return 1 164 | fi 165 | 166 | # You may also put in hooks into your backend. You don't need to though. :) 167 | # To do so, use the LOOKUP_hook function. The first argument should be a name 168 | # for the hook. That will adjust the local-part of the context to that name. 169 | # If you don't want that, use -- as the first argument. Then the context 170 | # remains unchanged. 171 | # The rest of the arguments are handed over to the hook function unchanged. 172 | # There is no convention as to what arguments should be provided or whether 173 | # $lookup_communicate[] should be used. Everything is possible; just make 174 | # sure you document your hooks properly in the help function earlier. 175 | # 176 | # A sample hook call may look like this: 177 | #LOOKUP_hook "pre-encode" $QUERY $lang $interface_lang 178 | 179 | # Use LOOKUP_encode() for proper url encoding of the QUERY. 180 | # Since, QUERY is the most common use case of LOOKUP_encode, it has 181 | # a special option to handle that variable. 182 | # For other variables you want to encode, do: 183 | # foo="$(LOOKUP_encode ${foo})" 184 | LOOKUP_encode -q 185 | 186 | # Use our browser wrapper to open the URI, it'll handle everything just right. 187 | LOOKUP_browser "http://dict.leo.org?lang=${interface_lang}&lp=${lang}&search=${QUERY}" 188 | 189 | # Explicitly return $?. 190 | return $? 191 | -------------------------------------------------------------------------------- /usr_share_grml/zsh/functions/Lookup/Backends/LOOKUP_be_letssingit: -------------------------------------------------------------------------------- 1 | ### vim:ft=zsh:foldmethod=marker 2 | ## letssingit.com search backend for lookup 3 | ## Copyright: 2009, Frank Terbeck 4 | 5 | LOOKUP_guard || return 1 6 | [[ -n ${lookup_describe} ]] && 7 | printf '%s' 'search letssingit.com' && 8 | return 0 9 | 10 | local mode lookup_context 11 | local -a comp_args 12 | local -A opts supported_modes 13 | local -x QUERY 14 | 15 | lookup_context="$(LOOKUP_context)" 16 | 17 | supported_modes=( 18 | artist 'search by artist' 19 | album 'search by album' 20 | song 'search by song name' 21 | lyrics 'search contents of lyrics' 22 | ) 23 | 24 | LOOKUP_guard -fd LOOKUP_help_${backend} || 25 | function LOOKUP_help_${backend}() { 26 | LOOKUP_guard || return 1 27 | printf 'usage: %s [-m mode] \n' ${backend} 28 | printf ' -m specify search mode\n' 29 | printf '\n Make music related queries via letssingit.com\n' 30 | printf '\nAvailable modes are::\n' 31 | for mode in ${(kon)supported_modes} ; do 32 | printf '%8s - %s\n' ${mode} ${supported_modes[$mode]} 33 | done 34 | printf '\n The default mode is '\''artist'\'', which can be modified via the\n' 35 | printf ' '\''default-mode'\'' style in this context: %s\n\n' ${lookup_context} 36 | printf 'Examples:\n' 37 | printf ' %% zstyle '\'':lookup:*:%s:*'\'' default-mode song\n' ${backend} 38 | printf ' %% lookup %s Led Zeppelin\n' ${backend} 39 | printf ' %% lookup %s -m album Machine Head\n' ${backend} 40 | printf ' %% lookup %s -m song Paint it Black\n' ${backend} 41 | } 42 | LOOKUP_help && return 0 43 | 44 | if [[ -n ${lookup_complete} ]] ; then 45 | LOOKUP_guard -fd __lookup_${backend}_supported_modes || 46 | function __lookup_${backend}_supported_modes() { 47 | local m 48 | local -a ms 49 | 50 | ms=() 51 | for m in ${(k)supported_modes}; do 52 | ms+=("$m:${supported_modes[$m]}") 53 | done 54 | _describe -t letssingit_modes 'supported search modes' ms 55 | } 56 | 57 | comp_args=( 58 | '-m[set search mode]:supported search modes:__lookup_'${backend}'_supported_modes' 59 | '*:letssingit.com query:true' 60 | ) 61 | 62 | _arguments -s -w -A '-*' ${comp_args} && return 0 63 | _message 'letssingit.com query' 64 | return 0 65 | fi 66 | 67 | lu_parseopts_args=( m string ) 68 | LOOKUP_parseopts "$@" || return 1 69 | mode=${opts[-m]} 70 | 71 | if [[ -z ${mode} ]] ; then 72 | zstyle -s "${lookup_context}" default-mode mode || mode='artist' 73 | fi 74 | 75 | QUERY="${args[*]}" 76 | lookup_communicate[mode]=${mode} 77 | LOOKUP_query_handler || return 1 78 | if [[ -z ${(Mk)supported_modes:#$mode} ]] ; then 79 | printf 'Unknown search mode: '\''%s'\''.\n\n' ${mode} 80 | QUERY='' 81 | fi 82 | if [[ -z ${QUERY} ]] ; then 83 | LOOKUP_help -f 84 | return 1 85 | fi 86 | 87 | LOOKUP_encode -q 88 | LOOKUP_browser "http://search.letssingit.com/cgi-exe/am.cgi?a=search_quick&l=${mode}&s=${QUERY}" 89 | return $? 90 | -------------------------------------------------------------------------------- /usr_share_grml/zsh/functions/Lookup/Backends/LOOKUP_be_rfc: -------------------------------------------------------------------------------- 1 | ### vim:ft=zsh:foldmethod=marker 2 | ## RFC backend for lookup 3 | ## Copyright: 2009, Frank Terbeck 4 | 5 | # TODO: This is currently just a real lookup. rfc-editor.com supports searching. 6 | # ...would be nice... 7 | 8 | LOOKUP_guard || return 1 9 | [[ -n ${lookup_describe} ]] && 10 | printf '%s' 'RFC lookup' && 11 | return 0 12 | 13 | local lookup_context 14 | local -a comp_args 15 | 16 | lookup_context="$(LOOKUP_context)" 17 | 18 | LOOKUP_guard -fd LOOKUP_help_${backend} || 19 | function LOOKUP_help_${backend}() { 20 | LOOKUP_guard || return 1 21 | #-80characters-----------------------------------------------------------------# 22 | printf 'usage: %s [-{d,w}] \n' ${backend} 23 | printf ' -d ask to download RFC before reading\n' 24 | printf ' -w just watch. do not ask to download\n' 25 | printf '\n Read RFCs by number.\n' 26 | printf ' Supports local files and remote files (via rfc-editor.com).\n' 27 | printf '\n First, it looks for a local version of the RFC (within a given path, see\n' 28 | printf ' Styles below); if a local version is found, it is opened in a browser. If it\n' 29 | printf ' cannot be found (per default) the user is asked if we should try to download\n' 30 | printf ' the RFC in question via FTP from rfc-editor.com (only works if the zsh/zftp\n' 31 | printf ' module can be loaded). If the answer is yes, the file is downloaded. If that\n' 32 | printf ' was successful the *local* file is viewed. If the answer is no, the remote\n' 33 | printf ' URL is opened in a browser.\n' 34 | printf '\nStyles:\n' 35 | printf ' The context in which styles are looked up is:\n' 36 | printf ' %s\n' ${lookup_context} 37 | LOOKUP_context -l local-files 38 | lookup_context="$(LOOKUP_context)" 39 | printf ' If a local file is viewed, that changes to:\n' 40 | printf ' %s\n\n' ${lookup_context} 41 | printf ' search-path: a list style, defining where to look for local RFCs\n' 42 | printf ' (Default: one entry: $HOME - "%s")\n' ${HOME} 43 | printf ' save-path: when downloading RFCs, save them to this directory\n' 44 | printf ' (Default: $HOME - "%s")\n' ${HOME} 45 | printf ' download: boolean; changes the default downloading behaviour\n' 46 | printf ' (Default: true: always ask to download non-local RFCs)\n' 47 | printf '\n When looking for local RFCs, this backend looks for files named like this:\n' 48 | printf ' rfc<->.txt(|.gz|.bz2) (eg: rfc123.txt, rfc234.txt.gz or rfc345.txt.bz2)\n' 49 | printf '\nExamples:\n' 50 | printf ' %% zstyle '\'':lookup:*:%s:*'\'' search-path /usr/share/doc/RFC/links ~/myrfcs\n' ${backend} 51 | printf ' %% zstyle '\'':lookup:*:%s:*'\'' save-path ~/myrfcs\n' ${backend} 52 | printf ' %% zstyle '\'':lookup:*:%s:*'\'' download false\n' ${backend} 53 | printf ' %% lookup %s 881\n' ${backend} 54 | printf ' %% lookup %s -w 881\n\n' ${backend} 55 | } 56 | LOOKUP_help && return 0 57 | 58 | if [[ -n ${lookup_complete} ]] ; then 59 | comp_args=( 60 | '-d[attempt do download RFCs]:' 61 | '-w[never attempt do download RFCs]:' 62 | '*:RFC number:true' 63 | ) 64 | 65 | _arguments -s -w -A '-*' ${comp_args} && return 0 66 | _message 'RFC number' 67 | return 0 68 | fi 69 | 70 | local dir file save_path search_path yesno 71 | local -i justwatch 72 | local -A opts 73 | local -x QUERY 74 | 75 | zstyle -s "${lookup_context}" save-path save_path || save_path=${HOME} 76 | zstyle -a "${lookup_context}" search-path search_path || search_path=(${HOME}) 77 | 78 | if zstyle -t "${lookup_context}" download ; then 79 | justwatch='0' 80 | else 81 | justwatch='1' 82 | fi 83 | 84 | lu_parseopts_args=( d bool w bool ) 85 | LOOKUP_parseopts "$@" || return 1 86 | [[ ${opts[-d]} == 'yes' ]] && justwatch=0 87 | [[ ${opts[-w]} == 'yes' ]] && justwatch=1 88 | 89 | QUERY="${args[*]}" 90 | LOOKUP_query_handler || return 1 91 | if [[ -z ${QUERY} ]] ; then 92 | LOOKUP_help -f 93 | return 1 94 | fi 95 | 96 | for dir in ${search_path} ; do 97 | file="${dir}/rfc${QUERY}.txt" 98 | if [[ -r ${file} ]] ; then 99 | LOOKUP_browser ${file} 100 | return $? 101 | elif [[ -r ${file}.gz ]] ; then 102 | LOOKUP_context -l local-files 103 | LOOKUP_browser ${file}.gz 104 | return $? 105 | elif [[ -r ${file}.bz2 ]] ; then 106 | LOOKUP_context -l local-files 107 | LOOKUP_browser ${file}.bz2 108 | return $? 109 | fi 110 | done 111 | 112 | if (( lookup_printout == 0 )) && (( justwatch == 0 )) && [[ -n ${save_path} ]] ; then 113 | if [[ -z ${builtins[zftp]} ]] ; then 114 | if ! zmodload zsh/zftp ; then 115 | printf 'Module zsh/zftp could not be loaded, cannot download.\n' 116 | return 1 117 | fi 118 | fi 119 | printf 'RFC: %s, save-path: %s\n' ${QUERY} ${save_path} 120 | printf 'Shall I download the rfc in question? [y/n] ' 121 | read -q yesno 122 | if [[ ${yesno} == 'y' ]] ; then 123 | LOOKUP_context -l local-files 124 | file="${save_path}/rfc${QUERY}.txt" 125 | 126 | zftp open ftp.rfc-editor.org "anonymous" "zsh_lookup@somewhere.tld" 127 | zftp cd "/in-notes" 128 | zftp binary 129 | zftp get "rfc${QUERY}.txt" > ${file} 130 | quit 131 | 132 | LOOKUP_browser ${file} 133 | return $? 134 | fi 135 | fi 136 | 137 | LOOKUP_browser "ftp://ftp.rfc-editor.org/in-notes/rfc${QUERY}.txt" 138 | return $? 139 | -------------------------------------------------------------------------------- /usr_share_grml/zsh/functions/Lookup/Backends/LOOKUP_be_sourceforge: -------------------------------------------------------------------------------- 1 | ### vim:ft=zsh:foldmethod=marker 2 | ## sf.net search backend for lookup 3 | ## Copyright: 2009, Frank Terbeck 4 | 5 | LOOKUP_guard || return 1 6 | [[ -n ${lookup_describe} ]] && 7 | printf '%s' 'search sourceforge.net' && 8 | return 0 9 | 10 | local -a comp_args 11 | 12 | LOOKUP_guard -fd LOOKUP_help_${backend} || 13 | function LOOKUP_help_${backend}() { 14 | LOOKUP_guard || return 1 15 | printf 'usage: %s \n' ${backend} 16 | printf '\n Query sourceforge.net for software projects.\n' 17 | printf '\nExamples:\n' 18 | printf ' %% lookup %s zsh\n' ${backend} 19 | printf ' %% lookup %s fdm\n\n' ${backend} 20 | } 21 | LOOKUP_help && return 0 22 | 23 | if [[ -n ${lookup_complete} ]] ; then 24 | _message 'sf.net search string' 25 | return 0 26 | fi 27 | 28 | local -x QUERY 29 | 30 | QUERY="$*" 31 | LOOKUP_query_handler || return 1 32 | if [[ -z ${QUERY} ]] ; then 33 | LOOKUP_help -f 34 | return 1 35 | fi 36 | 37 | LOOKUP_encode -s -q 38 | LOOKUP_browser "http://sourceforge.net/search/?words=${QUERY}&type_of_search=soft" 39 | return $? 40 | -------------------------------------------------------------------------------- /usr_share_grml/zsh/functions/Lookup/Backends/LOOKUP_be_usenet: -------------------------------------------------------------------------------- 1 | ### vim:ft=zsh:foldmethod=marker 2 | ## usenet search backend for lookup via groups.google.com 3 | ## Copyright: 2009, Frank Terbeck 4 | 5 | LOOKUP_guard || return 1 6 | [[ -n ${lookup_describe} ]] && 7 | printf '%s' 'usenet search' && 8 | return 0 9 | 10 | local lookup_context 11 | local -a comp_args 12 | local -A known_modes 13 | 14 | lookup_context="$(LOOKUP_context)" 15 | 16 | known_modes=( 17 | text 'Free text search' 18 | msgid 'Search for Message-ID: header' 19 | author 'Search for a specific author' 20 | ) 21 | 22 | LOOKUP_guard -fd LOOKUP_help_${backend} || 23 | function LOOKUP_help_${backend}() { 24 | LOOKUP_guard || return 1 25 | local m 26 | printf 'usage: %s [-{t,m}] [-a ] \n' ${backend} 27 | printf ' -m search for message id\n' 28 | printf ' -t free text search\n' 29 | printf ' -a search for messages by \n' 30 | printf '\n Search google'\''s usenet archives via groups.google.com.\n' 31 | printf '\n Per default, free text searches are done, which can be modified via the\n' 32 | printf ' '\''default-mode'\'' style in this context: %s\n\n' ${lookup_context} 33 | for m in ${(k)known_modes} ; do 34 | printf '%8s - %s\n' $m ${known_modes[$m]} 35 | done 36 | printf '\n As an exception the argument may be empty in author mode.\n' 37 | printf ' If you set default-mode to '\''author'\'', you may also set the\n' 38 | printf ' '\''default-author'\'' style (which defaults to '\''Joe User'\'').\n' 39 | printf '\nExamples:\n' 40 | printf ' %% zstyle '\'':lookup:*:%s:*'\'' default-mode author\n' ${backend} 41 | printf ' %% zstyle '\'':lookup:*:%s:*'\'' default-author "Dr. Foo Bar"\n' ${backend} 42 | printf ' %% lookup %s zsh prompt colours\n' ${backend} 43 | printf ' %% lookup %s -a pws Bugs in zsh\n\n' ${backend} 44 | } 45 | LOOKUP_help && return 0 46 | 47 | if [[ -n ${lookup_complete} ]] ; then 48 | comp_args=( 49 | '-a[specify author]:author:' 50 | '-m[search for message id]:message id:' 51 | '-t[free text search]:text:' 52 | '*:usenet search string:true' 53 | ) 54 | 55 | _arguments -s -w -A '-*' ${comp_args} && return 0 56 | _message 'usenet search string' 57 | return 0 58 | fi 59 | 60 | local mode author 61 | local -A opts 62 | local -x QUERY 63 | 64 | lu_parseopts_args=( m bool t bool a string ) 65 | LOOKUP_parseopts "$@" || return 1 66 | [[ ${opts[-t]} == 'yes' ]] && mode='text' 67 | [[ ${opts[-m]} == 'yes' ]] && mode='msgid' 68 | if [[ -n ${opts[-a]} ]] ; then 69 | mode='author' 70 | author="&as_uauthors=$(LOOKUP_encode ${opts[-a]})" 71 | fi 72 | 73 | if [[ -z ${mode} ]] ; then 74 | zstyle -s "${lookup_context}" default-mode mode || mode='text' 75 | if [[ mode == 'author' ]] && [[ -z ${author} ]] ; then 76 | local a 77 | zstyle -s "${lookup_context}" default-author a || a='Joe User' 78 | author="&as_uauthors=$(LOOKUP_encode $a)" 79 | fi 80 | fi 81 | 82 | QUERY="${args[*]}" 83 | LOOKUP_query_handler || return 1 84 | if [[ -z ${(Mk)known_modes:#$mode} ]] ; then 85 | printf 'Unknown mode: '\''%s'\''.\n\n' ${mode} 86 | QUERY='' 87 | fi 88 | if [[ -z ${QUERY} ]] && [[ ${mode} != 'author' ]] ; then 89 | LOOKUP_help -f 90 | return 1 91 | fi 92 | 93 | LOOKUP_encode -s -q 94 | if [[ ${mode} == 'msgid' ]] ; then 95 | LOOKUP_browser "http://groups.google.com/groups?selm=${QUERY}" 96 | return $? 97 | fi 98 | 99 | LOOKUP_browser "http://groups.google.com/groups?q=${QUERY}${author}" 100 | return $? 101 | -------------------------------------------------------------------------------- /usr_share_grml/zsh/functions/Lookup/Backends/LOOKUP_be_wikipedia: -------------------------------------------------------------------------------- 1 | ### vim:ft=zsh:foldmethod=marker 2 | ## wikipedia backend for lookup 3 | ## Copyright: 2009, Frank Terbeck 4 | 5 | LOOKUP_guard || return 1 6 | [[ -n ${lookup_describe} ]] && 7 | printf '%s' 'search wikipedia' && 8 | return 0 9 | 10 | local lookup_context 11 | local -a comp_args private_completions 12 | local -A known_locations 13 | 14 | lookup_context="$(LOOKUP_context)" 15 | 16 | known_locations=( 17 | # yeah, there are more... a lot more. 18 | ca 'Catalan' 19 | cs 'Czech' 20 | da 'Danish' 21 | de 'German' 22 | en 'English' 23 | eo 'Esperanto' 24 | es 'Spanish' 25 | 'fi' 'Finnish' 26 | fr 'French' 27 | hu 'Hungarian' 28 | it 'Italian' 29 | ja 'Japanese' 30 | nl 'Dutch' 31 | no 'Norwegian' 32 | pt 'Portuguese' 33 | pl 'Polish' 34 | ro 'Romanian' 35 | ru 'Russian' 36 | sk 'Slovenian' 37 | sv 'Swedish' 38 | tr 'Turkish' 39 | uk 'Ukrainian' 40 | ) 41 | 42 | LOOKUP_guard -fd LOOKUP_help_${backend} || 43 | function LOOKUP_help_${backend}() { 44 | LOOKUP_guard || return 1 45 | local l 46 | printf 'usage: %s [-l ] \n' ${backend} 47 | printf ' -l use a specific non-default wikipedia location\n' 48 | printf '\n Query wikipedia.org about stuff you don'\''t know. :-)\n' 49 | printf '\nKnown location codes:\n' 50 | for l in ${(kon)known_locations}; do 51 | printf '%6s - %s\n' $l ${known_locations[$l]} 52 | done 53 | printf '\n There are more than that, obviously. Inclusion of codes had to stop\n' 54 | printf ' somewhere, so I settled for codes, that had 100.000+ articles at the time\n' 55 | printf ' of writing. The default location is '\''en'\'', which can be modified via the\n' 56 | printf ' '\''default-location'\'' style in this context:\n' 57 | printf ' %s\n' ${lookup_context} 58 | printf '\n The completion code only completes the known locations by default. If your\n' 59 | printf ' code is missing you can add it via the '\''my-completions'\'' list style,\n' 60 | printf ' looked up in this context: '\'':completion:*:lookup-%s:'\''\n' ${backend} 61 | printf '\nExamples:\n' 62 | printf ' %% zstyle '\'':lookup:*:%s:*'\'' default-location de\n' ${backend} 63 | printf ' %% zstyle '\'':completion:*:lookup-%s:'\'' my-completions gr:Greek\n' ${backend} 64 | printf ' %% lookup %s zsh\n' ${backend} 65 | printf ' %% lookup %s -l de zsh\n' ${backend} 66 | printf ' %% lookup %s -l no zsh\n\n' ${backend} 67 | } 68 | LOOKUP_help && return 0 69 | 70 | if [[ -n ${lookup_complete} ]] ; then 71 | 72 | zstyle -a ":completion:${curcontext}" my-completions private_completions 73 | 74 | LOOKUP_guard -fd __lookup_${backend}_known_locations || 75 | function __lookup_${backend}_known_locations() { 76 | local l 77 | local -a ls 78 | 79 | ls=(${private_completions}) 80 | for l in ${(k)known_locations}; do 81 | ls+=("$l:${known_locations[$l]}") 82 | done 83 | _describe -t leo_langs 'known locations' ls 84 | } 85 | 86 | comp_args=( 87 | '-l[choose a wikipedia flavour]:known locations:__lookup_'${backend}'_known_locations' 88 | '*:wikipedia search:true' 89 | ) 90 | 91 | _arguments -s -w -A '-*' ${comp_args} && return 0 92 | _message 'wikipedia search' 93 | return 0 94 | fi 95 | 96 | local loc 97 | local -A opts 98 | local -x QUERY 99 | 100 | zstyle -s "${lookup_context}" default-location loc || loc='en' 101 | 102 | lu_parseopts_args=( l string ) 103 | LOOKUP_parseopts "$@" || return 1 104 | [[ -n ${opts[-l]} ]] && loc="${opts[-l]}" 105 | 106 | QUERY="${args[*]}" 107 | LOOKUP_query_handler || return 1 108 | if [[ -z ${QUERY} ]] ; then 109 | LOOKUP_help -f 110 | return 1 111 | fi 112 | 113 | LOOKUP_encode -q 114 | LOOKUP_browser "http://${loc}.wikipedia.org/w/wiki.phtml?search=${QUERY}&go=Go" 115 | return $? 116 | -------------------------------------------------------------------------------- /usr_share_grml/zsh/functions/Lookup/Backends/LOOKUP_be_zsh_mla: -------------------------------------------------------------------------------- 1 | ### vim:ft=zsh:foldmethod=marker 2 | ## zsh mla search backend for lookup 3 | ## Copyright: 2009, Frank Terbeck 4 | 5 | LOOKUP_guard || return 1 6 | [[ -n ${lookup_describe} ]] && 7 | printf '%s' 'search interface for zsh'\''s ML archive' && 8 | return 0 9 | 10 | local lookup_context 11 | local -a comp_args 12 | 13 | lookup_context="$(LOOKUP_context)" 14 | 15 | LOOKUP_guard -fd LOOKUP_help_${backend} || 16 | function LOOKUP_help_${backend}() { 17 | LOOKUP_guard || return 1 18 | printf 'usage: %s [-{n,u,w}] [-{l,y} ] \n' ${backend} 19 | printf ' -n search the archives for keywords ('\''normal'\'' mode)\n' 20 | printf ' -u search user archive by X-Seq: header\n' 21 | printf ' -w search workers archive by X-Seq: header\n' 22 | printf ' -l limit search to a specific list\n' 23 | printf ' -y limit search to a specific year\n' 24 | printf '\n Query zsh[1]'\''s Mailing List Arhive[2].' 25 | printf '\n The normal keyword search is done via google'\''s '\''site:'\'' feature.\n' 26 | printf ' In X-Seq modes (-u and -w), all non-digits are stripped from query.\n' 27 | printf '\n The default mode is '\''normal'\'', which can be modified via the\n' 28 | printf ' '\''default-mode'\'' style in this context: %s\n' ${lookup_context} 29 | printf ' Valid values are: normal, users, workers\n' 30 | printf '\nExamples:\n' 31 | printf ' %% zstyle '\'':lookup:*:%s:*'\'' default-mode users\n' ${backend} 32 | printf ' %% lookup %s released\n' ${backend} 33 | printf ' %% lookup %s -u 12345\n' ${backend} 34 | printf ' %% lookup %s -w 12345\n' ${backend} 35 | printf '\n[1] \n' 36 | printf '[2] \n' 37 | } 38 | LOOKUP_help && return 0 39 | 40 | if [[ -n ${lookup_complete} ]] ; then 41 | comp_args=( 42 | '-u[users x-seq search]:users\: X-Seq header number:' 43 | '-w[workers x-seq search]:workers\: X-Seq header number:' 44 | '-l[limit search to a specific list]:list name:(users workers "*")' 45 | '-y[limit search to a specific year]:year - "*" means all years:' 46 | '*:zsh mla search:true' 47 | ) 48 | 49 | _arguments -s -w -A '-*' ${comp_args} && return 0 50 | _message 'zsh mla search' 51 | return 0 52 | fi 53 | 54 | local list year mode 55 | local -A opts 56 | local -x QUERY 57 | 58 | list='*' 59 | year='*' 60 | lu_parseopts_args=( 61 | n bool 62 | u bool 63 | w bool 64 | l string 65 | y string 66 | ) 67 | LOOKUP_parseopts "$@" || return 1 68 | [[ ${opts[-u]} == 'yes' ]] && mode='users' 69 | [[ ${opts[-w]} == 'yes' ]] && mode='workers' 70 | [[ ${opts[-n]} == 'yes' ]] && mode='normal' 71 | [[ -n ${opts[-l]} ]] && list="${opts[-l]}" 72 | [[ -n ${opts[-y]} ]] && year="${opts[-y]}" 73 | 74 | if [[ -z ${mode} ]] ; then 75 | zstyle -s "${lookup_context}" default-mode mode || mode='normal' 76 | fi 77 | 78 | QUERY="${args[*]}" 79 | LOOKUP_query_handler || return 1 80 | if [[ -z ${QUERY} ]] ; then 81 | LOOKUP_help -f 82 | return 1 83 | fi 84 | 85 | case ${mode} in 86 | (users|workers) 87 | QUERY="${QUERY//[^0-9]/}" 88 | if [[ ${mode} == 'users' ]] ; then 89 | LOOKUP_browser "http://www.zsh.org/cgi-bin/mla/redirect?USERNUMBER=${QUERY}" 90 | return $? 91 | else 92 | LOOKUP_browser "http://www.zsh.org/cgi-bin/mla/redirect?WORKERNUMBER=${QUERY}" 93 | return $? 94 | fi 95 | ;; 96 | (*) 97 | LOOKUP_encode -s -q 98 | LOOKUP_browser "http://www.google.com/search?q=site:www.zsh.org/mla/${list}/${year}/+${QUERY}" 99 | return $? 100 | ;; 101 | esac 102 | -------------------------------------------------------------------------------- /usr_share_grml/zsh/functions/Lookup/LOOKUP_browser: -------------------------------------------------------------------------------- 1 | ### vim:ft=zsh:foldmethod=marker 2 | ## 3 | ## Spawn an appropriate browser. 4 | ## Copyright: 2009, Frank Terbeck 5 | ## 6 | 7 | LOOKUP_guard || return 1 8 | local arg debug format lookup_browser uri i lookup_context 9 | local -a lookup_browser_args 10 | 11 | lookup_ei='-browser-' 12 | uri="$1" 13 | 14 | lookup_context="$(LOOKUP_context)" 15 | 16 | LOOKUP_hook -- "$@" 17 | zstyle -t "${lookup_context}" debug && 18 | printf 'LOOKUP_browser: current context: "%s"\n' "${lookup_context}" 19 | 20 | if (( lookup_printout > 0 )) || zstyle -t "${lookup_context}" debug ; then 21 | debug='yes' 22 | fi 23 | 24 | if (( lookup_remote > 0 )) ; then 25 | zstyle -s "${lookup_context}" gui-browser lookup_browser 26 | zstyle -a "${lookup_context}" gui-formats lookup_browser_args 27 | else 28 | zstyle -s "${lookup_context}" txt-browser lookup_browser 29 | zstyle -a "${lookup_context}" txt-formats lookup_browser_args 30 | fi 31 | 32 | [[ -z ${lookup_browser} ]] && lookup_browser=${BROWSER:-w3m} 33 | (( ${#lookup_browser_args} == 0 )) && lookup_browser_args=( "%s" ) 34 | 35 | for i in {1..${#lookup_browser_args}} ; do 36 | zformat -f format ${lookup_browser_args[$i]} s:${uri} 37 | lookup_browser_args[$i]="${format}" 38 | done 39 | 40 | if [[ -n ${debug} ]] ; then 41 | print -- ${lookup_browser} ${(qq)lookup_browser_args} 42 | return 0 43 | else 44 | ${lookup_browser} ${lookup_browser_args} 45 | return $? 46 | fi 47 | -------------------------------------------------------------------------------- /usr_share_grml/zsh/functions/Lookup/LOOKUP_context: -------------------------------------------------------------------------------- 1 | ### vim:ft=zsh:foldmethod=marker 2 | ## get and set the current context 3 | ## Copyright: 2009, Frank Terbeck 4 | 5 | # If called without arguments, it spits out the current context. 6 | # If called with -l it sets the of the context 7 | # to . If called with -d, it sets the to its default. 8 | 9 | LOOKUP_guard || return 1 10 | local opt 11 | local -A opts 12 | 13 | lu_parseopts_args=( d bool l string ) 14 | LOOKUP_parseopts "$@" || return 1 15 | if [[ ${opts[-d]} == 'yes' ]] ; then 16 | lookup_lp="-default-" 17 | elif [[ -n ${opts[-l]} ]] ; then 18 | lookup_lp="${opts[-l]}" 19 | else 20 | printf ':lookup:%s:%s:%s' ${lookup_ei} ${backend} ${lookup_lp} 21 | fi 22 | return 0 23 | -------------------------------------------------------------------------------- /usr_share_grml/zsh/functions/Lookup/LOOKUP_encode: -------------------------------------------------------------------------------- 1 | ### vim:ft=zsh:foldmethod=marker 2 | ## url encoding for lookup queries, etc. 3 | 4 | LOOKUP_guard || return 1 5 | emulate -L zsh 6 | setopt extendedglob 7 | local input output ws=$'\t ' 8 | local -A opts 9 | 10 | lu_parseopts_args=( s bool q bool ) 11 | LOOKUP_parseopts "$@" || return 1 12 | if [[ ${opts[-q]} == 'yes' ]] ; then 13 | # -q: QUERY is declared 'local -x QUERY' in backends. 14 | # That means, it gets handed down to us. Apply our filters to it. 15 | unencQUERY="${QUERY}" 16 | set -- "${QUERY}" 17 | else 18 | set -- "${args[@]}" 19 | fi 20 | 21 | input=( ${(s::)1} ) 22 | output=${(j::)input/(#b)([^A-Za-z0-9_${ws}.!~*\'\(\)+-])/%${(l:2::0:)$(([##16]#match))}} 23 | 24 | if [[ ${opts[-s]} == 'yes' ]] ; then 25 | output=${${output##[$ws]#}%%[$ws]#} 26 | output="${output//+/%2B}" 27 | output=${output//[$ws]##/+} 28 | else 29 | output="${output//[$ws]/%20}" 30 | fi 31 | 32 | if [[ ${opts[-q]} == 'yes' ]] ; then 33 | QUERY=${output} 34 | else 35 | printf '%s' ${output} 36 | fi 37 | -------------------------------------------------------------------------------- /usr_share_grml/zsh/functions/Lookup/LOOKUP_guard: -------------------------------------------------------------------------------- 1 | ### vim:ft=zsh:foldmethod=marker 2 | ## Copyright: 2009, Frank Terbeck 3 | 4 | ### Usage: 5 | ## Check if we're called from the lookup subsystem. 6 | # This way you can guard your functions from being called by hand 7 | # by the user. Every function in lookup should do this as soon as 8 | # possible. 9 | # 10 | # LOOKUP_guard || return 1 11 | # 12 | ## Check if a function is defined already. 13 | # This is used to avoid nested functions to get defined over and 14 | # over again. Everytime you introduce a function in a backend, you 15 | # should use this idom. No matter if it's a helper function 16 | # (LOOKU_beh_${backend}_my_helper) or the function, that prints 17 | # the backend's documentation (LOOKUP_help_${backend}). 18 | # 19 | # LOOKUP_guard -fd LOOKUP_help_${backend} || 20 | # function LOOKUP_help_${backend}() { 21 | # LOOKUP_guard || return 1 22 | # ... 23 | # } 24 | 25 | local -i fail 26 | fail=1 27 | 28 | if [[ $1 == '-fd' ]] ; then 29 | # This function cannot use LOOKUP_parseopts() because that function 30 | # already uses LOOKUP_guard(). That would be an endless loop. 31 | # Since this function does not alter any 'local -x' variables, it 32 | # should be the one that doesn't require any other lookup() function. 33 | shift 34 | (( ${+functions[$1]} )) && return 0 35 | return 1 36 | fi 37 | 38 | (( lookup_complete > 0 )) && fail=0 39 | [[ -n ${backend} ]] && [[ -n ${lookup_ei} ]] && [[ -n ${lookup_help} ]] && fail=0 40 | 41 | if (( fail > 0 )) ; then 42 | printf '\nThis function is part of the lookup subsystem.\n' 43 | printf 'It is not supposed to be run by you, the user directly.\n' 44 | printf 'Use the appropriate backend via: lookup \n' 45 | printf 'See:\n' 46 | printf ' lookup -h\n' 47 | printf ' and\n' 48 | printf ' lookup -h \n' 49 | printf 'for details.\n\n' 50 | return 1 51 | fi 52 | return 0 53 | -------------------------------------------------------------------------------- /usr_share_grml/zsh/functions/Lookup/LOOKUP_help: -------------------------------------------------------------------------------- 1 | ### vim:ft=zsh:foldmethod=marker 2 | ## Copyright: 2009, Frank Terbeck 3 | 4 | LOOKUP_guard || return 1 5 | 6 | if [[ $1 != '-f' ]] ; then 7 | (( lookup_help == 0 )) && return 1 8 | else 9 | shift 10 | fi 11 | 12 | local line use_pager pager_auto pager 13 | local -i prompt_height 14 | local -a lines 15 | 16 | zstyle -t "${lookup_context}" use-pager && use_pager='yes' || use_pager='no' 17 | zstyle -t "${lookup_context}" pager-auto && pager_auto='yes' || pager_auto='no' 18 | zstyle -s "${lookup_context}" pager pager || pager=${PAGER:-more} 19 | zstyle -s "${lookup_context}" prompt-height prompt_height || prompt_height=1 20 | (( prompt_height == 0 )) && prompt_height=1 21 | 22 | if [[ ${LINES} != [0-9]## ]] || [[ ${LINES} -eq 0 ]] ; then 23 | # $LINES is either 0, empty or other rubbish that's not a positive integer. 24 | pager_auto='no' 25 | fi 26 | 27 | if [[ ${use_pager} == 'no' ]] ; then 28 | LOOKUP_help_${backend} 29 | return 0 30 | fi 31 | 32 | if [[ ${use_pager} == 'yes' ]] && [[ ${pager_auto} == 'no' ]] ; then 33 | LOOKUP_help_${backend} | ${=pager} 34 | return 0 35 | fi 36 | 37 | # use-pager: true, pager-auto: true 38 | lines=() 39 | LOOKUP_help_${backend} | while IFS='' read -r line; do 40 | lines+=( "${line}" ) 41 | done 42 | 43 | if (( ${#lines} > LINES - prompt_height )); then 44 | print -l -- "${lines[@]}" | ${=pager} 45 | else 46 | print -l -- "${lines[@]}" 47 | fi 48 | return 0 49 | -------------------------------------------------------------------------------- /usr_share_grml/zsh/functions/Lookup/LOOKUP_hook: -------------------------------------------------------------------------------- 1 | ### vim:ft=zsh:foldmethod=marker 2 | ## run hooks 3 | ## Copyright: 2009, Frank Terbeck 4 | 5 | LOOKUP_guard || return 1 6 | local hook obackend old_lookup_ei ret lookup_context 7 | local -a hooks 8 | 9 | lookup_context="$(LOOKUP_context)" 10 | 11 | obackend="${backend}" 12 | if [[ $1 != '--' ]] ; then 13 | backend="$1" 14 | fi 15 | shift 16 | 17 | zstyle -t "${lookup_context}" debug && 18 | printf 'LOOKUP_hook: current context: "%s"\n' "${lookup_context}" 19 | 20 | zstyle -a "${lookup_context}" hooks hooks || return 0 21 | 22 | old_lookup_ei=${lookup_ei} 23 | lookup_ei='-hook-' 24 | for hook in ${hooks} ; do 25 | (( ${+functions[$hook]} == 0 )) && continue 26 | ${hook} "$@" 27 | case $? in 28 | (1) 29 | break 30 | ;; 31 | (0|*) 32 | ;; 33 | esac 34 | done 35 | lookup_ei="${old_lookup_ei}" 36 | backend="${obackend}" 37 | return 0 38 | -------------------------------------------------------------------------------- /usr_share_grml/zsh/functions/Lookup/LOOKUP_parseopts: -------------------------------------------------------------------------------- 1 | ### vim:ft=zsh:foldmethod=marker 2 | ## parse cmdline options 3 | ## Copyright: 2009, Frank Terbeck 4 | 5 | # This is lookup's option parsing slave. 6 | # To use it, you'll have to follow the following idiom: 7 | # lu_parseopts_args=( 8 | # l bool 9 | # h bool 10 | # x string 11 | # i int 12 | # ) 13 | # LOOKUP_parseopts "$@" || return 1 14 | # 15 | # ...the result of LOOKUP_parseopts is now stored in $opts[] and $args[]. 16 | # $args[] is an array containing the remaining args from "$@" after parsing. 17 | # $opts[] is an associative array containing key value pairs in the following 18 | # form: 19 | # -x "a string" 20 | # -i 12345 21 | # For boolean args an entry is only added if the was given and will look 22 | # like this: 23 | # -l "yes" 24 | # -h "yes" 25 | # 26 | # If you define integer arguments in $lu_parseopts_args[], LOOKUP_parseopts() 27 | # will check its value and return with an error if the argument is not a 28 | # signed integer. 29 | # Hence, in the above example the following calls are valid: 30 | # foo -i 123 31 | # foo -i -123 32 | # foo -i +123 33 | # while this is not: 34 | # foo -i bar 35 | 36 | LOOKUP_guard || return 1 37 | 38 | local char o dashdash firstarg who 39 | local -a largs match 40 | 41 | if [[ ${lookup_ei} == '-backend-' ]] ; then 42 | who="${backend}" 43 | else 44 | who="lookup" 45 | fi 46 | 47 | if (( ${#lu_parseopts_args} == 0 )) ; then 48 | printf '%s: $lu_parseopts_args is emtpy.\n' ${who} 49 | printf '%s: Read the example on top of the LOOKUP_parseopts file.\n' ${who} 50 | return 1 51 | fi 52 | 53 | args=() 54 | opts=() 55 | for o in ${(k)lu_parseopts_args} ; do 56 | case ${lu_parseopts_args[$o]} in 57 | (bool) largs+=($o) ;; 58 | (string|int) largs+=($o:) ;; 59 | (*) 60 | printf '%s: Unknown option type (%s: %s)!\n' ${who} $o ${lu_parseopts_args[$o]} 61 | return 1 62 | ;; 63 | esac 64 | done 65 | 66 | for o in "$@" ; do 67 | case $o in 68 | (-|--) 69 | dashdash='found' 70 | continue 71 | ;; 72 | esac 73 | if [[ ${dashdash} == 'found' ]] ; then 74 | firstarg="$o" 75 | break 76 | fi 77 | done 78 | zparseopts -A opts -D "${largs[@]}" || return 1 79 | if [[ $1 == -* ]] && [[ $1 != ${firstarg} ]] ; then 80 | printf '%s: Unknown option: %s\n' ${who} "$1" 81 | return 1 82 | fi 83 | for o in ${(k)opts} ; do 84 | match=() 85 | : ${o/(#b)-(*)/} 86 | char="${match[1]}" 87 | case ${lu_parseopts_args[$char]} in 88 | (bool) 89 | [[ -z ${opts[$o]} ]] && opts[$o]='yes' 90 | ;; 91 | (int) 92 | opts[$o]=${${opts[$o]}/(#s)+/} 93 | if [[ ${${opts[$o]}/(#s)-/} == (-|)*[^0-9]* ]]; then 94 | printf '%s: %s requires an integer argument.\n' ${who} $o 95 | return 1 96 | fi 97 | ;; 98 | esac 99 | done 100 | 101 | args=( "$@" ) 102 | -------------------------------------------------------------------------------- /usr_share_grml/zsh/functions/Lookup/LOOKUP_query_handler: -------------------------------------------------------------------------------- 1 | ### vim:ft=zsh:foldmethod=marker 2 | ## run query handlers 3 | ## Copyright: 2009, Frank Terbeck 4 | 5 | LOOKUP_guard || return 1 6 | local old_lookup_ei qh qh_return ret 7 | local -a qhs 8 | 9 | zstyle -t "${lookup_context}" debug && 10 | printf 'LOOKUP_query_handler: current context: "%s"\n' "${lookup_context}" 11 | 12 | (( lookup_use_qh == 0 )) && return 0 13 | zstyle -a "${lookup_context}" query-handlers qhs || return 0 14 | 15 | qh_return=0 16 | old_lookup_ei=${lookup_ei} 17 | lookup_ei='-queryhandler-' 18 | for qh in ${qhs} ; do 19 | if (( ${+functions[LOOKUP_qh_$qh]} == 0 )) ; then 20 | printf 'query-handler %s requires this function: %s\n' "${qa}" "LOOKUP_qh_${qh}" 21 | printf 'Hit any key to continue...\n' 22 | read -k 1 23 | else 24 | if [[ ${lookup_qh_arg-wasunset} == 'wasunset' ]] ; then 25 | LOOKUP_qh_${qh} 26 | ret=$? 27 | else 28 | LOOKUP_qh_${qh} ${lookup_qh_arg} 29 | ret=$? 30 | fi 31 | case ${ret} in 32 | (1) # stop processing 33 | break 34 | ;; 35 | (2) # clear QUERY and stop processing 36 | QUERY='' 37 | break 38 | ;; 39 | (3) # clear QUERY and stop processing and return 1 40 | # which means, the backends are supposed to return 1, too. 41 | # thus, no browser will be called. 42 | QUERY='' 43 | qh_return=1 44 | break 45 | ;; 46 | (0|*) # just continue 47 | ;; 48 | esac 49 | fi 50 | done 51 | lookup_ei=${old_lookup_ei} 52 | return ${qh_return} 53 | -------------------------------------------------------------------------------- /usr_share_grml/zsh/functions/Lookup/lookupinit: -------------------------------------------------------------------------------- 1 | ### vim:ft=zsh:foldmethod=marker 2 | ## 3 | ## zsh function that looks up an argument in various webservices. 4 | ## Copyright: 2009, Frank Terbeck 5 | ## 6 | ## This file, all LOOKUP_* files and all backends in the Backends/ subdirectory 7 | ## are distributed under the same licence as zsh itself (BSD-like). 8 | ## 9 | 10 | typeset -ga LOOKUP_backends 11 | typeset -gA LOOKUP_aliases 12 | 13 | function lookup() { 14 | emulate -L zsh 15 | setopt extendedglob 16 | setopt warncreateglobal 17 | 18 | local file opt 19 | local -a alias_words backend_args 20 | local -A lu_aliases 21 | 22 | local -x backend lookup_describe lookup_qh_arg lookup_lp lookup_ei unencQUERY 23 | local -ix lookup_remote lookup_printout lookup_use_qh lookup_help 24 | local -ax args 25 | local -Ax lookup_communicate lu_parseopts_args opts 26 | # Silence a few warnings for now. 27 | # See http://www.zsh.org/mla/workers/2015/msg03364.html for details. 28 | local -a match mbegin mend 29 | local MATCH; integer MBEGIN MEND 30 | 31 | backend='-init-' 32 | lookup_ei='-main-' 33 | lookup_help=0 34 | lookup_use_qh=0 35 | lookup_remote=0 36 | lookup_printout=0 37 | 38 | lu_parseopts_args=( 39 | a string 40 | d string 41 | q string 42 | h bool 43 | i bool 44 | l bool 45 | L bool 46 | P bool 47 | Q bool 48 | R bool 49 | ) 50 | LOOKUP_parseopts "$@" || return 1 51 | 52 | if [[ -n ${opts[-l]} ]] ; then 53 | printf 'Available backends:\n\n' 54 | lookup_describe="yes" 55 | for backend in ${LOOKUP_backends} ; do 56 | printf '%16s - %s\n' ${backend} "$(LOOKUP_be_${backend})" 57 | done 58 | printf '\n' 59 | return 0 60 | fi 61 | 62 | if [[ -n ${opts[-L]} ]] ; then 63 | if (( ${#LOOKUP_aliases} == 0 )) ; then 64 | printf 'lookup: No aliases defined.\n' 65 | return 0 66 | fi 67 | printf 'Defined backend aliases:\n\n' 68 | for al in ${(k)LOOKUP_aliases}; do 69 | printf '%16s=%s\n' ${al} ${LOOKUP_aliases[$al]} 70 | done 71 | printf '\n' 72 | return 0 73 | fi 74 | 75 | if [[ -n ${opts[-i]} ]] ; then 76 | local f 77 | local -a fcts 78 | 79 | LOOKUP_backends=() 80 | fcts=( 81 | LOOKUP_browser LOOKUP_context LOOKUP_encode LOOKUP_guard 82 | LOOKUP_help LOOKUP_hook LOOKUP_query_handler 83 | ) 84 | 85 | for file in ${^fpath}/LOOKUP_be_*~*(\~|.zwc)(N.) ; do 86 | file=${file:t} 87 | : ${file:#(#b)LOOKUP_be_(*)} 88 | backend=${match[1]} 89 | 90 | [[ -n ${(M)LOOKUP_backends:#${backend}} ]] && continue 91 | LOOKUP_backends+=(${backend}) 92 | (( ${+functions[LOOKUP_be_$backend]} )) || 93 | autoload -Uz LOOKUP_be_${backend} 94 | done 95 | 96 | for f in ${fcts} ; do 97 | (( ${+functions[$f]} )) || autoload -Uz $f 98 | done 99 | return 0 100 | fi 101 | 102 | if [[ -n ${opts[-a]} ]] ; then 103 | local al val 104 | 105 | match=() 106 | : ${${opts[-a]}/(#b)(*)=(*)} 107 | al="${match[1]}" 108 | val="${match[2]}" 109 | if [[ -z ${al} ]] || [[ -z ${val} ]] ; then 110 | printf 'An alias definition *must* look like this: aliasname="originalname -options"\n' 111 | return 1 112 | fi 113 | 114 | LOOKUP_aliases[$al]="${val}" 115 | return 0 116 | fi 117 | 118 | if [[ -n ${opts[-d]} ]] ; then 119 | if [[ -n ${LOOKUP_aliases[${opts[-d]}]} ]] ; then 120 | unset "LOOKUP_aliases[${opts[-d]}]" 121 | return 0 122 | else 123 | printf 'No such backend alias defined: "%s"\n' ${opts[-d]} 124 | printf 'Use lookup -L to get a list.\n' 125 | return 1 126 | fi 127 | fi 128 | 129 | [[ -n ${opts[-h]} ]] && lookup_help=1 130 | [[ -n ${opts[-R]} ]] && lookup_remote=1 131 | [[ -n ${opts[-P]} ]] && lookup_printout=1 132 | [[ -n ${opts[-Q]} ]] && lookup_use_qh=1 133 | [[ -n ${opts[-q]} ]] && lookup_use_qh=1 && lookup_qh_arg=${opts[-q]} 134 | 135 | if (( ${#args} == 0 )) ; then 136 | printf 'usage: lookup [-{i,a,d,Q,l,L,P,R}] [-{h,q} ] OPTION(s)...\n' 137 | printf ' Options:\n' 138 | printf ' -h [backend] print this text or help for '\''backend'\''\n\n' 139 | printf ' -i (re)initialize lookup\n\n' 140 | printf ' -a add a backend alias\n' 141 | printf ' -d remove an alias for a backend\n\n' 142 | printf ' -Q let a handler create the QUERY string\n' 143 | printf ' -q same as -Q, but let'\''s you give an argument, too\n\n' 144 | printf ' -l list available backends\n' 145 | printf ' -L list defined backend aliases\n\n' 146 | printf ' -P print which browser command would be used\n' 147 | printf ' -R send url to remote browser\n' 148 | (( ${+functions[lu]} )) && 149 | printf '\n Instead of '\''lookup'\'' the shorter '\''lu'\'' may be used.\n' 150 | (( lookup_help > 0 )) && return 0 || return 1 151 | fi 152 | 153 | if (( ${+LOOKUP_aliases[${args[1]}]} )) ; then 154 | alias_words=( ${(z)${LOOKUP_aliases[${args[1]}]}} ) 155 | shift args 156 | backend=${alias_words[1]} 157 | shift alias_words 158 | backend_args=( "${alias_words[@]}" "${args[@]}" ) 159 | else 160 | backend=${args[1]} 161 | shift args 162 | backend_args=( "${args[@]}" ) 163 | fi 164 | 165 | if [[ -z ${(M)LOOKUP_backends:#$backend} ]] ; then 166 | printf 'Unknown backend '\''%s'\''.\n' ${backend} 167 | return 1 168 | fi 169 | 170 | args=() 171 | opts=() 172 | LOOKUP_hook -- "${backend_args[@]}" 173 | lookup_ei='-backend-' 174 | LOOKUP_context -d 175 | LOOKUP_be_${backend} "${backend_args[@]}" 176 | return $? 177 | } 178 | 179 | function lu() { 180 | lookup "$@" 181 | } 182 | 183 | # initialize the system 184 | autoload -Uz LOOKUP_parseopts LOOKUP_guard # lookup -i needs this 185 | lookup -i 186 | -------------------------------------------------------------------------------- /usr_share_grml/zsh/functions/exirename: -------------------------------------------------------------------------------- 1 | # Rename pictures based on information found in exif headers 2 | emulate -L zsh 3 | 4 | if [[ $# -lt 1 ]] ; then 5 | echo 'Usage: jpgrename $FILES' >& 2 6 | return 1 7 | else 8 | echo -n 'Checking for jhead with version newer than 1.9: ' 9 | jhead_version=`jhead -h | \ 10 | grep 'used by most Digital Cameras. v.*' | \ 11 | awk '{print $6}' | tr -d v` 12 | if [[ $jhead_version > '1.9' ]]; then 13 | echo 'success - now running jhead.' 14 | jhead -n%Y-%m-%d_%Hh%M_%f $* 15 | else 16 | echo 'failed - exiting.' 17 | fi 18 | fi 19 | -------------------------------------------------------------------------------- /usr_share_grml/zsh/functions/grml/grml-wallpaper: -------------------------------------------------------------------------------- 1 | # vim:filetype=zsh 2 | if [[ -f /usr/share/grml/"$1" ]] ; then 3 | Esetroot -scale /usr/share/grml/"$1" 4 | else 5 | Esetroot -scale "$@" 6 | fi 7 | -------------------------------------------------------------------------------- /usr_share_grml/zsh/functions/hl: -------------------------------------------------------------------------------- 1 | # -*- shell-script -*- 2 | 3 | # Taken from: 4 | # https://dev.0x50.de/projects/ftzsh/repository/revisions/master/entry/functions/hl 5 | 6 | if ! [[ -x ${commands[highlight]} ]]; then 7 | printf 'hl: Could not find `highlight'\'' binary!\n' 8 | return 1 9 | fi 10 | 11 | local context file format lang suffix syntax theme o 12 | local -i nopager=0 13 | local -a pager hl_opts 14 | local -A opt syntaxmap 15 | 16 | while [[ $1 == -* ]]; do 17 | case $1 in 18 | (-c|--cat|--no-pager) 19 | nopager=1 20 | shift 21 | ;; 22 | (-F|--format) 23 | opt[format]=$2 24 | shift 25 | shift 26 | ;; 27 | (-h|--help) 28 | printf 'usage: hl [OPTION(s)] \n' 29 | return 0 30 | ;; 31 | (-l|--list) 32 | ( printf 'available languages (syntax parameter):\n\n' ; 33 | highlight --list-langs ; ) | less -SM 34 | return 0 35 | ;; 36 | (-P|--pager) 37 | opt[pager]=$2 38 | shift 39 | shift 40 | ;; 41 | (-s|--syntax) 42 | opt[syntax]=$2 43 | shift 44 | shift 45 | ;; 46 | (-t|--themes) 47 | ( printf 'available themes (style parameter):\n\n' ; 48 | highlight --list-themes ; ) | less -SM 49 | return 0 50 | ;; 51 | (-T|--theme) 52 | opt[theme]=$2 53 | shift 54 | shift 55 | ;; 56 | (*) 57 | printf 'hl: Unknown option `%s'\''!\n' $1 58 | printf 'usage: hl [OPTION(s)] \n' 59 | return 1 60 | ;; 61 | esac 62 | done 63 | 64 | if (( ${#argv} < 1 )) ; then 65 | printf 'usage: hl [OPTION(s)] \n' 66 | printf ' available options: --list (-l), --themes (-t), --help (-h)\n' 67 | printf ' --no-pager (--cat, -c), --syntax (-s)\n' 68 | (( ${#argv} > 2 )) && printf ' Too many arguments.\n' 69 | return 1 70 | fi 71 | 72 | syntaxmap=( 73 | scm lisp 74 | ) 75 | 76 | for file in "$@"; do 77 | suffix=${file:e} 78 | context=":functions:hl:$OSTYPE:$TERM:$suffix" 79 | hl_opts=() 80 | syntax='' 81 | 82 | if (( ${+opt[format]} )); then 83 | format=${opt[format]} 84 | else 85 | if ! zstyle -a $context format format; then 86 | case $TERM in 87 | ((screen|xterm)-256color) 88 | format=xterm256 89 | ;; 90 | (*) 91 | format=ansi 92 | ;; 93 | esac 94 | fi 95 | fi 96 | 97 | if (( ${+opt[theme]} )); then 98 | theme=${opt[theme]} 99 | else 100 | zstyle -s $context theme theme || theme=solarized-dark 101 | fi 102 | 103 | if (( nopager )); then 104 | pager=cat 105 | elif (( ${+opt[pager]} )); then 106 | pager=${(z)opt[pager]} 107 | else 108 | zstyle -a $context pager pager || pager=( less -Mr ) 109 | fi 110 | 111 | if (( ${+opt[syntax]} )); then 112 | syntax=${opt[syntax]} 113 | else 114 | if ! zstyle -s $context syntax syntax; then 115 | (( ${+syntaxmap[$suffix]} )) && syntax=${syntaxmap[$suffix]} 116 | fi 117 | fi 118 | [[ -n $syntax ]] && hl_opts=( --syntax=$syntax ) 119 | 120 | highlight --out-format=$format "${hl_opts[@]}" --style=$theme $file \ 121 | | "${pager[@]}" 122 | done 123 | 124 | return 0 125 | -------------------------------------------------------------------------------- /usr_share_grml/zsh/functions/ipv6-tunnel: -------------------------------------------------------------------------------- 1 | # set up an ipv6 tunnel 2 | emulate -L zsh 3 | 4 | case $1 in 5 | start) 6 | if ifconfig sit1 2>/dev/null | grep -q 'inet6 addr: 2002:.*:1::1' ; then 7 | print 'ipv6 tunnel already set up, nothing to be done.' 8 | print 'execute: "ifconfig sit1 down ; ifconfig sit0 down" to remove ipv6-tunnel.' ; return 1 9 | else 10 | [[ -n "$PUBLIC_IP" ]] || \ 11 | local PUBLIC_IP=$(ifconfig $(route -n | awk '/^0\.0\.0\.0/{print $8; exit}') | \ 12 | awk '/inet addr:/ {print $2}' | tr -d 'addr:') 13 | 14 | [[ -n "$PUBLIC_IP" ]] || { 15 | print 'No $PUBLIC_IP set and could not determine default one.' 16 | return 1 17 | } 18 | local IPV6ADDR=$(printf "2002:%02x%02x:%02x%02x:1::1" $(print ${PUBLIC_IP//./ })) 19 | print -n "Setting up ipv6 tunnel $IPV6ADDR via ${PUBLIC_IP}: " 20 | ifconfig sit0 tunnel ::192.88.99.1 up 21 | ifconfig sit1 add "$IPV6ADDR" && print done || print failed 22 | fi 23 | ;; 24 | status) 25 | if ifconfig sit1 2>/dev/null | grep -q 'inet6 addr: 2002:.*:1::1' ; then 26 | print 'ipv6 tunnel available' ; return 0 27 | else 28 | print 'ipv6 tunnel not available' ; return 1 29 | fi 30 | ;; 31 | stop) 32 | if ifconfig sit1 2>/dev/null | grep -q 'inet6 addr: 2002:.*:1::1' ; then 33 | print -n 'Stopping ipv6 tunnel (sit0 + sit1): ' 34 | ifconfig sit1 down ; ifconfig sit0 down && print done || print failed 35 | else 36 | print 'No ipv6 tunnel found, nothing to be done.' ; return 1 37 | fi 38 | ;; 39 | *) 40 | print "Usage: ipv6-tunnel [start|stop|status]">&2 ; return 1 41 | ;; 42 | esac 43 | -------------------------------------------------------------------------------- /usr_share_grml/zsh/functions/linenr: -------------------------------------------------------------------------------- 1 | # Print a specific line of file(s). 2 | emulate -L zsh 3 | 4 | if [ $# -lt 2 ] ; then 5 | print "Usage: linenr [,] " ; return 1 6 | elif [ $# -eq 2 ] ; then 7 | local number=$1 8 | local file=$2 9 | command ed -s $file <<< "${number}n" 10 | else 11 | local number=$1 12 | shift 13 | for file in "$@" ; do 14 | if [ ! -d $file ] ; then 15 | echo "${file}:" 16 | command ed -s $file <<< "${number}n" 2> /dev/null 17 | else 18 | continue 19 | fi 20 | done | less 21 | fi 22 | -------------------------------------------------------------------------------- /usr_share_grml/zsh/functions/lsdisk: -------------------------------------------------------------------------------- 1 | # show labels and uuids of disk devices 2 | emulate -L zsh 3 | setopt extendedglob 4 | 5 | local -a -U disks 6 | local -A mountinfo 7 | 8 | disks=( /dev/disk/by-id/*(N@:A) ) 9 | 10 | if (( ${#disks} == 0 )); then 11 | printf 'No disks detected.\n' 12 | return 1 13 | fi 14 | 15 | if [[ -r /proc/mounts ]]; then 16 | for cline in "${(f)$(}/${dev:t}/size(N) 34 | do 35 | print -f " Size: %.3f GiB (%d Byte)\n" \ 36 | $(($(<$sysdevsize)/(2.0*1024.0*1024.0))) \ 37 | $(($(<$sysdevsize)*512)) 38 | done 39 | 40 | print -f " Id: %s\n" /dev/disk/by-id/*(@e/'[[ ${REPLY:A} == $dev ]]'/N:t) 41 | done 42 | -------------------------------------------------------------------------------- /usr_share_grml/zsh/functions/minimal-shell: -------------------------------------------------------------------------------- 1 | # spawn a minimally set up mksh - useful if you want to umount /usr/. 2 | emulate -L zsh 3 | 4 | local shell="/bin/mksh" 5 | local env_file="/etc/minimal-shellrc" 6 | 7 | if [[ ! -x ${shell} ]]; then 8 | printf '`%s'\'' not available, giving up.\n' ${shell} >&2 9 | return 1 10 | elif [[ ! -f ${env_file} ]]; then 11 | printf 'minimal-shell: Configuration missing: `%s'\''\n' ${shell} >&2 12 | return 2 13 | fi 14 | 15 | exec env -i ENV="$env_file" HOME="$HOME" TERM="$TERM" ${shell} 16 | -------------------------------------------------------------------------------- /usr_share_grml/zsh/functions/purge: -------------------------------------------------------------------------------- 1 | # Clean up directory - remove well known tempfiles 2 | emulate -L zsh 3 | 4 | setopt HIST_SUBST_PATTERN 5 | local -a TEXTEMPFILES GHCTEMPFILES PYTEMPFILES 6 | local -a -U FILES 7 | 8 | [[ -d "$1" ]] && { TRAPEXIT() { popd -q } && pushd -q "$1" } 9 | 10 | TEXTEMPFILES=(*.tex(N-.:s/%tex/'(log|toc|aux|nav|snm|out|tex.backup|bbl|blg|bib.backup|vrb|lof|lot|hd|idx|fdb_latexmk|fls|glo|ilg|ind|synctex.gz)(.N)'/)) 11 | 12 | GHCTEMPFILES=(*.(hs|lhs)(N-.:r:s/%/'.(hi|hc|(p|u|s)_(o|hi))(.N)'/)) 13 | 14 | PYTEMPFILES=(*.py(N-.:s/%py/'(pyc|pyo)(.N)'/)) 15 | 16 | LONELY_MOOD_FILES=((*.mood)(.NDe:'local -a AF;AF=( ${${REPLY#.}%mood}(mp3|flac|ogg|asf|wmv|aac)(N-.) ); [[ -z "$AF" ]]':)) 17 | 18 | ZSH_COMPILED=(*.zwc(.NDe:'[[ -f ${REPLY%.zwc} && ${REPLY%.zwc} -nt ${REPLY} ]]':)) 19 | 20 | FILES=( 21 | *~(.N) 22 | \#*\#(.N) 23 | *.o(.N) 24 | *.d(.N) 25 | *.d.<->(.N) 26 | a.out(.N) 27 | (*.|)core(|.<->)(.N) 28 | *.cmo(.N) 29 | *.cmi(.N) 30 | .*.swp(.N) 31 | *.(orig|rej)(.DN) 32 | *.dpkg-(old|dist|new)(DN) 33 | ._(cfg|mrg)[0-9][0-9][0-9][0-9]_*(N) 34 | ${~TEXTEMPFILES} 35 | ${~GHCTEMPFILES} 36 | ${~PYTEMPFILES} 37 | ${LONELY_MOOD_FILES} 38 | ${ZSH_COMPILED} 39 | ) 40 | 41 | local NBFILES=${#FILES} 42 | local CURDIRSUDO="" 43 | 44 | [[ ! -w ./ ]] && CURDIRSUDO=$SUDO 45 | 46 | if [[ $NBFILES > 0 ]] ; then 47 | print "in $PWD:" 48 | print -f " %s\n" $FILES 49 | local ans 50 | echo -n "Remove these files? [y/N] " 51 | read -q ans; echo 52 | if [[ $ans == [yY] ]] ; then 53 | $CURDIRSUDO rm ${FILES} 54 | echo ">> $PWD purged, $NBFILES files removed" 55 | else 56 | echo "Ok. .. then not.." 57 | fi 58 | fi 59 | -------------------------------------------------------------------------------- /usr_share_grml/zsh/functions/readme: -------------------------------------------------------------------------------- 1 | # View all README-like files in current directory in pager 2 | emulate -L zsh 3 | 4 | setopt extendedglob 5 | local files 6 | files=(./(#i)*(read*me|lue*m(in|)ut|lies*mich)*(NDr^/=p%)) 7 | if (($#files)) ; then 8 | $PAGER $files 9 | else 10 | print 'No README files.' 11 | fi 12 | -------------------------------------------------------------------------------- /usr_share_grml/zsh/functions/urldecode: -------------------------------------------------------------------------------- 1 | #f5# RFC 2396 URL encoding in Z-Shell 2 | emulate -L zsh 3 | 4 | setopt extendedglob 5 | input=( ${(s::)1} ) 6 | print ${(j::)input/(#b)([^A-Za-z0-9_.!~*\'\(\)-])/%${(l:2::0:)$(([##16]#match))}} 7 | -------------------------------------------------------------------------------- /usr_share_grml/zsh/functions/weather: -------------------------------------------------------------------------------- 1 | # retrieve weather information on the console 2 | # Usage example: 'weather LOWG' 3 | 4 | emulate -L zsh 5 | 6 | if [[ -z "$1" ]]; then 7 | print 'Usage: weather ' 8 | print \ 9 | 'List of stations: http://en.wikipedia.org/wiki/List_of_airports_by_ICAO_code' 10 | return 0 11 | fi 12 | 13 | local VERBOSE="yes" # TODO: Make this a command line switch 14 | 15 | local ODIR=`pwd` 16 | local PLACE="${1:u}" 17 | local DIR="${HOME}/.weather" 18 | local LOG="${DIR}/log" 19 | 20 | if ! [[ -d ${DIR} ]]; then 21 | print -n "Creating ${DIR}: " 22 | mkdir ${DIR} 23 | print 'done' 24 | fi 25 | 26 | print "Retrieving information for ${PLACE}:" 27 | print 28 | cd ${DIR} && \ 29 | wget -T 10 --no-verbose --output-file=$LOG --timestamping \ 30 | https://tgftp.nws.noaa.gov/data/observations/metar/decoded/$PLACE.TXT 31 | 32 | if [[ $? -eq 0 ]]; then 33 | if [[ -n "$VERBOSE" ]] ; then 34 | cat ${PLACE}.TXT 35 | else 36 | DATE=$(grep 'UTC' ${PLACE}.TXT | sed 's#.* /##') 37 | TEMPERATURE=$(awk '/Temperature/ { 38 | print $4" degree Celcius / " $2" degree Fahrenheit" 39 | }' ${PLACE}.TXT | tr -d '(') 40 | echo "date: $DATE" 41 | echo "temp: $TEMPERATURE" 42 | fi 43 | else 44 | print "There was an error retrieving the weather information for $PLACE" >&2 45 | cat $LOG 46 | cd $ODIR 47 | return 1 48 | fi 49 | cd $ODIR 50 | --------------------------------------------------------------------------------