diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3dfecb6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*-cache +private.zsh +history +zshrc.bak diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..6fc24b2 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "zsh-syntax-highlighting"] + path = zsh-syntax-highlighting + url = git://github.com/nicoulaj/zsh-syntax-highlighting.git +[submodule "autojump"] + path = autojump + url = git://github.com/joelthelion/autojump.git diff --git a/.hgignore b/.hgignore deleted file mode 100644 index c0d271a..0000000 --- a/.hgignore +++ /dev/null @@ -1,5 +0,0 @@ -functions.d -history -private -.*-cache -zshrc.bak diff --git a/Makefile b/Makefile index 760c91f..ec173a3 100644 --- a/Makefile +++ b/Makefile @@ -1,16 +1,9 @@ UNAME_INSTALL=install-$(shell uname -s) update: - hg pull -q --repository autojump - @hg update --repository autojump - hg pull -q --repository zsh-syntax-highlighting - @hg update --repository zsh-syntax-highlighting - hg pull -q --repository oh-my-zsh - @hg update --repository oh-my-zsh - hg pull -q --repository fizsh - @hg update --repository fizsh + git submodule foreach git pull -install: install-core $(UNAME_INSTALL) +install: install-externals install-core $(UNAME_INSTALL) install-core: @echo "Core install tasks." @@ -24,19 +17,15 @@ install-core: @mkdir -p $(HOME)/.local/share # Autojump writes to this dir if existing (otherwise we get a autojump_erros file) @echo "Creating functions.d directory iff neccessary (for autocompletion files)..." @mkdir -p $(PWD)/functions.d # folder for autocompletion files - @echo "Checking out autojump iff neccessary..." - @ls $(PWD)/autojump > /dev/null 2> /dev/null || hg clone git://github.com/joelthelion/autojump.git - @echo "Checking out zsh-syntax-highlighting iff neccessary..." - @ls $(PWD)/zsh-syntax-highlighting > /dev/null 2> /dev/null || hg clone git://github.com/nicoulaj/zsh-syntax-highlighting.git - @echo "Checking out oh-my-zsh iff neccessary..." - @ls $(PWD)/oh-my-zsh > /dev/null 2> /dev/null || hg clone git://github.com/robbyrussell/oh-my-zsh.git - @echo "Checking out fizsh iff neccessary..." - @ls $(PWD)/fizsh > /dev/null 2> /dev/null || hg clone git://fizsh.git.sourceforge.net/gitroot/fizsh/fizsh @echo "Copying autojump autocompletion script..." @cp -f $(PWD)/autojump/_j $(PWD)/functions.d/_j @echo "Creating custom user files iff neccessary..." @touch history private.zsh # create custom files for users @echo "DONE with core install tasks." + +install-externals: + git submodule init + git submodule update install-Darwin: @echo "Darwin specific install tasks." @@ -49,15 +38,4 @@ install-Darwin: install-Linux: @echo "Linux specific install tasks." @echo "DONE." - -clean: - @echo "Cleaning up." - @echo "Removing autojump..." - @!(ls $(PWD)/autojump > /dev/null 2> /dev/null) || rm -r ./autojump - @echo "Removing zsh-syntax-highlighting..." - @!(ls $(PWD)/zsh-syntax-highlighting > /dev/null 2> /dev/null) || rm -r ./zsh-syntax-highlighting - @echo "Removing oh-my-zsh..." - @!(ls $(PWD)/oh-my-zsh > /dev/null 2> /dev/null) || rm -r ./oh-my-zsh - @echo "Removing fizsh..." - @!(ls $(PWD)/fizsh > /dev/null 2> /dev/null) || rm -r ./fizsh - @echo "DONE." \ No newline at end of file + diff --git a/aliases.zsh b/aliases.zsh index c0d3972..8246a2c 100644 --- a/aliases.zsh +++ b/aliases.zsh @@ -9,6 +9,7 @@ alias aedit=" $EDITOR ~/.zsh/aliases.zsh; source ~/.zsh/aliases.zsh" alias fedit=" $EDITOR ~/.zsh/functions.zsh; source ~/.zsh/functions.zsh" alias pedit=" $EDITOR ~/.zsh/private.zsh; source ~/.zsh/private.zsh" alias vedit=" $EDITOR ~/.vimrc" +alias gedit=" $EDITOR ~/.gitconfig" #alias man="unset PAGER; man" alias grep='grep --color=auto' @@ -17,22 +18,27 @@ alias feierabend='sudo shutdown -h now' alias j=' j' ##### standard aliases (start with a space to be ignored in history) -alias ls='ls --color=auto' -alias ll=' ls -lhF' +alias ls=' ls -C -F -h --color=always' +alias l=" ls" +alias ll=' ls -l' alias la=' ls -A' -alias l=' ls -CF' -alias v=" clear; ls -Flgh" +alias v=" clear; ll -g" # standard directory view +alias vs=" v **/*(.)" # show all files in all subdirs plain in a list -alias g='ps aux|grep ' +alias g=' ps aux|grep ' alias d=' dirs -v' +#alias .='xdg-open .' +alias cd=' cd' alias ..=' cd ..; ls' alias ...=' cd ..; cd ..; ls' alias ....=' cd ..; cd ..; cd ..; ls' -alias cd..='cd ..' -alias cd...='cd ../..' -alias cd....='cd ../../..' -alias cd.....='cd ../../../..' +alias cd..='..' +alias cd...='...' +alias cd....='....' + +# alias to create a next-link in your home to tag the current workingdir +alias linkthis='rm -f ~/next; ln -s $PWD ~/next' ##### global aliases # zsh buch s.82 (z.B. find / ... NE) @@ -55,6 +61,13 @@ alias -g R=' &; jobs | tail -1 | read A0 A1 A2 cmd; echo "running $cmd"; fg "$cm alias -s tex="rubber --inplace --maxerr -1 --short --force --warn all --pdf" +alias -s 1="man -l" +alias -s 2="man -l" +alias -s 3="man -l" +alias -s 4="man -l" +alias -s 5="man -l" +alias -s 6="man -l" +alias -s 7="man -l" alias -s pdf="xdg-open" alias -s PDF="xdg-open" alias -s xoj="xournal" @@ -62,12 +75,15 @@ alias -s xoj="xournal" alias -s jar="java -jar" alias -s iso="vlc" -alias -s avi="xdg-open" -alias -s mov="xdg-open" -alias -s mpg="xdg-open" -alias -s m4v="xdg-open" -alias -s ogg="xdg-open" -alias -s ogv="xdg-open" +alias -s avi=" xdg-open" +alias -s AVI=" xdg-open" +alias -s mov=" xdg-open" +alias -s mpg=" xdg-open" +alias -s m4v=" xdg-open" +alias -s ogg=" xdg-open" +alias -s ogv=" xdg-open" +alias -s flv=" xdg-open" +alias -s mkv=" xdg-open" alias -s tif="xdg-open" alias -s tiff="xdg-open" @@ -86,6 +102,7 @@ alias -s org="xdg-open" alias -s rdf="rapper --count" alias -s owl="rapper --count" alias -s ttl="rapper -i turtle --count" +alias -s tt="rapper -i turtle --count" alias -s n3="rapper -i turtle --count" alias -s nt="rapper -i ntriples --count" alias -s ntriples="rapper -i ntriples --count" diff --git a/autojump b/autojump new file mode 160000 index 0000000..3c67f84 --- /dev/null +++ b/autojump @@ -0,0 +1 @@ +Subproject commit 3c67f8443790d3ba0cb7281e4074b9b3707effe6 diff --git a/functions.d/_efa b/functions.d/_efa new file mode 100644 index 0000000..97955c3 --- /dev/null +++ b/functions.d/_efa @@ -0,0 +1,35 @@ +#compdef efa + +typeset -a arguments +arguments=( + '--'{from,to,via}':city: :stop: ' + '--'{from,to,via}'-type:type:(stop address poi)' + '--bike' + '--debug' + '(--depart --arrive)--time:time' + '(--depart --time)--arrive:time' + '(--arrive --time)--depart:time' + '--date:date' + '*--exclude:transports:_efa_transports' + '--max-change:number' + '--prefer:type:(speed nowait nowalk)' + '--proximity' + '--include:type:(local ic ice)' + '--walk-speed:speed:(normal fast slow)' + '--ignore-info:regex' + '*--post:POST key=value' +) + +function _efa_transports { + typeset -a keys used_prefixes + typeset prefix='' + keys=(zug s-bahn u-bahn stadtbahn tram stadtbus regionalbus schnellbus seilbahn schiff ast sonstige) + + if [[ -prefix *, ]] { + prefix=${words[$CURRENT]%,*}, + used_prefixes=(${(s:,:)prefix}) + } + _wanted expression expl 'sort expression' \ + compadd -F used_prefixes -qS , -P "$prefix" $keys +} +_arguments -s $arguments diff --git a/functions.d/_hg b/functions.d/_hg new file mode 100644 index 0000000..850215b --- /dev/null +++ b/functions.d/_hg @@ -0,0 +1,964 @@ +#compdef hg + +# Zsh completion script for mercurial. Rename this file to _hg and copy +# it into your zsh function path (/usr/share/zsh/site-functions for +# instance) +# +# If you do not want to install it globally, you can copy it somewhere +# else and add that directory to $fpath. This must be done before +# compinit is called. If the file is copied to ~/.zsh.d, your ~/.zshrc +# file could look like this: +# +# fpath=("$HOME/.zsh.d" $fpath) +# autoload -U compinit +# compinit +# +# Copyright (C) 2005, 2006 Steve Borho +# Copyright (C) 2006-9 Brendan Cully +# Copyright (C) 2010 Sebastian Tramp (special revisions / named branches) +# +# Permission is hereby granted, without written agreement and without +# licence or royalty fees, to use, copy, modify, and distribute this +# software and to distribute modified versions of this software for any +# purpose, provided that the above copyright notice and the following +# two paragraphs appear in all copies of this software. +# +# In no event shall the authors be liable to any party for direct, +# indirect, special, incidental, or consequential damages arising out of +# the use of this software and its documentation, even if the authors +# have been advised of the possibility of such damage. +# +# The authors specifically disclaim any warranties, including, but not +# limited to, the implied warranties of merchantability and fitness for +# a particular purpose. The software provided hereunder is on an "as +# is" basis, and the authors have no obligation to provide maintenance, +# support, updates, enhancements, or modifications. + +emulate -LR zsh +setopt extendedglob + +local curcontext="$curcontext" state line +typeset -A _hg_cmd_globals + +_hg() { + local cmd _hg_root + integer i=2 + _hg_cmd_globals=() + + while (( i < $#words )) + do + case "$words[$i]" in + -R|--repository) + eval _hg_root="$words[$i+1]" + _hg_cmd_globals+=("$words[$i]" "$_hg_root") + (( i += 2 )) + continue + ;; + -R*) + _hg_cmd_globals+="$words[$i]" + eval _hg_root="${words[$i]#-R}" + (( i++ )) + continue + ;; + --cwd|--config) + # pass along arguments to hg completer + _hg_cmd_globals+=("$words[$i]" "$words[$i+1]") + (( i += 2 )) + continue + ;; + -*) + # skip option + (( i++ )) + continue + ;; + esac + if [[ -z "$cmd" ]] + then + cmd="$words[$i]" + words[$i]=() + (( CURRENT-- )) + fi + (( i++ )) + done + + if [[ -z "$cmd" ]] + then + _arguments -s -w : $_hg_global_opts \ + ':mercurial command:_hg_commands' + return + fi + + # resolve abbreviations and aliases + if ! (( $+functions[_hg_cmd_${cmd}] )) + then + local cmdexp + (( $#_hg_cmd_list )) || _hg_get_commands + + cmdexp=$_hg_cmd_list[(r)${cmd}*] + if [[ $cmdexp == $_hg_cmd_list[(R)${cmd}*] ]] + then + # might be nice to rewrite the command line with the expansion + cmd="$cmdexp" + fi + if [[ -n $_hg_alias_list[$cmd] ]] + then + cmd=$_hg_alias_list[$cmd] + fi + fi + + curcontext="${curcontext%:*:*}:hg-${cmd}:" + + zstyle -s ":completion:$curcontext:" cache-policy update_policy + + if [[ -z "$update_policy" ]] + then + zstyle ":completion:$curcontext:" cache-policy _hg_cache_policy + fi + + if (( $+functions[_hg_cmd_${cmd}] )) + then + _hg_cmd_${cmd} + else + # complete unknown commands normally + _arguments -s -w : $_hg_global_opts \ + '*:files:_hg_files' + fi +} + +_hg_cache_policy() { + typeset -a old + + # cache for a minute + old=( "$1"(mm+10) ) + (( $#old )) && return 0 + + return 1 +} + +_hg_get_commands() { + typeset -ga _hg_cmd_list + typeset -gA _hg_alias_list + local hline cmd cmdalias + + _call_program hg hg debugcomplete -v | while read -A hline + do + cmd=$hline[1] + _hg_cmd_list+=($cmd) + + for cmdalias in $hline[2,-1] + do + _hg_cmd_list+=($cmdalias) + _hg_alias_list+=($cmdalias $cmd) + done + done +} + +_hg_commands() { + (( $#_hg_cmd_list )) || _hg_get_commands + _describe -t commands 'mercurial command' _hg_cmd_list +} + +_hg_revrange() { + compset -P 1 '*:' + _hg_tags "$@" +} + +_hg_tags() { + typeset -a tags + local tag rev + + _hg_cmd tags 2> /dev/null | while read tag + do + tags+=(${tag/ # [0-9]#:*}) + done + (( $#tags )) && _describe -t tags 'tags' tags +} + +# named branches as described in http://mercurial.selenic.com/wiki/NamedBranches +_hg_branches() { + typeset -a branches + local branch rev + + _hg_cmd branches 2> /dev/null | cut -f 1 -d ' ' | while read branch + do + branches+=(${branch/ # [0-9]#:*}) + done + (( $#branches )) && _describe -t branches 'named branches' branches +} + +# current heads of the repository +_hg_heads() { + typeset -a heads + local myrev + + heads=(${(f)"$(_hg_cmd heads --template '{rev}\\n')"}) + # exclude own revision + myrev=$(_hg_cmd log -r . --template '{rev}\\n') + heads=(${heads:#$myrev}) + + (( $#heads )) && _describe -t heads 'heads' heads +} + +# this is an alternative of named branches, tags and heads +_hg_specialrevisions() { + _alternative 'branches:named branches:_hg_branches' 'tags:tags:_hg_tags' 'heads:heads:_hg_heads' +} + +_hg_files() { + if [[ -n "$_hg_root" ]] + then + [[ -d "$_hg_root/.hg" ]] || return + case "$_hg_root" in + /*) + _files -W $_hg_root + ;; + *) + _files -W $PWD/$_hg_root + ;; + esac + else + _files + fi +} + +_hg_status() { + [[ -d $PREFIX ]] || PREFIX=$PREFIX:h + status_files=(${(ps:\0:)"$(_hg_cmd status -0n$1 ./$PREFIX 2>/dev/null)"}) +} + +_hg_unknown() { + typeset -a status_files + _hg_status u + _wanted files expl 'unknown files' _multi_parts / status_files +} + +_hg_missing() { + typeset -a status_files + _hg_status d + _wanted files expl 'missing files' _multi_parts / status_files +} + +_hg_modified() { + typeset -a status_files + _hg_status m + _wanted files expl 'modified files' _multi_parts / status_files +} + +_hg_resolve() { + local rstate rpath + + [[ -d $PREFIX ]] || PREFIX=$PREFIX:h + + _hg_cmd resolve -l ./$PREFIX 2> /dev/null | while read rstate rpath + do + [[ $rstate == 'R' ]] && resolved_files+=($rpath) + [[ $rstate == 'U' ]] && unresolved_files+=($rpath) + done +} + +_hg_resolved() { + typeset -a resolved_files unresolved_files + _hg_resolve + _wanted files expl 'resolved files' _multi_parts / resolved_files +} + +_hg_unresolved() { + typeset -a resolved_files unresolved_files + _hg_resolve + _wanted files expl 'unresolved files' _multi_parts / unresolved_files +} + +_hg_config() { + typeset -a items + items=(${${(%f)"$(_call_program hg hg showconfig)"}%%\=*}) + (( $#items )) && _describe -t config 'config item' items +} + +_hg_addremove() { + _alternative 'files:unknown files:_hg_unknown' \ + 'files:missing files:_hg_missing' +} + +_hg_ssh_urls() { + if [[ -prefix */ ]] + then + if zstyle -T ":completion:${curcontext}:files" remote-access + then + local host=${PREFIX%%/*} + typeset -a remdirs + compset -p $(( $#host + 1 )) + local rempath=${(M)PREFIX##*/} + local cacheid="hg:${host}-${rempath//\//_}" + cacheid=${cacheid%[-_]} + compset -P '*/' + if _cache_invalid "$cacheid" || ! _retrieve_cache "$cacheid" + then + remdirs=(${${(M)${(f)"$(_call_program files ssh -a -x $host ls -1FL "${(q)rempath}" 2> /dev/null)"}##*/}%/}) + _store_cache "$cacheid" remdirs + fi + _describe -t directories 'remote directory' remdirs -S/ + else + _message 'remote directory' + fi + else + if compset -P '*@' + then + _hosts -S/ + else + _alternative 'hosts:remote host name:_hosts -S/' \ + 'users:user:_users -S@' + fi + fi +} + +_hg_urls() { + if compset -P bundle:// + then + _files + elif compset -P ssh:// + then + _hg_ssh_urls + elif [[ -prefix *: ]] + then + _urls + else + local expl + compset -S '[^:]*' + _wanted url-schemas expl 'URL schema' compadd -S '' - \ + http:// https:// ssh:// bundle:// + fi +} + +_hg_paths() { + typeset -a paths pnames + _hg_cmd paths 2> /dev/null | while read -A pnames + do + paths+=($pnames[1]) + done + (( $#paths )) && _describe -t path-aliases 'repository alias' paths +} + +_hg_remote() { + _alternative 'path-aliases:repository alias:_hg_paths' \ + 'directories:directory:_files -/' \ + 'urls:URL:_hg_urls' +} + +_hg_clone_dest() { + _alternative 'directories:directory:_files -/' \ + 'urls:URL:_hg_urls' +} + +# Common options +_hg_global_opts=( + '(--repository -R)'{-R+,--repository}'[repository root directory]:repository:_files -/' + '--cwd[change working directory]:new working directory:_files -/' + '(--noninteractive -y)'{-y,--noninteractive}'[do not prompt, assume yes for any required answers]' + '(--verbose -v)'{-v,--verbose}'[enable additional output]' + '*--config[set/override config option]:defined config items:_hg_config' + '(--quiet -q)'{-q,--quiet}'[suppress output]' + '(--help -h)'{-h,--help}'[display help and exit]' + '--debug[debug mode]' + '--debugger[start debugger]' + '--encoding[set the charset encoding (default: UTF8)]' + '--encodingmode[set the charset encoding mode (default: strict)]' + '--lsprof[print improved command execution profile]' + '--traceback[print traceback on exception]' + '--time[time how long the command takes]' + '--profile[profile]' + '--version[output version information and exit]' +) + +_hg_pat_opts=( + '*'{-I+,--include}'[include names matching the given patterns]:dir:_files -W $(_hg_cmd root) -/' + '*'{-X+,--exclude}'[exclude names matching the given patterns]:dir:_files -W $(_hg_cmd root) -/') + +_hg_diff_opts=( + '(--text -a)'{-a,--text}'[treat all files as text]' + '(--git -g)'{-g,--git}'[use git extended diff format]' + "--nodates[don't include dates in diff headers]") + +_hg_dryrun_opts=( + '(--dry-run -n)'{-n,--dry-run}'[do not perform actions, just print output]') + +_hg_style_opts=( + '--style[display using template map file]:' + '--template[display with template]:') + +_hg_commit_opts=( + '(-m --message -l --logfile --edit -e)'{-e,--edit}'[edit commit message]' + '(-e --edit -l --logfile --message -m)'{-m+,--message}'[use as commit message]:message:' + '(-e --edit -m --message --logfile -l)'{-l+,--logfile}'[read the commit message from ]:log file:_files') + +_hg_remote_opts=( + '(--ssh -e)'{-e+,--ssh}'[specify ssh command to use]:' + '--remotecmd[specify hg command to run on the remote side]:') + +_hg_cmd() { + _call_program hg hg --config ui.verbose=0 --config defaults."$1"= \ + "$_hg_cmd_globals[@]" "$@" 2> /dev/null +} + +_hg_cmd_add() { + _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \ + '*:unknown files:_hg_unknown' +} + +_hg_cmd_addremove() { + _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \ + '(--similarity -s)'{-s+,--similarity}'[guess renamed files by similarity (0<=s<=100)]:' \ + '*:unknown or missing files:_hg_addremove' +} + +_hg_cmd_annotate() { + _arguments -s -w : $_hg_global_opts $_hg_pat_opts \ + '(--rev -r)'{-r+,--rev}'[annotate the specified revision]:revision:_hg_specialrevisions' \ + '(--follow -f)'{-f,--follow}'[follow file copies and renames]' \ + '(--text -a)'{-a,--text}'[treat all files as text]' \ + '(--user -u)'{-u,--user}'[list the author]' \ + '(--date -d)'{-d,--date}'[list the date]' \ + '(--number -n)'{-n,--number}'[list the revision number (default)]' \ + '(--changeset -c)'{-c,--changeset}'[list the changeset]' \ + '*:files:_hg_files' +} + +_hg_cmd_archive() { + _arguments -s -w : $_hg_global_opts $_hg_pat_opts \ + '--no-decode[do not pass files through decoders]' \ + '(--prefix -p)'{-p+,--prefix}'[directory prefix for files in archive]:' \ + '(--rev -r)'{-r+,--rev}'[revision to distribute]:revision:_hg_specialrevisions' \ + '(--type -t)'{-t+,--type}'[type of distribution to create]:archive type:(files tar tbz2 tgz uzip zip)' \ + '*:destination:_files' +} + +_hg_cmd_backout() { + _arguments -s -w : $_hg_global_opts $_hg_pat_opts \ + '--merge[merge with old dirstate parent after backout]' \ + '(--date -d)'{-d+,--date}'[record datecode as commit date]:date code:' \ + '--parent[parent to choose when backing out merge]' \ + '(--user -u)'{-u+,--user}'[record user as commiter]:user:' \ + '(--rev -r)'{-r+,--rev}'[revision]:revision:_hg_tags' \ + '(--message -m)'{-m+,--message}'[use as commit message]:text:' \ + '(--logfile -l)'{-l+,--logfile}'[read commit message from ]:log file:_files -g \*.txt' +} + +_hg_cmd_bisect() { + _arguments -s -w : $_hg_global_opts \ + '(-)'{-r,--reset}'[reset bisect state]' \ + '(--good -g --bad -b --skip -s --reset -r)'{-g,--good}'[mark changeset good]'::revision:_hg_tags \ + '(--good -g --bad -b --skip -s --reset -r)'{-b,--bad}'[mark changeset bad]'::revision:_hg_tags \ + '(--good -g --bad -b --skip -s --reset -r)'{-s,--skip}'[skip testing changeset]' \ + '(--command -c --noupdate -U)'{-c+,--command}'[use command to check changeset state]':commands:_command_names \ + '(--command -c --noupdate -U)'{-U,--noupdate}'[do not update to target]' +} + +_hg_cmd_branch() { + _arguments -s -w : $_hg_global_opts \ + '(--force -f)'{-f,--force}'[set branch name even if it shadows an existing branch]' \ + '(--clean -C)'{-C,--clean}'[reset branch name to parent branch name]' +} + +_hg_cmd_branches() { + _arguments -s -w : $_hg_global_opts \ + '(--active -a)'{-a,--active}'[show only branches that have unmerge heads]' +} + +_hg_cmd_bundle() { + _arguments -s -w : $_hg_global_opts $_hg_remote_opts \ + '(--force -f)'{-f,--force}'[run even when remote repository is unrelated]' \ + '(2)*--base[a base changeset to specify instead of a destination]:revision:_hg_tags' \ + ':output file:_files' \ + ':destination repository:_files -/' +} + +_hg_cmd_cat() { + _arguments -s -w : $_hg_global_opts $_hg_pat_opts \ + '(--output -o)'{-o+,--output}'[print output to file with formatted name]:filespec:' \ + '(--rev -r)'{-r+,--rev}'[revision]:revision:_hg_specialrevisions' \ + '*:file:_hg_files' +} + +_hg_cmd_clone() { + _arguments -s -w : $_hg_global_opts $_hg_remote_opts \ + '(--noupdate -U)'{-U,--noupdate}'[do not update the new working directory]' \ + '(--rev -r)'{-r+,--rev}'[a changeset you would like to have after cloning]:' \ + '--uncompressed[use uncompressed transfer (fast over LAN)]' \ + ':source repository:_hg_remote' \ + ':destination:_hg_clone_dest' +} + +_hg_cmd_commit() { + _arguments -s -w : $_hg_global_opts $_hg_pat_opts \ + '(--addremove -A)'{-A,--addremove}'[mark new/missing files as added/removed before committing]' \ + '(--message -m)'{-m+,--message}'[use as commit message]:text:' \ + '(--logfile -l)'{-l+,--logfile}'[read commit message from ]:log file:_files -g \*.txt' \ + '(--date -d)'{-d+,--date}'[record datecode as commit date]:date code:' \ + '(--user -u)'{-u+,--user}'[record user as commiter]:user:' \ + '*:file:_hg_files' +} + +_hg_cmd_copy() { + _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \ + '(--after -A)'{-A,--after}'[record a copy that has already occurred]' \ + '(--force -f)'{-f,--force}'[forcibly copy over an existing managed file]' \ + '*:file:_hg_files' +} + +_hg_cmd_diff() { + typeset -A opt_args + _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_diff_opts \ + '*'{-r,--rev}'+[revision]:revision:_hg_revrange' \ + '(--show-function -p)'{-p,--show-function}'[show which function each change is in]' \ + '(--ignore-all-space -w)'{-w,--ignore-all-space}'[ignore white space when comparing lines]' \ + '(--ignore-space-change -b)'{-b,--ignore-space-change}'[ignore changes in the amount of white space]' \ + '(--ignore-blank-lines -B)'{-B,--ignore-blank-lines}'[ignore changes whose lines are all blank]' \ + '*:file:->diff_files' + + if [[ $state == 'diff_files' ]] + then + if [[ -n $opt_args[-r] ]] + then + _hg_files + else + _hg_modified + fi + fi +} + +_hg_cmd_export() { + _arguments -s -w : $_hg_global_opts $_hg_diff_opts \ + '(--outout -o)'{-o+,--output}'[print output to file with formatted name]:filespec:' \ + '--switch-parent[diff against the second parent]' \ + '*:revision:_hg_specialrevisions' +} + +_hg_cmd_grep() { + _arguments -s -w : $_hg_global_opts $_hg_pat_opts \ + '(--print0 -0)'{-0,--print0}'[end filenames with NUL]' \ + '--all[print all revisions with matches]' \ + '(--follow -f)'{-f,--follow}'[follow changeset or file history]' \ + '(--ignore-case -i)'{-i,--ignore-case}'[ignore case when matching]' \ + '(--files-with-matches -l)'{-l,--files-with-matches}'[print only filenames and revs that match]' \ + '(--line-number -n)'{-n,--line-number}'[print matching line numbers]' \ + '*'{-r+,--rev}'[search in given revision range]:revision:_hg_revrange' \ + '(--user -u)'{-u,--user}'[print user who committed change]' \ + '1:search pattern:' \ + '*:files:_hg_files' +} + +_hg_cmd_heads() { + _arguments -s -w : $_hg_global_opts $_hg_style_opts \ + '(--rev -r)'{-r+,--rev}'[show only heads which are descendants of rev]:revision:_hg_tags' +} + +_hg_cmd_help() { + _arguments -s -w : $_hg_global_opts \ + '*:mercurial command:_hg_commands' +} + +_hg_cmd_identify() { + _arguments -s -w : $_hg_global_opts \ + '(--rev -r)'{-r+,--rev}'[identify the specified rev]:revision:_hg_specialrevisions' \ + '(--num -n)'{-n+,--num}'[show local revision number]' \ + '(--id -i)'{-i+,--id}'[show global revision id]' \ + '(--branch -b)'{-b+,--branch}'[show branch]' \ + '(--tags -t)'{-t+,--tags}'[show tags]' +} + +_hg_cmd_import() { + _arguments -s -w : $_hg_global_opts \ + '(--strip -p)'{-p+,--strip}'[directory strip option for patch (default: 1)]:count:' \ + '(--message -m)'{-m+,--message}'[use as commit message]:text:' \ + '(--force -f)'{-f,--force}'[skip check for outstanding uncommitted changes]' \ + '*:patch:_files' +} + +_hg_cmd_incoming() { + _arguments -s -w : $_hg_global_opts $_hg_remote_opts $_hg_style_opts \ + '(--no-merges -M)'{-M,--no-merges}'[do not show merge revisions]' \ + '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \ + '(--patch -p)'{-p,--patch}'[show patch]' \ + '(--rev -r)'{-r+,--rev}'[a specific revision up to which you would like to pull]:revision:_hg_specialrevisions' \ + '(--newest-first -n)'{-n,--newest-first}'[show newest record first]' \ + '--bundle[file to store the bundles into]:bundle file:_files' \ + ':source:_hg_remote' +} + +_hg_cmd_init() { + _arguments -s -w : $_hg_global_opts $_hg_remote_opts \ + ':dir:_files -/' +} + +_hg_cmd_locate() { + _arguments -s -w : $_hg_global_opts $_hg_pat_opts \ + '(--rev -r)'{-r+,--rev}'[search repository as it stood at revision]:revision:_hg_specialrevisions' \ + '(--print0 -0)'{-0,--print0}'[end filenames with NUL, for use with xargs]' \ + '(--fullpath -f)'{-f,--fullpath}'[print complete paths]' \ + '*:search pattern:_hg_files' +} + +_hg_cmd_log() { + _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_style_opts \ + '(--follow --follow-first -f)'{-f,--follow}'[follow changeset or history]' \ + '(-f --follow)--follow-first[only follow the first parent of merge changesets]' \ + '(--copies -C)'{-C,--copies}'[show copied files]' \ + '(--keyword -k)'{-k+,--keyword}'[search for a keyword]:' \ + '(--limit -l)'{-l+,--limit}'[limit number of changes displayed]:' \ + '*'{-r,--rev}'[show the specified revision or range]:revision:_hg_revrange' \ + '(--no-merges -M)'{-M,--no-merges}'[do not show merges]' \ + '(--only-merges -m)'{-m,--only-merges}'[show only merges]' \ + '(--patch -p)'{-p,--patch}'[show patch]' \ + '(--prune -P)'{-P+,--prune}'[do not display revision or any of its ancestors]:revision:_hg_specialrevisions' \ + '*:files:_hg_files' +} + +_hg_cmd_manifest() { + _arguments -s -w : $_hg_global_opts \ + ':revision:_hg_specialrevisions' +} + +_hg_cmd_merge() { + _arguments -s -w : $_hg_global_opts \ + '(--force -f)'{-f,--force}'[force a merge with outstanding changes]' \ + '(--rev -r 1)'{-r,--rev}'[revision to merge]:revision:_hg_specialrevisions' \ + '(--preview -P)'{-P,--preview}'[review revisions to merge (no merge is performed)]' \ + ':revision:_hg_specialrevisions' +} + +_hg_cmd_outgoing() { + _arguments -s -w : $_hg_global_opts $_hg_remote_opts $_hg_style_opts \ + '(--no-merges -M)'{-M,--no-merges}'[do not show merge revisions]' \ + '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \ + '(--patch -p)'{-p,--patch}'[show patch]' \ + '(--rev -r)'{-r+,--rev}'[a specific revision you would like to push]' \ + '(--newest-first -n)'{-n,--newest-first}'[show newest record first]' \ + ':destination:_hg_remote' +} + +_hg_cmd_parents() { + _arguments -s -w : $_hg_global_opts $_hg_style_opts \ + '(--rev -r)'{-r+,--rev}'[show parents of the specified rev]:revision:_hg_specialrevisions' \ + ':last modified file:_hg_files' +} + +_hg_cmd_paths() { + _arguments -s -w : $_hg_global_opts \ + ':path:_hg_paths' +} + +_hg_cmd_pull() { + _arguments -s -w : $_hg_global_opts $_hg_remote_opts \ + '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \ + '(--update -u)'{-u,--update}'[update to new tip if changesets were pulled]' \ + '(--rev -r)'{-r+,--rev}'[a specific revision up to which you would like to pull]:revision:' \ + ':source:_hg_remote' +} + +_hg_cmd_push() { + _arguments -s -w : $_hg_global_opts $_hg_remote_opts \ + '(--force -f)'{-f,--force}'[force push]' \ + '(--rev -r)'{-r+,--rev}'[a specific revision you would like to push]:revision:_hg_specialrevisions' \ + ':destination:_hg_remote' +} + +_hg_cmd_remove() { + _arguments -s -w : $_hg_global_opts $_hg_pat_opts \ + '(--after -A)'{-A,--after}'[record remove that has already occurred]' \ + '(--force -f)'{-f,--force}'[remove file even if modified]' \ + '*:file:_hg_files' +} + +_hg_cmd_rename() { + _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \ + '(--after -A)'{-A,--after}'[record a rename that has already occurred]' \ + '(--force -f)'{-f,--force}'[forcibly copy over an existing managed file]' \ + '*:file:_hg_files' +} + +_hg_cmd_resolve() { + local context state line + typeset -A opt_args + + _arguments -s -w : $_hg_global_opts \ + '(--list -l --mark -m --unmark -u)'{-l,--list}'[list state of files needing merge]:*:merged files:->resolve_files' \ + '(--mark -m --list -l --unmark -u)'{-m,--mark}'[mark files as resolved]:*:unresolved files:_hg_unresolved' \ + '(--unmark -u --list -l --mark -m)'{-u,--unmark}'[unmark files as resolved]:*:resolved files:_hg_resolved' \ + '*:file:_hg_unresolved' + + if [[ $state == 'resolve_files' ]] + then + _alternative 'files:resolved files:_hg_resolved' \ + 'files:unresolved files:_hg_unresolved' + fi +} + +_hg_cmd_revert() { + local context state line + typeset -A opt_args + + _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \ + '(--all -a :)'{-a,--all}'[revert all changes when no arguments given]' \ + '(--rev -r)'{-r+,--rev}'[revision to revert to]:revision:_hg_tags' \ + '--no-backup[do not save backup copies of files]' \ + '*:file:->diff_files' + + if [[ $state == 'diff_files' ]] + then + if [[ -n $opt_args[-r] ]] + then + _hg_files + else + typeset -a status_files + _hg_status mard + _wanted files expl 'modified, added, removed or deleted file' _multi_parts / status_files + fi + fi +} + +_hg_cmd_serve() { + _arguments -s -w : $_hg_global_opts \ + '(--accesslog -A)'{-A+,--accesslog}'[name of access log file]:log file:_files' \ + '(--errorlog -E)'{-E+,--errorlog}'[name of error log file]:log file:_files' \ + '(--daemon -d)'{-d,--daemon}'[run server in background]' \ + '(--port -p)'{-p+,--port}'[listen port]:listen port:' \ + '(--address -a)'{-a+,--address}'[interface address]:interface address:' \ + '(--name -n)'{-n+,--name}'[name to show in web pages]:repository name:' \ + '(--templates -t)'{-t,--templates}'[web template directory]:template dir:_files -/' \ + '--style[web template style]:style' \ + '--stdio[for remote clients]' \ + '(--ipv6 -6)'{-6,--ipv6}'[use IPv6 in addition to IPv4]' +} + +_hg_cmd_showconfig() { + _arguments -s -w : $_hg_global_opts \ + '(--untrusted -u)'{-u+,--untrusted}'[show untrusted configuration options]' \ + ':config item:_hg_config' +} + +_hg_cmd_status() { + _arguments -s -w : $_hg_global_opts $_hg_pat_opts \ + '(--all -A)'{-A,--all}'[show status of all files]' \ + '(--modified -m)'{-m,--modified}'[show only modified files]' \ + '(--added -a)'{-a,--added}'[show only added files]' \ + '(--removed -r)'{-r,--removed}'[show only removed files]' \ + '(--deleted -d)'{-d,--deleted}'[show only deleted (but tracked) files]' \ + '(--clean -c)'{-c,--clean}'[show only files without changes]' \ + '(--unknown -u)'{-u,--unknown}'[show only unknown files]' \ + '(--ignored -i)'{-i,--ignored}'[show ignored files]' \ + '(--no-status -n)'{-n,--no-status}'[hide status prefix]' \ + '(--copies -C)'{-C,--copies}'[show source of copied files]' \ + '(--print0 -0)'{-0,--print0}'[end filenames with NUL, for use with xargs]' \ + '--rev[show difference from revision]:revision:_hg_specialrevisions' \ + '*:files:_files' +} + +_hg_cmd_tag() { + _arguments -s -w : $_hg_global_opts \ + '(--local -l)'{-l,--local}'[make the tag local]' \ + '(--message -m)'{-m+,--message}'[message for tag commit log entry]:message:' \ + '(--date -d)'{-d+,--date}'[record datecode as commit date]:date code:' \ + '(--user -u)'{-u+,--user}'[record user as commiter]:user:' \ + '(--rev -r)'{-r+,--rev}'[revision to tag]:revision:_hg_tags' \ + ':tag name:' +} + +_hg_cmd_tip() { + _arguments -s -w : $_hg_global_opts $_hg_style_opts \ + '(--patch -p)'{-p,--patch}'[show patch]' +} + +_hg_cmd_unbundle() { + _arguments -s -w : $_hg_global_opts \ + '(--update -u)'{-u,--update}'[update to new tip if changesets were unbundled]' \ + ':files:_files' +} + +_hg_cmd_update() { + _arguments -s -w : $_hg_global_opts \ + '(--clean -C)'{-C,--clean}'[overwrite locally modified files]' \ + '(--rev -r)'{-r+,--rev}'[revision]:revision:_hg_specialrevisions' \ + ':revision:_hg_specialrevisions' +} + +# HGK +_hg_cmd_view() { + _arguments -s -w : $_hg_global_opts \ + '(--limit -l)'{-l+,--limit}'[limit number of changes displayed]:' \ + ':revision range:_hg_tags' +} + +# MQ +_hg_qseries() { + typeset -a patches + patches=(${(f)"$(_hg_cmd qseries 2> /dev/null)"}) + (( $#patches )) && _describe -t hg-patches 'patches' patches +} + +_hg_qapplied() { + typeset -a patches + patches=(${(f)"$(_hg_cmd qapplied 2> /dev/null)"}) + if (( $#patches )) + then + patches+=(qbase qtip) + _describe -t hg-applied-patches 'applied patches' patches + fi +} + +_hg_qunapplied() { + typeset -a patches + patches=(${(f)"$(_hg_cmd qunapplied 2> /dev/null)"}) + (( $#patches )) && _describe -t hg-unapplied-patches 'unapplied patches' patches +} + +# unapplied, including guarded patches +_hg_qdeletable() { + typeset -a unapplied + unapplied=(${(f)"$(_hg_cmd qseries 2> /dev/null)"}) + for p in $(_hg_cmd qapplied) + do + unapplied=(${unapplied:#$p}) + done + + (( $#unapplied )) && _describe -t hg-allunapplied-patches 'all unapplied patches' unapplied +} + +_hg_qguards() { + typeset -a guards + local guard + compset -P "+|-" + _hg_cmd qselect -s 2> /dev/null | while read guard + do + guards+=(${guard#(+|-)}) + done + (( $#guards )) && _describe -t hg-guards 'guards' guards +} + +_hg_qseries_opts=( + '(--summary -s)'{-s,--summary}'[print first line of patch header]') + +_hg_cmd_qapplied() { + _arguments -s -w : $_hg_global_opts $_hg_qseries_opts +} + +_hg_cmd_qdelete() { + _arguments -s -w : $_hg_global_opts \ + '(--keep -k)'{-k,--keep}'[keep patch file]' \ + '*'{-r+,--rev}'[stop managing a revision]:applied patch:_hg_revrange' \ + '*:unapplied patch:_hg_qdeletable' +} + +_hg_cmd_qdiff() { + _arguments -s -w : $_hg_global_opts $_hg_pat_opts \ + '*:pattern:_hg_files' +} + +_hg_cmd_qfold() { + _arguments -s -w : $_hg_global_opts $_h_commit_opts \ + '(--keep,-k)'{-k,--keep}'[keep folded patch files]' \ + '*:unapplied patch:_hg_qunapplied' +} + +_hg_cmd_qgoto() { + _arguments -s -w : $_hg_global_opts \ + '(--force -f)'{-f,--force}'[overwrite any local changes]' \ + ':patch:_hg_qseries' +} + +_hg_cmd_qguard() { + _arguments -s -w : $_hg_global_opts \ + '(--list -l)'{-l,--list}'[list all patches and guards]' \ + '(--none -n)'{-n,--none}'[drop all guards]' \ + ':patch:_hg_qseries' \ + '*:guards:_hg_qguards' +} + +_hg_cmd_qheader() { + _arguments -s -w : $_hg_global_opts \ + ':patch:_hg_qseries' +} + +_hg_cmd_qimport() { + _arguments -s -w : $_hg_global_opts \ + '(--existing -e)'{-e,--existing}'[import file in patch dir]' \ + '(--name -n 2)'{-n+,--name}'[patch file name]:name:' \ + '(--force -f)'{-f,--force}'[overwrite existing files]' \ + '*'{-r+,--rev}'[place existing revisions under mq control]:revision:_hg_revrange' \ + '*:patch:_files' +} + +_hg_cmd_qnew() { + _arguments -s -w : $_hg_global_opts $_hg_commit_opts \ + '(--force -f)'{-f,--force}'[import uncommitted changes into patch]' \ + ':patch:' +} + +_hg_cmd_qnext() { + _arguments -s -w : $_hg_global_opts $_hg_qseries_opts +} + +_hg_cmd_qpop() { + _arguments -s -w : $_hg_global_opts \ + '(--all -a :)'{-a,--all}'[pop all patches]' \ + '(--name -n)'{-n+,--name}'[queue name to pop]:' \ + '(--force -f)'{-f,--force}'[forget any local changes]' \ + ':patch:_hg_qapplied' +} + +_hg_cmd_qprev() { + _arguments -s -w : $_hg_global_opts $_hg_qseries_opts +} + +_hg_cmd_qpush() { + _arguments -s -w : $_hg_global_opts \ + '(--all -a :)'{-a,--all}'[apply all patches]' \ + '(--list -l)'{-l,--list}'[list patch name in commit text]' \ + '(--merge -m)'{-m+,--merge}'[merge from another queue]:' \ + '(--name -n)'{-n+,--name}'[merge queue name]:' \ + '(--force -f)'{-f,--force}'[apply if the patch has rejects]' \ + ':patch:_hg_qunapplied' +} + +_hg_cmd_qrefresh() { + _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_commit_opts \ + '(--git -g)'{-g,--git}'[use git extended diff format]' \ + '(--short -s)'{-s,--short}'[short refresh]' \ + '*:files:_hg_files' +} + +_hg_cmd_qrename() { + _arguments -s -w : $_hg_global_opts \ + ':patch:_hg_qseries' \ + ':destination:' +} + +_hg_cmd_qselect() { + _arguments -s -w : $_hg_global_opts \ + '(--none -n :)'{-n,--none}'[disable all guards]' \ + '(--series -s :)'{-s,--series}'[list all guards in series file]' \ + '--pop[pop to before first guarded applied patch]' \ + '--reapply[pop and reapply patches]' \ + '*:guards:_hg_qguards' +} + +_hg_cmd_qseries() { + _arguments -s -w : $_hg_global_opts $_hg_qseries_opts \ + '(--missing -m)'{-m,--missing}'[print patches not in series]' +} + +_hg_cmd_qunapplied() { + _arguments -s -w : $_hg_global_opts $_hg_qseries_opts +} + +_hg_cmd_qtop() { + _arguments -s -w : $_hg_global_opts $_hg_qseries_opts +} + +_hg_cmd_strip() { + _arguments -s -w : $_hg_global_opts \ + '(--force -f)'{-f,--force}'[force multi-head removal]' \ + '(--backup -b)'{-b,--backup}'[bundle unrelated changesets]' \ + '(--nobackup -n)'{-n,--nobackup}'[no backups]' \ + ':revision:_hg_tags' +} + +_hg "$@" diff --git a/functions.d/_j b/functions.d/_j new file mode 100644 index 0000000..e5e25ae --- /dev/null +++ b/functions.d/_j @@ -0,0 +1,23 @@ +#compdef j + +#Copyright Joel Schaerer 2008, 2009 +#This file is part of autojump + +#autojump is free software: you can redistribute it and/or modify +#it under the terms of the GNU General Public License as published by +#the Free Software Foundation, either version 3 of the License, or +#(at your option) any later version. +# +#autojump is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +#GNU General Public License for more details. +# +#You should have received a copy of the GNU General Public License +#along with autojump. If not, see . + +cur=${words[2, -1]} + +autojump --completion ${=cur[*]} | while read i; do + compadd -U "$i"; +done diff --git a/functions.d/_owcli b/functions.d/_owcli new file mode 100644 index 0000000..f802f83 --- /dev/null +++ b/functions.d/_owcli @@ -0,0 +1,78 @@ +#compdef owcli + +_owcliInputFile () { + local expl + _wanted files expl 'RDF File' _files -g '*.(#i)(rdf|n3|nt|owl|tt|ntriples|ntriple)(.)' +} + +_owcliModelsLive () { + local -a models + if [ -z "$words[$CURRENT]" ] + then + models="(`$words ttt -l -z models 2>/dev/null`)" + else + models="(`$words -l -z models 2>/dev/null`)" + fi + _describe -t model "Knowledge Base" $models +} + +_owcliModelHistory () { + typeset -a mhistory + local model + touch ~/.model_history + rm -rf ~/.model_history.uniq + uniq ~/.model_history >~/.model_history.uniq + rm ~/.model_history + mv ~/.model_history.uniq ~/.model_history + cat ~/.model_history 2> /dev/null | sed 's/:/\\\\:/' | while read model + do + mhistory+=(${model/ # [0-9]#:*}) + done + _describe -t mhistory 'Knowledge Base (history)' mhistory +} + +_owcliModel () { + _alternative 'model:Knowledge Base:_owcliModelsLive' 'mhistory:Knowledge Base (history):_owcliModelHistory' +} + +_owclWiki () { + local -a wikis + if [ -z "$words[$CURRENT]" ] + then + wikis="(`$words ttt -z wikis 2>/dev/null`)" + else + wikis="(`$words -z wikis 2>/dev/null`)" + fi + _describe -t wiki "Wiki Instance" $wikis +} + +_owcliCommand () { + local -a rprocs + if [ -z "$words[$CURRENT]" ] + then + rprocs="(`$words ttt -p -z procedures 2>/dev/null`)" + else + rprocs="(`$words -p -z procedures 2>/dev/null`)" + fi + _describe -t rproc "Remote Procedure" $rprocs +} + +_owcli () { + local context state line + typeset -A opt_args + _arguments -S \ + '(-e --execute)'{-e,--execute}'[Execute one or more commands on a given wiki/graph]:command:_owcliCommand' \ + '(-w --wiki)'{-w,--wiki}'[Set OntoWiki database which should be used]:wiki instance:_owclWiki' \ + '(-m --model)'{-m,--model}'[Set model which should be used]:model uri:_owcliModel' \ + '(-i --input)'{-i,--input}'[input model file (- for STDIN)]:input model:_owcliInputFile' \ + '(-c --config)'{-c,--config}'[Set config file]:config file:_files' \ + '(-l --listModels)'{-l,--listModels}'[This is a shortcut for -e store:listModels]' \ + '(-p --listProcedures)'{-p,--listProcedures}'[This is a shortcut for -e meta:listAllProcedures]' \ + '(-d --debug)'{-d,--debug}'[Output some debug infos]' \ + '(-q --quiet)'{-q,--quiet}'[Do not output info messages]' \ + '(-r --raw)'{-r,--raw}'[Outputs raw json results]' \ + '(-h --help)'{-h,--help}'[Prints the help screen]' \ + ; +} + +compdef _owcli owcli owcli.php diff --git a/functions.d/_rdf b/functions.d/_rdf new file mode 100644 index 0000000..db6ad91 --- /dev/null +++ b/functions.d/_rdf @@ -0,0 +1,55 @@ +#compdef rdf + +_rdfshInputFile () { + local expl + _wanted files expl 'RDF File' _files -g '*.(#i)(rdf|n3|nt|owl|tt)(.)' +} + +_rdfshResourceHistory () { + typeset -a rhistory + local hresource + tail ~/.resource_history 2> /dev/null | sed 's/:/\\\\:/' | while read hresource + do + rhistory+=(${hresource/ # [0-9]#:*}) + done + _describe -t rhistory 'resource history' rhistory +} + +_rdfshCatchedResources () { + typeset -a rlist + local cresource + rdf list $words[$CURRENT] | sed 's/:/\\\\:/' | while read cresource + do + rlist+=(${cresource/ # [0-9]#:*}) + done + _describe -t rlist 'catched resource list' rlist +} + + +_rdf() { + if [ "$CURRENT" -eq "2" ] + then + _describe -t command "RDF commands" "`rdf zshcomp`" + else + #_wanted files expl 'RDF Files' _files -g '*.(#i)(rdf|n3|owl|nt|xml|ttl)(.)' + _alternative 'files:RDF File:_rdfshInputFile' 'rhistory:resource history:_rdfshResourceHistory' + #_alternative 'files:RDF File:_rdfshInputFile' 'rhistory:resource history:_rdfshResourceHistory' 'rlist:catched resource list:_rdfshCatchedResources' + fi + + #local cmd expl + #`rdf zshcomp` + #local args=(eins:Einmal zwei:ttt) + #_files -J "RDF files" -g '*.(#i)rdf.' + #_describe 'Argument' args + #_describe -t command "commands" args + #_description files expl 'RDF files' + #_files "$expl[@]" -g '*.(#i)(rdf|n3|owl|nt|xml)(.)' + + # + + #_arguments '-n[]' '-e[enable]' + #_arguments `rdf zshcomp` + #_arguments '-ntt[tt]' '-ett[enable]' +} + compdef _rdf rdf rdf.sh + diff --git a/functions.d/_tmux b/functions.d/_tmux new file mode 100644 index 0000000..e9977fb --- /dev/null +++ b/functions.d/_tmux @@ -0,0 +1,1548 @@ +#compdef tmux + +# tmux completion for zsh . +# +# Configuration: +# +# - On some OSs, the directory for tmux's server sockets may not be +# the default (which is /tmp/tmux-/), but say +# /var/run/tmux/tmux-, in which case the completion for +# 'tmux -L ' will not be able to find the sockets in the default +# location (debian does this, for instance); tell _tmux the right place +# to look: +# % zstyle ':completion:*:*:tmux:*:sockets' socketdir "/var/run/tmux/tmux-${UID}" +# +# - tmux knows a *lot* of sub-commands, hence 'tmux ' returns a lot +# of possible completions. _tmux knows about all commands and their aliases. +# By default, both are offered. If you do not care about the aliases, do this: +# % zstyle ':completion:*:*:tmux:*:subcommands' mode 'commands' +# +# The same can be done to only return aliases by setting the above style +# to 'aliases'. The default value is 'both' (but actually every value +# different from 'commands' and 'aliases' will have the same effect). +# +# 'lsw' is an alias for 'list-windows' for example; note that not all +# commands have aliases. So probably, either the default 'both' or +# 'commands' makes most sense for this style. +# +# - For finer grained control over what is suggested as possible completions, +# the 'ignored-patterns' style may be used; suppose you think that only +# '*-window' or '*-windows' are worth being completed. You would get that +# behaviour like this: +# % zstyle ':completion:*:*:tmux:*:subcommands' ignored-patterns '^*-window(|s)' +# +# Some tmux commands currently do not work if called from a shell prompt, +# so it would make sense to ignore them per default (at the time of writing, +# those commands are choose-{session,client,window}, confirm-before and +# find-window. This would ignore them: +# % zstyle ':completion:*:*:tmux:*:subcommands' ignored-patterns \ +# 'choose-*' 'confirm-before' 'find-window' +# +# The configuration for subcommand completions may be done in +# this context: ':completion:*:*:tmux-:*:*' + +# Global variables; setup the first time _tmux is called. +# For $_tmux_commands[] generation, see the very end of this file. +typeset -ga _tmux_commands _tmux_aliases +typeset -gA _tmux_aliasmap + +_tmux_aliasmap=( + # clients and sessions + attach attach-session + detach detach-client + has has-session + lsc list-clients + lscm list-commands + ls list-sessions + new new-session + refresh refresh-client + rename rename-session + showmsgs show-messages + source source-file + start start-server + suspendc suspend-client + switchc switch-client + + # windows and panes + breakp break-pane + capturep capture-pane + displayp display-panes + downp down-pane + findw find-window + joinp join-pane + killp kill-pane + killw kill-window + last last-window + linkw link-window + lsp list-panes + lsw list-windows + movew move-window + neww new-window + nextl next-layout + next next-window + pipep pipe-pane + prev previous-window + renamew rename-window + resizep resize-pane + respawnw respawn-window + rotatew rotate-window + selectl select-layout + selectp select-pane + selectw select-window + splitw split-window + swapp swap-pane + swapw swap-window + unlinkw unlink-window + upp up-pane + + # key bindings + bind bind-key + lsk list-keys + send send-keys + unbind unbind-key + + # options + set set-option + setw set-window-option + show show-options + showw show-window-options + + # environment + setenv set-environment + showenv show-environment + + # status line + confirm confirm-before + display display-message + + # buffers + clearhist clear-history + copyb copy-buffer + deleteb delete-buffer + lsb list-buffers + loadb load-buffer + pasteb paste-buffer + saveb save-buffer + setb set-buffer + showb show-buffer + + # miscellaneous + if if-shell + lock lock-server + run run-shell + info server-info +) + +# --- Sub-command functions --- +# These *must* be called _tmux-*(); The description generation relies on +# them being names that way. *No* other functions may match that pattern. +# Other utility functions should be named __tmux-*() (see below). +# +# Another thing, the description generation needs, is handling of +# $tmux_describe: If that parameter is non-empty, the sub-command function +# should only print a description of the sub-command it handles and return +# immidiately after doing so. +# +# To add support for a new sub-command, you only have to add a new +# _tmux-() function below (preferably alphabetically sorted), that +# behaves like described above; and add a alias->command pair in the +# _tmux_aliasmap associative array above (if the comand in fact has an +# alias). The rest should just work[tm]. + +function _tmux-attach-session() { + [[ -n ${tmux_describe} ]] && print "Attach or switch to a session" && return + local -a args + + args=( + '-d[detach other clients attached to target session]' + '-r[put the client into read-only mode]' + '-t[choose a target session]:target session:__tmux-sessions' + ) + _arguments ${args} +} + +function _tmux-bind-key() { + [[ -n ${tmux_describe} ]] && print "Bind a key to a command" && return + local curcontext="${curcontext}" state + local -a args + + args=( + '-c[bind to command mode instead of normal mode]' + '-n[make the binding work without the need for the prefix key]' + '-r[the key may repeat]' + '-t[choose a key table for the binding]:key tables:__tmux-key-tables' + '1: :->key' + '*:: :->command_and_args' + ) + _arguments -C ${args} && return + + if [[ ${state} == 'key' ]]; then + _message "key" + else + # quite cool, that this works. :-) + _tmux + fi +} + +function _tmux-break-pane() { + [[ -n ${tmux_describe} ]] && print "Break a pane from an existing into a new window" && return + local -a args + args=( + '-d[do not make the new window become the active one]' + '-t[choose a target pane]:panes:__tmux-panes' + ) + _arguments ${args} +} + +function _tmux-capture-pane() { + [[ -n ${tmux_describe} ]] && print "Capture the contents of a pane to a buffer" && return + local -a args + args=( + '-b[choose target buffer]:target buffer:__tmux-buffers' + '-t[choose source pane]:source pane:__tmux-panes' + ) + _arguments ${args} +} + +function _tmux-choose-client() { + [[ -n ${tmux_describe} ]] && print "Put a window into client choice mode" && return + __tmux-choose-stuff +} + +function _tmux-choose-session() { + [[ -n ${tmux_describe} ]] && print "Put a window into session choice mode" && return + __tmux-choose-stuff +} + +function _tmux-choose-window() { + [[ -n ${tmux_describe} ]] && print "Put a window into window choice mode" && return + __tmux-choose-stuff +} + +function _tmux-clear-history() { + [[ -n ${tmux_describe} ]] && print "Remove and clear history for a pane" && return + local -a args + args=('-t[choose a target pane]:panes:__tmux-panes') + _arguments ${args} +} + +function _tmux-clock-mode() { + [[ -n ${tmux_describe} ]] && print "Enter clock mode" && return + local -a args + args=('-t[choose a target pane]:panes:__tmux-panes') + _arguments ${args} +} + +function _tmux-command-prompt() { + [[ -n ${tmux_describe} ]] && print "Open the tmux command prompt in a client" && return + local state + local -a args + args=( + '-p[list of prompts]:prompts:->plist' + '-t[choose a target client]:clients:__tmux-clients' + '*:: :->tmpl' + ) + _arguments -C ${args} && return + if [[ ${state} == 'plist' ]]; then + _message "comma seperated list of prompts" + return + fi + __tmux-lastarg ${state} 'tmpl' 1 "command template" +} + +function _tmux-confirm-before() { + [[ -n ${tmux_describe} ]] && print "Run a command but ask for confirmation before" && return + local state + local -a args + args=( + '-t[choose a target client]:clients:__tmux-clients' + '*:: :->command_and_args' + ) + _arguments -C ${args} && return + __tmux-lastarg ${state} 'command_and_args' 1 "command string" +} + +function _tmux-copy-buffer() { + [[ -n ${tmux_describe} ]] && print "Copy session paste buffers" && return + local state session + local -a args + local -ax bopts + + args=( + '-a[choose a source buffer index]:buffer:->srcbuf' + '-b[choose a destination buffer index]:buffer:->dstbuf' + '-s[choose a source session]:session:->srcsession' + '-t[choose a destination session]:session:->dstsession' + ) + _arguments ${args} + + case ${state} in + ((src|dst)session) + __tmux-sessions + return + ;; + (srcbuf) + session="$(__tmux-get-optarg -s "${words[@]}")" + ;; + (srcbuf) + session="$(__tmux-get-optarg -t "${words[@]}")" + ;; + esac + if [[ -n ${session} ]]; then + bopts=( -t ${session} ) + __tmux-buffers + return + fi + bopts=() + __tmux-buffers +} + +function _tmux-copy-mode() { + [[ -n ${tmux_describe} ]] && print "Enter copy mode" && return + local -a args + args=( + '-t[choose a target pane]:panes:__tmux-panes' + '-u[scroll up one page]' + ) + _arguments ${args} +} + +function _tmux-delete-buffer() { + [[ -n ${tmux_describe} ]] && print "Delete a paste buffer" && return + local state session + local -a args + local -ax bopts + + args=( + '-b[choose a target buffer index]:panes:->buffer' + '-t[choose a target session]:panes:->session' + ) + _arguments ${args} + + case ${state} in + (session) + __tmux-sessions + return + ;; + (buffer) + session="$(__tmux-get-optarg -t "${words[@]}")" + ;; + (*) return ;; + esac + if [[ -n ${session} ]]; then + bopts=( -t ${session} ) + __tmux-buffers + return + fi + bopts=() + __tmux-buffers +} + +function _tmux-detach-client() { + [[ -n ${tmux_describe} ]] && print "Detach a client from the server" && return + local -a args + args=('-t[choose a target client]:clients:__tmux-clients') + _arguments ${args} +} + +function _tmux-display-message() { + [[ -n ${tmux_describe} ]] && print "Display a message in the status line" && return + local -a args + args=( + '-p[print message to stdout]' + '-t[choose a target client]:clients:__tmux-clients' + '*:: :->msg' + ) + _arguments ${args} && return + __tmux-lastarg ${state} 'msg' 1 "message" +} + +function _tmux-display-panes() { + [[ -n ${tmux_describe} ]] && print "Display an indicator for each visible pane" && return + local -a args + args=('-t[choose a target client]:clients:__tmux-clients') + _arguments ${args} +} + +function _tmux-down-pane() { + [[ -n ${tmux_describe} ]] && print "Move down a pane" && return + local -a args + args=('-t[choose a target pane]:panes:__tmux-panes') + _arguments ${args} +} + +function _tmux-find-window() { + [[ -n ${tmux_describe} ]] && print "Search for a pattern in windows" && return + local curcontext="${curcontext}" state + local -a args + args=( + '-t[choose a target window]:windows:__tmux-windows' + '*:: :->pattern' + ) + _arguments ${args} && return + __tmux-lastarg ${state} 'pattern' 1 "window search pattern" +} + +function _tmux-has-session() { + [[ -n ${tmux_describe} ]] && print "Check and report if a session exists on the server" && return + local -a args + args=('-t[choose a target session]:sessions:__tmux-sessions') + _arguments ${args} +} + +function _tmux-if-shell() { + [[ -n ${tmux_describe} ]] && print "Execute a tmux command if a shell-command succeeded" && return + local -a args + args=( + '1:shell command:' + '2:tmux command:' + ) + _arguments ${args} +} + +function _tmux-join-pane() { + [[ -n ${tmux_describe} ]] && print "Split a pane and move an existing one into the new space" && return + local -a args + args=( + '-d[do not make the new window become the active one]' + '-h[split horizontally]' + '-v[split vertically]' + '-l[define new pane'\''s size]: :_guard "[0-9]#" "numeric value"' + '-p[define new pane'\''s size in percent]: :_guard "[0-9]#" "numeric value"' + '-s[choose source pane]:window:__tmux-panes' + '-t[choose target pane]:window:__tmux-panes' + ) + _arguments ${args} && return +} + +function _tmux-kill-pane() { + [[ -n ${tmux_describe} ]] && print "Destroy a given pane" && return + local -a args + args=( + '-a[kill all panes, except current]' + '-t[choose a target pane]:panes:__tmux-panes' + ) + _arguments ${args} +} + +function _tmux-kill-server() { + [[ -n ${tmux_describe} ]] && print "Kill clients, sessions and server" && return + __tmux-nothing-else +} + +function _tmux-kill-session() { + [[ -n ${tmux_describe} ]] && print "Destroy a given session" && return + local -a args + args=('-t[choose a target session]:sessions:__tmux-sessions') + _arguments ${args} +} + +function _tmux-kill-window() { + [[ -n ${tmux_describe} ]] && print "Destroy a given window" && return + local -a args + args=('-t[choose a target window]:windows:__tmux-windows') + _arguments ${args} +} + +function _tmux-last-window() { + [[ -n ${tmux_describe} ]] && print "Select the previously selected window" && return + local -a args + args=('-t[choose a session]:sessions:__tmux-sessions') + _arguments ${args} && return +} + +function _tmux-link-window() { + [[ -n ${tmux_describe} ]] && print "Link a window to another" && return + local -a args + args=( + '-d[do not make the new window become the active one]' + '-k[kill the target window if it exists]' + '-s[choose source window]:window:__tmux-windows' + '-t[choose destination window]:window:__tmux-windows' + ) + _arguments ${args} +} + +function _tmux-list-buffers() { + [[ -n ${tmux_describe} ]] && print "List paste buffers of a session" && return + local -a args + args=('-t[choose a session]:sessions:__tmux-sessions') + _arguments ${args} && return +} + +function _tmux-list-clients() { + [[ -n ${tmux_describe} ]] && print "List clients attached to server" && return + __tmux-nothing-else +} + +function _tmux-list-commands() { + [[ -n ${tmux_describe} ]] && print "List supported sub-commands" && return + __tmux-nothing-else +} + +function _tmux-list-keys() { + [[ -n ${tmux_describe} ]] && print "List all key-bindings" && return + local -a args + args=('-t[choose a key table]:key table:__tmux-key-tables') + _arguments ${args} && return +} + +function _tmux-list-panes() { + [[ -n ${tmux_describe} ]] && print "List panes of a window" && return + local -a args + args=('-t[choose a window]:windows:__tmux-windows') + _arguments ${args} && return +} + +function _tmux-list-sessions() { + [[ -n ${tmux_describe} ]] && print "List sessions managed by server" && return + __tmux-nothing-else +} + +function _tmux-list-windows() { + [[ -n ${tmux_describe} ]] && print "List windows of a session" && return + local -a args + args=('-t[choose a session]:sessions:__tmux-sessions') + _arguments ${args} && return +} + +function _tmux-load-buffer() { + [[ -n ${tmux_describe} ]] && print "Load a file into a paste buffer" && return + local state session + local -a args + local -ax bopts + + args=( + '-b[choose a target buffer index]:panes:->buffer' + '-t[choose a target session]:panes:->session' + '1:file name:_files -g "*(-.)"' + ) + _arguments ${args} + + case ${state} in + (session) + __tmux-sessions + return + ;; + (buffer) + session="$(__tmux-get-optarg -t "${words[@]}")" + ;; + (*) return ;; + esac + if [[ -n ${session} ]]; then + bopts=( -t ${session} ) + __tmux-buffers + return + fi + bopts=() + __tmux-buffers +} + +function _tmux-lock-client() { + [[ -n ${tmux_describe} ]] && print "Lock a client" && return + local -a args + args=('-t[choose a client]:clients:__tmux-clients') + _arguments ${args} && return +} + +function _tmux-lock-server() { + [[ -n ${tmux_describe} ]] && print "Lock all clients attached to the server" && return + __tmux-nothing-else +} + +function _tmux-lock-session() { + [[ -n ${tmux_describe} ]] && print "Lock all clients attached to a session" && return + local -a args + args=('-t[choose a session]:sessions:__tmux-sessions') + _arguments ${args} && return +} + +function _tmux-move-window() { + [[ -n ${tmux_describe} ]] && print "Move a window to another" && return + local -a args + args=( + '-d[do not make the new window become the active one]' + '-s[choose source window]:window:__tmux-windows' + '-t[choose destination window]:window:__tmux-windows' + ) + _arguments ${args} +} + +function _tmux-new-session() { + [[ -n ${tmux_describe} ]] && print "Create a new session" && return + local -a args + args=( + '-d[attach the new session the current terminal]' + '-n[name the initial window]:window name' + '-s[name the session]:session name' + '-t[specify target session]:sessions:__tmux-sessions' + '*:: :_command' + ) + _arguments ${args} +} + +function _tmux-new-window() { + [[ -n ${tmux_describe} ]] && print "Create a new window" && return + local -a args + args=( + '-d[do not make the new window become the active one]' + '-k[destroy it if the specified window exists]' + '-n[specify a window name]:window name:' + '-t[specify target window]:windows:__tmux-windows' + '*:: :_command' + ) + _arguments ${args} +} + +function _tmux-next-layout() { + [[ -n ${tmux_describe} ]] && print "Move a window to the next layout" && return + local -a args + args=('-t[choose target window]:window:__tmux-windows') + _arguments ${args} +} + +function _tmux-next-window() { + [[ -n ${tmux_describe} ]] && print "Move to the next window in a session" && return + local -a args + args=( + '-a[move to the next window with activity]' + '-t[choose target session]:session:__tmux-sessions' + ) + _arguments ${args} +} + +function _tmux-paste-buffer() { + [[ -n ${tmux_describe} ]] && print "Insert a paste buffer into the window" && return + local -a args + args=( + '-d[remove buffer from stack after pasting]' + '-r[do not replace LF with CR when pasting]' + '-b[choose buffer]:source buffer:__tmux-buffers' + '-t[choose target window]:window:__tmux-windows' + ) + _arguments ${args} +} + +function _tmux-pipe-pane() { + [[ -n ${tmux_describe} ]] && print "Pipe output from a pane to a shell command" && return + local state + args=( + '-o[only open a pipe if none is currently opened]' + '-t[choose target pane]:pane:__tmux-panes' + '*:: :->cmd' + ) + _arguments ${args} && return + __tmux-lastarg ${state} 'cmd' 1 "command string" +} + +function _tmux-previous-layout() { + [[ -n ${tmux_describe} ]] && print "Move a window to the previous layout" && return + local -a args + args=('-t[choose target window]:window:__tmux-windows') + _arguments ${args} +} + +function _tmux-previous-window() { + [[ -n ${tmux_describe} ]] && print "Move to the previous window in a session" && return + local -a args + args=( + '-a[move to the previous window with activity]' + '-t[choose target session]:session:__tmux-sessions' + ) + _arguments ${args} +} + +function _tmux-refresh-client() { + [[ -n ${tmux_describe} ]] && print "Refresh a client" && return + local -a args + args=('-t[choose target client]:client:__tmux-clients') + _arguments ${args} +} + +function _tmux-rename-session() { + [[ -n ${tmux_describe} ]] && print "Rename a session" && return + local state + args=( + '-t[choose target session]:session:__tmux-sessions' + '*:: :->name' + ) + _arguments ${args} && return + __tmux-lastarg ${state} 'name' 1 "new session name" +} + +function _tmux-rename-window() { + [[ -n ${tmux_describe} ]] && print "Rename a window" && return + local state + args=( + '-t[choose target window]:window:__tmux-windows' + '*:: :->name' + ) + _arguments ${args} && return + __tmux-lastarg ${state} 'name' 1 "new window name" +} + +function _tmux-resize-pane() { + [[ -n ${tmux_describe} ]] && print "Resize a pane" && return + args=( + '-D[resize downward]' + '-L[resize to the left]' + '-R[resize to the right]' + '-U[resize upward]' + '-t[choose target pane]:pane:__tmux-panes' + '1::adjustment (defaults to one):_guard "[0-9]#" "numeric value"' + ) + _arguments ${args} +} + +function _tmux-respawn-window() { + [[ -n ${tmux_describe} ]] && print "Reuse a window in which a command has exited" && return + local -a args + args=( + '-k[kill window if it is in use]' + '-t[choose target window]:window:__tmux-windows' + '*::command:_command' + ) + _arguments ${args} +} + +function _tmux-rotate-window() { + [[ -n ${tmux_describe} ]] && print "Rotate positions of panes in a window" && return + local -a args + args=( + '-D[rotate downward]' + '-U[rotate upward]' + '-t[choose target window]:window:__tmux-windows' + ) + _arguments ${args} +} + +function _tmux-run-shell() { + [[ -n ${tmux_describe} ]] && print "Execute a command without creating a new window" && return + _command +} + +function _tmux-save-buffer() { + [[ -n ${tmux_describe} ]] && print "Save a paste buffer to a file" && return + local state session + local -a args + local -ax bopts + + args=( + '-b[choose a target buffer index]:buffer:->buffer' + '-t[choose a target session]:buffer:->session' + ) + _arguments ${args} + + case ${state} in + (session) + __tmux-sessions + return + ;; + (buffer) + session="$(__tmux-get-optarg -t "${words[@]}")" + ;; + (*) return ;; + esac + if [[ -n ${session} ]]; then + bopts=( -t ${session} ) + __tmux-buffers + return + fi + bopts=() + __tmux-buffers +} + +function _tmux-select-layout() { + [[ -n ${tmux_describe} ]] && print "Choose a layout for a window" && return + args=( + '-t[choose a target window]:target window:__tmux-windows' + '*::layout name:__tmux-layouts' + ) + _arguments ${args} +} + +function _tmux-select-pane() { + [[ -n ${tmux_describe} ]] && print "Make a pane the active one in the window" && return + local -a args + args=('-t[choose a target pane]:panes:__tmux-panes') + _arguments ${args} && return +} + +function _tmux-select-prompt() { + [[ -n ${tmux_describe} ]] && print "Open a prompt to enter a window index" && return + local -a args + args=('-t[choose a target client]:clients:__tmux-clients') + _arguments ${args} && return +} + +function _tmux-select-window() { + [[ -n ${tmux_describe} ]] && print "Select a window" && return + local -a args + args=('-t[choose a target window]:windows:__tmux-windows') + _arguments ${args} && return +} + +function _tmux-send-keys() { + [[ -n ${tmux_describe} ]] && print "Send key(s) to a window" && return + local curcontext="${curcontext}" state + local -a args + args=( + '-t[choose a target pane]:panes:__tmux-panes' + '*:: :->key' + ) + _arguments ${args} && return + __tmux-lastarg ${state} 'key' 1 "key" +} + +function _tmux-send-prefix() { + [[ -n ${tmux_describe} ]] && print "Send the prefix key to a window" && return + local -a args + args=('-t[choose a target pane]:panes:__tmux-panes') + _arguments ${args} +} + +function _tmux-server-info() { + [[ -n ${tmux_describe} ]] && print "Show server information" && return + __tmux-nothing-else +} + +function _tmux-set-buffer() { + [[ -n ${tmux_describe} ]] && print "Set contents of a paster buffer" && return + local state session + local -a args + local -ax bopts + + args=( + '-b[choose a target buffer index]:panes:->buffer' + '-t[choose a target session]:panes:->session' + ) + _arguments ${args} + + case ${state} in + (session) + __tmux-sessions + return + ;; + (buffer) + session="$(__tmux-get-optarg -t "${words[@]}")" + ;; + (*) return ;; + esac + if [[ -n ${session} ]]; then + bopts=( -t ${session} ) + __tmux-buffers + return + fi + bopts=() + __tmux-buffers +} + +function _tmux-set-environment() { + [[ -n ${tmux_describe} ]] && print "(Un)Set an environment variable" && return + local state + local -a args + args=( + '-g[modify global environment]' + '-r[remove variable before starting new processes]' + '-u[unset a variable]' + '-t[choose a target session]:target session:__tmux-sessions' + '*:: :->name_or_value' + ) + _arguments -C ${args} + + case ${state} in + name_or_value) + if (( CURRENT == 1 )); then + _message 'name' + elif (( CURRENT == 2 )); then + _message 'value' + else + __tmux-nothing-else + fi + ;; + esac +} + +function _tmux-set-option() { + [[ -n ${tmux_describe} ]] && print "Set a session option" && return + local mode + local -a args + args=( + '-a[append to string options]' + '-g[set a global session option]' + '-u[unset a non-global option]' + '-w[change window (not session) options]' + '-s[change server (not session) options]' + '-t[choose a target session]:target session:__tmux-sessions' + '*:: :->name_or_value' + ) + if __tmux-got-option-already -w; then + mode=window + elif __tmux-got-option-already -s; then + mode=server + else + mode=session + fi + _arguments -C ${args} + __tmux-options-complete ${mode} ${state} +} + +function _tmux-set-window-option() { + [[ -n ${tmux_describe} ]] && print "Set a window option" && return + local -a args + args=( + '-a[append to string options]' + '-g[set a global window option]' + '-u[unset a non-global option]' + '-t[choose a target window]:target window:__tmux-windows' + '*:: :->name_or_value' + ) + _arguments -C ${args} + __tmux-options-complete window ${state} +} + +function _tmux-show-buffer() { + [[ -n ${tmux_describe} ]] && print "Display the contents of a paste buffer" && return + local state session + local -a args + local -ax bopts + + args=( + '-b[choose a target buffer index]:panes:->buffer' + '-t[choose a target session]:panes:->session' + ) + _arguments ${args} + + case ${state} in + (session) + __tmux-sessions + return + ;; + (buffer) + session="$(__tmux-get-optarg -t "${words[@]}")" + ;; + (*) return ;; + esac + if [[ -n ${session} ]]; then + bopts=( -t ${session} ) + __tmux-buffers + return + fi + bopts=() + __tmux-buffers +} + +function _tmux-show-environment() { + [[ -n ${tmux_describe} ]] && print "Display the environment" && return + local -a args + args=( + '-g[show global environment]' + '-t[choose a target session]:target session:__tmux-sessions' + ) + _arguments ${args} +} + +function _tmux-show-messages() { + [[ -n ${tmux_describe} ]] && print "Show client"\'"s message log" && return + args=('-t[choose target client]:client:__tmux-clients') + _arguments ${args} +} + +function _tmux-show-options() { + [[ -n ${tmux_describe} ]] && print "Show session options" && return + local -a args + args=( + '-g[show global options]' + '-t[choose a target session]:target session:__tmux-sessions' + ) + _arguments ${args} +} + +function _tmux-show-window-options() { + [[ -n ${tmux_describe} ]] && print "Show window options" && return + local -a args + args=( + '-g[show global options]' + '-t[choose a target window]:target window:__tmux-windows' + ) + _arguments ${args} +} + +function _tmux-source-file() { + [[ -n ${tmux_describe} ]] && print "Execute tmux commands from a file" && return + _files -g "*(-.)" +} + +function _tmux-split-window() { + [[ -n ${tmux_describe} ]] && print "Splits a pane into two" && return + local -a args + args=( + '-d[do not make the new window become the active one]' + '-h[split horizontally]' + '-v[split vertically]' + '-l[define new pane'\''s size]: :_guard "[0-9]#" "numeric value"' + '-p[define new pane'\''s size in percent]: :_guard "[0-9]#" "numeric value"' + # Yes, __tmux_pane is correct here. The behaviour was changed + # in recent tmux versions and makes more sense. Except that + # changing the command's name might annoy users. So it stays like + # this. + '-t[choose target pane]:window:__tmux-panes' + '*:: :_command' + ) + _arguments ${args} && return +} + +function _tmux-start-server() { + [[ -n ${tmux_describe} ]] && print "Start a tmux server" && return + __tmux-nothing-else +} + +function _tmux-suspend-client() { + [[ -n ${tmux_describe} ]] && print "Suspend a client" && return + local -a args + args=('-t[choose destination client]:client:__tmux-clients') + _arguments ${args} +} + +function _tmux-swap-pane() { + [[ -n ${tmux_describe} ]] && print "Swap two panes" && return + local -a args + args=( + '-D[move pane down]' + '-U[move pane up]' + '-d[do not change the active pane]' + '-s[choose source pane]:pane:__tmux-panes' + '-t[choose destination pane]:pane:__tmux-panes' + ) + _arguments ${args} +} + +function _tmux-swap-window() { + [[ -n ${tmux_describe} ]] && print "Swap two windows" && return + local -a args + args=( + '-d[do not make the new window become the active one]' + '-s[choose source window]:window:__tmux-windows' + '-t[choose destination window]:window:__tmux-windows' + ) + _arguments ${args} +} + +function _tmux-switch-client() { + [[ -n ${tmux_describe} ]] && print "Switch the client to another session" && return + local -a args + args=( + '-c[choose a target client]:client:__tmux-clients' + '-t[choose a target window]:window:__tmux-windows' + ) + _arguments ${args} +} + +function _tmux-unbind-key() { + [[ -n ${tmux_describe} ]] && print "Unbind a key" && return + local state keytable + local -a args ow + + ow=( "${words[@]}" ) + args=( + '-c[kill the window if it is only in one session]' + '-n[remove a non-prefix binding]' + '-t[choose a key table]:key table:__tmux-key-tables' + '*:: :->boundkeys' + ) + _arguments ${args} && return + [[ ${state} != 'boundkeys' ]] && return + keytable="$(__tmux-get-optarg -t "${ow[@]}")" + if [[ -n ${keytable} ]]; then + __tmux-bound-keys -t ${keytable} + return + fi + __tmux-bound-keys +} + +function _tmux-unlink-window() { + [[ -n ${tmux_describe} ]] && print "Unlink a window" && return + local -a args + args=( + '-k[kill the window if it is only in one session]' + '-t[choose a target window]:target window:__tmux-windows' + ) + _arguments ${args} +} + +function _tmux-up-pane() { + [[ -n ${tmux_describe} ]] && print "Move up a pane" && return + local -a args + args=('-t[choose a target pane]:panes:__tmux-panes') + _arguments ${args} +} + +# --- Utility functions --- +# They should be called __tmux-*() and kept seperate from the +# sub-command functions. + +function __tmux-attributes() { + local -a attr already + attr=( default bright bold dim underscore blink reverse hidden italics ) + compset -P '*,' + already=(${(s<,>)IPREFIX}) + _describe -t tmux-attribute 'tmux attribute' attr -S, -F already -q +} + +function __tmux-buffers() { + local expl + local -a buffers + + if [[ ${(t)bopts} != *array* ]]; then + local -a bopts; bopts=() + fi + + buffers=( ${${(f)"$(command tmux list-buffers "${bopts[@]}")"}/:[ $'\t']##/:} ) + _describe -t buffers 'buffers' buffers +} + +function __tmux-bound-keys() { + local expl + local -a keys + + keys=( ${${${${(f)"$(command tmux list-keys "$@")"}/:[ $'\t']##/:}/(#s)[ $'\t']##/}/(#s):/\\:} ) + _describe -t keys 'keys' keys +} + +function __tmux-choose-stuff() { + # choose-{client,session,window} accept exactly the same arguments, so... + local curcontext="${curcontext}" state + local -a args + args=( + '-t[choose a target pane]:panes:__tmux-panes' + '*:: :->tmpl' + ) + _arguments ${args} && return + __tmux-lastarg ${state} 'tmpl' 1 "tmux command template" +} + +function __tmux-clients() { + local expl + local -a clients + clients=( ${${(f)"$(command tmux list-clients)"}/:[ $'\t']##/:} ) + _describe -t clients 'clients' clients +} + +function __tmux-colours() { + local -a colnames + colnames=( default black red green yellow blue magenta cyan white colourN:"replace N by a number between 0 and 255" ) + compset -P 'colour*' + if [[ -z ${IPREFIX} ]]; then + _describe -t tmux-colours 'colour' colnames + else + _message 'colour number 0..255' + fi +} + +function __tmux-get-optarg() { + local opt="$1" + local -i i + shift + + for (( i = 1; i <= $#; i++ )); do + if [[ ${argv[$i]} == ${opt} ]]; then + if [[ ${argv[$(( i + 1 ))]} != -* ]]; then + print -- ${argv[$(( i + 1 ))]} + fi + return + fi + done +} + +function __tmux-got-option-already() { + [[ -n ${(M)words:#$1} ]] && return 0 + return 1 +} + +function __tmux-key-tables() { + local expl + local -a tables + tables=( vi-edit emacs-edit vi-choice emacs-choice vi-copy emacs-copy ) + _wanted keytable expl 'key tables' compadd ${expl} -- ${tables} +} + +function __tmux-lastarg() { + local got_state="$1" want_state="$2" pos="$3" msg="$4" + + if [[ ${want_state} == ${got_state} ]] && (( CURRENT == ${pos} )); then + _message ${msg} + else + __tmux-nothing-else + fi +} + +function __tmux-layouts() { + local expl + local -a layouts + layouts=( even-horizontal even-vertical main-horizontal main-vertical ) + _wanted layout expl 'layouts' compadd ${expl} -- ${layouts} +} + +function __tmux-nothing-else() { + _message "no further arguments" +} + +function __tmux-option-guard() { + local mode opt guard int_guard + mode="$1" + opt="$2" + shift; shift + local -a options desc + int_guard='_guard "[0-9]#" "'${opt}': numeric value"' + if [[ ${mode} == 'session' ]]; then + options=( + 'base-index:'${int_guard} + 'bell-action:DESC:any none current' + 'buffer-limit:'${int_guard} + 'default-command:MSG:command string' + 'default-path:MSG:path name' + 'default-shell:MSG:shell executable' + 'default-terminal:MSG:terminal string' + 'display-panes-colour:__tmux-colours' + 'display-panes-active-colour:__tmux-colours' + 'display-panes-time:'${int_guard} + 'display-time:'${int_guard} + 'history-limit:'${int_guard} + 'lock-after-time:'${int_guard} + 'lock-command:MSG:command string' + 'lock-server:DESC:on off' + 'message-attr:__tmux-attributes' + 'message-bg:__tmux-colours' + 'message-fg:__tmux-colours' + 'message-limit:'${int_guard} + 'mouse-select-pane:DESC:on off' + 'pane-border-bg:__tmux-colours' + 'pane-border-fg:__tmux-colours' + 'pane-active-border-bg:__tmux-colours' + 'pane-active-border-fg:__tmux-colours' + 'prefix:MSG:comma-seperated key list' + 'repeat-time:'${int_guard} + 'set-remain-on-exit:DESC:on off' + 'set-titles:DESC:on off' + 'set-titles-string:MSG:title format string' + 'status:DESC:on off' + 'status-attr:__tmux-attributes' + 'status-bg:__tmux-colours' + 'status-fg:__tmux-colours' + 'status-interval:'${int_guard} + 'status-justify:DESC:left centre right' + 'status-keys:DESC:vi emacs' + 'status-left:MSG:format string' + 'status-left-attr:__tmux-attributes' + 'status-left-bg:__tmux-colours' + 'status-left-fg:__tmux-colours' + 'status-left-length:'${int_guard} + 'status-right:MSG:format string' + 'status-right-attr:__tmux-attributes' + 'status-right-bg:__tmux-colours' + 'status-right-fg:__tmux-colours' + 'status-right-length:'${int_guard} + 'status-utf8:DESC:on off' + 'terminal-overrides:MSG:overrides string' + 'update-environment:MSG:string listing env. variables' + 'visual-activity:DESC:on off' + 'visual-bell:DESC:on off' + 'visual-content:DESC:on off' + ) + elif [[ ${mode} == 'server' ]]; then + options=( + 'escape-time:'${int_guard} + 'quiet:DESC:on off' + ) + else + options=( + 'aggressive-resize:DESC:on off' + 'alternate-screen:DESC:on off' + 'automatic-rename:DESC:on off' + 'clock-mode-colour:__tmux-colours' + 'clock-mode-style:DESC:12 24' + 'force-height:'${int_guard} + 'force-width:'${int_guard} + 'main-pane-height:'${int_guard} + 'main-pane-width:'${int_guard} + 'mode-attr:__tmux-attributes' + 'mode-bg:__tmux-colours' + 'mode-fg:__tmux-colours' + 'mode-keys:DESC:vi emacs' + 'mode-mouse:DESC:on off' + 'monitor-activity:DESC:on off' + 'monitor-content:MSG:fnmatch(3) pattern' + 'remain-on-exit:DESC:on off' + 'synchronize-panes:DESC:on off' + 'utf8:DESC:on off' + 'window-status-attr:__tmux-attributes' + 'window-status-bg:__tmux-colours' + 'window-status-current-attr:__tmux-attributes' + 'window-status-current-bg:__tmux-colours' + 'window-status-current-fg:__tmux-colours' + 'window-status-current-format:MSG:status format string' + 'window-status-fg:__tmux-colours' + 'window-status-format:MSG:status format string' + 'xterm-keys:DESC:on off' + ) + fi + + guard=${(M)options:#$opt:*} + if [[ -z ${guard} ]]; then + _message "unknown ${mode} option: ${opt}" + return + fi + _message "${mode} option value" + guard=${guard#*:} + case ${guard} in + ('') ;; + (MSG:*) + _message ${guard#*:} + ;; + (DESC:*) + eval "desc=( ${guard#*:} )" + _describe -t "tmux-${mode}-option-value" "${opt}" desc + ;; + (*) + eval ${guard} + ;; + esac +} + +function __tmux-options() { + local -a tmux_options + tmux_options=( + 'base-index:define where to start numbering' + 'bell-action:set action on window bell' + 'buffer-limit:number of buffers kept per session' + 'default-command:default command for new windows' + 'default-path:default working directory' + 'default-shell:default shell executable' + 'default-terminal:default terminal definition string' + 'display-panes-colour:colour used for display-panes' + 'display-panes-active-colour:colour for active pane in display-panes' + 'display-panes-time:time (in msecs) of display-panes output' + 'display-time:time (in msecs) messages are displayed' + 'history-limit:number of copy-mode lines per window' + 'lock-after-time:lock sessions after N seconds' + 'lock-command:command to run for locking a client' + 'lock-server:make lock-after-time lock the server instead of sessions' + 'message-attr:set status line message attributes' + 'message-bg:set status line message background colour' + 'message-fg:set status line message foreground colour' + 'message-limit:set size of message log per client' + 'mouse-select-pane:make mouse clicks select window panes' + 'pane-border-bg:set pane border foreground colour' + 'pane-border-fg:set pane border background colour' + 'pane-active-border-bg:set active pane border foreground colour' + 'pane-active-border-fg:set active pane border background colour' + 'prefix:comma seperated line of keys accepted as prefix key' + 'repeat-time:time for multiple commands without prefix-key presses' + 'set-remain-on-exit:set remain-on-exit window option' + 'set-titles:try to set xterm window titles' + 'set-titles-string:format used by set-titles' + 'status:show or hide the status bar' + 'status-attr:status bar attributes' + 'status-bg:status bar background colour' + 'status-fg:status bar foreground colour' + 'status-interval:interval (in seconds) for status bar updates' + 'status-justify:position of the window list in status bar' + 'status-keys:mode to use in status bar modes (vi/emacs)' + 'status-left:format to use left in status bar' + 'status-left-attr:attribute for the left part of the status bar' + 'status-left-bg:background colour of the left part of the status bar' + 'status-left-fg:foreground colour of the left part of the status bar' + 'status-left-length:maximum length of the left part of the status bar' + 'status-right:format to use right in status bar' + 'status-right-attr:attribute for the right part of the status bar' + 'status-right-bg:background colour of the right part of the status bar' + 'status-right-fg:foreground colour of the right part of the status bar' + 'status-right-length:maximum length of the right part of the status bar' + 'status-utf8:assume UTF-8 sequences to appear in status bar' + 'terminal-overrides:override terminal descriptions' + 'update-environment:list of variables to be copied to a session'\''s environment' + 'visual-activity:display status line messages upon activity' + 'visual-bell:use visual bell instead of audible' + 'visual-content:display status line messages upon content changes' + ) + _describe -t tmux-options 'tmux option' tmux_options +} + +function __tmux-options-complete() { + local mode="$1" state="$2" + + case ${state} in + name_or_value) + if (( CURRENT == 1 )) && [[ ${mode} == 'session' ]]; then + __tmux-options + elif (( CURRENT == 1 )) && [[ ${mode} == 'server' ]]; then + __tmux-server-options + elif (( CURRENT == 1 )) && [[ ${mode} == 'window' ]]; then + __tmux-window-options + elif (( CURRENT == 2 )); then + __tmux-option-guard ${mode} ${words[1]} + else + __tmux-nothing-else + fi + ;; + esac +} + +function __tmux-panes() { + local expl line + local -i num + local -a panes opts + + compset -P '*.' + if [[ -n ${IPREFIX} ]]; then + opts=( -t "${IPREFIX%.}" ) + else + opts=( ) + fi + num=0 + command tmux list-panes "${opts[@]}" | while IFS= read -r line; do + panes+=( $(( num++ )):${line//:/} ) + done + _describe -t panes 'panes' panes "$@" + if [[ ${IPREFIX} != *. ]]; then + _wanted windows expl 'windows' __tmux-windows -S. + fi +} + +function __tmux-server-options() { + local -a tmux_server_options + tmux_server_options=( + 'escape-time:set timeout to detect single escape characters (in msecs)' + 'quiet:enable/disable the display of various informational messages' + ) + _describe -t tmux-server-options 'tmux server option' tmux_server_options +} + +function __tmux-sessions() { + local expl + local -a sessions + sessions=( ${${(f)"$(command tmux list-sessions)"}/:[ $'\t']##/:} ) + _describe -t sessions 'sessions' sessions "$@" +} + +function __tmux-socket-name() { + local expl sdir + local curcontext="${curcontext}" + local -a socks + zstyle -s ":completion:${curcontext}:sockets" socketdir sdir || sdir="/tmp/tmux-${UID}" + socks=(${sdir}/*(=:t)) + _wanted socket expl 'socket name' compadd ${expl} -- ${socks} +} + +function __tmux-window-options() { + local -a tmux_window_options + tmux_window_options=( + 'aggressive-resize:aggressively resize windows' + 'alternate-screen:allow alternate screen feature to be used' + 'automatic-rename:attempt to automatically rename windows' + 'clock-mode-colour:set clock colour' + 'clock-mode-style:set clock hour format (12/24)' + 'force-height:force a windows to a certain height' + 'force-width:force a windows to a certain width' + 'main-pane-height:set height for main-* layouts' + 'main-pane-width:set width for main-* layouts' + 'mode-attr:set window modes attributes' + 'mode-bg:set window modes background colour' + 'mode-fg:set window modes foreground colour' + 'mode-keys:mode to use in copy and choice modes (vi/emacs)' + 'mode-mouse:use mouse in modes' + 'monitor-activity:monitor window activity' + 'monitor-content:monitor window contents for a fnmatch(3) pattern' + 'remain-on-exit:do not destroy windows after the program exits' + 'synchronize-panes:send input to all panes of a window' + 'utf8:assume UTF-8 sequences to appear in a window' + 'window-status-attr:set status line attributes for a window' + 'window-status-bg:set status line background for a window' + 'window-status-current-attr:set status line attributes for active window' + 'window-status-current-bg:set status line background for active window' + 'window-status-current-fg:set status line foreground for active window' + 'window-status-current-format:set status line format for active window' + 'window-status-fg:set status line foreground for a window' + 'window-status-format:set status line format for all but the active window' + 'xterm-keys:generate xterm-style function key sequences' + ) + _describe -t tmux-window-options 'tmux window option' tmux_window_options +} + +function __tmux-windows() { + local expl + local -a wins opts + + compset -P '*:' + if [[ -n ${IPREFIX} ]]; then + opts=( -t "${IPREFIX%:}" ) + else + opts=( ) + fi + wins=( ${${(M)${(f)"$(command tmux list-windows "${opts[@]}")"}:#<->*}/:[ $'\t']##/:} ) + _describe -t windows 'windows' wins "$@" + if [[ ${IPREFIX} != *: ]]; then + _wanted sessions expl 'sessions' __tmux-sessions -S: + fi +} + +# And here is the actual _tmux(), that puts it all together: +function _tmux() { + local curcontext="${curcontext}" + local mode state ret + local -a args + local -x tmuxcommand + unset tmux_describe + + args=( + '-2[force using 256 colours]' + '-8[force using 88 colours]' + '-c[execute a shell command]:command name:_command_names' + '-f[specify configuration file]:tmux config file:_files -g "*(-.)"' + '-l[behave like a login shell]' + '-L[specify socket name]:socket name:__tmux-socket-name' + '-q[do not send informational messages]' + '-S[specify socket path]:server socket:_path_files -g "*(=,/)"' + '-u[force using UTF-8]' + '-v[request verbose logging]' + '*:: :->subcommand_or_options' + ) + _arguments -C -s -w ${args} && return + + if [[ ${state} == "subcommand_or_options" ]]; then + if (( CURRENT == 1 )) ; then + zstyle -s ":completion:${curcontext}:subcommands" mode mode || mode='both' + if [[ ${mode} == 'commands' ]]; then + _describe -t subcommands 'tmux commands' _tmux_commands + elif [[ ${mode} == 'aliases' ]]; then + _describe -t subcommands 'tmux aliases' _tmux_aliases + else + _describe -t subcommands 'tmux commands and aliases' _tmux_commands -- _tmux_aliases + fi + else + tmuxcommand="${words[1]}" + if [[ -n ${_tmux_aliasmap[$tmuxcommand]} ]] ; then + tmuxcommand="${_tmux_aliasmap[$tmuxcommand]}" + fi + curcontext="${curcontext%:*:*}:tmux-${tmuxcommand}:" + _call_function ret _tmux-${tmuxcommand} + fi + fi +} + +# description generation follows; only done on 1st _tmux call. +local f desc +local -A rev +local -x tmux_describe +tmux_describe='yes, please' +for f in ${(k)_tmux_aliasmap} ; do + rev+=( ${_tmux_aliasmap[$f]} $f ) +done +for f in ${(M)${(k)functions}:#_tmux-*} ; do + desc="$($f)" + _tmux_commands+=( "${f#_tmux-}${desc:+:$desc}" ) + [[ -n ${rev[${f#_tmux-}]} ]] && _tmux_aliases+=( "${rev[${f#_tmux-}]}${desc:+:$desc}" ) +done +unset desc f rev tmux_describe + +_tmux diff --git a/functions.zsh b/functions.zsh index 38cef21..1e9517b 100644 --- a/functions.zsh +++ b/functions.zsh @@ -132,6 +132,16 @@ shebang() { else echo "'which' could not find $1, is it in your \$PATH?"; fi; + # in case the new script is in path, this throw out the command hash table and + # start over (man zshbuiltins) + rehash } - +# a rough equivalent to "hg out" +# http://www.doof.me.uk/2011/01/08/list-outgoing-changesets-in-git/ +git-out() { + for i in $(git push -n $* 2>&1 | awk '$1 ~ /[a-f0-9]+\.\.[a-f0-9]+/ { print $1; }') + do + git xlog $i + done +} diff --git a/linux.zsh b/linux.zsh index a0a3ec7..4a76b61 100644 --- a/linux.zsh +++ b/linux.zsh @@ -14,7 +14,10 @@ fi # linux specific aliases ## autocomplete-able apt-xxx aliases alias acs='apt-cache show' -alias agi='apt-get install' -alias agu='apt-get uninstall' -alias agp='apt-get purge' +alias agi='sudo apt-get install' +alias ag='sudo apt-get' +alias agu='sudo apt-get update' +alias agug='sudo apt-get upgrade' +alias agr='sudo apt-get uninstall' +alias agp='sudo apt-get purge' diff --git a/options.zsh b/options.zsh index 4dc7334..7d5c4da 100644 --- a/options.zsh +++ b/options.zsh @@ -17,7 +17,12 @@ bindkey '^[[A' up-line-or-search bindkey '^[[B' down-line-or-search # History Settings (big history for use with many open shells and no dups) -HISTFILE=~/.zsh/history +# Different History files for root and standard user +if (( ! EUID )); then + HISTFILE=~/.zsh/history_root +else + HISTFILE=~/.zsh/history +fi SAVEHIST=10000 HISTSIZE=12000 setopt share_history append_history extended_history hist_no_store hist_ignore_all_dups hist_ignore_space diff --git a/zsh-syntax-highlighting b/zsh-syntax-highlighting new file mode 160000 index 0000000..eb749f2 --- /dev/null +++ b/zsh-syntax-highlighting @@ -0,0 +1 @@ +Subproject commit eb749f26814ad988535e64bcbe01fad2f4e0da7b diff --git a/zshrc b/zshrc index e08cf4e..0ea14d1 100644 --- a/zshrc +++ b/zshrc @@ -20,6 +20,10 @@ sources+="$HOME/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" # (sudo apt-get install command-not-found) sources+="/etc/zsh_command_not_found" +# Bash and Zsh completion support for git-flow +# https://github.com/bobthecow/git-flow-completion +sources+="$HOME/.zsh/git-flow-completion/git-flow-completion.zsh" + # Autojump: a cd command that learns # Cloned From: git://github.com/joelthelion/autojump.git sources+="$HOME/.zsh/autojump/autojump.zsh"