mirror of
https://github.com/dcarrillo/prezto.git
synced 2025-06-14 19:31:43 +00:00
[#23] Rename plugins to modules
This commit is contained in:
14
modules/archive/completions/_extract
Normal file
14
modules/archive/completions/_extract
Normal file
@ -0,0 +1,14 @@
|
||||
#compdef extract
|
||||
#autoload
|
||||
|
||||
#
|
||||
# Completes extract.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
_arguments \
|
||||
'(-r --remove)'{-r,--remove}'[remove archive]' \
|
||||
"*::archive file:_files -g '(#i)*.(tar|tgz|tbz|tbz2|txz|tlz|gz|bz2|xz|lzma|Z|zip|rar|7z|deb)(-.)'" && return 0
|
||||
|
14
modules/archive/completions/_ls-archive
Normal file
14
modules/archive/completions/_ls-archive
Normal file
@ -0,0 +1,14 @@
|
||||
#compdef ls-archive
|
||||
#autoload
|
||||
|
||||
#
|
||||
# Completes ls-archive.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
_arguments \
|
||||
'(-v --verbose)'{-v,--remove}'[verbose archive listing]' \
|
||||
"*::archive file:_files -g '(#i)*.(tar|tgz|tbz|tbz2|txz|tlz|gz|bz2|xz|lzma|Z|zip|rar|7z)(-.)'" && return 0
|
||||
|
77
modules/archive/functions/extract
Normal file
77
modules/archive/functions/extract
Normal file
@ -0,0 +1,77 @@
|
||||
#
|
||||
# Extracts the contents of popular archive formats.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
local remove_archive
|
||||
local success
|
||||
local file_name
|
||||
local extract_dir
|
||||
|
||||
if (( $# == 0 )); then
|
||||
cat >&2 <<EOF
|
||||
usage: $0 [-option] [file ...]
|
||||
|
||||
options:
|
||||
-r, --remove remove archive
|
||||
|
||||
Report bugs to <sorin.ionescu@gmail.com>.
|
||||
EOF
|
||||
fi
|
||||
|
||||
remove_archive=1
|
||||
if [[ "$1" == "-r" || "$1" == "--remove" ]]; then
|
||||
remove_archive=0
|
||||
shift
|
||||
fi
|
||||
|
||||
while (( $# > 0 )); do
|
||||
if [[ ! -f "$1" ]]; then
|
||||
print "$0: file not valid: $1" >&2
|
||||
shift
|
||||
continue
|
||||
fi
|
||||
|
||||
success=0
|
||||
file_name="${1:t}"
|
||||
extract_dir="${file_name:r}"
|
||||
case "$1" in
|
||||
(*.tar.gz|*.tgz) tar xvzf "$1" ;;
|
||||
(*.tar.bz2|*.tbz|*.tbz2) tar xvjf "$1" ;;
|
||||
(*.tar.xz|*.txz) tar --xz --help &> /dev/null \
|
||||
&& tar --xz -xvf "$1" \
|
||||
|| xzcat "$1" | tar xvf - ;;
|
||||
(*.tar.zma|*.tlz) tar --lzma --help &> /dev/null \
|
||||
&& tar --lzma -xvf "$1" \
|
||||
|| lzcat "$1" | tar xvf - ;;
|
||||
(*.tar) tar xvf "$1" ;;
|
||||
(*.gz) gunzip "$1" ;;
|
||||
(*.bz2) bunzip2 "$1" ;;
|
||||
(*.xz) unxz "$1" ;;
|
||||
(*.lzma) unlzma "$1" ;;
|
||||
(*.Z) uncompress "$1" ;;
|
||||
(*.zip) unzip "$1" -d $extract_dir ;;
|
||||
(*.rar) unrar e -ad "$1" ;;
|
||||
(*.7z) 7za x "$1" ;;
|
||||
(*.deb)
|
||||
mkdir -p "$extract_dir/control"
|
||||
mkdir -p "$extract_dir/data"
|
||||
cd "$extract_dir"; ar vx "../${1}" > /dev/null
|
||||
cd control; tar xzvf ../control.tar.gz
|
||||
cd ../data; tar xzvf ../data.tar.gz
|
||||
cd ..; rm *.tar.gz debian-binary
|
||||
cd ..
|
||||
;;
|
||||
(*)
|
||||
print "$0: cannot extract: $1" >&2
|
||||
success=1
|
||||
;;
|
||||
esac
|
||||
|
||||
(( success = $success > 0 ? $success : $? ))
|
||||
(( $success == 0 )) && (( $remove_archive == 0 )) && rm "$1"
|
||||
shift
|
||||
done
|
||||
|
54
modules/archive/functions/ls-archive
Normal file
54
modules/archive/functions/ls-archive
Normal file
@ -0,0 +1,54 @@
|
||||
#
|
||||
# Lists the contents of popular archive formats.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
local verbose
|
||||
|
||||
if (( $# == 0 )); then
|
||||
cat >&2 <<EOF
|
||||
usage: $0 [-option] [file ...]
|
||||
|
||||
options:
|
||||
-v, --verbose verbose archive listing
|
||||
|
||||
Report bugs to <sorin.ionescu@gmail.com>.
|
||||
EOF
|
||||
fi
|
||||
|
||||
if [[ "$1" == "-v" || "$1" == "--verbose" ]]; then
|
||||
verbose=0
|
||||
shift
|
||||
fi
|
||||
|
||||
while (( $# > 0 )); do
|
||||
if [[ ! -f "$1" ]]; then
|
||||
print "$0: file not valid: $1" >&2
|
||||
shift
|
||||
continue
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
(*.tar.gz|*.tgz) tar t${verbose:+v}vzf "$1" ;;
|
||||
(*.tar.bz2|*.tbz|*.tbz2) tar t${verbose:+v}jf "$1" ;;
|
||||
(*.tar.xz|*.txz) tar --xz --help &> /dev/null \
|
||||
&& tar --xz -t${verbose:+v}f "$1" \
|
||||
|| xzcat "$1" | tar t${verbose:+v}f - ;;
|
||||
(*.tar.zma|*.tlz) tar --lzma --help &> /dev/null \
|
||||
&& tar --lzma -t${verbose:+v}f "$1" \
|
||||
|| lzcat "$1" | tar x${verbose:+v}f - ;;
|
||||
(*.tar) tar t${verbose:+v}f "$1" ;;
|
||||
(*.zip) unzip -l${verbose:+v} "$1" ;;
|
||||
(*.rar) unrar ${${verbose:+v}:-l} "$1" ;;
|
||||
(*.7z) 7za l "$1" ;;
|
||||
(*)
|
||||
print "$0: cannot list: $1" >&2
|
||||
success=1
|
||||
;;
|
||||
esac
|
||||
|
||||
shift
|
||||
done
|
||||
|
14
modules/command-not-found/README.md
Normal file
14
modules/command-not-found/README.md
Normal file
@ -0,0 +1,14 @@
|
||||
command-not-found
|
||||
=================
|
||||
|
||||
Loads the [command-not-found][1] tool on Debian-based distributions.
|
||||
|
||||
Authors
|
||||
-------
|
||||
|
||||
*The authors of this module should be contacted via the GitHub issue tracker.*
|
||||
|
||||
- [Joseph Booker](/sargas)
|
||||
|
||||
[1]: https://code.launchpad.net/command-not-found
|
||||
|
11
modules/command-not-found/init.zsh
Normal file
11
modules/command-not-found/init.zsh
Normal file
@ -0,0 +1,11 @@
|
||||
#
|
||||
# Displays installation information for not found commands.
|
||||
#
|
||||
# Authors:
|
||||
# Joseph Jon Booker <joe@neoturbine.net>
|
||||
#
|
||||
|
||||
if [[ -f /etc/zsh_command_not_found ]]; then
|
||||
source /etc/zsh_command_not_found
|
||||
fi
|
||||
|
20
modules/compleat/init.zsh
Normal file
20
modules/compleat/init.zsh
Normal file
@ -0,0 +1,20 @@
|
||||
#
|
||||
# Loads Compleat completions.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
if (( ${+commands[compleat]} )); then
|
||||
compleat_setup="${commands[compleat]:h:h}/share/compleat-1.0/compleat_setup"
|
||||
|
||||
if [[ -f "$compleat_setup" ]]; then
|
||||
if autoloadable bashcompinit; then
|
||||
autoload -Uz bashcompinit && bashcompinit
|
||||
fi
|
||||
|
||||
source "$compleat_setup"
|
||||
unset compleat_setup
|
||||
fi
|
||||
fi
|
||||
|
1
modules/completion/completions
Submodule
1
modules/completion/completions
Submodule
Submodule modules/completion/completions added at b877df4e70
16
modules/dpkg/functions/apt-copy
Normal file
16
modules/dpkg/functions/apt-copy
Normal file
@ -0,0 +1,16 @@
|
||||
#
|
||||
# Generates a script that can be used to duplicate a dpkg-based system.
|
||||
#
|
||||
# Authors:
|
||||
# Daniel Bolton <danielbarrettbolton@gmail.com>
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
print '#!/bin/sh'"\n" > apt-copy.sh
|
||||
|
||||
list=$(perl -m'AptPkg::Cache' -e '$c=AptPkg::Cache->new; for (keys %$c){ push @a, $_ if $c->{$_}->{'CurrentState'} eq 'Installed';} print "$_ " for sort @a;')
|
||||
|
||||
print 'aptitude install '"$list\n" >> apt-copy.sh
|
||||
|
||||
chmod +x apt-copy.sh
|
||||
|
37
modules/dpkg/functions/apt-history
Normal file
37
modules/dpkg/functions/apt-history
Normal file
@ -0,0 +1,37 @@
|
||||
#
|
||||
# Displays dpkg history.
|
||||
#
|
||||
# Authors:
|
||||
# Peter Leung <commandolinux@gmail.com>
|
||||
# Benjamin Boudreau <boudreau.benjamin@gmail.com>
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
case "$1" in
|
||||
(install)
|
||||
zgrep --no-filename 'install ' $(ls -rt /var/log/dpkg*)
|
||||
;;
|
||||
(upgrade|remove)
|
||||
zgrep --no-filename $1 $(ls -rt /var/log/dpkg*)
|
||||
;;
|
||||
(rollback)
|
||||
zgrep --no-filename upgrade $(ls -rt /var/log/dpkg*) | \
|
||||
grep "$2" -A10000000 | \
|
||||
grep "$3" -B10000000 | \
|
||||
awk '{print $4"="$5}'
|
||||
;;
|
||||
(list)
|
||||
zcat $(ls -rt /var/log/dpkg*)
|
||||
;;
|
||||
(*)
|
||||
cat >&2 <<EOF
|
||||
Commands:
|
||||
install - List installed packages
|
||||
upgrade - List upgraded packages
|
||||
remove - List removed packages
|
||||
rollback - List rollback information
|
||||
list - Display contents of dpkg logs
|
||||
EOF
|
||||
;;
|
||||
esac
|
||||
|
17
modules/dpkg/functions/dbb-build
Normal file
17
modules/dpkg/functions/dbb-build
Normal file
@ -0,0 +1,17 @@
|
||||
#
|
||||
# Makes a dpkg Linux kernel package.
|
||||
#
|
||||
# Authors:
|
||||
# Daniel Bolton <dbb@9y.com>
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
MAKEFLAGS='' # Temporarily unset MAKEFLAGS ('-j3' will fail).
|
||||
appendage='-custom' # Displayed in $(uname -r).
|
||||
revision=$(date +"%Y%m%d") # Displayed in the dpkg package file name.
|
||||
|
||||
make-kpkg clean
|
||||
|
||||
time fakeroot make-kpkg --append-to-version "$appendage" --revision \
|
||||
"$revision" kernel_image kernel_headers
|
||||
|
31
modules/dpkg/init.zsh
Normal file
31
modules/dpkg/init.zsh
Normal file
@ -0,0 +1,31 @@
|
||||
#
|
||||
# Defines dpkg aliases.
|
||||
#
|
||||
# Authors:
|
||||
# Daniel Bolton <dbb@9y.com>
|
||||
# Benjamin Boudreau <boudreau.benjamin@gmail.com>
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
# Aliases
|
||||
alias as="aptitude -F \"* %p -> %d \n(%v/%V)\" --no-gui --disable-columns search" # Search package.
|
||||
alias ad="sudo apt-get update" # Update packages lists.
|
||||
alias au="sudo apt-get update && sudo apt-get dselect-upgrade" # Upgrade packages.
|
||||
alias ai="sudo apt-get install" # Install package.
|
||||
alias ar="sudo apt-get remove --purge && sudo apt-get autoremove --purge" # Remove package.
|
||||
alias ap="apt-cache policy" # Apt policy.
|
||||
alias av="apt-cache show" # Show package info.
|
||||
alias acs="apt-cache search" # Search package.
|
||||
alias ac="sudo apt-get clean && sudo apt-get autoclean" # Clean apt cache.
|
||||
alias afs='apt-file search --regexp' # Find file's packake.
|
||||
|
||||
# Install all .deb files in the current directory.
|
||||
# WARNING: you will need to put the glob in single quotes if you use glob_subst.
|
||||
alias debi='su -c "dpkg -i ./*.deb"'
|
||||
|
||||
# Create a basic .deb package.
|
||||
alias debc='time dpkg-buildpackage -rfakeroot -us -uc'
|
||||
|
||||
# Remove ALL kernel images and headers EXCEPT the one in use.
|
||||
alias kclean='su -c '\''aptitude remove -P ?and(~i~nlinux-(ima|hea) ?not(~n`uname -r`))'\'' root'
|
||||
|
1
modules/git/.gitignore
vendored
Normal file
1
modules/git/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
_git
|
254
modules/git/alias.zsh
Normal file
254
modules/git/alias.zsh
Normal file
@ -0,0 +1,254 @@
|
||||
#
|
||||
# Defines Git aliases.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
# Git
|
||||
alias g='git'
|
||||
compdef g=git
|
||||
|
||||
# Branch (b)
|
||||
alias gb='git branch'
|
||||
compdef _git gb=git-branch
|
||||
alias gbc='git checkout -b'
|
||||
compdef _git gbc=git-checkout
|
||||
alias gbl='git branch -v'
|
||||
compdef _git gbl=git-branch
|
||||
alias gbL='git branch -av'
|
||||
compdef _git gbL=git-branch
|
||||
alias gbx='git branch -d'
|
||||
compdef _git gbx=git-branch
|
||||
alias gbX='git branch -D'
|
||||
compdef _git gbX=git-branch
|
||||
alias gbm='git branch -m'
|
||||
compdef _git gbm=git-branch
|
||||
alias gbM='git branch -M'
|
||||
compdef _git gbM=git-branch
|
||||
|
||||
# Commit (c)
|
||||
alias gc='git commit'
|
||||
compdef _git gc=git-commit
|
||||
alias gca='git commit --all'
|
||||
compdef _git gca=git-commit
|
||||
alias gcm='git commit --message'
|
||||
compdef _git gcm=git-commit
|
||||
alias gco='git checkout'
|
||||
compdef _git gco=git-checkout
|
||||
alias gcO='git checkout HEAD --'
|
||||
compdef _git gcO=git-checkout
|
||||
alias gcf='git commit --amend --reuse-message HEAD'
|
||||
compdef _git gcf=git-commit
|
||||
alias gcp='git cherry-pick --ff'
|
||||
compdef _git gcp=git-cherry-pick
|
||||
alias gcP='git cherry-pick --no-commit'
|
||||
compdef _git gcP=git-cherry-pick
|
||||
alias gcr='git revert'
|
||||
compdef _git gcr=git-revert
|
||||
alias gcR='git reset "HEAD^"'
|
||||
compdef _git gcR=git-reset
|
||||
alias gcs='git show'
|
||||
compdef _git gcs=git-show
|
||||
alias gcv='git fsck | awk '\''/dangling commit/ {print $3}'\'' | git show --format="SHA1: %C(green)%h%C(reset) %f" --stdin | awk '\''/SHA1/ {sub("SHA1: ", ""); print}'\'''
|
||||
|
||||
# Data (d)
|
||||
alias gd='git ls-files'
|
||||
compdef _git gd=git-ls-files
|
||||
alias gdc='git ls-files --cached'
|
||||
compdef _git gdc=git-ls-files
|
||||
alias gdx='git ls-files --deleted'
|
||||
compdef _git gdx=git-ls-files
|
||||
alias gdm='git ls-files --modified'
|
||||
compdef _git gdm=git-ls-files
|
||||
alias gdu='git ls-files --other --exclude-standard'
|
||||
compdef _git gdu=git-ls-files
|
||||
alias gdk='git ls-files --killed'
|
||||
compdef _git gdk=git-ls-files
|
||||
alias gdi='git status --porcelain --short --ignored | sed -n "s/^!! //p"'
|
||||
|
||||
# Fetch (f)
|
||||
alias gf='git fetch'
|
||||
compdef _git gf=git-fetch
|
||||
alias gfc='git clone'
|
||||
compdef _git gfc=git-clone
|
||||
alias gfm='git pull'
|
||||
compdef _git gfm=git-pull
|
||||
alias gfr='git pull --rebase'
|
||||
compdef _git gfr=git-pull
|
||||
|
||||
# Index (i)
|
||||
alias gia='git add'
|
||||
compdef _git gia=git-add
|
||||
alias giA='git add --patch'
|
||||
compdef _git giA=git-add
|
||||
alias giu='git add --update'
|
||||
compdef _git giu=git-add
|
||||
alias gid='git diff --no-ext-diff --cached'
|
||||
compdef _git gid=git-diff
|
||||
alias giD='git diff --no-ext-diff --cached --word-diff'
|
||||
compdef _git giD=git-diff
|
||||
alias gir='git reset --mixed'
|
||||
compdef _git gir=git-reset
|
||||
alias giR='git reset --keep'
|
||||
compdef _git giR=git-reset
|
||||
alias gix='git rm -r --cached'
|
||||
compdef _git gix=git-rm
|
||||
alias giX='git rm -rf --cached'
|
||||
compdef _git giX=git-rm
|
||||
alias gig='git grep --cached'
|
||||
compdef _git gig=git-grep
|
||||
|
||||
# Konflict (k)
|
||||
alias gkl='git status | sed -n "s/^.*both [a-z]*ed: *//p"'
|
||||
alias gka='git add $(gkl)'
|
||||
compdef _git gka=git-add
|
||||
alias gke='git mergetool $(gkl)'
|
||||
alias gko='git checkout --ours --'
|
||||
compdef _git gko=git-checkout
|
||||
alias gkO='gko $(gkl)'
|
||||
alias gkt='git checkout --theirs --'
|
||||
compdef _git gkt=git-checkout
|
||||
alias gkT='gkt $(gkl)'
|
||||
|
||||
# Log (l)
|
||||
git_log_format_medium='--pretty=format:%C(bold)Commit:%C(reset) %C(green)%H%C(red)%d%n%C(bold)Author:%C(reset) %C(cyan)%an <%ae>%n%C(bold)Date:%C(reset) %C(blue)%ai (%ar)%C(reset)%n%+B'
|
||||
git_log_format_oneline='--pretty=format:%C(green)%h%C(reset) %s%n'
|
||||
git_log_format_brief='--pretty=format:%C(green)%h%C(reset) %s%n%C(blue)(%ar by %an)%C(red)%d%C(reset)%n'
|
||||
|
||||
alias gl='git log --topo-order ${git_log_format_medium}'
|
||||
compdef _git gl=git-log
|
||||
alias gls='git log --topo-order --stat ${git_log_format_medium}'
|
||||
compdef _git gls=git-log
|
||||
alias gld='git log --topo-order --stat --patch --full-diff ${git_log_format_medium}'
|
||||
compdef _git gld=git-log
|
||||
alias glo='git log --topo-order ${git_log_format_oneline}'
|
||||
compdef _git glo=git-log
|
||||
alias glg='git log --topo-order --all --graph ${git_log_format_oneline}'
|
||||
compdef _git glg=git-log
|
||||
alias glb='git log --topo-order ${git_log_format_brief}'
|
||||
compdef _git glb=git-log
|
||||
alias glc='git shortlog --summary --numbered'
|
||||
compdef _git glc=git-shortlog
|
||||
|
||||
# Merge (m)
|
||||
alias gm='git merge'
|
||||
compdef _git gm=git-merge
|
||||
alias gmC='git merge --no-commit'
|
||||
compdef _git gmC=git-merge
|
||||
alias gmF='git merge --no-ff'
|
||||
compdef _git gmF=git-merge
|
||||
alias gma='git merge --abort'
|
||||
compdef _git gma=git-merge
|
||||
alias gmt='git mergetool'
|
||||
compdef _git gmt=git-mergetool
|
||||
|
||||
# Push (p)
|
||||
alias gp='git push'
|
||||
compdef _git gp=git-push
|
||||
alias gpf='git push --force'
|
||||
compdef _git gpf=git-push
|
||||
alias gpa='git push --all'
|
||||
compdef _git gpa=git-push
|
||||
alias gpA='git push --all && git push --tags'
|
||||
compdef _git gpA=git-push
|
||||
alias gpt='git push --tags'
|
||||
compdef _git gpt=git-push
|
||||
alias gpc='git push --set-upstream origin "$(git-current-branch)"'
|
||||
compdef _git gpc=git-push
|
||||
alias gpp='git pull origin "$(git-current-branch)" && git push origin "$(git-branch)"'
|
||||
|
||||
# Rebase (r)
|
||||
alias gr='git rebase'
|
||||
compdef _git gr=git-rebase
|
||||
alias gra='git rebase --abort'
|
||||
compdef _git gra=git-rebase
|
||||
alias grc='git rebase --continue'
|
||||
compdef _git grc=git-rebase
|
||||
alias gri='git rebase --interactive'
|
||||
compdef _git gri=git-rebase
|
||||
alias grs='git rebase --skip'
|
||||
compdef _git grs=git-rebase
|
||||
|
||||
# Remote (R)
|
||||
alias gR='git remote'
|
||||
compdef _git gh=git-remote
|
||||
alias gRl='git remote --verbose'
|
||||
compdef _git gRl=git-remote
|
||||
alias gRa='git remote add'
|
||||
compdef _git gRa=git-remote
|
||||
alias gRx='git remote rm'
|
||||
compdef _git gRx=git-remote
|
||||
alias gRm='git remote rename'
|
||||
compdef _git gRm=git-remote
|
||||
alias gRu='git remote update'
|
||||
compdef _git gRu=git-remote
|
||||
alias gRc='git remote prune'
|
||||
compdef _git gRc=git-remote
|
||||
alias gRs='git remote show'
|
||||
compdef _git gRs=git-remote
|
||||
alias gRb='git-hub'
|
||||
compdef _git-hub gRb=git-hub
|
||||
|
||||
# Stash (s)
|
||||
alias gs='git stash'
|
||||
compdef _git gs=git-stash
|
||||
alias gsa='git stash apply'
|
||||
compdef _git gsa=git-stash
|
||||
alias gsc='git stash clear'
|
||||
compdef _git gsc=git-stash
|
||||
alias gsx='git stash drop'
|
||||
compdef _git gsx=git-stash
|
||||
alias gsl='git stash list'
|
||||
compdef _git gsl=git-stash
|
||||
alias gsL='git stash show --patch --stat'
|
||||
compdef _git gsL=git-stash
|
||||
alias gsp='git stash pop'
|
||||
compdef _git gsp=git-stash
|
||||
alias gss='git stash save --include-untracked'
|
||||
compdef _git gss=git-stash
|
||||
alias gsS='git stash save --patch --no-keep-index'
|
||||
compdef _git gsS=git-stash
|
||||
|
||||
# Submodule (S)
|
||||
alias gS='git submodule'
|
||||
compdef _git gS=git-submodule
|
||||
alias gSa='git submodule add'
|
||||
compdef _git gSa=git-submodule
|
||||
alias gSf='git submodule foreach'
|
||||
compdef _git gSf=git-submodule
|
||||
alias gSi='git submodule init'
|
||||
compdef _git gSi=git-submodule
|
||||
alias gSl='git submodule status'
|
||||
compdef _git gSl=git-submodule
|
||||
alias gSs='git submodule sync'
|
||||
compdef _git gSs=git-submodule
|
||||
alias gSu='git submodule update'
|
||||
compdef _git gSu=git-submodule
|
||||
alias gSU='git submodule update --init --recursive'
|
||||
compdef _git gSU=git-submdoule
|
||||
|
||||
# Working Copy (w)
|
||||
alias gws='git status --short'
|
||||
compdef _git gws=git-status
|
||||
alias gwS='git status'
|
||||
compdef _git gwS=git-status
|
||||
alias gwd='git diff --no-ext-diff'
|
||||
compdef _git gwd=git-diff
|
||||
alias gwD='git diff --no-ext-diff --word-diff'
|
||||
compdef _git gwD=git-diff
|
||||
alias gwr='git reset --soft'
|
||||
compdef _git gwr=git-reset
|
||||
alias gwR='git reset --hard'
|
||||
compdef _git gwR=git-reset
|
||||
alias gwc='git clean -n'
|
||||
compdef _git gwc=git-clean
|
||||
alias gwC='git clean -f'
|
||||
compdef _git gwC=git-clean
|
||||
alias gwx='git rm -r'
|
||||
compdef _git gwx=git-rm
|
||||
alias gwX='git rm -rf'
|
||||
compdef _git gwX=git-rm
|
||||
alias gwg='git grep'
|
||||
compdef _git gwg=git-grep
|
||||
|
44
modules/git/completions/_git-hub
Normal file
44
modules/git/completions/_git-hub
Normal file
@ -0,0 +1,44 @@
|
||||
#compdef git-hub
|
||||
#autoload
|
||||
|
||||
#
|
||||
# Completes git-hub.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
local state remotes remote branches files ret=1
|
||||
|
||||
_arguments -C -s -S \
|
||||
'1::args:->remote' \
|
||||
'2::args:->branch' \
|
||||
'3::args:->file' && ret=0
|
||||
|
||||
case "$state" in
|
||||
(remote)
|
||||
remotes=($(
|
||||
git config -l \
|
||||
| grep 'remote\.[^.]*\.url' \
|
||||
| cut -d'.' -f2))
|
||||
_describe -t branch 'remotes' remotes && ret=0
|
||||
;;
|
||||
(branch)
|
||||
remote="$words[(($CURRENT - 1))]"
|
||||
branches=($(
|
||||
git branch -r \
|
||||
| grep "${remote}/" \
|
||||
| sed \
|
||||
-e "/${remote}\/HEAD -> ${remote}/d" \
|
||||
-e "s/^[[:space:]]*${remote}\///g"
|
||||
))
|
||||
_describe -t branch 'branches' branches && ret=0
|
||||
;;
|
||||
(file)
|
||||
files=(${(0)"$(_call_program files git ls-files -z --exclude-standard 2>/dev/null)"})
|
||||
_wanted file expl 'file' _multi_parts - / files && ret=0
|
||||
;;
|
||||
esac
|
||||
|
||||
return $ret
|
||||
|
12
modules/git/completions/_git-hub-short-url
Normal file
12
modules/git/completions/_git-hub-short-url
Normal file
@ -0,0 +1,12 @@
|
||||
#compdef git-hub-short-url
|
||||
#autoload
|
||||
|
||||
#
|
||||
# Completes git-hub-short-url.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
_arguments '1:url:' && return 0
|
||||
|
15
modules/git/completions/_git-info
Normal file
15
modules/git/completions/_git-info
Normal file
@ -0,0 +1,15 @@
|
||||
#compdef git-info
|
||||
#autoload
|
||||
|
||||
#
|
||||
# Completes git-info.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
_arguments "1:toggle:((
|
||||
on\:'enable in-prompt information for the current repository'
|
||||
off\:'disable in-prompt information for the current repository'
|
||||
))" && return 0
|
||||
|
15
modules/git/functions/git-current-branch
Normal file
15
modules/git/functions/git-current-branch
Normal file
@ -0,0 +1,15 @@
|
||||
#
|
||||
# Displays the current Git branch.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
local ref="$(git symbolic-ref HEAD 2> /dev/null)"
|
||||
if [[ -n "$ref" ]]; then
|
||||
print "${ref#refs/heads/}"
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
|
45
modules/git/functions/git-hub
Normal file
45
modules/git/functions/git-hub
Normal file
@ -0,0 +1,45 @@
|
||||
#
|
||||
# Opens a GitHub repository in the default browser.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
local remote branches branch current_branch file url
|
||||
|
||||
remote="${1:-origin}"
|
||||
url=$(
|
||||
git config -l \
|
||||
| grep "remote.${remote}.url" \
|
||||
| sed -En "s/remote.${remote}.url=(git|https?)(@|:\/\/)github.com(:|\/)(.+)\/(.+).git/https:\/\/github.com\/\4\/\5/p"
|
||||
)
|
||||
branches=($(
|
||||
git branch -r | sed -e "/${remote}\/HEAD -> ${remote}/d" -e "s/^[[:space:]]*${remote}\///g"
|
||||
))
|
||||
current_branch="$(git-current-branch)"
|
||||
branch="${2:-master}"
|
||||
file="$3"
|
||||
|
||||
if [[ -z "$2" ]]; then
|
||||
if (( $branches[(I)$current_branch] != 0 )); then
|
||||
branch="$current_branch"
|
||||
else
|
||||
branch='master'
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -n "$url" ]]; then
|
||||
url="${url}/tree/${branch}/${file}"
|
||||
|
||||
if (( $+commands[$BROWSER] )); then
|
||||
"$BROWSER" "$url"
|
||||
return 0
|
||||
else
|
||||
print "$0: browser not set or set to a non-existent browser" >&2
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
print "$0: not a Git repository or remote origin not set" >&2
|
||||
return 1
|
||||
fi
|
||||
|
23
modules/git/functions/git-hub-short-url
Normal file
23
modules/git/functions/git-hub-short-url
Normal file
@ -0,0 +1,23 @@
|
||||
#
|
||||
# Shortens GitHub URLs.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
local url="$1"
|
||||
|
||||
if [[ "$url" == '-' ]]; then
|
||||
read url <&0
|
||||
fi
|
||||
|
||||
if [[ -z "$url" ]]; then
|
||||
print "usage: $0 [ url | - ]" >&2
|
||||
fi
|
||||
|
||||
if (( $+commands[curl] )); then
|
||||
curl -s -i 'http://git.io' -F "url=$url" | grep 'Location:' | sed 's/Location: //'
|
||||
else
|
||||
print "$0: command not found: curl" >&2
|
||||
fi
|
||||
|
364
modules/git/functions/git-info
Normal file
364
modules/git/functions/git-info
Normal file
@ -0,0 +1,364 @@
|
||||
#
|
||||
# Displays Git repository information.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
# Gets the path to the Git directory.
|
||||
function _git-dir {
|
||||
local git_dir="${$(git rev-parse --git-dir):A}"
|
||||
|
||||
if [[ -n "$git_dir" ]]; then
|
||||
print "$git_dir"
|
||||
return 0
|
||||
fi
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
# Gets the Git special action (am, merge, rebase, etc.).
|
||||
# Borrowed from vcs_info and edited.
|
||||
function _git-action {
|
||||
local action=''
|
||||
local action_dir
|
||||
local git_dir="$(_git-dir)"
|
||||
|
||||
for action_dir in \
|
||||
"${git_dir}/rebase-apply" \
|
||||
"${git_dir}/rebase" \
|
||||
"${git_dir}/../.dotest"; do
|
||||
if [[ -d "$action_dir" ]] ; then
|
||||
if [[ -f "${action_dir}/rebasing" ]] ; then
|
||||
action='rebase'
|
||||
elif [[ -f "${action_dir}/applying" ]] ; then
|
||||
action='am'
|
||||
else
|
||||
action='am/rebase'
|
||||
fi
|
||||
print "$action"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
for action_dir in \
|
||||
"${git_dir}/rebase-merge/interactive" \
|
||||
"${git_dir}/.dotest-merge/interactive"; do
|
||||
if [[ -f "$action_dir" ]]; then
|
||||
print 'rebase-i'
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
for action_dir in \
|
||||
"${git_dir}/rebase-merge" \
|
||||
"${git_dir}/.dotest-merge"; do
|
||||
if [[ -d "$action_dir" ]]; then
|
||||
print 'rebase-m'
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -f "${git_dir}/MERGE_HEAD" ]]; then
|
||||
print 'merge'
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ -f "${git_dir}/CHERRY_PICK_HEAD" ]]; then
|
||||
print 'cherry-pick'
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ -f "${git_dir}/BISECT_LOG" ]]; then
|
||||
print 'bisect'
|
||||
return 0
|
||||
fi
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
# Turns off git-info for the current repository.
|
||||
function _git-info-abort {
|
||||
if ! is-true "$_git_info_executing"; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
cat >&2 <<EOF
|
||||
|
||||
|
||||
Gathering status for certain repositories is time intensive.
|
||||
By pressing CTRL + C, you have turned off prompt Git status
|
||||
for this repository.
|
||||
|
||||
To revert, execute:
|
||||
git-info on
|
||||
|
||||
EOF
|
||||
|
||||
unset _git_info_executing
|
||||
git config --bool prompt.showinfo false
|
||||
git-info
|
||||
return 0
|
||||
}
|
||||
add-zsh-trap INT _git-info-abort
|
||||
|
||||
# Gets the Git status information.
|
||||
function git-info {
|
||||
# Extended globbing is needed to parse repository status.
|
||||
setopt LOCAL_OPTIONS
|
||||
setopt EXTENDED_GLOB
|
||||
|
||||
local action
|
||||
local action_format
|
||||
local action_formatted
|
||||
local added=0
|
||||
local added_format
|
||||
local added_formatted
|
||||
local ahead
|
||||
local ahead_and_behind
|
||||
local ahead_and_behind_cmd
|
||||
local ahead_format
|
||||
local ahead_formatted
|
||||
local ahead_or_behind
|
||||
local behind
|
||||
local behind_format
|
||||
local behind_formatted
|
||||
local branch
|
||||
local branch_format
|
||||
local branch_formatted
|
||||
local branch_info
|
||||
local commit
|
||||
local commit_format
|
||||
local commit_formatted
|
||||
local deleted=0
|
||||
local deleted_format
|
||||
local deleted_formatted
|
||||
local dirty=0
|
||||
local dirty_format
|
||||
local dirty_formatted
|
||||
local ignore_submodule
|
||||
local ignore_submodule_when
|
||||
local line_number=0
|
||||
local modified=0
|
||||
local modified_format
|
||||
local modified_formatted
|
||||
local position
|
||||
local position_format
|
||||
local position_formatted
|
||||
local prompt_format
|
||||
local remote
|
||||
local remote_cmd
|
||||
local remote_format
|
||||
local remote_formatted
|
||||
local renamed=0
|
||||
local renamed_format
|
||||
local renamed_formatted
|
||||
local rprompt_format
|
||||
local stashed=0
|
||||
local stashed_format
|
||||
local stashed_formatted
|
||||
local status_cmd
|
||||
local unmerged=0
|
||||
local unmerged_format
|
||||
local unmerged_formatted
|
||||
local untracked=0
|
||||
local untracked_format
|
||||
local untracked_formatted
|
||||
local -A git_info_vars
|
||||
local git_info_var
|
||||
|
||||
# Clean up previous git-info.
|
||||
unset git_prompt_info
|
||||
unset git_rprompt_info
|
||||
|
||||
# Return if not inside a Git repository work tree.
|
||||
if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
if (( $# > 0 )); then
|
||||
if [[ "$1" == [Oo][Nn] ]]; then
|
||||
git config --bool prompt.showinfo true
|
||||
elif [[ "$1" == [Oo][Ff][Ff] ]]; then
|
||||
git config --bool prompt.showinfo false
|
||||
else
|
||||
print "usage: $0 [ on | off ]" >&2
|
||||
fi
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Return if git-info is disabled.
|
||||
if ! is-true "${$(git config --bool prompt.showinfo):-true}"; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Used to abort and turn git-info off on SIGINT.
|
||||
_git_info_executing=true
|
||||
|
||||
# Use porcelain status for easy parsing.
|
||||
status_cmd='git status --porcelain'
|
||||
|
||||
# Gets the remote name.
|
||||
remote_cmd='git rev-parse --symbolic-full-name --verify HEAD@{upstream}'
|
||||
|
||||
# Gets the commit difference counts between local and remote.
|
||||
ahead_and_behind_cmd='git rev-list --count --left-right HEAD...@{upstream}'
|
||||
|
||||
# Ignore submodule status.
|
||||
zstyle -b \
|
||||
':omz:module:git:prompt:ignore' submodule 'ignore_submodule'
|
||||
zstyle -s \
|
||||
':omz:module:git:prompt:ignore:submodule' when 'ignore_submodule_when'
|
||||
if is-true "$ignore_submodule"; then
|
||||
status_cmd+=" --ignore-submodules=${ignore_submodule_when:-all}"
|
||||
fi
|
||||
|
||||
# Format commit.
|
||||
commit="$(git rev-parse HEAD 2> /dev/null)"
|
||||
if [[ -n "$commit" ]]; then
|
||||
zstyle -s ':omz:module:git:prompt' commit 'commit_format'
|
||||
zformat -f commit_formatted "$commit_format" "c:$commit"
|
||||
fi
|
||||
|
||||
# Format stashed.
|
||||
if [[ -f "$(_git-dir)/refs/stash" ]]; then
|
||||
stashed="$(git stash list 2> /dev/null | wc -l)"
|
||||
zstyle -s ':omz:module:git:prompt' stashed 'stashed_format'
|
||||
zformat -f stashed_formatted "$stashed_format" "S:$stashed"
|
||||
fi
|
||||
|
||||
# Format action.
|
||||
action="$(_git-action)"
|
||||
if [[ -n "$action" ]]; then
|
||||
zstyle -s ':omz:module:git:prompt' action 'action_format'
|
||||
zformat -f action_formatted "$action_format" "s:$action"
|
||||
fi
|
||||
|
||||
# Get current status.
|
||||
while IFS=$'\n' read line; do
|
||||
# Count added, deleted, modified, renamed, unmerged, untracked, dirty.
|
||||
# T (type change) is undocumented, see http://git.io/FnpMGw.
|
||||
# For a table of scenarii, see http://i.imgur.com/2YLu1.png.
|
||||
[[ "$line" == ([ACDMT][\ MT]|[ACMT]D)\ * ]] && (( added++ ))
|
||||
[[ "$line" == [\ ACMRT]D\ * ]] && (( deleted++ ))
|
||||
[[ "$line" == ?[MT]\ * ]] && (( modified++ ))
|
||||
[[ "$line" == R?\ * ]] && (( renamed++ ))
|
||||
[[ "$line" == (AA|DD|U?|?U)\ * ]] && (( unmerged++ ))
|
||||
[[ "$line" == \?\?\ * ]] && (( untracked++ ))
|
||||
(( dirty++ ))
|
||||
done < <(${(z)status_cmd} 2> /dev/null)
|
||||
|
||||
# Format branch.
|
||||
branch="${$(git symbolic-ref -q HEAD)##refs/heads/}"
|
||||
if [[ -n "$branch" ]]; then
|
||||
zstyle -s ':omz:module:git:prompt' branch 'branch_format'
|
||||
zformat -f branch_formatted "$branch_format" "b:$branch"
|
||||
|
||||
# Format remote.
|
||||
remote="${$(${(z)remote_cmd} 2> /dev/null)##refs/remotes/}"
|
||||
if [[ -n "$remote" ]]; then
|
||||
zstyle -s ':omz:module:git:prompt' remote 'remote_format'
|
||||
zformat -f remote_formatted "$remote_format" "R:$remote"
|
||||
|
||||
# Get ahead and behind counts.
|
||||
ahead_and_behind="$(${(z)ahead_and_behind_cmd} 2> /dev/null)"
|
||||
|
||||
# Format ahead.
|
||||
ahead="$ahead_and_behind[(w)1]"
|
||||
if (( $ahead > 0 )); then
|
||||
zstyle -s ':omz:module:git:prompt' ahead 'ahead_format'
|
||||
zformat -f ahead_formatted "$ahead_format" "A:$ahead"
|
||||
fi
|
||||
|
||||
# Format behind.
|
||||
behind="$ahead_and_behind[(w)2]"
|
||||
if (( $behind > 0 )); then
|
||||
zstyle -s ':omz:module:git:prompt' behind 'behind_format'
|
||||
zformat -f behind_formatted "$behind_format" "B:$behind"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
# Format position.
|
||||
position="$(git describe --contains --all HEAD 2> /dev/null)"
|
||||
if [[ -n "$position" ]]; then
|
||||
zstyle -s ':omz:plugin:git:prompt' position 'position_format'
|
||||
zformat -f position_formatted "$position_format" "p:$position"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Format added.
|
||||
if (( $added > 0 )); then
|
||||
zstyle -s ':omz:module:git:prompt' added 'added_format'
|
||||
zformat -f added_formatted "$added_format" "a:$added_format"
|
||||
fi
|
||||
|
||||
# Format deleted.
|
||||
if (( $deleted > 0 )); then
|
||||
zstyle -s ':omz:module:git:prompt' deleted 'deleted_format'
|
||||
zformat -f deleted_formatted "$deleted_format" "d:$deleted_format"
|
||||
fi
|
||||
|
||||
# Format modified.
|
||||
if (( $modified > 0 )); then
|
||||
zstyle -s ':omz:module:git:prompt' modified 'modified_format'
|
||||
zformat -f modified_formatted "$modified_format" "m:$modified"
|
||||
fi
|
||||
|
||||
# Format renamed.
|
||||
if (( $renamed > 0 )); then
|
||||
zstyle -s ':omz:module:git:prompt' renamed 'renamed_format'
|
||||
zformat -f renamed_formatted "$renamed_format" "r:$renamed"
|
||||
fi
|
||||
|
||||
# Format unmerged.
|
||||
if (( $unmerged > 0 )); then
|
||||
zstyle -s ':omz:module:git:prompt' unmerged 'unmerged_format'
|
||||
zformat -f unmerged_formatted "$unmerged_format" "U:$unmerged"
|
||||
fi
|
||||
|
||||
# Format untracked.
|
||||
if (( $untracked > 0 )); then
|
||||
zstyle -s ':omz:module:git:prompt' untracked 'untracked_format'
|
||||
zformat -f untracked_formatted "$untracked_format" "u:$untracked"
|
||||
fi
|
||||
|
||||
# Format dirty.
|
||||
if (( $dirty > 0 )); then
|
||||
zstyle -s ':omz:module:git:prompt' dirty 'dirty_format'
|
||||
zformat -f dirty_formatted "$dirty_format" "D:$dirty"
|
||||
fi
|
||||
|
||||
# Format prompts.
|
||||
zstyle -s ':omz:module:git:prompt' prompt 'prompt_format'
|
||||
zstyle -s ':omz:module:git:prompt' rprompt 'rprompt_format'
|
||||
|
||||
git_info_vars=(
|
||||
git_prompt_info "$prompt_format"
|
||||
git_rprompt_info "$rprompt_format"
|
||||
)
|
||||
|
||||
for git_info_var in ${(k)git_info_vars}; do
|
||||
zformat -f "$git_info_var" "$git_info_vars[$git_info_var]" \
|
||||
"A:$ahead_formatted" \
|
||||
"B:$behind_formatted" \
|
||||
"D:$dirty_formatted" \
|
||||
"R:$remote_formatted" \
|
||||
"S:$stashed_formatted" \
|
||||
"U:$unmerged_formatted" \
|
||||
"a:$added_formatted" \
|
||||
"b:$branch_formatted" \
|
||||
"c:$commit_formatted" \
|
||||
"d:$deleted_formatted" \
|
||||
"m:$modified_formatted" \
|
||||
"p:$position_formatted" \
|
||||
"r:$renamed_formatted" \
|
||||
"s:$action_formatted" \
|
||||
"u:$untracked_formatted"
|
||||
done
|
||||
|
||||
unset _git_info_executing
|
||||
return 0
|
||||
}
|
||||
|
||||
git-info "$@"
|
||||
|
15
modules/git/functions/git-root
Normal file
15
modules/git/functions/git-root
Normal file
@ -0,0 +1,15 @@
|
||||
#
|
||||
# Displays the Git repository root.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
local root="$(git rev-parse --show-toplevel 2> /dev/null)"
|
||||
if [[ -n "$root" ]]; then
|
||||
print "$root"
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
|
15
modules/git/hub.zsh
Normal file
15
modules/git/hub.zsh
Normal file
@ -0,0 +1,15 @@
|
||||
#
|
||||
# Adds GitHub knowledge to the Git command.
|
||||
# https://github.com/defunkt/hub
|
||||
#
|
||||
# Authors:
|
||||
# Chris Wanstrath <chris@wanstrath.com>
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
if (( $+commands[hub] )); then
|
||||
function git {
|
||||
hub "$@"
|
||||
}
|
||||
fi
|
||||
|
12
modules/git/init.zsh
Normal file
12
modules/git/init.zsh
Normal file
@ -0,0 +1,12 @@
|
||||
#
|
||||
# Provides Git aliases and functions.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
# Source module files.
|
||||
source "${0:h}/alias.zsh"
|
||||
source "${0:h}/hub.zsh"
|
||||
source "${0:h}/style.zsh"
|
||||
|
64
modules/git/style.zsh
Normal file
64
modules/git/style.zsh
Normal file
@ -0,0 +1,64 @@
|
||||
#
|
||||
# Defines Git information display styles.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
# %s - Special action name (am, merge, rebase).
|
||||
zstyle ':omz:module:git:prompt' action 'action:%s'
|
||||
|
||||
# %a - Indicator to notify of added files.
|
||||
zstyle ':omz:module:git:prompt' added 'added:%a'
|
||||
|
||||
# %A - Indicator to notify of ahead branch.
|
||||
zstyle ':omz:module:git:prompt' ahead 'ahead:%A'
|
||||
|
||||
# %B - Indicator to notify of behind branch.
|
||||
zstyle ':omz:module:git:prompt' behind 'behind:%B'
|
||||
|
||||
# %b - Branch name.
|
||||
zstyle ':omz:module:git:prompt' branch 'branch:%b'
|
||||
|
||||
# %c - SHA-1 hash.
|
||||
zstyle ':omz:module:git:prompt' commit 'commit:%c'
|
||||
|
||||
# %d - Indicator to notify of deleted files.
|
||||
zstyle ':omz:module:git:prompt' deleted 'deleted:%d'
|
||||
|
||||
# %D - Indicator to notify of dirty files.
|
||||
zstyle ':omz:module:git:prompt' dirty 'dirty:%D'
|
||||
|
||||
# %m - Indicator to notify of modified files.
|
||||
zstyle ':omz:module:git:prompt' modified 'modified:%m'
|
||||
|
||||
# %p - HEAD position in relation to the nearest branch, remote, tag.
|
||||
zstyle ':omz:module:git:prompt' position 'position:%p'
|
||||
|
||||
# %R - Remote name.
|
||||
zstyle ':omz:module:git:prompt' remote 'remote:%R'
|
||||
|
||||
# %r - Indicator to notify of renamed files.
|
||||
zstyle ':omz:module:git:prompt' renamed 'renamed:%r'
|
||||
|
||||
# %S - Indicator to notify of stashed files.
|
||||
zstyle ':omz:module:git:prompt' stashed 'stashed:%S'
|
||||
|
||||
# %U - Indicator to notify of unmerged files.
|
||||
zstyle ':omz:module:git:prompt' unmerged 'unmerged:%U'
|
||||
|
||||
# %u - Indicator to notify of untracked files.
|
||||
zstyle ':omz:module:git:prompt' untracked 'untracked:%u'
|
||||
|
||||
# Left prompt.
|
||||
zstyle ':omz:module:git:prompt' prompt ' git:(%b %D)'
|
||||
|
||||
# Right prompt.
|
||||
zstyle ':omz:module:git:prompt' rprompt ''
|
||||
|
||||
# Ignore submodule.
|
||||
zstyle ':omz:module:git:prompt:ignore' submodule 'no'
|
||||
|
||||
# Ignore submodule when it is 'dirty', 'untracked', 'all', or 'none'.
|
||||
zstyle ':omz:module:git:prompt:ignore:submodule' when 'all'
|
||||
|
31
modules/gnu-utils/README.md
Normal file
31
modules/gnu-utils/README.md
Normal file
@ -0,0 +1,31 @@
|
||||
gnu-utils
|
||||
=========
|
||||
|
||||
Provides for the interactive use of [GNU Core Utilities][1] on non-GNU systems.
|
||||
|
||||
Installing the GNU Core Utilities on non-GNU systems in `$PATH` without
|
||||
a prefix, i.e. `ls` instead of `gls`, is not recommended since scripts that
|
||||
target other core utilities will be broken.
|
||||
|
||||
However, for interactive use, prefixed commands can be hashed to their
|
||||
non-prefixed counterparts.
|
||||
|
||||
Settings
|
||||
--------
|
||||
|
||||
### Prefix
|
||||
|
||||
To use a different prefix, add the following to *zshrc*, and replace 'g' with
|
||||
the desired prefix:
|
||||
|
||||
zstyle ':omz:module:gnu-utils' prefix 'g'
|
||||
|
||||
Authors
|
||||
-------
|
||||
|
||||
*The authors of this module should be contacted via the GitHub issue tracker.*
|
||||
|
||||
- [Sorin Ionescu](/sorin-ionescu)
|
||||
|
||||
[1]: http://www.gnu.org/software/coreutils/
|
||||
|
98
modules/gnu-utils/init.zsh
Normal file
98
modules/gnu-utils/init.zsh
Normal file
@ -0,0 +1,98 @@
|
||||
#
|
||||
# Provides for the interactive usage of GNU Coreutils on BSD systems.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
# Get the prefix or use the default.
|
||||
zstyle -s ':omz:module:gnu-utils' prefix '_gnu_utils_prefix' ||
|
||||
_gnu_utils_prefix='g'
|
||||
|
||||
# Check for the presence of GNU Core Utilities.
|
||||
if (( ! $+commands[${_gnu_utils_prefix}dircolors] )); then
|
||||
return 1
|
||||
fi
|
||||
|
||||
function _gnu-utils-hash-commands {
|
||||
emulate -L zsh
|
||||
|
||||
local cmds
|
||||
local cmd
|
||||
local pcmd
|
||||
|
||||
cmds=(
|
||||
# Coreutils
|
||||
'[' 'base64' 'basename' 'cat' 'chcon' 'chgrp' 'chmod' 'chown'
|
||||
'chroot' 'cksum' 'comm' 'cp' 'csplit' 'cut' 'date' 'dd' 'df'
|
||||
'dir' 'dircolors' 'dirname' 'du' 'echo' 'env' 'expand' 'expr'
|
||||
'factor' 'false' 'fmt' 'fold' 'groups' 'head' 'hostid' 'id'
|
||||
'install' 'join' 'kill' 'link' 'ln' 'logname' 'ls' 'md5sum'
|
||||
'mkdir' 'mkfifo' 'mknod' 'mktemp' 'mv' 'nice' 'nl' 'nohup' 'nproc'
|
||||
'od' 'paste' 'pathchk' 'pinee' 'pr' 'printenv' 'printf' 'ptx'
|
||||
'pwd' 'readlink' 'realpath' 'rm' 'rmdir' 'runcon' 'seq' 'sha1sum'
|
||||
'sha224sum' 'sha256sum' 'sha384sum' 'sha512sum' 'shred' 'shuf'
|
||||
'sleep' 'sort' 'split' 'stat' 'stty' 'sum' 'sync' 'tac' 'tail'
|
||||
'tee' 'test' 'timeout' 'touch' 'tr' 'true' 'truncate' 'tsort'
|
||||
'tty' 'uname' 'unexpand' 'uniq' 'unlink' 'uptime' 'users' 'vdir'
|
||||
'wc' 'who' 'whoami' 'yes'
|
||||
|
||||
# The following are not part of Coreutils but installed separately.
|
||||
|
||||
# Binutils
|
||||
'addr2line' 'ar' 'c++filt' 'elfedit' 'nm' 'objcopy' 'objdump'
|
||||
'ranlib' 'readelf' 'size' 'strings' 'strip'
|
||||
|
||||
# Findutils
|
||||
'find' 'locate' 'oldfind' 'updatedb' 'xargs'
|
||||
|
||||
# Libtool
|
||||
'libtool' 'libtoolize'
|
||||
|
||||
# Miscellaneous
|
||||
'getopt' 'grep' 'indent' 'sed' 'tar' 'time' 'units' 'which'
|
||||
)
|
||||
|
||||
for cmd in "$cmds[@]"; do
|
||||
#
|
||||
# This method allows for builtin commands to be primary but it's
|
||||
# lost if hash -r or rehash -f is executed. Thus, those two
|
||||
# functions have to be wrapped.
|
||||
#
|
||||
pcmd="${_gnu_utils_prefix}${cmd}"
|
||||
if (( $+commands[$pcmd] )); then
|
||||
builtin hash "$cmd"="$commands[$pcmd]"
|
||||
fi
|
||||
done
|
||||
|
||||
return 0
|
||||
}
|
||||
_gnu-utils-hash-commands
|
||||
|
||||
function hash {
|
||||
if (( $+argv[(er)-r] )) || (( $+argv[(er)-f] )); then
|
||||
builtin hash "$@"
|
||||
_gnu-utils-hash-commands
|
||||
else
|
||||
builtin hash "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
function rehash {
|
||||
hash -r "$@"
|
||||
}
|
||||
|
||||
# A sensible default for ls.
|
||||
alias ls='ls --group-directories-first'
|
||||
|
||||
if zstyle -t ':omz:alias:ls' color; then
|
||||
if [[ -f "$HOME/.dir_colors" ]]; then
|
||||
eval "$(dircolors "$HOME/.dir_colors")"
|
||||
else
|
||||
eval "$(dircolors)"
|
||||
fi
|
||||
alias ls="$aliases[ls] --color=auto"
|
||||
else
|
||||
alias ls="$aliases[ls] -F"
|
||||
fi
|
||||
|
35
modules/gpg-agent/init.zsh
Normal file
35
modules/gpg-agent/init.zsh
Normal file
@ -0,0 +1,35 @@
|
||||
#
|
||||
# Provides for an easier use of gpg-agent.
|
||||
#
|
||||
# Authors:
|
||||
# Florian Walch <florian.walch@gmx.at>
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
if (( ! $+commands[gpg-agent] )); then
|
||||
return 1
|
||||
fi
|
||||
|
||||
_gpg_env="$HOME/.gnupg/gpg-agent.env"
|
||||
|
||||
function _gpg-agent-start {
|
||||
gpg-agent --daemon --enable-ssh-support --write-env-file "${_gpg_env}" > /dev/null
|
||||
chmod 600 "${_gpg_env}"
|
||||
source "${_gpg_env}" > /dev/null
|
||||
}
|
||||
|
||||
# Source GPG agent settings, if applicable.
|
||||
if [[ -f "${_gpg_env}" ]]; then
|
||||
source "${_gpg_env}" > /dev/null
|
||||
ps -ef | grep "${SSH_AGENT_PID}" | grep -q 'gpg-agent' || {
|
||||
_gpg-agent-start
|
||||
}
|
||||
else
|
||||
_gpg-agent-start
|
||||
fi
|
||||
|
||||
export GPG_AGENT_INFO
|
||||
export SSH_AUTH_SOCK
|
||||
export SSH_AGENT_PID
|
||||
export GPG_TTY="$(tty)"
|
||||
|
36
modules/history-substring-search/README.md
Normal file
36
modules/history-substring-search/README.md
Normal file
@ -0,0 +1,36 @@
|
||||
history-substring-search
|
||||
========================
|
||||
|
||||
It implements the [Fish shell][1]'s history search feature, where the user can
|
||||
type in any part of a previously entered command and press the `UP` and `DOWN`
|
||||
arrow keys to cycle through matching commands.
|
||||
|
||||
Settings
|
||||
--------
|
||||
|
||||
### Case Sensitivity
|
||||
|
||||
To enable case-sensitivity for this module only, add the following line to
|
||||
*zshrc*:
|
||||
|
||||
zstyle ':omz:module:history-substring-search' case-sensitive 'yes'
|
||||
|
||||
### Highlighting
|
||||
|
||||
If colors are enabled, _history-substring-search_ will automatically highlight
|
||||
positive results.
|
||||
|
||||
To enable highlighting for this module only, and the following line to *zshrc*:
|
||||
|
||||
zstyle -t ':omz:module:history-substring-search' color 'yes'
|
||||
|
||||
Authors
|
||||
-------
|
||||
|
||||
*The authors of this module should be contacted via the GitHub issue tracker.*
|
||||
|
||||
- [Sorin Ionescu](/sorin-ionescu)
|
||||
- [Suraj N. Kurapati](/sunaku)
|
||||
|
||||
[1]: http://fishshell.com
|
||||
|
1
modules/history-substring-search/external
Submodule
1
modules/history-substring-search/external
Submodule
Submodule modules/history-substring-search/external added at 04c2eca00c
24
modules/history-substring-search/init.zsh
Normal file
24
modules/history-substring-search/init.zsh
Normal file
@ -0,0 +1,24 @@
|
||||
#
|
||||
# Integrates history-substring-search into Oh My Zsh.
|
||||
#
|
||||
# Authors:
|
||||
# Suraj N. Kurapati <sunaku@gmail.com>
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
source "${0:h}/external/zsh-history-substring-search.zsh"
|
||||
|
||||
if zstyle -t ':omz:module:history-substring-search' case-sensitive; then
|
||||
unset HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS
|
||||
fi
|
||||
|
||||
if ! zstyle -t ':omz:module:history-substring-search' color; then
|
||||
unset HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND
|
||||
unset HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND
|
||||
fi
|
||||
|
||||
bindkey -M emacs "$keyinfo[Control]P" history-substring-search-up
|
||||
bindkey -M emacs "$keyinfo[Control]N" history-substring-search-down
|
||||
bindkey -M vicmd "k" history-substring-search-up
|
||||
bindkey -M vicmd "j" history-substring-search-down
|
||||
|
15
modules/macports/init.zsh
Normal file
15
modules/macports/init.zsh
Normal file
@ -0,0 +1,15 @@
|
||||
#
|
||||
# Defines MacPorts aliases.
|
||||
#
|
||||
# Authors:
|
||||
# Matt Cable <wozz@wookie.net>
|
||||
#
|
||||
|
||||
# Aliases
|
||||
alias pc="sudo port clean --all installed"
|
||||
alias pi="sudo port install $1"
|
||||
alias psu="sudo port selfupdate"
|
||||
alias puni="sudo port uninstall inactive"
|
||||
alias puo="sudo port upgrade outdated"
|
||||
alias pup="psu && puo"
|
||||
|
10
modules/node/functions/node-doc
Normal file
10
modules/node/functions/node-doc
Normal file
@ -0,0 +1,10 @@
|
||||
#
|
||||
# Opens the Node.js online API documentation in the default browser.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
# TODO: Make the sections easier to use.
|
||||
open "http://nodejs.org/docs/$(node --version | sed 's/-.*//')/api/all.html#${1}"
|
||||
|
19
modules/node/init.zsh
Normal file
19
modules/node/init.zsh
Normal file
@ -0,0 +1,19 @@
|
||||
#
|
||||
# Completes npm.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
cache_file="${0:h}/cache.zsh"
|
||||
if [[ ! -f "$cache_file" ]]; then
|
||||
if (( $+commands[npm] )); then
|
||||
# npm is slow; cache its output.
|
||||
npm completion >! "$cache_file" 2> /dev/null
|
||||
source "$cache_file"
|
||||
fi
|
||||
else
|
||||
source "$cache_file"
|
||||
fi
|
||||
unset cache_file
|
||||
|
32
modules/osx/README.md
Normal file
32
modules/osx/README.md
Normal file
@ -0,0 +1,32 @@
|
||||
OSX
|
||||
===
|
||||
Defines [Mac OS X][1] aliases and functions.
|
||||
|
||||
Aliases
|
||||
-------
|
||||
change to the current _Finder_ directory.
|
||||
- `cdf` change the current working director to the current _Finder_ directory.
|
||||
- `pushdf` push the current working directory onto the directory queue and
|
||||
- `ql` quick look at files.
|
||||
- `rm-osx-cruft` delete .DS\_Store, \_\_MACOSX cruft.
|
||||
|
||||
Functions
|
||||
---------
|
||||
|
||||
- `manb` open _man_ pages in [_Bwana.app_][2].
|
||||
- `manp` open _man_ pages in _Preview.app_.
|
||||
- `pfd` print current _Finder_ directory.
|
||||
- `pfs` print current _Finder_ selection.
|
||||
- `tab` create a new tab (works in both _Terminal_ and [_iTerm_][3]).
|
||||
- `trash` move files and folders to _Trash_.
|
||||
|
||||
Authors
|
||||
-------
|
||||
*The authors of this module should be contacted via the GitHub issue tracker.*
|
||||
|
||||
- [Sorin Ionescu](/sorin-ionescu)
|
||||
|
||||
[1]: http://www.apple.com/macosx/
|
||||
[2]: http://bruji.com/bwana/
|
||||
[3]: http://www.iterm2.com/
|
||||
|
24
modules/osx/functions/manb
Normal file
24
modules/osx/functions/manb
Normal file
@ -0,0 +1,24 @@
|
||||
#
|
||||
# Opens man pages in Bwana.app.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
function manb {
|
||||
local page
|
||||
if (( $# > 0 )); then
|
||||
for page in "$@"; do
|
||||
open "man:$page" 2>/dev/null
|
||||
if (( $? != 0 )); then
|
||||
print "$0: Bwana is not installed" >&2
|
||||
break
|
||||
fi
|
||||
done
|
||||
else
|
||||
print 'What manual page do you want?' >&2
|
||||
fi
|
||||
}
|
||||
compdef _man manb
|
||||
manb "$@"
|
||||
|
20
modules/osx/functions/manp
Normal file
20
modules/osx/functions/manp
Normal file
@ -0,0 +1,20 @@
|
||||
#
|
||||
# Opens man pages in Preview.app.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
function manp {
|
||||
local page
|
||||
if (( $# > 0 )); then
|
||||
for page in "$@"; do
|
||||
man -t "$page" | open -f -a Preview
|
||||
done
|
||||
else
|
||||
print 'What manual page do you want?' >&2
|
||||
fi
|
||||
}
|
||||
compdef _man manp
|
||||
manp "$@"
|
||||
|
13
modules/osx/functions/pfd
Normal file
13
modules/osx/functions/pfd
Normal file
@ -0,0 +1,13 @@
|
||||
#
|
||||
# Displays the current Finder.app directory.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
osascript 2>/dev/null <<EOF
|
||||
tell application "Finder"
|
||||
return POSIX path of (target of window 1 as alias)
|
||||
end tell
|
||||
EOF
|
||||
|
18
modules/osx/functions/pfs
Normal file
18
modules/osx/functions/pfs
Normal file
@ -0,0 +1,18 @@
|
||||
#
|
||||
# Displays the current Finder.app selection.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
osascript 2>/dev/null <<EOF
|
||||
set output to ""
|
||||
tell application "Finder" to set the_selection to selection
|
||||
set item_count to count the_selection
|
||||
repeat with item_index from 1 to count the_selection
|
||||
if item_index is less than item_count then set the_delimiter to "\n"
|
||||
if item_index is item_count then set the_delimiter to ""
|
||||
set output to output & ((item item_index of the_selection as alias)'s POSIX path) & the_delimiter
|
||||
end repeat
|
||||
EOF
|
||||
|
42
modules/osx/functions/tab
Normal file
42
modules/osx/functions/tab
Normal file
@ -0,0 +1,42 @@
|
||||
#
|
||||
# Opens a new Terminal.app/iTerm.app tab in the current directory.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
local command="cd \\\"$PWD\\\""
|
||||
(( $# > 0 )) && command="${command}; $*"
|
||||
|
||||
the_app=$(
|
||||
osascript 2>/dev/null <<EOF
|
||||
tell application "System Events"
|
||||
name of first item of (every process whose frontmost is true)
|
||||
end tell
|
||||
EOF
|
||||
)
|
||||
|
||||
[[ "$the_app" == 'Terminal' ]] && {
|
||||
osascript 2>/dev/null <<EOF
|
||||
tell application "System Events"
|
||||
tell process "Terminal" to keystroke "t" using command down
|
||||
tell application "Terminal" to do script "${command}" in front window
|
||||
end tell
|
||||
EOF
|
||||
}
|
||||
|
||||
[[ "$the_app" == 'iTerm' ]] && {
|
||||
osascript 2>/dev/null <<EOF
|
||||
tell application "iTerm"
|
||||
set current_terminal to current terminal
|
||||
tell current_terminal
|
||||
launch session "Default Session"
|
||||
set current_session to current session
|
||||
tell current_session
|
||||
write text "${command}"
|
||||
end tell
|
||||
end tell
|
||||
end tell
|
||||
EOF
|
||||
}
|
||||
|
27
modules/osx/functions/trash
Normal file
27
modules/osx/functions/trash
Normal file
@ -0,0 +1,27 @@
|
||||
#
|
||||
# Moves directories and files to Trash.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
print -N "${@:a}" | xargs -0 osascript -e '
|
||||
on run theFilePaths
|
||||
tell application "Finder"
|
||||
set thePOSIXFiles to {}
|
||||
repeat with aFilePath in theFilePaths
|
||||
set aPOSIXFile to aFilePath as POSIX file
|
||||
if exists aPOSIXFile
|
||||
set end of thePOSIXFiles to aPOSIXFile
|
||||
end if
|
||||
end repeat
|
||||
move every item of thePOSIXFiles to trash
|
||||
end tell
|
||||
end run
|
||||
' &>/dev/null
|
||||
|
||||
if (( $? != 0)); then
|
||||
print "$0: failed to move one or more items" >&2
|
||||
return 1
|
||||
fi
|
||||
|
26
modules/osx/init.zsh
Normal file
26
modules/osx/init.zsh
Normal file
@ -0,0 +1,26 @@
|
||||
#
|
||||
# Defines Mac OS X aliases and functions.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
# Change directory to the current Finder directory.
|
||||
alias cdf='cd "$(pfd)"'
|
||||
|
||||
# Push directory to the current Finder directory.
|
||||
alias pushdf='pushd "$(pfd)"'
|
||||
|
||||
# Open files in Quick Look.
|
||||
function ql {
|
||||
(( $# > 0 )) && qlmanage -p "$@" &> /dev/null
|
||||
}
|
||||
|
||||
# Delete .DS_Store and __MACOSX directories.
|
||||
function rm-osx-cruft {
|
||||
find "${@:-$PWD}" \( \
|
||||
-type f -name '.DS_Store' -o \
|
||||
-type d -name '__MACOSX' \
|
||||
\) -print0 | xargs -0 rm -rf
|
||||
}
|
||||
|
23
modules/pacman/functions/pacdisowned
Normal file
23
modules/pacman/functions/pacdisowned
Normal file
@ -0,0 +1,23 @@
|
||||
#
|
||||
# Lists pacman disowned files.
|
||||
#
|
||||
# Authors:
|
||||
# Benjamin Boudreau <dreurmail@gmail.com>
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
tmp="${TMPDIR-/tmp}/pacman-disowned-$UID-$$"
|
||||
db="$tmp/db"
|
||||
fs="$tmp/fs"
|
||||
|
||||
mkdir "$tmp"
|
||||
trap 'rm -rf "$tmp"' EXIT
|
||||
|
||||
pacman -Qlq | sort -u > "$db"
|
||||
|
||||
find /bin /etc /lib /sbin /usr \
|
||||
! -name lost+found \
|
||||
\( -type d -printf '%p/\n' -o -print \) | sort > "$fs"
|
||||
|
||||
comm -23 "$fs" "$db"
|
||||
|
11
modules/pacman/functions/paclist
Normal file
11
modules/pacman/functions/paclist
Normal file
@ -0,0 +1,11 @@
|
||||
#
|
||||
# Lists explicitly installed pacman packages.
|
||||
#
|
||||
# Authors:
|
||||
# Benjamin Boudreau <dreurmail@gmail.com>
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
sudo pacman -Qei $(pacman -Qu|cut -d" " -f 1) \
|
||||
| awk ' BEGIN {FS=":"}/^Name/{printf("\033[1;36m%s\033[1;37m", $2)}/^Description/{print $2}'
|
||||
|
110
modules/pacman/init.zsh
Normal file
110
modules/pacman/init.zsh
Normal file
@ -0,0 +1,110 @@
|
||||
#
|
||||
# Defines pacman aliases.
|
||||
#
|
||||
# Authors:
|
||||
# Benjamin Boudreau <dreurmail@gmail.com>
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
# Tips:
|
||||
# https://wiki.archlinux.org/index.php/Pacman_Tips
|
||||
#
|
||||
|
||||
# Yaourt Aliases
|
||||
if (( $+commands[yaourt] )); then
|
||||
# Upgrade Arch Linux.
|
||||
alias arch-upgrade='yaourt -Syu'
|
||||
|
||||
# Fix all configuration files with vimdiff.
|
||||
alias yaconf='yaourt -C'
|
||||
|
||||
# Synchronize with repositories before upgrading packages that are out of date on the local system.
|
||||
alias yaupg='yaourt -Syu'
|
||||
|
||||
# Install specific package(s) from the repositories.
|
||||
alias yain='yaourt -S'
|
||||
|
||||
# Install specific package(s) not from the repositories but from a file .
|
||||
alias yains='yaourt -U'
|
||||
|
||||
# Remove the specified package(s), retaining its configuration(s) and required dependencies.
|
||||
alias yare='yaourt -R'
|
||||
|
||||
# Remove the specified package(s), its configuration(s) and unneeded dependencies.
|
||||
alias yarem='yaourt -Rns'
|
||||
|
||||
# Display information about a given package in the repositories.
|
||||
alias yarep='yaourt -Si'
|
||||
|
||||
# Search for package(s) in the repositories.
|
||||
alias yareps='yaourt -Ss'
|
||||
|
||||
# Display information about a given package in the local database.
|
||||
alias yaloc='yaourt -Qi'
|
||||
|
||||
# Search for package(s) in the local database.
|
||||
alias yalocs='yaourt -Qs'
|
||||
|
||||
# Force refresh of all package lists after updating /etc/pacman.d/mirrorlist
|
||||
alias yamir='yaourt -Syy'
|
||||
|
||||
# Install given package(s) as dependencies of another package
|
||||
alias yainsd='yaourt -S --asdeps'
|
||||
|
||||
# Update and refresh the local package and ABS databases against repositories.
|
||||
if (( $+commands[abs] )); then
|
||||
alias yaupd='yaourt -Sy && sudo abs'
|
||||
else
|
||||
alias yaupd='yaourt -Sy'
|
||||
fi
|
||||
else
|
||||
# Upgrade Arch Linux.
|
||||
alias arch-upgrade='sudo pacman -Syu'
|
||||
fi
|
||||
|
||||
# Pacman Aliases
|
||||
# Synchronize with repositories before upgrading packages that are out of date on the local system.
|
||||
alias pacupg='sudo pacman -Syu'
|
||||
|
||||
# Install specific package(s) from the repositories.
|
||||
alias pacin='sudo pacman -S'
|
||||
|
||||
# Install specific package not from the repositories but from a file.
|
||||
alias pacins='sudo pacman -U'
|
||||
|
||||
# Remove the specified package(s), retaining its configuration(s) and required dependencies.
|
||||
alias pacre='sudo pacman -R'
|
||||
|
||||
# Remove the specified package(s), its configuration(s) and unneeded dependencies.
|
||||
alias pacrem='sudo pacman -Rns'
|
||||
|
||||
# Display information about a given package in the repositories.
|
||||
alias pacrep='pacman -Si'
|
||||
|
||||
# Search for package(s) in the repositories.
|
||||
alias pacreps='pacman -Ss'
|
||||
|
||||
# Display information about a given package in the local database.
|
||||
alias pacloc='pacman -Qi'
|
||||
|
||||
# Search for package(s) in the local database.
|
||||
alias paclocs='pacman -Qs'
|
||||
|
||||
# Install given package(s) as dependencies of another package.
|
||||
alias pacinsd='sudo pacman -S --asdeps'
|
||||
|
||||
# Force refresh of all package lists after updating /etc/pacman.d/mirrorlist.
|
||||
alias pacmir='sudo pacman -Syy'
|
||||
|
||||
# List orphan packages(s).
|
||||
alias paclsorphans='sudo pacman -Qdt'
|
||||
|
||||
# Remove orphan package(s).
|
||||
alias pacrmorphans='sudo pacman -Rs $(pacman -Qtdq)'
|
||||
|
||||
# Update and refresh the local package and ABS databases against repositories.
|
||||
if (( $+commands[abs] )); then
|
||||
alias pacupd='sudo pacman -Sy && sudo abs'
|
||||
else
|
||||
alias pacupd='sudo pacman -Sy'
|
||||
fi
|
||||
|
19
modules/perl/completions/_prep
Normal file
19
modules/perl/completions/_prep
Normal file
@ -0,0 +1,19 @@
|
||||
#compdef prep
|
||||
#autoload
|
||||
|
||||
#
|
||||
# Completes prep.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
_arguments \
|
||||
'-i[ignore case]' \
|
||||
'-m[^ and $ match the start and the end of a line]' \
|
||||
'-s[. matches newline]' \
|
||||
'-v[invert match]' \
|
||||
'-x[ignore whitespace and comments]' \
|
||||
'1::pattern:' \
|
||||
'2::files:_files' && return 0
|
||||
|
20
modules/perl/completions/_psub
Normal file
20
modules/perl/completions/_psub
Normal file
@ -0,0 +1,20 @@
|
||||
#compdef psub
|
||||
#autoload
|
||||
|
||||
#
|
||||
# Completes psub.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
_arguments \
|
||||
'-g[match globally]' \
|
||||
'-i[ignore case]' \
|
||||
'-m[^ and $ match the start and the end of a line]' \
|
||||
'-s[. matches newline]' \
|
||||
'-x[ignore whitespace and comments]' \
|
||||
'1::pattern:' \
|
||||
'2::replacement:' \
|
||||
'3::files:_files' && return 0
|
||||
|
53
modules/perl/functions/prep
Normal file
53
modules/perl/functions/prep
Normal file
@ -0,0 +1,53 @@
|
||||
#
|
||||
# Provides a grep-like pattern search.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
local usage pattern modifiers invert
|
||||
|
||||
usage="$(
|
||||
cat <<EOF
|
||||
usage: $0 [-option ...] [--] pattern [file ...]
|
||||
|
||||
options:
|
||||
-i ignore case
|
||||
-m ^ and $ match the start and the end of a line
|
||||
-s . matches newline
|
||||
-v invert match
|
||||
-x ignore whitespace and comments
|
||||
EOF
|
||||
)"
|
||||
|
||||
while getopts ':imsxv' opt; do
|
||||
case "$opt" in
|
||||
(i) modifiers="${modifiers}i" ;;
|
||||
(m) modifiers="${modifiers}m" ;;
|
||||
(s) modifiers="${modifiers}s" ;;
|
||||
(x) modifiers="${modifiers}x" ;;
|
||||
(v) invert="yes" ;;
|
||||
(:)
|
||||
print "$0: option requires an argument: $OPTARG" >&2
|
||||
print "$usage" >&2
|
||||
return 1
|
||||
;;
|
||||
([?])
|
||||
print "$0: unknown option: $OPTARG" >&2
|
||||
print "$usage" >&2
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift $(( $OPTIND - 1 ))
|
||||
|
||||
if (( $# < 1 )); then
|
||||
print "$usage" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
pattern="$1"
|
||||
shift
|
||||
|
||||
perl -n -l -e "print if ${invert:+not} m/${pattern//\//\\/}/${modifiers}" "$@"
|
||||
|
54
modules/perl/functions/psub
Normal file
54
modules/perl/functions/psub
Normal file
@ -0,0 +1,54 @@
|
||||
#
|
||||
# Provides a sed-like pattern substitution.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
local usage pattern replacement modifiers
|
||||
|
||||
usage="$(
|
||||
cat <<EOF
|
||||
usage: $0 [-option ...] [--] pattern replacement [file ...]
|
||||
|
||||
options:
|
||||
-g match globally
|
||||
-i ignore case
|
||||
-m ^ and $ match the start and the end of a line
|
||||
-s . matches newline
|
||||
-x ignore whitespace and comments
|
||||
EOF
|
||||
)"
|
||||
|
||||
while getopts ':gimsx' opt; do
|
||||
case "$opt" in
|
||||
(g) modifiers="${modifiers}g" ;;
|
||||
(i) modifiers="${modifiers}i" ;;
|
||||
(m) modifiers="${modifiers}m" ;;
|
||||
(s) modifiers="${sodifiers}s" ;;
|
||||
(x) modifiers="${modifiers}x" ;;
|
||||
(:)
|
||||
print "$0: option requires an argument: $OPTARG" >&2
|
||||
print "$usage" >&2
|
||||
return 1
|
||||
;;
|
||||
([?])
|
||||
print "$0: unknown option: $OPTARG" >&2
|
||||
print "$usage" >&2
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift $(( $OPTIND - 1 ))
|
||||
|
||||
if (( $# < 2 )); then
|
||||
print "$usage" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
pattern="$1"
|
||||
replacement="$2"
|
||||
repeat 2 shift
|
||||
|
||||
perl -i'.orig' -n -l -e "s/${pattern//\//\\/}/${replacement//\//\\/}/${modifiers}; print" "$@"
|
||||
|
49
modules/perl/init.zsh
Normal file
49
modules/perl/init.zsh
Normal file
@ -0,0 +1,49 @@
|
||||
#
|
||||
# Enables local Perl module installation on Mac OS X and defines aliases.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
# For Perl older than 5.10.14, install local::lib.
|
||||
# curl -L -C - -O http://search.cpan.org/CPAN/authors/id/A/AP/APEIRON/local-lib-1.008004.tar.gz
|
||||
# tar xvf local-lib-1.008004.tar.gz
|
||||
# cd local-lib-1.008004
|
||||
# perl Makefile.PL --bootstrap=$HOME/Library/Perl/5.12
|
||||
# make && make test && make install
|
||||
#
|
||||
# Install cpanminus:
|
||||
# curl -L http://cpanmin.us | perl - --self-upgrade
|
||||
#
|
||||
if [[ "$OSTYPE" == darwin* ]]; then
|
||||
# Perl is slow; cache its output.
|
||||
cache_file="${0:h}/cache.zsh"
|
||||
perl_path="$HOME/Library/Perl/5.12"
|
||||
if [[ -f "$perl_path/lib/perl5/local/lib.pm" ]]; then
|
||||
manpath=("$perl_path/man" $manpath)
|
||||
if [[ ! -f "$cache_file" ]]; then
|
||||
perl -I$perl_path/lib/perl5 -Mlocal::lib=$perl_path >! "$cache_file"
|
||||
source "$cache_file"
|
||||
else
|
||||
source "$cache_file"
|
||||
fi
|
||||
fi
|
||||
unset perl_path
|
||||
unset cache_file
|
||||
|
||||
# Set environment variables for launchd processes.
|
||||
for env_var in PERL_LOCAL_LIB_ROOT PERL_MB_OPT PERL_MM_OPT PERL5LIB; do
|
||||
launchctl setenv "$env_var" "${(P)env_var}" &!
|
||||
done
|
||||
unset env_var
|
||||
fi
|
||||
|
||||
# Aliases
|
||||
alias pbi='perlbrew install'
|
||||
alias pbl='perlbrew list'
|
||||
alias pbo='perlbrew off'
|
||||
alias pbs='perlbrew switch'
|
||||
alias pbu='perlbrew use'
|
||||
alias ple='perl -wlne'
|
||||
alias pd='perldoc'
|
||||
|
18
modules/python/init.zsh
Normal file
18
modules/python/init.zsh
Normal file
@ -0,0 +1,18 @@
|
||||
#
|
||||
# Enables local Python package installation.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
# Prepend PEP 370 per user site packages directory, which defaults to
|
||||
# ~/Library/Python on Mac OS X and ~/.local elsewhere, to PATH/MANPATH.
|
||||
if [[ "$OSTYPE" == darwin* ]]; then
|
||||
path=($HOME/Library/Python/*/bin(N) $path)
|
||||
manpath=($HOME/Library/Python/*/{,share/}man(N) $manpath)
|
||||
else
|
||||
# This is subject to change.
|
||||
path=($HOME/.local/bin $path)
|
||||
manpath=($HOME/.local/{,share/}man(N) $manpath)
|
||||
fi
|
||||
|
30
modules/rails/init.zsh
Normal file
30
modules/rails/init.zsh
Normal file
@ -0,0 +1,30 @@
|
||||
#
|
||||
# Defines Ruby on Rails aliases.
|
||||
#
|
||||
# Authors:
|
||||
# Robby Russell <robby@planetargon.com>
|
||||
# Jake Bell <jake.b.bell@gmail.com>
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
# Aliases (compatible with Rails 2)
|
||||
alias rc='_rails-command console'
|
||||
alias rd='_rails-command destroy'
|
||||
alias rdb='_rails-command dbconsole'
|
||||
alias rdbm='rake db:migrate db:test:clone'
|
||||
alias rg='_rails-command generate'
|
||||
alias rp='_rails-command plugin'
|
||||
alias rr='_rails-command runner'
|
||||
alias rs='_rails-command server'
|
||||
alias rsd='_rails-command server --debugger'
|
||||
alias devlog='tail -f log/development.log'
|
||||
|
||||
# Functions
|
||||
function _rails-command {
|
||||
if [[ -e "script/server" ]]; then
|
||||
ruby script/"$@"
|
||||
else
|
||||
ruby script/rails "$@"
|
||||
fi
|
||||
}
|
||||
|
27
modules/rsync/init.zsh
Normal file
27
modules/rsync/init.zsh
Normal file
@ -0,0 +1,27 @@
|
||||
#
|
||||
# Defines rsync aliases.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
# Aliases
|
||||
rsync_cmd='rsync --verbose --progress --human-readable --compress --archive --hard-links --one-file-system'
|
||||
|
||||
# Mac OS X and HFS+ Enhancements
|
||||
# http://www.bombich.com/rsync.html
|
||||
if [[ "$OSTYPE" == darwin* ]] && grep -q 'file-flags' <(rsync --help 2>&1); then
|
||||
rsync_cmd="${rsync_cmd} --crtimes --acls --xattrs --fileflags --protect-decmpfs --force-change"
|
||||
fi
|
||||
|
||||
alias rsync-copy="${rsync_cmd}"
|
||||
compdef _rsync rsync-copy=rsync
|
||||
alias rsync-move="${rsync_cmd} --remove-source-files"
|
||||
compdef _rsync rsync-move=rsync
|
||||
alias rsync-update="${rsync_cmd} --update"
|
||||
compdef _rsync rsync-upate=rsync
|
||||
alias rsync-synchronize="${rsync_cmd} --update --delete"
|
||||
compdef _rsync rsync-synchronize=rsync
|
||||
|
||||
unset rsync_cmd
|
||||
|
43
modules/ruby/init.zsh
Normal file
43
modules/ruby/init.zsh
Normal file
@ -0,0 +1,43 @@
|
||||
#
|
||||
# Configures Ruby gem installation and loads rvm/rbenv.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
# Loads RVM into the shell session.
|
||||
if [[ -s "$HOME/.rvm/scripts/rvm" ]]; then
|
||||
# Auto adding variable-stored paths to ~ list conflicts with RVM.
|
||||
unsetopt AUTO_NAME_DIRS
|
||||
|
||||
# Source RVM.
|
||||
source "$HOME/.rvm/scripts/rvm"
|
||||
# Loads manually installed rbenv into the shell session.
|
||||
elif [[ -s "$HOME/.rbenv/bin/rbenv" ]]; then
|
||||
path=("$HOME/.rbenv/bin" $path)
|
||||
eval "$(rbenv init - zsh)"
|
||||
# Loads package manager installed rbenv into the shell session.
|
||||
elif (( $+commands[rbenv] )); then
|
||||
eval "$(rbenv init - zsh)"
|
||||
else
|
||||
# Install local gems according to Mac OS X conventions.
|
||||
if [[ "$OSTYPE" == darwin* ]]; then
|
||||
export GEM_HOME="$HOME/Library/Ruby/Gems/1.8"
|
||||
path=("$GEM_HOME/bin" $path)
|
||||
fi
|
||||
fi
|
||||
|
||||
# Aliases
|
||||
alias b='bundle'
|
||||
alias be='b exec'
|
||||
alias bi='b install --path vendor/bundle'
|
||||
alias bl='b list'
|
||||
alias bo='b open'
|
||||
alias bp='b package'
|
||||
alias bu='b update'
|
||||
alias bI='bi \
|
||||
&& b package \
|
||||
&& print .bundle >>! .gitignore \
|
||||
&& print vendor/bundle >>! .gitignore \
|
||||
&& print vendor/cache >>! .gitignore'
|
||||
|
32
modules/screen/README.md
Normal file
32
modules/screen/README.md
Normal file
@ -0,0 +1,32 @@
|
||||
screen
|
||||
======
|
||||
|
||||
Defines [GNU Screen][1] aliases and provides for auto launching it at start-up.
|
||||
|
||||
Aliases
|
||||
-------
|
||||
|
||||
- `sl` list sessions/socket directory.
|
||||
- `sn` start a new session.
|
||||
- `sr` attach to a session if one exists or start a new one.
|
||||
|
||||
Settings
|
||||
--------
|
||||
|
||||
### Auto-start
|
||||
|
||||
Start a Screen session automatically when Zsh is launched.
|
||||
|
||||
To enable this feature, add the following line to *zshrc*:
|
||||
|
||||
zstyle ':omz:module:screen' auto-start 'yes'
|
||||
|
||||
Authors
|
||||
-------
|
||||
|
||||
*The authors of this module should be contacted via the GitHub issue tracker.*
|
||||
|
||||
- [Sorin Ionescu](/sorin-ionescu)
|
||||
|
||||
[1]: http://www.gnu.org/software/screen/
|
||||
|
27
modules/screen/init.zsh
Normal file
27
modules/screen/init.zsh
Normal file
@ -0,0 +1,27 @@
|
||||
#
|
||||
# Defines GNU Screen aliases and provides for auto launching it at start-up.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
# Aliases
|
||||
alias sl="screen -list"
|
||||
alias sn="screen -U -S"
|
||||
alias sr="screen -a -A -U -D -R"
|
||||
|
||||
# Auto Start
|
||||
if [[ -z "$STY" ]] && zstyle -t ':omz:module:screen' auto-start; then
|
||||
session="$(
|
||||
screen -list 2> /dev/null \
|
||||
| sed '1d;$d' \
|
||||
| awk '{print $1}' \
|
||||
| head -1)"
|
||||
|
||||
if [[ -n "$session" ]]; then
|
||||
exec screen -x "$session"
|
||||
else
|
||||
exec screen -a -A -U -D -R -m "$SHELL" -l
|
||||
fi
|
||||
fi
|
||||
|
68
modules/ssh-agent/init.zsh
Normal file
68
modules/ssh-agent/init.zsh
Normal file
@ -0,0 +1,68 @@
|
||||
#
|
||||
# Provides for an easier use of ssh-agent.
|
||||
#
|
||||
# Authors:
|
||||
# Robby Russell <robby@planetargon.com>
|
||||
# Theodore Robert Campbell Jr <trcjr@stupidfoot.com>
|
||||
# Joseph M. Reagle Jr. <reagle@mit.edu>
|
||||
# Florent Thoumie <flz@xbsd.org>
|
||||
# Jonas Pfenniger <jonas@pfenniger.name>
|
||||
# gwjo <gowen72@gmail.com>
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
# Usage:
|
||||
# To enable agent forwarding, add the following to your .zshrc:
|
||||
#
|
||||
# zstyle ':omz:module:ssh-agent' forwarding 'yes'
|
||||
#
|
||||
# To load multiple identities, add the following to your .zshrc:
|
||||
#
|
||||
# zstyle ':omz:module:ssh-agent' identities 'id_rsa' 'id_rsa2' 'id_github'
|
||||
#
|
||||
|
||||
if (( ! $+commands[ssh-agent] )); then
|
||||
return 1
|
||||
fi
|
||||
|
||||
_ssh_agent_env="${HOME}/.ssh/environment-${HOST}"
|
||||
_ssh_agent_forwarding=
|
||||
|
||||
function _ssh-agent-start {
|
||||
local -a identities
|
||||
|
||||
# Start ssh-agent and setup the environment.
|
||||
rm -f "${_ssh_agent_env}"
|
||||
ssh-agent > "${_ssh_agent_env}"
|
||||
chmod 600 "${_ssh_agent_env}"
|
||||
source "${_ssh_agent_env}" > /dev/null
|
||||
|
||||
# Load identities.
|
||||
zstyle -a ':omz:module:ssh-agent' identities 'identities'
|
||||
|
||||
if (( ${#identities} > 0 )); then
|
||||
ssh-add "${HOME}/.ssh/${^identities[@]}"
|
||||
else
|
||||
ssh-add
|
||||
fi
|
||||
}
|
||||
|
||||
# Test if agent-forwarding is enabled.
|
||||
zstyle -b ':omz:module:ssh-agent' forwarding '_ssh_agent_forwarding'
|
||||
if is-true "${_ssh_agent_forwarding}" && [[ -n "$SSH_AUTH_SOCK" ]]; then
|
||||
# Add a nifty symlink for screen/tmux if agent forwarding.
|
||||
[[ -L "$SSH_AUTH_SOCK" ]] || ln -sf "$SSH_AUTH_SOCK" /tmp/ssh-agent-$USER-screen
|
||||
elif [ -f "${_ssh_agent_env}" ]; then
|
||||
# Source SSH settings, if applicable.
|
||||
source "${_ssh_agent_env}" > /dev/null
|
||||
ps -ef | grep "${SSH_AGENT_PID}" | grep -q 'ssh-agent$' || {
|
||||
_ssh-agent-start;
|
||||
}
|
||||
else
|
||||
_ssh-agent-start;
|
||||
fi
|
||||
|
||||
# Tidy up after ourselves.
|
||||
unfunction _ssh-agent-start
|
||||
unset _ssh_agent_forwarding
|
||||
unset _ssh_agent_env
|
||||
|
1
modules/syntax-highlighting/external
Submodule
1
modules/syntax-highlighting/external
Submodule
Submodule modules/syntax-highlighting/external added at bb0d575942
12
modules/syntax-highlighting/init.zsh
Normal file
12
modules/syntax-highlighting/init.zsh
Normal file
@ -0,0 +1,12 @@
|
||||
#
|
||||
# Integrates zsh-syntax-highlighting into Oh My Zsh.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
if zstyle -t ':omz:module:syntax-highlighting' color; then
|
||||
source "${0:h}/external/zsh-syntax-highlighting.zsh"
|
||||
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern cursor)
|
||||
fi
|
||||
|
46
modules/tmux/README.md
Normal file
46
modules/tmux/README.md
Normal file
@ -0,0 +1,46 @@
|
||||
tmux
|
||||
====
|
||||
|
||||
Defines [tmux][1] aliases and provides for auto launching it at start-up.
|
||||
|
||||
Aliases
|
||||
-------
|
||||
|
||||
- `ta` attach or switch to a tmux session.
|
||||
- `tl` list sessions managed by the tmux server.
|
||||
|
||||
Settings
|
||||
--------
|
||||
|
||||
### Auto-start
|
||||
|
||||
Start a tmux session automatically when Zsh is launched.
|
||||
|
||||
To enable this feature, add the following line to *zshrc*:
|
||||
|
||||
zstyle ':omz:module:tmux' auto-start 'yes'
|
||||
|
||||
It will create a background session named _#OMZ_ and attach every new shell to
|
||||
it.
|
||||
|
||||
To avoid keeping open sessions, this module sets `destroy-unattached off` on
|
||||
the background session and `destroy-unattached on` on every other session
|
||||
(global setting).
|
||||
|
||||
Caveats
|
||||
-------
|
||||
|
||||
tmux is known to cause kernel panics on Mac OS X. A discussion about this and
|
||||
OMZ has already been opened [here][2].
|
||||
|
||||
Authors
|
||||
-------
|
||||
|
||||
*The authors of this module should be contacted via the github bug tracker.*
|
||||
|
||||
- [Sorin Ionescu](/sorin-ionescu)
|
||||
- [Colin Hebert](/ColinHebert)
|
||||
|
||||
[1]: http://tmux.sourceforge.net
|
||||
[2]: http://git.io/jkPqHg
|
||||
|
34
modules/tmux/init.zsh
Normal file
34
modules/tmux/init.zsh
Normal file
@ -0,0 +1,34 @@
|
||||
#
|
||||
# Defines tmux aliases and provides for auto launching it at start-up.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
# Colin Hebert <hebert.colin@gmail.com>
|
||||
#
|
||||
|
||||
# Aliases
|
||||
alias ta="tmux attach-session"
|
||||
alias tl="tmux list-sessions"
|
||||
|
||||
# Auto Start
|
||||
if [[ -z "$TMUX" ]] && zstyle -t ':omz:module:tmux' auto-start; then
|
||||
tmux_session='#OMZ'
|
||||
|
||||
if ! tmux has-session -t "$tmux_session" 2> /dev/null; then
|
||||
# Disable the destruction of unattached sessions globally.
|
||||
tmux set-option -g destroy-unattached off &> /dev/null
|
||||
|
||||
# Create a new session.
|
||||
tmux new-session -d -s "$tmux_session"
|
||||
|
||||
# Disable the destruction of the new, unattached session.
|
||||
tmux set-option -t "$tmux_session" destroy-unattached off &> /dev/null
|
||||
|
||||
# Enable the destruction of unattached sessions globally to prevent
|
||||
# an abundance of open, detached sessions.
|
||||
tmux set-option -g destroy-unattached on &> /dev/null
|
||||
fi
|
||||
|
||||
exec tmux new-session -t "$tmux_session"
|
||||
fi
|
||||
|
30
modules/wakeonlan/README
Normal file
30
modules/wakeonlan/README
Normal file
@ -0,0 +1,30 @@
|
||||
This module provides a wrapper around the "wakeonlan" tool available from most
|
||||
distributions' package repositories, or from the following website:
|
||||
|
||||
http://gsd.di.uminho.pt/jpo/software/wakeonlan/
|
||||
|
||||
In order to use this wrapper, create the ~/.wakeonlan directory, and place in
|
||||
that directory one file for each device you would like to be able to wake. Give
|
||||
the file a name that describes the device, such as its hostname. Each file
|
||||
should contain a line with the mac address of the target device and the network
|
||||
broadcast address.
|
||||
|
||||
For instance, there might be a file ~/.wakeonlan/leto with the following
|
||||
contents:
|
||||
|
||||
00:11:22:33:44:55:66 192.168.0.255
|
||||
|
||||
To wake that device, use the following command:
|
||||
|
||||
# wake leto
|
||||
|
||||
The available device names will be autocompleted, so:
|
||||
|
||||
# wake <tab>
|
||||
|
||||
...will suggest "leto", along with any other configuration files that were
|
||||
placed in the ~/.wakeonlan directory.
|
||||
|
||||
For more information regarding the configuration file format, check the
|
||||
wakeonlan man page.
|
||||
|
13
modules/wakeonlan/completions/_wake
Normal file
13
modules/wakeonlan/completions/_wake
Normal file
@ -0,0 +1,13 @@
|
||||
#compdef wake
|
||||
#autoload
|
||||
|
||||
#
|
||||
# Completes wake.
|
||||
#
|
||||
# Authors:
|
||||
# Paul Gideon Dann <pdgiddie@gmail.com>
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
_arguments "1:device to wake:_files -W '$HOME/.wakeonlan'" && return 0
|
||||
|
21
modules/wakeonlan/functions/wake
Normal file
21
modules/wakeonlan/functions/wake
Normal file
@ -0,0 +1,21 @@
|
||||
#
|
||||
# Wakes devices via wakeonlan.
|
||||
#
|
||||
# Authors:
|
||||
# Paul Gideon Dann <pdgiddie@gmail.com>
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
local config_file="$HOME/.wakeonlan/$1"
|
||||
if [[ ! -f "$config_file" ]]; then
|
||||
print "$0: no such device file: $1" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
if (( ! $+commands[wakeonlan] )); then
|
||||
print "$0: command not found: wakeonlan" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
wakeonlan -f "$config_file"
|
||||
|
19
modules/yum/init.zsh
Normal file
19
modules/yum/init.zsh
Normal file
@ -0,0 +1,19 @@
|
||||
#
|
||||
# Defines yum aliases.
|
||||
#
|
||||
# Authors:
|
||||
# Simon <contact@saimon.org>
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
# Aliases
|
||||
alias ys="yum search" # Search package.
|
||||
alias yp="yum info" # Show package info.
|
||||
alias yl="yum list" # List packages.
|
||||
alias yli="yum list installed" # Print all installed packages.
|
||||
alias yu="sudo yum update" # Upgrate packages.
|
||||
alias yi="sudo yum install" # Install package.
|
||||
alias yr="sudo yum remove" # Remove package.
|
||||
alias yrl="sudo yum remove --remove-leaves" # Remove package and leaves.
|
||||
alias yc="sudo yum clean all" # Clean cache.
|
||||
|
25
modules/z/init.zsh
Normal file
25
modules/z/init.zsh
Normal file
@ -0,0 +1,25 @@
|
||||
#
|
||||
# Maintains a frequently used directory list for fast directory changes.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
if [[ -f /etc/profile.d/z.zsh ]]; then
|
||||
source /etc/profile.d/z.zsh
|
||||
elif [[ -f /opt/local/etc/profile.d/z.zsh ]]; then
|
||||
source /opt/local/etc/profile.d/z.zsh
|
||||
elif [[ -f "$(brew --prefix 2> /dev/null)/etc/profile.d/z.sh" ]]; then
|
||||
source "$(brew --prefix 2> /dev/null)/etc/profile.d/z.sh"
|
||||
fi
|
||||
|
||||
if (( $+functions[_z] )); then
|
||||
alias z='nocorrect _z 2>&1'
|
||||
alias j='z'
|
||||
function z-precmd {
|
||||
z --add "$(pwd -P)"
|
||||
}
|
||||
autoload -Uz add-zsh-hook
|
||||
add-zsh-hook precmd z-precmd
|
||||
fi
|
||||
|
Reference in New Issue
Block a user