mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2025-12-26 02:12:33 +01:00
Merge branch 'master' of git://github.com/robbyrussell/oh-my-zsh
This commit is contained in:
commit
a3183b9817
31 changed files with 1095 additions and 79 deletions
15
oh-my-zsh.sh
15
oh-my-zsh.sh
|
|
@ -1,7 +1,7 @@
|
|||
# Check for updates on initial load...
|
||||
if [ "$DISABLE_AUTO_UPDATE" != "true" ]
|
||||
then
|
||||
/usr/bin/env zsh $ZSH/tools/check_for_upgrade.sh
|
||||
/usr/bin/env ZSH=$ZSH zsh $ZSH/tools/check_for_upgrade.sh
|
||||
fi
|
||||
|
||||
# Initializes Oh My Zsh
|
||||
|
|
@ -21,17 +21,24 @@ for plugin ($plugins) fpath=($ZSH/plugins/$plugin $fpath)
|
|||
autoload -U compinit
|
||||
compinit -i
|
||||
|
||||
# Set ZSH_CUSTOM to the path where your custom config files
|
||||
# and plugins exists, or else we will use the default custom/
|
||||
if [ "$ZSH_CUSTOM" = "" ]
|
||||
then
|
||||
ZSH_CUSTOM="$ZSH/custom"
|
||||
fi
|
||||
|
||||
# Load all of the plugins that were defined in ~/.zshrc
|
||||
for plugin ($plugins); do
|
||||
if [ -f $ZSH/custom/plugins/$plugin/$plugin.plugin.zsh ]; then
|
||||
source $ZSH/custom/plugins/$plugin/$plugin.plugin.zsh
|
||||
if [ -f $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh ]; then
|
||||
source $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh
|
||||
elif [ -f $ZSH/plugins/$plugin/$plugin.plugin.zsh ]; then
|
||||
source $ZSH/plugins/$plugin/$plugin.plugin.zsh
|
||||
fi
|
||||
done
|
||||
|
||||
# Load all of your custom configurations from custom/
|
||||
for config_file ($ZSH/custom/*.zsh) source $config_file
|
||||
for config_file ($ZSH_CUSTOM/*.zsh) source $config_file
|
||||
|
||||
# Load the theme
|
||||
if [ "$ZSH_THEME" = "random" ]
|
||||
|
|
|
|||
82
plugins/bundler/_bundler
Normal file
82
plugins/bundler/_bundler
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
#compdef bundle
|
||||
|
||||
local curcontext="$curcontext" state line _gems _opts ret=1
|
||||
|
||||
_arguments -C -A "-v" -A "--version" \
|
||||
'(- 1 *)'{-v,--version}'[display version information]' \
|
||||
'1: :->cmds' \
|
||||
'*:: :->args' && ret=0
|
||||
|
||||
case $state in
|
||||
cmds)
|
||||
_values "bundle command" \
|
||||
"install[Install the gems specified by the Gemfile or Gemfile.lock]" \
|
||||
"update[Update dependencies to their latest versions]" \
|
||||
"package[Package the .gem files required by your application]" \
|
||||
"exec[Execute a script in the context of the current bundle]" \
|
||||
"config[Specify and read configuration options for bundler]" \
|
||||
"check[Determine whether the requirements for your application are installed]" \
|
||||
"list[Show all of the gems in the current bundle]" \
|
||||
"show[Show the source location of a particular gem in the bundle]" \
|
||||
"console[Start an IRB session in the context of the current bundle]" \
|
||||
"open[Open an installed gem in the editor]" \
|
||||
"viz[Generate a visual representation of your dependencies]" \
|
||||
"init[Generate a simple Gemfile, placed in the current directory]" \
|
||||
"gem[Create a simple gem, suitable for development with bundler]" \
|
||||
"help[Describe available tasks or one specific task]"
|
||||
ret=0
|
||||
;;
|
||||
args)
|
||||
case $line[1] in
|
||||
help)
|
||||
_values 'commands' \
|
||||
'install' \
|
||||
'update' \
|
||||
'package' \
|
||||
'exec' \
|
||||
'config' \
|
||||
'check' \
|
||||
'list' \
|
||||
'show' \
|
||||
'console' \
|
||||
'open' \
|
||||
'viz' \
|
||||
'init' \
|
||||
'gem' \
|
||||
'help' && ret=0
|
||||
;;
|
||||
install)
|
||||
_arguments \
|
||||
'(--no-color)--no-color[disable colorization in output]' \
|
||||
'(--local)--local[do not attempt to connect to rubygems.org]' \
|
||||
'(--quiet)--quiet[only output warnings and errors]' \
|
||||
'(--gemfile)--gemfile=-[use the specified gemfile instead of Gemfile]:gemfile' \
|
||||
'(--system)--system[install to the system location]' \
|
||||
'(--deployment)--deployment[install using defaults tuned for deployment environments]' \
|
||||
'(--frozen)--frozen[do not allow the Gemfile.lock to be updated after this install]' \
|
||||
'(--path)--path=-[specify a different path than the system default]:path:_files' \
|
||||
'(--binstubs)--binstubs=-[generate bin stubs for bundled gems to ./bin]:directory:_files' \
|
||||
'(--without)--without=-[exclude gems that are part of the specified named group]:groups'
|
||||
ret=0
|
||||
;;
|
||||
exec)
|
||||
_normal && ret=0
|
||||
;;
|
||||
(open|show)
|
||||
_gems=( $(bundle show 2> /dev/null | sed -e '/^ \*/!d; s/^ \* \([^ ]*\) .*/\1/') )
|
||||
if [[ $_gems != "" ]]; then
|
||||
_values 'gems' $_gems && ret=0
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
_opts=( $(bundle help $line[1] | sed -e '/^ \[-/!d; s/^ \[\(-[^=]*\)=.*/\1/') )
|
||||
_opts+=( $(bundle help $line[1] | sed -e '/^ -/!d; s/^ \(-.\), \[\(-[^=]*\)=.*/\1 \2/') )
|
||||
if [[ $_opts != "" ]]; then
|
||||
_values 'options' $_opts && ret=0
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
||||
return ret
|
||||
|
|
@ -1,12 +1,16 @@
|
|||
fpath=($ZSH/plugins/bundler $fpath)
|
||||
autoload -U compinit
|
||||
compinit -i
|
||||
|
||||
alias be="bundle exec"
|
||||
alias bi="bundle install"
|
||||
alias bl="bundle list"
|
||||
alias bu="bundle update"
|
||||
alias bp="bundle package"
|
||||
alias bu="bundle update"
|
||||
|
||||
# The following is based on https://github.com/gma/bundler-exec
|
||||
|
||||
bundled_commands=(cap capify cucumber guard heroku rackup rails rake rspec ruby shotgun spec spork thin unicorn unicorn_rails)
|
||||
bundled_commands=(cap capify cucumber foreman guard heroku nanoc rackup rails rainbows rake rspec ruby shotgun spec spork thin unicorn unicorn_rails)
|
||||
|
||||
## Functions
|
||||
|
||||
|
|
@ -33,5 +37,10 @@ _run-with-bundler() {
|
|||
|
||||
## Main program
|
||||
for cmd in $bundled_commands; do
|
||||
alias $cmd="_run-with-bundler $cmd"
|
||||
eval "function bundled_$cmd () { _run-with-bundler $cmd \$@}"
|
||||
alias $cmd=bundled_$cmd
|
||||
|
||||
if which _$cmd > /dev/null 2>&1; then
|
||||
compdef _$cmd bundled_$cmd
|
||||
fi
|
||||
done
|
||||
|
|
|
|||
|
|
@ -1,18 +1,22 @@
|
|||
# Set this to 1 if you want to cache the tasks
|
||||
cache_task_list=1
|
||||
_cake_cache_task_list=1
|
||||
|
||||
# Cache filename
|
||||
cache_file='.cake_task_cache'
|
||||
_cake_task_cache_file='.cake_task_cache'
|
||||
|
||||
_cake_get_target_list () {
|
||||
cake | grep '^cake ' | sed -e "s/cake \([^ ]*\) .*/\1/" | grep -v '^$'
|
||||
}
|
||||
|
||||
_cake_does_target_list_need_generating () {
|
||||
|
||||
if [ $cache_task_list -eq 0 ]; then
|
||||
if [ ${_cake_cache_task_list} -eq 0 ]; then
|
||||
return 1;
|
||||
fi
|
||||
|
||||
if [ ! -f $cache_file ]; then return 0;
|
||||
if [ ! -f ${_cake_task_cache_file} ]; then return 0;
|
||||
else
|
||||
accurate=$(stat -f%m $cache_file)
|
||||
accurate=$(stat -f%m $_cake_task_cache_file)
|
||||
changed=$(stat -f%m Cakefile)
|
||||
return $(expr $accurate '>=' $changed)
|
||||
fi
|
||||
|
|
@ -21,12 +25,12 @@ _cake_does_target_list_need_generating () {
|
|||
_cake () {
|
||||
if [ -f Cakefile ]; then
|
||||
if _cake_does_target_list_need_generating; then
|
||||
cake | sed -e "s/cake \([^ ]*\) .*/\1/" | grep -v '^$' > $cache_file
|
||||
compadd `cat $cache_file`
|
||||
_cake_get_target_list > ${_cake_task_cache_file}
|
||||
compadd `cat ${_cake_task_cache_file}`
|
||||
else
|
||||
compadd `cake | sed -e "s/cake \([^ ]*\) .*/\1/" | grep -v '^$'`
|
||||
compadd `_cake_get_target_list`
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
compdef _cake cake
|
||||
compdef _cake cake
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
# 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
|
||||
|
|
@ -1,53 +1,143 @@
|
|||
# https://github.com/dbbolton/
|
||||
# Authors:
|
||||
# https://github.com/AlexBio
|
||||
# https://github.com/dbb
|
||||
#
|
||||
# Debian-related zsh aliases and functions for zsh
|
||||
|
||||
# Use aptitude if installed, or apt-get if not.
|
||||
# You can just set apt_pref='apt-get' to override it.
|
||||
if [[ -e $( which aptitude ) ]]; then
|
||||
apt_pref='aptitude'
|
||||
else
|
||||
apt_pref='apt-get'
|
||||
fi
|
||||
|
||||
# Use sudo by default if it's installed
|
||||
if [[ -e $( which sudo ) ]]; then
|
||||
use_sudo=1
|
||||
fi
|
||||
|
||||
# Aliases ###################################################################
|
||||
# These are for more obscure uses of apt-get and aptitude that aren't covered
|
||||
# below.
|
||||
alias ag='apt-get'
|
||||
alias at='aptitude'
|
||||
|
||||
# Some self-explanatory aliases
|
||||
alias afs='apt-file search --regexp'
|
||||
alias acs="apt-cache search"
|
||||
alias aps='aptitude search'
|
||||
alias apsrc='apt-get source'
|
||||
alias apv='apt-cache policy'
|
||||
alias as="aptitude -F \"* %p -> %d \n(%v/%V)\" \
|
||||
--no-gui --disable-columns search" # search package
|
||||
|
||||
alias apdg='su -c "aptitude update && aptitude safe-upgrade"'
|
||||
alias apud='su -c "aptitude update"'
|
||||
alias apug='su -c "aptitude safe-upgrade"'
|
||||
# apt-file
|
||||
alias afs='apt-file search --regexp'
|
||||
|
||||
|
||||
# These are apt-get only
|
||||
alias asrc='apt-get source'
|
||||
alias ap='apt-cache policy'
|
||||
|
||||
# superuser operations ######################################################
|
||||
if [[ $use_sudo -eq 1 ]]; then
|
||||
# commands using sudo #######
|
||||
alias aac="sudo $apt_pref autoclean"
|
||||
alias abd="sudo $apt_pref build-dep"
|
||||
alias ac="sudo $apt_pref clean"
|
||||
alias ad="sudo $apt_pref update"
|
||||
alias adg="sudo $apt_pref update && sudo $apt_pref upgrade"
|
||||
alias adu="sudo $apt_pref update && sudo $apt_pref dist-upgrade"
|
||||
alias afu='sudo apt-file update'
|
||||
alias ag="sudo $apt_pref upgrade"
|
||||
alias ai="sudo $apt_pref install"
|
||||
alias ap="sudo $apt_pref purge"
|
||||
alias ar="sudo $apt_pref remove"
|
||||
|
||||
# apt-get only
|
||||
alias ads="sudo $apt_pref dselect-upgrade"
|
||||
|
||||
# Install all .deb files in the current directory.
|
||||
# Warning: you will need to put the glob in single quotes if you use:
|
||||
# glob_subst
|
||||
alias di='sudo dpkg -i ./*.deb'
|
||||
|
||||
# Remove ALL kernel images and headers EXCEPT the one in use
|
||||
alias kclean='sudo aptitude remove -P ?and(~i~nlinux-(ima|hea) \
|
||||
?not(~n`uname -r`))'
|
||||
|
||||
|
||||
# commands using su #########
|
||||
else
|
||||
alias aac='su -ls "'"$apt_pref"' autoclean" root'
|
||||
abd() {
|
||||
cmd="su -lc '$apt_pref build-dep $@' root"
|
||||
print "$cmd"
|
||||
eval "$cmd"
|
||||
}
|
||||
alias ac='su -ls "'"$apt_pref"' clean" root'
|
||||
alias ad='su -lc "'"$apt_pref"' update" root'
|
||||
alias adg='su -lc "'"$apt_pref"' update && aptitude safe-upgrade" root'
|
||||
alias adu='su -lc "'"$apt_pref"' update && aptitude dist-upgrade" root'
|
||||
alias afu='su -lc "apt-file update"'
|
||||
alias ag='su -lc "'"$apt_pref"' safe-upgrade" root'
|
||||
ai() {
|
||||
cmd="su -lc 'aptitude -P install $@' root"
|
||||
print "$cmd"
|
||||
eval "$cmd"
|
||||
}
|
||||
ap() {
|
||||
cmd="su -lc '$apt_pref -P purge $@' root"
|
||||
print "$cmd"
|
||||
eval "$cmd"
|
||||
}
|
||||
ar() {
|
||||
cmd="su -lc '$apt_pref -P remove $@' root"
|
||||
print "$cmd"
|
||||
eval "$cmd"
|
||||
}
|
||||
|
||||
# Install all .deb files in the current directory
|
||||
# Assumes glob_subst is off
|
||||
alias di='su -lc "dpkg -i ./*.deb" root'
|
||||
|
||||
# Remove ALL kernel images and headers EXCEPT the one in use
|
||||
alias kclean='su -lc '\''aptitude remove -P ?and(~i~nlinux-(ima|hea) \
|
||||
?not(~n`uname -r`))'\'' root'
|
||||
fi
|
||||
|
||||
|
||||
# Misc. #####################################################################
|
||||
# print all installed packages
|
||||
alias allpkgs='aptitude search -F "%p" --disable-columns ~i'
|
||||
|
||||
# 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 di='su -c "dpkg -i ./*.deb"'
|
||||
|
||||
# Create a basic .deb package
|
||||
alias mydeb='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'
|
||||
|
||||
|
||||
|
||||
|
||||
# Functions #################################################################
|
||||
|
||||
# create a simple script that can be used to 'duplicate' a system
|
||||
apt-copy() {
|
||||
print '#!/bin/sh'"\n" > apt-copy.sh
|
||||
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;')
|
||||
cmd="$apt_pref install "
|
||||
|
||||
print 'aptitude install '"$list\n" >> apt-copy.sh
|
||||
for p in ${(f)"$(aptitude search -F "%p" --disable-columns \~i)"}; {
|
||||
cmd="${cmd} ${p}"
|
||||
}
|
||||
|
||||
chmod +x apt-copy.sh
|
||||
print $cmd "\n" >> apt-copy.sh
|
||||
|
||||
chmod +x apt-copy.sh
|
||||
}
|
||||
|
||||
|
||||
# Kernel-package building shortcut
|
||||
dbb-build () {
|
||||
MAKEFLAGS='' # temporarily unset MAKEFLAGS ( '-j3' will fail )
|
||||
kerndeb () {
|
||||
# temporarily unset MAKEFLAGS ( '-j3' will fail )
|
||||
MAKEFLAGS=$( print - $MAKEFLAGS | perl -pe 's/-j\s*[\d]+//g' )
|
||||
print '$MAKEFLAGS set to '"'$MAKEFLAGS'"
|
||||
appendage='-custom' # this shows up in $ (uname -r )
|
||||
revision=$(date +"%Y%m%d") # this shows up in the .deb file name
|
||||
|
||||
|
|
@ -57,4 +147,3 @@ dbb-build () {
|
|||
"$revision" kernel_image kernel_headers
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@ alias gss='git status -s'
|
|||
compdef _git gss=git-status
|
||||
alias ga='git add'
|
||||
compdef _git ga=git-add
|
||||
alias gm='git merge'
|
||||
compdef _git gm=git-merge
|
||||
|
||||
# Git and svn mix
|
||||
alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk'
|
||||
|
|
|
|||
|
|
@ -1,6 +1,60 @@
|
|||
# hub alias from defunkt
|
||||
# https://github.com/defunkt/hub
|
||||
if [ "$commands[(I)hub]" ]; then
|
||||
# Setup hub function for git, if it is available; http://github.com/defunkt/hub
|
||||
if [ "$commands[(I)hub]" ] && [ "$commands[(I)ruby]" ]; then
|
||||
# eval `hub alias -s zsh`
|
||||
function git(){hub "$@"}
|
||||
fi
|
||||
|
||||
# Functions #################################################################
|
||||
|
||||
# https://github.com/dbb
|
||||
|
||||
|
||||
# empty_gh [NAME_OF_REPO]
|
||||
#
|
||||
# Use this when creating a new repo from scratch.
|
||||
empty_gh() { # [NAME_OF_REPO]
|
||||
repo = $1
|
||||
ghuser=$( git config github.user )
|
||||
|
||||
mkdir "$repo"
|
||||
cd "$repo"
|
||||
git init
|
||||
touch README
|
||||
git add README
|
||||
git commit -m 'Initial commit.'
|
||||
git remote add origin git@github.com:${ghuser}/${repo}.git
|
||||
git push -u origin master
|
||||
}
|
||||
|
||||
# new_gh [DIRECTORY]
|
||||
#
|
||||
# Use this when you have a directory that is not yet set up for git.
|
||||
# This function will add all non-hidden files to git.
|
||||
new_gh() { # [DIRECTORY]
|
||||
cd "$1"
|
||||
ghuser=$( git config github.user )
|
||||
|
||||
git init
|
||||
# add all non-dot files
|
||||
print '.*'"\n"'*~' >> .gitignore
|
||||
git add ^.*
|
||||
git commit -m 'Initial commit.'
|
||||
git remote add origin git@github.com:${ghuser}/${repo}.git
|
||||
git push -u origin master
|
||||
}
|
||||
|
||||
# exist_gh [DIRECTORY]
|
||||
#
|
||||
# Use this when you have a git repo that's ready to go and you want to add it
|
||||
# to your GitHub.
|
||||
exist_gh() { # [DIRECTORY]
|
||||
cd "$1"
|
||||
name=$( git config user.name )
|
||||
ghuser=$( git config github.user )
|
||||
|
||||
git remote add origin git@github.com:${ghuser}/${repo}.git
|
||||
git push -u origin master
|
||||
}
|
||||
|
||||
# End Functions #############################################################
|
||||
|
||||
|
|
|
|||
80
plugins/gnu-utils/gnu-utils.plugin.zsh
Normal file
80
plugins/gnu-utils/gnu-utils.plugin.zsh
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
# ------------------------------------------------------------------------------
|
||||
# FILE: gnu-utils.plugin.zsh
|
||||
# DESCRIPTION: oh-my-zsh plugin file.
|
||||
# AUTHOR: Sorin Ionescu (sorin.ionescu@gmail.com)
|
||||
# VERSION: 1.0.0
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
|
||||
if [[ -x "${commands[gwhoami]}" ]]; then
|
||||
__gnu_utils() {
|
||||
emulate -L zsh
|
||||
local gcmds
|
||||
local gcmd
|
||||
local cmd
|
||||
local prefix
|
||||
|
||||
# coreutils
|
||||
gcmds=('g[' 'gbase64' 'gbasename' 'gcat' 'gchcon' 'gchgrp' 'gchmod'
|
||||
'gchown' 'gchroot' 'gcksum' 'gcomm' 'gcp' 'gcsplit' 'gcut' 'gdate'
|
||||
'gdd' 'gdf' 'gdir' 'gdircolors' 'gdirname' 'gdu' 'gecho' 'genv' 'gexpand'
|
||||
'gexpr' 'gfactor' 'gfalse' 'gfmt' 'gfold' 'ggroups' 'ghead' 'ghostid'
|
||||
'gid' 'ginstall' 'gjoin' 'gkill' 'glink' 'gln' 'glogname' 'gls' 'gmd5sum'
|
||||
'gmkdir' 'gmkfifo' 'gmknod' 'gmktemp' 'gmv' 'gnice' 'gnl' 'gnohup' 'gnproc'
|
||||
'god' 'gpaste' 'gpathchk' 'gpinky' 'gpr' 'gprintenv' 'gprintf' 'gptx' 'gpwd'
|
||||
'greadlink' 'grm' 'grmdir' 'gruncon' 'gseq' 'gsha1sum' 'gsha224sum'
|
||||
'gsha256sum' 'gsha384sum' 'gsha512sum' 'gshred' 'gshuf' 'gsleep' 'gsort'
|
||||
'gsplit' 'gstat' 'gstty' 'gsum' 'gsync' 'gtac' 'gtail' 'gtee' 'gtest'
|
||||
'gtimeout' 'gtouch' 'gtr' 'gtrue' 'gtruncate' 'gtsort' 'gtty' 'guname'
|
||||
'gunexpand' 'guniq' 'gunlink' 'guptime' 'gusers' 'gvdir' 'gwc' 'gwho'
|
||||
'gwhoami' 'gyes')
|
||||
|
||||
# Not part of coreutils, installed separately.
|
||||
gcmds+=('gsed' 'gtar' 'gtime')
|
||||
|
||||
for gcmd in "${gcmds[@]}"; 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.
|
||||
#
|
||||
(( ${+commands[$gcmd]} )) && hash ${gcmd[2,-1]}=${commands[$gcmd]}
|
||||
|
||||
#
|
||||
# This method generates wrapper functions.
|
||||
# It will override shell builtins.
|
||||
#
|
||||
# (( ${+commands[$gcmd]} )) && \
|
||||
# eval "function $gcmd[2,-1]() { \"${prefix}/${gcmd//"["/"\\["}\" \"\$@\"; }"
|
||||
|
||||
#
|
||||
# This method is inflexible since the aliases are at risk of being
|
||||
# overriden resulting in the BSD coreutils being called.
|
||||
#
|
||||
# (( ${+commands[$gcmd]} )) && \
|
||||
# alias "$gcmd[2,-1]"="${prefix}/${gcmd//"["/"\\["}"
|
||||
done
|
||||
|
||||
return 0
|
||||
}
|
||||
__gnu_utils;
|
||||
|
||||
function hash() {
|
||||
if [[ "$*" =~ "-(r|f)" ]]; then
|
||||
builtin hash "$@"
|
||||
__gnu_utils
|
||||
else
|
||||
builtin hash "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
function rehash() {
|
||||
if [[ "$*" =~ "-f" ]]; then
|
||||
builtin rehash "$@"
|
||||
__gnu_utils
|
||||
else
|
||||
builtin rehash "$@"
|
||||
fi
|
||||
}
|
||||
fi
|
||||
|
||||
119
plugins/gradle/gradle.plugin.zsh
Normal file
119
plugins/gradle/gradle.plugin.zsh
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
#!zsh
|
||||
##############################################################################
|
||||
# A descriptive listing of core Gradle commands
|
||||
############################################################################
|
||||
function _gradle_core_commands() {
|
||||
local ret=1 state
|
||||
_arguments ':subcommand:->subcommand' && ret=0
|
||||
|
||||
case $state in
|
||||
subcommand)
|
||||
subcommands=(
|
||||
"properties:Display all project properties"
|
||||
"tasks:Calculate and display all tasks"
|
||||
"dependencies:Calculate and display all dependencies"
|
||||
"projects:Discover and display all sub-projects"
|
||||
"build:Build the project"
|
||||
"help:Display help"
|
||||
)
|
||||
_describe -t subcommands 'gradle subcommands' subcommands && ret=0
|
||||
esac
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
function _gradle_arguments() {
|
||||
_arguments -C \
|
||||
'-a[Do not rebuild project dependencies]' \
|
||||
'-h[Help]' \
|
||||
'-D[System property]' \
|
||||
'-d[Log at the debug level]' \
|
||||
'--gui[Launches the Gradle GUI app]' \
|
||||
'--stop[Stop the Gradle daemon]' \
|
||||
'--daemon[Use the Gradle daemon]' \
|
||||
'--no-daemon[Do not use the Gradle daemon]' \
|
||||
'--no-opt[Do not perform any task optimization]' \
|
||||
'-i[Log at the info level]' \
|
||||
'-m[Dry run]' \
|
||||
'-P[Set a project property]' \
|
||||
'--profile[Profile the build time]' \
|
||||
'-q[Log at the quiet level (only show errors)]' \
|
||||
'-v[Print the Gradle version info]' \
|
||||
'-x[Specify a task to be excluded]' \
|
||||
'*::command:->command' \
|
||||
&& return 0
|
||||
}
|
||||
|
||||
|
||||
##############################################################################
|
||||
# Are we in a directory containing a build.gradle file?
|
||||
############################################################################
|
||||
function in_gradle() {
|
||||
if [[ -f build.gradle ]]; then
|
||||
echo 1
|
||||
fi
|
||||
}
|
||||
|
||||
############################################################################
|
||||
# Define the stat_cmd command based on platform behavior
|
||||
##########################################################################
|
||||
stat -f%m . > /dev/null 2>&1
|
||||
if [ "$?" = 0 ]; then
|
||||
stat_cmd=(stat -f%m)
|
||||
else
|
||||
stat_cmd=(stat -L --format=%Y)
|
||||
fi
|
||||
|
||||
############################################################################## Examine the build.gradle file to see if its
|
||||
# timestamp has changed, and if so, regen
|
||||
# the .gradle_tasks cache file
|
||||
############################################################################
|
||||
_gradle_does_task_list_need_generating () {
|
||||
if [ ! -f .gradletasknamecache ]; then return 0;
|
||||
else
|
||||
accurate=$($stat_cmd .gradletasknamecache)
|
||||
changed=$($stat_cmd build.gradle)
|
||||
return $(expr $accurate '>=' $changed)
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
##############################################################################
|
||||
# Discover the gradle tasks by running "gradle tasks --all"
|
||||
############################################################################
|
||||
_gradle_tasks () {
|
||||
if [ in_gradle ]; then
|
||||
_gradle_arguments
|
||||
if _gradle_does_task_list_need_generating; then
|
||||
gradle tasks --all | grep "^[ ]*[a-zA-Z0-9]*\ -\ " | sed "s/ - .*$//" | sed "s/[\ ]*//" > .gradletasknamecache
|
||||
fi
|
||||
compadd -X "==== Gradle Tasks ====" `cat .gradletasknamecache`
|
||||
fi
|
||||
}
|
||||
|
||||
_gradlew_tasks () {
|
||||
if [ in_gradle ]; then
|
||||
_gradle_arguments
|
||||
if _gradle_does_task_list_need_generating; then
|
||||
gradlew tasks --all | grep "^[ ]*[a-zA-Z0-9]*\ -\ " | sed "s/ - .*$//" | sed "s/[\ ]*//" > .gradletasknamecache
|
||||
fi
|
||||
compadd -X "==== Gradlew Tasks ====" `cat .gradletasknamecache`
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
##############################################################################
|
||||
# Register the completions against the gradle and gradlew commands
|
||||
############################################################################
|
||||
compdef _gradle_tasks gradle
|
||||
compdef _gradlew_tasks gradlew
|
||||
|
||||
|
||||
##############################################################################
|
||||
# Open questions for future improvements:
|
||||
# 1) Should 'gradle tasks' use --all or just the regular set?
|
||||
# 2) Should gradlew use the same approach as gradle?
|
||||
# 3) Should only the " - " be replaced with a colon so it can work
|
||||
# with the richer descriptive method of _arguments?
|
||||
# gradle tasks | grep "^[a-zA-Z0-9]*\ -\ " | sed "s/ - /\:/"
|
||||
#############################################################################
|
||||
54
plugins/grails/grails.plugin.zsh
Executable file
54
plugins/grails/grails.plugin.zsh
Executable file
|
|
@ -0,0 +1,54 @@
|
|||
_enumerateGrailsScripts() {
|
||||
# Default directoryies
|
||||
directories=($GRAILS_HOME/scripts ~/.grails/scripts ./scripts)
|
||||
|
||||
# Check all of the plugins directories, if they exist
|
||||
if [ -d plugins ]
|
||||
then
|
||||
directories+=(plugins/*/scripts)
|
||||
fi
|
||||
|
||||
# Enumerate all of the Groovy files
|
||||
files=()
|
||||
for dir in $directories;
|
||||
do
|
||||
if [ -d $dir ]
|
||||
then
|
||||
files+=($dir/[^_]*.groovy)
|
||||
fi
|
||||
done
|
||||
|
||||
# Don't try to basename ()
|
||||
if [ ${#files} -eq 0 ];
|
||||
then
|
||||
return
|
||||
fi
|
||||
|
||||
# - Strip the path
|
||||
# - Remove all scripts with a leading '_'
|
||||
# - PackagePlugin_.groovy -> PackagePlugin
|
||||
# - PackagePlugin -> Package-Plugin
|
||||
# - Package-Plugin -> package-plugin
|
||||
basename $files \
|
||||
| sed -E -e 's/^_?([^_]+)_?.groovy/\1/'\
|
||||
-e 's/([a-z])([A-Z])/\1-\2/g' \
|
||||
| tr "[:upper:]" "[:lower:]" \
|
||||
| sort \
|
||||
| uniq
|
||||
}
|
||||
|
||||
_grails() {
|
||||
if (( CURRENT == 2 )); then
|
||||
scripts=( $(_enumerateGrailsScripts) )
|
||||
|
||||
if [ ${#scripts} -ne 0 ];
|
||||
then
|
||||
_multi_parts / scripts
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
_files
|
||||
}
|
||||
|
||||
compdef _grails grails
|
||||
14
plugins/mercurial/mercurial.plugin.zsh
Normal file
14
plugins/mercurial/mercurial.plugin.zsh
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
|
||||
# Mercurial
|
||||
alias hgc='hg commit -v'
|
||||
alias hgb='hg branch -v'
|
||||
alias hgba='hg branches'
|
||||
alias hgco='hg checkout'
|
||||
alias hgd='hg diff'
|
||||
alias hged='hg diffmerge'
|
||||
# pull and update
|
||||
alias hgl='hg pull -u -v'
|
||||
alias hgp='hg push -v'
|
||||
alias hgs='hg status -v'
|
||||
# this is the 'git commit --amend' equivalent
|
||||
alias hgca='hg qimport -r tip ; hg qrefresh -e ; hg qfinish tip'
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
#compdef npm
|
||||
|
||||
# Node Package Manager 0.3.15 completion, letting npm do all the completion work
|
||||
|
||||
_npm() {
|
||||
compadd -- $(_npm_complete $words)
|
||||
}
|
||||
|
||||
# We want to show all errors of any substance, but never the "npm (not )ok" one.
|
||||
# (Also doesn't consider "ERR! no match found" worth breaking the terminal for.)
|
||||
_npm_complete() {
|
||||
local ask_npm
|
||||
ask_npm=(npm completion --color false --loglevel error -- $@)
|
||||
{ _call_program npm $ask_npm 2>&1 >&3 \
|
||||
| egrep -v '^(npm (not |)ok|ERR! no match found)$' >&2; \
|
||||
} 3>&1
|
||||
}
|
||||
|
||||
_npm "$@"
|
||||
1
plugins/npm/npm.plugin.zsh
Normal file
1
plugins/npm/npm.plugin.zsh
Normal file
|
|
@ -0,0 +1 @@
|
|||
eval "$(npm completion 2>/dev/null)"
|
||||
5
plugins/python/python.plugin.zsh
Normal file
5
plugins/python/python.plugin.zsh
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
# Find python file
|
||||
alias pyfind='find . -name "*.py"'
|
||||
|
||||
# Remove python compiled byte-code
|
||||
alias pyclean='find . -type f -name "*.py[co]" -exec rm -f \{\} \;'
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
function svn_prompt_info {
|
||||
if [ in_svn ]; then
|
||||
if [ $(in_svn) ]; then
|
||||
echo "$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_PREFIX\
|
||||
$ZSH_THEME_REPO_NAME_COLOR$(svn_get_repo_name)$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_SUFFIX$ZSH_PROMPT_BASE_COLOR$(svn_dirty)$ZSH_PROMPT_BASE_COLOR"
|
||||
fi
|
||||
|
|
@ -13,7 +13,7 @@ function in_svn() {
|
|||
}
|
||||
|
||||
function svn_get_repo_name {
|
||||
if [ in_svn ]; then
|
||||
if [ $(in_svn) ]; then
|
||||
svn info | sed -n 's/Repository\ Root:\ .*\///p' | read SVN_ROOT
|
||||
|
||||
svn info | sed -n "s/URL:\ .*$SVN_ROOT\///p" | sed "s/\/.*$//"
|
||||
|
|
@ -21,13 +21,13 @@ function svn_get_repo_name {
|
|||
}
|
||||
|
||||
function svn_get_rev_nr {
|
||||
if [ in_svn ]; then
|
||||
if [ $(in_svn) ]; then
|
||||
svn info 2> /dev/null | sed -n s/Revision:\ //p
|
||||
fi
|
||||
}
|
||||
|
||||
function svn_dirty_choose {
|
||||
if [ in_svn ]; then
|
||||
if [ $(in_svn) ]; then
|
||||
s=$(svn status|grep -E '^\s*[ACDIM!?L]' 2>/dev/null)
|
||||
if [ $s ]; then
|
||||
echo $1
|
||||
|
|
|
|||
38
plugins/terminitor/_terminitor
Normal file
38
plugins/terminitor/_terminitor
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
#compdef terminitor
|
||||
#autoload
|
||||
|
||||
# terminitor zsh completion
|
||||
|
||||
_terminitor_available_scripts() {
|
||||
scripts=(`for SCRIPT in ~/.config/terminitor/*.term ; do basename $SCRIPT .term ; done`)
|
||||
}
|
||||
|
||||
local -a _1st_arguments
|
||||
_1st_arguments=(
|
||||
'create:create a Termfile in directory'
|
||||
'delete:delete terminitor script'
|
||||
'edit:open termitor script'
|
||||
'fetch:clone the designated repo and run setup'
|
||||
'help:Describe available tasks or one specific task'
|
||||
'init:create initial root terminitor folder'
|
||||
'list:lists all terminitor scripts'
|
||||
'setup:execute setup in the terminitor script'
|
||||
'start:runs the terminitor script'
|
||||
'update:update Terminitor to new global path(.config/.terminitor)'
|
||||
)
|
||||
|
||||
local expl
|
||||
|
||||
_arguments \
|
||||
'*:: :->subcmds' && return 0
|
||||
|
||||
if (( CURRENT == 1 )); then
|
||||
_describe -t commands "terminitor task" _1st_arguments
|
||||
return
|
||||
fi
|
||||
|
||||
case "$words[1]" in
|
||||
start|edit|delete|setup)
|
||||
_terminitor_available_scripts
|
||||
_wanted scripts expl 'installed scripts' compadd -a scripts ;;
|
||||
esac
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
alias et='mate .'
|
||||
alias ett='mate app config lib db public spec test Rakefile Capfile Todo'
|
||||
alias ett='mate Gemfile app config features lib db public spec test Rakefile Capfile Todo'
|
||||
alias etp='mate app config lib db public spec test vendor/plugins vendor/gems Rakefile Capfile Todo'
|
||||
alias etts='mate app config lib db public script spec test vendor/plugins vendor/gems Rakefile Capfile Todo'
|
||||
|
||||
|
|
|
|||
23
plugins/vundle/vundle.plugin.zsh
Normal file
23
plugins/vundle/vundle.plugin.zsh
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
function vundle-init () {
|
||||
if [ ! -d ~/.vim/bundle/vundle/ ]
|
||||
then
|
||||
mkdir -p ~/.vim/bundle/vundle/
|
||||
fi
|
||||
|
||||
if [ ! -d ~/.vim/bundle/vundle/.git/ ]
|
||||
then
|
||||
git clone http://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
|
||||
echo "\n\tRead about vim configuration for vundle at https://github.com/gmarik/vundle\n"
|
||||
fi
|
||||
}
|
||||
|
||||
function vundle () {
|
||||
vundle-init
|
||||
vim -c "execute \"BundleInstall\" | q | q"
|
||||
}
|
||||
|
||||
|
||||
function vundle-update () {
|
||||
vundle-init
|
||||
vim -c "execute \"BundleInstall!\" | q | q"
|
||||
}
|
||||
26
themes/apple.zsh-theme
Normal file
26
themes/apple.zsh-theme
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
function toon {
|
||||
echo -n ""
|
||||
}
|
||||
|
||||
get_git_dirty() {
|
||||
git diff --quiet || echo '*'
|
||||
}
|
||||
|
||||
autoload -Uz vcs_info
|
||||
autoload -U colors && colors
|
||||
zstyle ':vcs_info:*' check-for-changes true
|
||||
zstyle ':vcs_info:*' unstagedstr '%F{red}*' # display this when there are unstaged changes
|
||||
zstyle ':vcs_info:*' stagedstr '%F{yellow}+' # display this when there are staged changes
|
||||
zstyle ':vcs_info:*' actionformats \
|
||||
'%F{5}%F{5}[%F{2}%b%F{3}|%F{1}%a%c%u%F{5}]%f '
|
||||
zstyle ':vcs_info:*' formats \
|
||||
'%F{5}%F{5}[%F{2}%b%c%u%F{5}]%f '
|
||||
zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{3}%r'
|
||||
zstyle ':vcs_info:*' enable git cvs svn
|
||||
|
||||
precmd () {
|
||||
vcs_info
|
||||
}
|
||||
|
||||
setopt prompt_subst
|
||||
PROMPT='%{$fg[magenta]%}$(toon)%{$reset_color%} %~/ %{$reset_color%}${vcs_info_msg_0_}%{$reset_color%}'
|
||||
37
themes/crunch.zsh-theme
Normal file
37
themes/crunch.zsh-theme
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
# CRUNCH - created from Steve Eley's cat waxing.
|
||||
# Initially hacked from the Dallas theme. Thanks, Dallas Reedy.
|
||||
#
|
||||
# This theme assumes you do most of your oh-my-zsh'ed "colorful" work at a single machine,
|
||||
# and eschews the standard space-consuming user and hostname info. Instead, only the
|
||||
# things that vary in my own workflow are shown:
|
||||
#
|
||||
# * The time (not the date)
|
||||
# * The RVM version and gemset (omitting the 'ruby' name if it's MRI)
|
||||
# * The current directory
|
||||
# * The Git branch and its 'dirty' state
|
||||
#
|
||||
# Colors are at the top so you can mess with those separately if you like.
|
||||
# For the most part I stuck with Dallas's.
|
||||
|
||||
CRUNCH_BRACKET_COLOR="%{$fg[white]%}"
|
||||
CRUNCH_TIME_COLOR="%{$fg[yellow]%}"
|
||||
CRUNCH_RVM_COLOR="%{$fg[magenta]%}"
|
||||
CRUNCH_DIR_COLOR="%{$fg[cyan]%}"
|
||||
CRUNCH_GIT_BRANCH_COLOR="%{$fg[green]%}"
|
||||
CRUNCH_GIT_CLEAN_COLOR="%{$fg[green]%}"
|
||||
CRUNCH_GIT_DIRTY_COLOR="%{$fg[red]%}"
|
||||
|
||||
# These Git variables are used by the oh-my-zsh git_prompt_info helper:
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX="$CRUNCH_BRACKET_COLOR:$CRUNCH_GIT_BRANCH_COLOR"
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX=""
|
||||
ZSH_THEME_GIT_PROMPT_CLEAN=" $CRUNCH_GIT_CLEAN_COLOR✓"
|
||||
ZSH_THEME_GIT_PROMPT_DIRTY=" $CRUNCH_GIT_DIRTY_COLOR✗"
|
||||
|
||||
# Our elements:
|
||||
CRUNCH_TIME_="$CRUNCH_BRACKET_COLOR{$CRUNCH_TIME_COLOR%T$CRUNCH_BRACKET_COLOR}%{$reset_color%}"
|
||||
CRUNCH_RVM_="$CRUNCH_BRACKET_COLOR"["$CRUNCH_RVM_COLOR\${\$(~/.rvm/bin/rvm-prompt i v g)#ruby-}$CRUNCH_BRACKET_COLOR"]"%{$reset_color%}"
|
||||
CRUNCH_DIR_="$CRUNCH_DIR_COLOR%~\$(git_prompt_info) "
|
||||
CRUNCH_PROMPT="$CRUNCH_BRACKET_COLOR➭ "
|
||||
|
||||
# Put it all together!
|
||||
PROMPT="$CRUNCH_TIME_$CRUNCH_RVM_$CRUNCH_DIR_$CRUNCH_PROMPT%{$reset_color%}"
|
||||
39
themes/fino.zsh-theme
Normal file
39
themes/fino.zsh-theme
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
# Fino theme by Max Masnick (http://max.masnick.me)
|
||||
|
||||
# Use with a dark background and 256-color terminal!
|
||||
# Meant for people with RVM and git. Tested only on OS X 10.7.
|
||||
|
||||
# You can set your computer name in the ~/.box-name file if you want.
|
||||
|
||||
# Borrowing shamelessly from these oh-my-zsh themes:
|
||||
# bira
|
||||
# robbyrussell
|
||||
#
|
||||
# Also borrowing from http://stevelosh.com/blog/2010/02/my-extravagant-zsh-prompt/
|
||||
|
||||
function virtualenv_info {
|
||||
[ $VIRTUAL_ENV ] && echo '('`basename $VIRTUAL_ENV`') '
|
||||
}
|
||||
|
||||
function prompt_char {
|
||||
git branch >/dev/null 2>/dev/null && echo '±' && return
|
||||
echo '○'
|
||||
}
|
||||
|
||||
function box_name {
|
||||
[ -f ~/.box-name ] && cat ~/.box-name || hostname -s
|
||||
}
|
||||
|
||||
|
||||
local rvm_ruby='‹$(rvm-prompt i v g)›%{$reset_color%}'
|
||||
local current_dir='${PWD/#$HOME/~}'
|
||||
local git_info='$(git_prompt_info)'
|
||||
|
||||
|
||||
PROMPT="╭─%{$FG[040]%}%n%{$reset_color%} %{$FG[239]%}at%{$reset_color%} %{$FG[033]%}$(box_name)%{$reset_color%} %{$FG[239]%}in%{$reset_color%} %{$terminfo[bold]$FG[226]%}${current_dir}%{$reset_color%}${git_info} %{$FG[239]%}using%{$FG[243]%} ${rvm_ruby}
|
||||
╰─$(virtualenv_info)$(prompt_char) "
|
||||
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX=" %{$FG[239]%}on%{$reset_color%} %{$fg[255]%}"
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
|
||||
ZSH_THEME_GIT_PROMPT_DIRTY="%{$FG[202]%}✘✘✘"
|
||||
ZSH_THEME_GIT_PROMPT_CLEAN="%{$FG[040]%}✔"
|
||||
8
themes/fox.zsh-theme
Normal file
8
themes/fox.zsh-theme
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#fox theme
|
||||
PROMPT='%{$fg[cyan]%}┌[%{$fg_bold[white]%}%n%{$reset_color%}%{$fg[cyan]%}☮%{$fg_bold[white]%}%M%{$reset_color%}%{$fg[cyan]%}]%{$fg[white]%}-%{$fg[cyan]%}(%{$fg_bold[white]%}%~%{$reset_color%}%{$fg[cyan]%})$(git_prompt_info)
|
||||
└> % %{$reset_color%}'
|
||||
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX="-[%{$reset_color%}%{$fg[white]%}git://%{$fg_bold[white]%}"
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}%{$fg[cyan]%}]-"
|
||||
ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg[red]%}✗%{$reset_color%}"
|
||||
ZSH_THEME_GIT_PROMPT_CLEAN=" %{$fg[green]%}✔%{$reset_color%}"
|
||||
54
themes/gnzh.zsh-theme
Normal file
54
themes/gnzh.zsh-theme
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
# ZSH Theme - Preview: http://dl.dropbox.com/u/4109351/pics/gnzh-zsh-theme.png
|
||||
# Based on bira theme
|
||||
|
||||
# load some modules
|
||||
autoload -U colors zsh/terminfo # Used in the colour alias below
|
||||
colors
|
||||
setopt prompt_subst
|
||||
|
||||
# make some aliases for the colours: (coud use normal escap.seq's too)
|
||||
for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do
|
||||
eval PR_$color='%{$fg[${(L)color}]%}'
|
||||
done
|
||||
eval PR_NO_COLOR="%{$terminfo[sgr0]%}"
|
||||
eval PR_BOLD="%{$terminfo[bold]%}"
|
||||
|
||||
# Check the UID
|
||||
if [[ $UID -ge 1000 ]]; then # normal user
|
||||
eval PR_USER='${PR_GREEN}%n${PR_NO_COLOR}'
|
||||
eval PR_USER_OP='${PR_GREEN}%#${PR_NO_COLOR}'
|
||||
local PR_PROMPT='$PR_NO_COLOR➤ $PR_NO_COLOR'
|
||||
elif [[ $UID -eq 0 ]]; then # root
|
||||
eval PR_USER='${PR_RED}%n${PR_NO_COLOR}'
|
||||
eval PR_USER_OP='${PR_RED}%#${PR_NO_COLOR}'
|
||||
local PR_PROMPT='$PR_RED➤ $PR_NO_COLOR'
|
||||
fi
|
||||
|
||||
# Check if we are on SSH or not
|
||||
if [[ -n "$SSH_CLIENT" || -n "$SSH2_CLIENT" ]]; then
|
||||
eval PR_HOST='${PR_YELLOW}%M${PR_NO_COLOR}' #SSH
|
||||
else
|
||||
eval PR_HOST='${PR_GREEN}%M${PR_NO_COLOR}' # no SSH
|
||||
fi
|
||||
|
||||
local return_code="%(?..%{$PR_RED%}%? ↵%{$PR_NO_COLOR%})"
|
||||
|
||||
local user_host='${PR_USER}${PR_CYAN}@${PR_HOST}'
|
||||
local current_dir='%{$PR_BOLD$PR_BLUE%}%~%{$PR_NO_COLOR%}'
|
||||
local rvm_ruby=''
|
||||
if which rvm-prompt &> /dev/null; then
|
||||
rvm_ruby='%{$PR_RED%}‹$(rvm-prompt i v g s)›%{$PR_NO_COLOR%}'
|
||||
else
|
||||
if which rbenv &> /dev/null; then
|
||||
rvm_ruby='%{$PR_RED%}‹$(rbenv version | sed -e "s/ (set.*$//")›%{$PR_NO_COLOR%}'
|
||||
fi
|
||||
fi
|
||||
local git_branch='$(git_prompt_info)%{$PR_NO_COLOR%}'
|
||||
|
||||
#PROMPT="${user_host} ${current_dir} ${rvm_ruby} ${git_branch}$PR_PROMPT "
|
||||
PROMPT="╭─${user_host} ${current_dir} ${rvm_ruby} ${git_branch}
|
||||
╰─$PR_PROMPT "
|
||||
RPS1="${return_code}"
|
||||
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX="%{$PR_YELLOW%}‹"
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX="› %{$PR_NO_COLOR%}"
|
||||
4
themes/norm.zsh-theme
Normal file
4
themes/norm.zsh-theme
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
PROMPT='%{$fg[yellow]%}λ %{$fg[green]%}%c %{$fg[yellow]%}→ $(git_prompt_info)%{$reset_color%}'
|
||||
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX="λ %{$fg[blue]%}git %{$fg[red]%}"
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$fg[yellow]%} → %{$reset_color%}"
|
||||
29
themes/rkj-repos.zsh-theme
Normal file
29
themes/rkj-repos.zsh-theme
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
# user, host, full path, and time/date
|
||||
# on two lines for easier vgrepping
|
||||
# entry in a nice long thread on the Arch Linux forums: http://bbs.archlinux.org/viewtopic.php?pid=521888#p521888
|
||||
|
||||
function hg_prompt_info {
|
||||
hg prompt --angle-brackets "\
|
||||
<hg:%{$fg[magenta]%}<branch>%{$reset_color%}>\
|
||||
</%{$fg[yellow]%}<tags|%{$reset_color%}, %{$fg[yellow]%}>%{$reset_color%}>\
|
||||
%{$fg[red]%}<status|modified|unknown><update>%{$reset_color%}<
|
||||
patches: <patches|join( → )|pre_applied(%{$fg[yellow]%})|post_applied(%{$reset_color%})|pre_unapplied(%{$fg_bold[black]%})|post_unapplied(%{$reset_color%})>>" 2>/dev/null
|
||||
}
|
||||
|
||||
ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[cyan]%}+"
|
||||
ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg[yellow]%}✱"
|
||||
ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[red]%}✗"
|
||||
ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[blue]%}➦"
|
||||
ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[magenta]%}✂"
|
||||
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[grey]%}✈"
|
||||
|
||||
function mygit() {
|
||||
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
|
||||
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$( git_prompt_status )%{$reset_color%}$ZSH_THEME_GIT_PROMPT_SUFFIX"
|
||||
}
|
||||
|
||||
# alternate prompt with git & hg
|
||||
PROMPT=$'%{\e[0;34m%}%B┌─[%b%{\e[0m%}%{\e[1;32m%}%n%{\e[1;30m%}@%{\e[0m%}%{\e[0;36m%}%m%{\e[0;34m%}%B]%b%{\e[0m%} - %b%{\e[0;34m%}%B[%b%{\e[1;37m%}%~%{\e[0;34m%}%B]%b%{\e[0m%} - %{\e[0;34m%}%B[%b%{\e[0;33m%}'%D{"%Y-%m-%d %I:%M:%S"}%b$'%{\e[0;34m%}%B]%b%{\e[0m%}
|
||||
%{\e[0;34m%}%B└─%B[%{\e[1;35m%}$%{\e[0;34m%}%B] <$(mygit)$(hg_prompt_info)>%{\e[0m%}%b '
|
||||
PS2=$' \e[0;34m%}%B>%{\e[0m%}%b '
|
||||
|
||||
8
themes/rkj.zsh-theme
Normal file
8
themes/rkj.zsh-theme
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
# user, host, full path, and time/date
|
||||
# on two lines for easier vgrepping
|
||||
# entry in a nice long thread on the Arch Linux forums: http://bbs.archlinux.org/viewtopic.php?pid=521888#p521888
|
||||
|
||||
PROMPT=$'%{\e[0;34m%}%B┌─[%b%{\e[0m%}%{\e[1;32m%}%n%{\e[1;30m%}@%{\e[0m%}%{\e[0;36m%}%m%{\e[0;34m%}%B]%b%{\e[0m%} - %b%{\e[0;34m%}%B[%b%{\e[1;37m%}%~%{\e[0;34m%}%B]%b%{\e[0m%} - %{\e[0;34m%}%B[%b%{\e[0;33m%}'%D{"%Y-%m-%d %I:%M:%S"}%b$'%{\e[0;34m%}%B]%b%{\e[0m%}
|
||||
%{\e[0;34m%}%B└─%B[%{\e[1;35m%}$%{\e[0;34m%}%B]%{\e[0m%}%b '
|
||||
|
||||
|
||||
5
themes/wuffers.zsh-theme
Normal file
5
themes/wuffers.zsh-theme
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}["
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX="]%{$reset_color%} "
|
||||
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg_bold[red]%} x%{$fg_bold[blue]%}"
|
||||
|
||||
PROMPT='%{$(git_prompt_info)%}%{$fg_bold[green]%}{%{$(rvm current)%}}%{$reset_color%} %{$fg[cyan]%}%c%{$reset_color%} '
|
||||
|
|
@ -24,7 +24,7 @@ then
|
|||
read line
|
||||
if [ "$line" = Y ] || [ "$line" = y ]
|
||||
then
|
||||
/bin/sh $ZSH/tools/upgrade.sh
|
||||
/usr/bin/env ZSH=$ZSH /bin/sh $ZSH/tools/upgrade.sh
|
||||
# update the zsh file
|
||||
_update_zsh_update
|
||||
fi
|
||||
|
|
|
|||
161
tools/require_tool.sh
Executable file
161
tools/require_tool.sh
Executable file
|
|
@ -0,0 +1,161 @@
|
|||
__require_tool_version_compare ()
|
||||
{
|
||||
(
|
||||
# Locally ignore failures, otherwise we'll exit whenever $1 and $2
|
||||
# are not equal!
|
||||
set +e
|
||||
|
||||
awk_strverscmp='
|
||||
# Use only awk features that work with 7th edition Unix awk (1978).
|
||||
# My, what an old awk you have, Mr. Solaris!
|
||||
END {
|
||||
while (length(v1) || length(v2)) {
|
||||
# Set d1 to be the next thing to compare from v1, and likewise for d2.
|
||||
# Normally this is a single character, but if v1 and v2 contain digits,
|
||||
# compare them as integers and fractions as strverscmp does.
|
||||
if (v1 ~ /^[0-9]/ && v2 ~ /^[0-9]/) {
|
||||
# Split v1 and v2 into their leading digit string components d1 and d2,
|
||||
# and advance v1 and v2 past the leading digit strings.
|
||||
for (len1 = 1; substr(v1, len1 + 1) ~ /^[0-9]/; len1++) continue
|
||||
for (len2 = 1; substr(v2, len2 + 1) ~ /^[0-9]/; len2++) continue
|
||||
d1 = substr(v1, 1, len1); v1 = substr(v1, len1 + 1)
|
||||
d2 = substr(v2, 1, len2); v2 = substr(v2, len2 + 1)
|
||||
if (d1 ~ /^0/) {
|
||||
if (d2 ~ /^0/) {
|
||||
# Compare two fractions.
|
||||
while (d1 ~ /^0/ && d2 ~ /^0/) {
|
||||
d1 = substr(d1, 2); len1--
|
||||
d2 = substr(d2, 2); len2--
|
||||
}
|
||||
if (len1 != len2 && ! (len1 && len2 && substr(d1, 1, 1) == substr(d2, 1, 1))) {
|
||||
# The two components differ in length, and the common prefix
|
||||
# contains only leading zeros. Consider the longer to be less.
|
||||
d1 = -len1
|
||||
d2 = -len2
|
||||
} else {
|
||||
# Otherwise, compare as strings.
|
||||
d1 = "x" d1
|
||||
d2 = "x" d2
|
||||
}
|
||||
} else {
|
||||
# A fraction is less than an integer.
|
||||
exit 1
|
||||
}
|
||||
} else {
|
||||
if (d2 ~ /^0/) {
|
||||
# An integer is greater than a fraction.
|
||||
exit 2
|
||||
} else {
|
||||
# Compare two integers.
|
||||
d1 += 0
|
||||
d2 += 0
|
||||
}
|
||||
}
|
||||
} else {
|
||||
# The normal case, without worrying about digits.
|
||||
if (v1 == "") d1 = v1; else { d1 = substr(v1, 1, 1); v1 = substr(v1,2) }
|
||||
if (v2 == "") d2 = v2; else { d2 = substr(v2, 1, 1); v2 = substr(v2,2) }
|
||||
}
|
||||
if (d1 < d2) exit 1
|
||||
if (d1 > d2) exit 2
|
||||
}
|
||||
}
|
||||
'
|
||||
awk "$awk_strverscmp" v1="$1" v2="$2" /dev/null
|
||||
case $? in
|
||||
1) echo '<';;
|
||||
0) echo '=';;
|
||||
2) echo '>';;
|
||||
esac
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
__require_tool_fatal ()
|
||||
{
|
||||
echo $@ >/dev/stderr
|
||||
return 1
|
||||
}
|
||||
|
||||
# Usage: require_tool program version
|
||||
# Returns: 0 if $1 version if greater equals than $2, 1 otherwise.
|
||||
# In case of error, message is written on error output.
|
||||
#
|
||||
# Example: require_tool gcc 4.6
|
||||
# Use GCC environment variable if defined instead of lookup for the tool
|
||||
# in the environment.
|
||||
require_tool ()
|
||||
{
|
||||
envvar_name=$(echo $1 | tr '[:lower:]' '[:upper:]')
|
||||
tool=$(printenv $envvar_name || echo $1)
|
||||
local version=$($tool --version 2>/dev/null| \
|
||||
sed -n 's/.*[^0-9.]\([0-9]*\.[0-9.]*\).*/\1/p;q')
|
||||
if test x"$version" = x ; then
|
||||
echo "$tool is required" >/dev/stderr
|
||||
return 1
|
||||
fi
|
||||
case $(__require_tool_version_compare "$2" "$version") in
|
||||
'>')
|
||||
echo "$1 $2 or better is required: this is $tool $version" >/dev/stderr
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
NAME
|
||||
require_tool.sh - Ensure version of a tool is greater than the one expected
|
||||
|
||||
SYNOPSYS
|
||||
require_tool.sh [ -h ]
|
||||
[ --help ]
|
||||
[ TOOL MIN_VERSION ]
|
||||
|
||||
DESCRIPTION
|
||||
TOOL is the name or path of the program to check. If the name is specified, its
|
||||
path is deduced from PATH environment variable. If environment variable TOOL
|
||||
(in upper-case characters) is defined, considers its value as path to the tool.
|
||||
|
||||
MIN_VERSION is a string representing the minimum required version.
|
||||
|
||||
BEHAVIOR
|
||||
* locate path to the program.
|
||||
* execute $ TOOL_PATH --version
|
||||
* extract version from standard output.
|
||||
* compare this version to the expected one.
|
||||
|
||||
OPTIONS
|
||||
-h --help
|
||||
Display this message and exit 0
|
||||
|
||||
ERRORS
|
||||
if program is not found or its version is prior to expected version,
|
||||
a message is written to error output.
|
||||
|
||||
EXIT VALUE
|
||||
returns 0 if program version if greater equals than expected version,
|
||||
returns 1 otherwise.
|
||||
|
||||
EXAMPLE
|
||||
$ require_tool.sh emacs 23
|
||||
$ CC=g++ require_tool.sh cc 4.6
|
||||
$ require_tool.sh zsh 4.5
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
for arg in $@; do
|
||||
case $arg in
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
if [ $# -gt 2 ] ; then
|
||||
echo "ERROR: expecting 2 parameters. Please see option --help"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
require_tool $@
|
||||
96
tools/theme_chooser.sh
Executable file
96
tools/theme_chooser.sh
Executable file
|
|
@ -0,0 +1,96 @@
|
|||
#!/bin/zsh
|
||||
|
||||
# Zsh Theme Chooser by fox (fox91 at anche dot no)
|
||||
# This program is free software. It comes without any warranty, to
|
||||
# the extent permitted by applicable law. You can redistribute it
|
||||
# and/or modify it under the terms of the Do What The Fuck You Want
|
||||
# To Public License, Version 2, as published by Sam Hocevar. See
|
||||
# http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
|
||||
THEMES_DIR="$ZSH/themes"
|
||||
FAVLIST="${HOME}/.zsh_favlist"
|
||||
source $ZSH/oh-my-zsh.sh
|
||||
|
||||
function noyes() {
|
||||
read "a?$1 [y/N] "
|
||||
if [[ $a == "N" || $a == "n" || $a = "" ]]; then
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
function theme_preview() {
|
||||
THEME=$1
|
||||
THEME_NAME=`echo $THEME | sed s/\.zsh-theme$//`
|
||||
print "$fg[blue]${(l.((${COLUMNS}-${#THEME_NAME}-5))..─.)}$reset_color $THEME_NAME $fg[blue]───$reset_color"
|
||||
source "$THEMES_DIR/$THEME"
|
||||
print -P $PROMPT
|
||||
}
|
||||
|
||||
function banner() {
|
||||
echo
|
||||
echo "[0;1;35;95m╺━[0;1;31;91m┓┏[0;1;33;93m━┓[0;1;32;92m╻[0m [0;1;36;96m╻[0m [0;1;35;95m╺┳[0;1;31;91m╸╻[0m [0;1;33;93m╻[0;1;32;92m┏━[0;1;36;96m╸┏[0;1;34;94m┳┓[0;1;35;95m┏━[0;1;31;91m╸[0m [0;1;32;92m┏━[0;1;36;96m╸╻[0m [0;1;34;94m╻[0;1;35;95m┏━[0;1;31;91m┓┏[0;1;33;93m━┓[0;1;32;92m┏━[0;1;36;96m┓┏[0;1;34;94m━╸[0;1;35;95m┏━[0;1;31;91m┓[0m"
|
||||
echo "[0;1;31;91m┏━[0;1;33;93m┛┗[0;1;32;92m━┓[0;1;36;96m┣━[0;1;34;94m┫[0m [0;1;31;91m┃[0m [0;1;33;93m┣[0;1;32;92m━┫[0;1;36;96m┣╸[0m [0;1;34;94m┃[0;1;35;95m┃┃[0;1;31;91m┣╸[0m [0;1;36;96m┃[0m [0;1;34;94m┣[0;1;35;95m━┫[0;1;31;91m┃[0m [0;1;33;93m┃┃[0m [0;1;32;92m┃[0;1;36;96m┗━[0;1;34;94m┓┣[0;1;35;95m╸[0m [0;1;31;91m┣┳[0;1;33;93m┛[0m"
|
||||
echo "[0;1;33;93m┗━[0;1;32;92m╸┗[0;1;36;96m━┛[0;1;34;94m╹[0m [0;1;35;95m╹[0m [0;1;33;93m╹[0m [0;1;32;92m╹[0m [0;1;36;96m╹[0;1;34;94m┗━[0;1;35;95m╸╹[0m [0;1;31;91m╹[0;1;33;93m┗━[0;1;32;92m╸[0m [0;1;34;94m┗━[0;1;35;95m╸╹[0m [0;1;31;91m╹[0;1;33;93m┗━[0;1;32;92m┛┗[0;1;36;96m━┛[0;1;34;94m┗━[0;1;35;95m┛┗[0;1;31;91m━╸[0;1;33;93m╹┗[0;1;32;92m╸[0m"
|
||||
echo
|
||||
}
|
||||
|
||||
function usage() {
|
||||
echo "Usage: $0 [options] [theme]"
|
||||
echo
|
||||
echo "Options"
|
||||
echo " -l List available themes"
|
||||
echo " -s Show all themes"
|
||||
echo " -h Get this help message"
|
||||
exit 1
|
||||
}
|
||||
|
||||
function list_themes() {
|
||||
for THEME in $(ls $THEMES_DIR); do
|
||||
THEME_NAME=`echo $THEME | sed s/\.zsh-theme$//`
|
||||
echo $THEME_NAME
|
||||
done
|
||||
}
|
||||
|
||||
function insert_favlist() {
|
||||
if grep -q "$THEME_NAME" $FAVLIST 2> /dev/null ; then
|
||||
echo "Already in favlist"
|
||||
else
|
||||
echo $THEME_NAME >> $FAVLIST
|
||||
echo "Saved to favlist"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
function theme_chooser() {
|
||||
for THEME in $(ls $THEMES_DIR); do
|
||||
echo
|
||||
theme_preview $THEME
|
||||
echo
|
||||
if [[ -z $1 ]]; then
|
||||
noyes "Do you want to add it to your favourite list ($FAVLIST)?" || \
|
||||
insert_favlist $THEME_NAME
|
||||
echo
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
while getopts ":lhs" Option
|
||||
do
|
||||
case $Option in
|
||||
l ) list_themes ;;
|
||||
s ) theme_chooser 0 ;;
|
||||
h ) usage ;;
|
||||
* ) usage ;; # Default.
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ -z $Option ]]; then
|
||||
if [[ -z $1 ]]; then
|
||||
banner
|
||||
echo
|
||||
theme_chooser
|
||||
else
|
||||
theme_preview $1".zsh-theme"
|
||||
fi
|
||||
fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue