Merge master (rebase being super annoying). Fix conflicts

This commit is contained in:
Chris McCuller 2015-09-21 22:19:15 -04:00
commit e6ccd37b05
112 changed files with 6857 additions and 1042 deletions

View file

@ -3,9 +3,9 @@
Oh My Zsh is an open source, community-driven framework for managing your [zsh](http://www.zsh.org/) configuration. That sounds boring. Let's try this again. Oh My Zsh is an open source, community-driven framework for managing your [zsh](http://www.zsh.org/) configuration. That sounds boring. Let's try this again.
__Oh My Zsh is a way of life!__ Once installed, your terminal prompt will become the talk of the town _or your money back!_ Each time you interface with your command prompt, you'll be able take advantage of the hundreds of bundled plugins and pretty themes. Strangers will come up to you in cafés and ask you, _"that is amazing. are you some sort of genius?"_ Finally, you'll begin to get the sort of attention that you always felt that you deserved. ...or maybe you'll just use the time that you saved to start flossing more often. __Oh My Zsh is a way of life!__ Once installed, your terminal prompt will become the talk of the town _or your money back!_ Each time you interact with your command prompt, you'll be able take advantage of the hundreds of bundled plugins and pretty themes. Strangers will come up to you in cafés and ask you, _"that is amazing. are you some sort of genius?"_ Finally, you'll begin to get the sort of attention that you always felt that you deserved. ...or maybe you'll just use the time that you saved to start flossing more often.
To learn more, visit http://ohmyz.sh and/or follow [ohmyzsh](https://twitter.com/ohmyzsh) on twitter. To learn more, visit http://ohmyz.sh and/or follow [ohmyzsh](https://twitter.com/ohmyzsh) on Twitter.
## Getting Started ## Getting Started
@ -43,7 +43,9 @@ If you spot a plugin (or several) that you would like to use with Oh My Zsh, you
For example, this line might begin to look like... For example, this line might begin to look like...
`plugins=(git bundler osx rake ruby)` ```shell
plugins=(git bundler osx rake ruby)
```
#### Using Plugins #### Using Plugins
@ -51,7 +53,7 @@ Most plugins (should! we're working on this) include a __README__, which documen
### Themes ### Themes
We'll admit it. Early in the Oh My Zsh world... we may have gotten far too theme happy. We have over one hundred themes now bundled. Most of them have [screenshots](https://wiki.github.com/robbyrussell/oh-my-zsh/themes) on the wiki. Check them out! We'll admit it. Early in the Oh My Zsh world, we may have gotten a bit too theme happy. We have over one hundred themes now bundled. Most of them have [screenshots](https://wiki.github.com/robbyrussell/oh-my-zsh/themes) on the wiki. Check them out!
#### Selecting a Theme #### Selecting a Theme
@ -59,23 +61,37 @@ _Robby's theme is the default one. It's not the fanciest one. It's not the simpl
Once you find a theme that you want to use, you will need to edit the `~/.zshrc` file. You'll see an environment variable (all caps) in there that looks like: Once you find a theme that you want to use, you will need to edit the `~/.zshrc` file. You'll see an environment variable (all caps) in there that looks like:
`ZSH_THEME="robbyrussell"` ```shell
ZSH_THEME="robbyrussell"
```
To use a different theme, simple change the value to match the name of your desired theme. For example: To use a different theme, simply change the value to match the name of your desired theme. For example:
`ZSH_THEME="agnoster"` (this is one of the fancy ones) ```shell
ZSH_THEME="agnoster" # (this is one of the fancy ones)
```
Open up a new terminal window and your prompt should look something like... Open up a new terminal window and your prompt should look something like...
In case you did not find a suitable theme for your needs, please have a look at the wiki for [more themes](https://github.com/robbyrussell/oh-my-zsh/wiki/External-themes). ![Agnoster theme](https://cloud.githubusercontent.com/assets/2618447/6316862/70f58fb6-ba03-11e4-82c9-c083bf9a6574.png)
In case you did not find a suitable theme for your needs, please have a look at the wiki for [more of them](https://github.com/robbyrussell/oh-my-zsh/wiki/External-themes).
If you're feeling feisty, you can let the computer select one randomly for you each time you open a new terminal window.
```shell
ZSH_THEME="random" # (...please let it be pie... please be some pie..)
```
## Advanced Topics ## Advanced Topics
If you're the type that likes to get their hands dirty... these sections might resonate. If you're the type that likes to get their hands dirty, these sections might resonate.
### Advanced Installation ### Advanced Installation
For those who want to install this manually and/or set custom paths. Some users may want to change the default path, or manually install Oh My Zsh.
#### Custom Directory #### Custom Directory
@ -83,27 +99,37 @@ The default location is `~/.oh-my-zsh` (hidden in your home directory)
If you'd like to change the install directory with the `ZSH` environment variable, either by running `export ZSH=/your/path` before installing, or by setting it before the end of the install pipeline like this: If you'd like to change the install directory with the `ZSH` environment variable, either by running `export ZSH=/your/path` before installing, or by setting it before the end of the install pipeline like this:
`curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | ZSH=~/.dotfiles/zsh sh` ```shell
curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | ZSH=~/.dotfiles/zsh sh
```
#### Manual Installation #### Manual Installation
##### 1. Clone the repository: ##### 1. Clone the repository:
`git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh` ```shell
git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
```
##### 2. *Optionally*, backup your existing @~/.zshrc@ file: ##### 2. *Optionally*, backup your existing `~/.zshrc` file:
`cp ~/.zshrc ~/.zshrc.orig` ```shell
cp ~/.zshrc ~/.zshrc.orig
```
##### 3. Create a new zsh configuration file ##### 3. Create a new zsh configuration file
You can create a new zsh config file by copying the template that we included for you. You can create a new zsh config file by copying the template that we included for you.
`cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc` ```shell
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
```
##### 4. Change your default shell ##### 4. Change your default shell
`chsh -s /bin/zsh` ```shell
chsh -s /bin/zsh
```
##### 5. Initialize your new zsh configuration ##### 5. Initialize your new zsh configuration
@ -120,7 +146,7 @@ If you have any hiccups installing, here are a few common fixes.
If you want to override any of the default behaviors, just add a new file (ending in `.zsh`) in the `custom/` directory. If you want to override any of the default behaviors, just add a new file (ending in `.zsh`) in the `custom/` directory.
If you have many functions that go well together, you can put them as a `abcyzeae.plugin.zsh` file in the `custom/plugins/` directory and then enable this plugin. If you have many functions that go well together, you can put them as a `XYZ.plugin.zsh` file in the `custom/plugins/` directory and then enable this plugin.
If you would like to override the functionality of a plugin distributed with Oh My Zsh, create a plugin of the same name in the `custom/plugins/` directory and it will be loaded instead of the one in `plugins/`. If you would like to override the functionality of a plugin distributed with Oh My Zsh, create a plugin of the same name in the `custom/plugins/` directory and it will be loaded instead of the one in `plugins/`.
@ -128,17 +154,23 @@ If you would like to override the functionality of a plugin distributed with Oh
By default, you will be prompted to check for upgrades every few weeks. If you would like `oh-my-zsh` to automatically upgrade itself without prompting you, set the following in your `~/.zshrc`: By default, you will be prompted to check for upgrades every few weeks. If you would like `oh-my-zsh` to automatically upgrade itself without prompting you, set the following in your `~/.zshrc`:
`DISABLE_UPDATE_PROMPT=true` ```shell
DISABLE_UPDATE_PROMPT=true
```
To disable automatic upgrades, set the following in your `~/.zshrc`: To disable automatic upgrades, set the following in your `~/.zshrc`:
`DISABLE_AUTO_UPDATE=true` ```shell
DISABLE_AUTO_UPDATE=true
```
### Manual Updates ### Manual Updates
If you'd like to upgrade at any point in time (maybe someone just released a new plugin and you don't want to wait a week?)... you just need to run: If you'd like to upgrade at any point in time (maybe someone just released a new plugin and you don't want to wait a week?) you just need to run:
`upgrade_oh_my_zsh` ```shell
upgrade_oh_my_zsh
```
Magic! Magic!
@ -154,7 +186,7 @@ I'm far from being a [Zsh](http://www.zsh.org/) expert and suspect there are man
We also need people to test out pull-requests. So take a look through [the open issues](https://github.com/robbyrussell/oh-my-zsh/issues) and help where you can. We also need people to test out pull-requests. So take a look through [the open issues](https://github.com/robbyrussell/oh-my-zsh/issues) and help where you can.
### Do NOT Send Us Themes ### Do NOT send us themes
We have (more than) enough themes for the time being. Please add your theme to the [external themes](https://github.com/robbyrussell/oh-my-zsh/wiki/External-themes) wiki page. We have (more than) enough themes for the time being. Please add your theme to the [external themes](https://github.com/robbyrussell/oh-my-zsh/wiki/External-themes) wiki page.
@ -166,12 +198,12 @@ Thank you so much!
## Follow Us ## Follow Us
We have an [ohmyzsh](https://twitter.com/ohmyzsh) account. You should follow it. We have an [@ohmyzsh](https://twitter.com/ohmyzsh) Twitter account. You should follow it.
## Merchandise ## Merchandise
We have [stickers](http://shop.planetargon.com/products/ohmyzsh-stickers-set-of-3-stickers) and [shirts](http://shop.planetargon.com/products/ohmyzsh-t-shirts) for you to show off your love of Oh My Zsh. Again, this will help you become the talk of the town! We have [stickers](http://shop.planetargon.com/products/ohmyzsh-stickers-set-of-3-stickers) and [shirts](http://shop.planetargon.com/products/ohmyzsh-t-shirts) for you to show off your love of Oh My Zsh. Again, this will help you become the talk of the town!
## LICENSE ## License
Oh My Zsh is released under the [MIT license](https://github.com/robbyrussell/oh-my-zsh/blob/master/MIT-LICENSE.txt). Oh My Zsh is released under the [MIT license](https://github.com/robbyrussell/oh-my-zsh/blob/master/MIT-LICENSE.txt).

60
lib/compfix.zsh Normal file
View file

@ -0,0 +1,60 @@
# Handle completions insecurities (i.e., completion-dependent directories with
# insecure ownership or permissions) by:
#
# * Human-readably notifying the user of these insecurities.
# * Moving away all existing completion caches to a temporary directory. Since
# any of these caches may have been generated from insecure directories, they
# are all suspect now. Failing to do so typically causes subsequent compinit()
# calls to fail with "command not found: compdef" errors. (That's bad.)
function handle_completion_insecurities() {
# List of the absolute paths of all unique insecure directories, split on
# newline from compaudit()'s output resembling:
#
# There are insecure directories:
# /usr/share/zsh/site-functions
# /usr/share/zsh/5.0.6/functions
# /usr/share/zsh
# /usr/share/zsh/5.0.6
#
# Since the ignorable first line is printed to stderr and thus not captured,
# stderr is squelched to prevent this output from leaking to the user.
local -aU insecure_dirs
insecure_dirs=( ${(f@):-"$(compaudit 2>/dev/null)"} )
# If no such directories exist, get us out of here.
if (( ! ${#insecure_dirs} )); then
print "[oh-my-zsh] No insecure completion-dependent directories detected."
return
fi
# List ownership and permissions of all insecure directories.
print "[oh-my-zsh] Insecure completion-dependent directories detected:"
ls -ld "${(@)insecure_dirs}"
print "[oh-my-zsh] For safety, completions will be disabled until you manually fix all"
print "[oh-my-zsh] insecure directory permissions and ownership and restart oh-my-zsh."
print "[oh-my-zsh] See the above list for directories with group or other writability.\n"
# Locally enable the "NULL_GLOB" option, thus removing unmatched filename
# globs from argument lists *AND* printing no warning when doing so. Failing
# to do so prints an unreadable warning if no completion caches exist below.
setopt local_options null_glob
# List of the absolute paths of all unique existing completion caches.
local -aU zcompdump_files
zcompdump_files=( "${ZSH_COMPDUMP}"(.) "${ZDOTDIR:-${HOME}}"/.zcompdump* )
# Move such caches to a temporary directory.
if (( ${#zcompdump_files} )); then
# Absolute path of the directory to which such files will be moved.
local ZSH_ZCOMPDUMP_BAD_DIR="${ZSH_CACHE_DIR}/zcompdump-bad"
# List such files first.
print "[oh-my-zsh] Insecure completion caches also detected:"
ls -l "${(@)zcompdump_files}"
# For safety, move rather than permanently remove such files.
print "[oh-my-zsh] Moving to \"${ZSH_ZCOMPDUMP_BAD_DIR}/\"...\n"
mkdir -p "${ZSH_ZCOMPDUMP_BAD_DIR}"
mv "${(@)zcompdump_files}" "${ZSH_ZCOMPDUMP_BAD_DIR}/"
fi
}

View file

@ -58,9 +58,13 @@ zstyle ':completion:*:*:*:users' ignored-patterns \
# ... unless we really want to. # ... unless we really want to.
zstyle '*' single-ignored show zstyle '*' single-ignored show
if [ "x$COMPLETION_WAITING_DOTS" = "xtrue" ]; then if [[ $COMPLETION_WAITING_DOTS = true ]]; then
expand-or-complete-with-dots() { expand-or-complete-with-dots() {
echo -n "\e[31m......\e[0m" # toggle line-wrapping off and back on again
[[ -n "$terminfo[rmam]" && -n "$terminfo[smam]" ]] && echoti rmam
print -Pn "%{%F{red}......%f%}"
[[ -n "$terminfo[rmam]" && -n "$terminfo[smam]" ]] && echoti smam
zle expand-or-complete zle expand-or-complete
zle redisplay zle redisplay
} }

335
lib/diagnostics.zsh Normal file
View file

@ -0,0 +1,335 @@
# diagnostics.zsh
#
# Diagnostic and debugging support for oh-my-zsh
# omz_diagnostic_dump()
#
# Author: Andrew Janke <andrew@apjanke.net>
#
# Usage:
#
# omz_diagnostic_dump [-v] [-V] [file]
#
# NOTE: This is a work in progress. Its interface and behavior are going to change,
# and probably in non-back-compatible ways.
#
# Outputs a bunch of information about the state and configuration of
# oh-my-zsh, zsh, and the user's system. This is intended to provide a
# bunch of context for diagnosing your own or a third party's problems, and to
# be suitable for posting to public bug reports.
#
# The output is human-readable and its format may change over time. It is not
# suitable for parsing. All the output is in one single file so it can be posted
# as a gist or bug comment on GitHub. GitHub doesn't support attaching tarballs
# or other files to bugs; otherwise, this would probably have an option to produce
# tarballs that contain copies of the config and customization files instead of
# catting them all in to one file.
#
# This is intended to be widely portable, and run anywhere that oh-my-zsh does.
# Feel free to report any portability issues as bugs.
#
# This is written in a defensive style so it still works (and can detect) cases when
# basic functionality like echo and which have been redefined. In particular, almost
# everything is invoked with "builtin" or "command", to work in the face of user
# redefinitions.
#
# OPTIONS
#
# [file] Specifies the output file. If not given, a file in the current directory
# is selected automatically.
#
# -v Increase the verbosity of the dump output. May be specified multiple times.
# Verbosity levels:
# 0 - Basic info, shell state, omz configuration, git state
# 1 - (default) Adds key binding info and configuration file contents
# 2 - Adds zcompdump file contents
#
# -V Reduce the verbosity of the dump output. May be specified multiple times.
#
# TODO:
# * Multi-file capture
# * Add automatic gist uploading
# * Consider whether to move default output file location to TMPDIR. More robust
# but less user friendly.
#
function omz_diagnostic_dump() {
emulate -L zsh
builtin echo "Generating diagnostic dump; please be patient..."
local thisfcn=omz_diagnostic_dump
local -A opts
local opt_verbose opt_noverbose opt_outfile
local timestamp=$(date +%Y%m%d-%H%M%S)
local outfile=omz_diagdump_$timestamp.txt
builtin zparseopts -A opts -D -- "v+=opt_verbose" "V+=opt_noverbose"
local verbose n_verbose=${#opt_verbose} n_noverbose=${#opt_noverbose}
(( verbose = 1 + n_verbose - n_noverbose ))
if [[ ${#*} > 0 ]]; then
opt_outfile=$1
fi
if [[ ${#*} > 1 ]]; then
builtin echo "$thisfcn: error: too many arguments" >&2
return 1
fi
if [[ -n "$opt_outfile" ]]; then
outfile="$opt_outfile"
fi
# Always write directly to a file so terminal escape sequences are
# captured cleanly
_omz_diag_dump_one_big_text &> "$outfile"
if [[ $? != 0 ]]; then
builtin echo "$thisfcn: error while creating diagnostic dump; see $outfile for details"
fi
builtin echo
builtin echo Diagnostic dump file created at: "$outfile"
builtin echo
builtin echo To share this with OMZ developers, post it as a gist on GitHub
builtin echo at "https://gist.github.com" and share the link to the gist.
builtin echo
builtin echo "WARNING: This dump file contains all your zsh and omz configuration files,"
builtin echo "so don't share it publicly if there's sensitive information in them."
builtin echo
}
function _omz_diag_dump_one_big_text() {
local program programs progfile md5
builtin echo oh-my-zsh diagnostic dump
builtin echo
builtin echo $outfile
builtin echo
# Basic system and zsh information
command date
command uname -a
builtin echo OSTYPE=$OSTYPE
builtin echo ZSH_VERSION=$ZSH_VERSION
builtin echo User: $USER
builtin echo umask: $(umask)
builtin echo
_omz_diag_dump_os_specific_version
builtin echo
# Installed programs
programs=(sh zsh ksh bash sed cat grep ls find git posh)
local progfile="" extra_str="" sha_str=""
for program in $programs; do
extra_str="" sha_str=""
progfile=$(builtin which $program)
if [[ $? == 0 ]]; then
if [[ -e $progfile ]]; then
if builtin whence shasum &>/dev/null; then
sha_str=($(command shasum $progfile))
sha_str=$sha_str[1]
extra_str+=" SHA $sha_str"
fi
if [[ -h "$progfile" ]]; then
extra_str+=" ( -> ${progfile:A} )"
fi
fi
builtin printf '%-9s %-20s %s\n' "$program is" "$progfile" "$extra_str"
else
builtin echo "$program: not found"
fi
done
builtin echo
builtin echo Command Versions:
builtin echo "zsh: $(zsh --version)"
builtin echo "this zsh session: $ZSH_VERSION"
builtin echo "bash: $(bash --version | command grep bash)"
builtin echo "git: $(git --version)"
builtin echo "grep: $(grep --version)"
builtin echo
# Core command definitions
_omz_diag_dump_check_core_commands || return 1
builtin echo
# ZSH Process state
builtin echo Process state:
builtin echo pwd: $PWD
if builtin whence pstree &>/dev/null; then
builtin echo Process tree for this shell:
pstree -p $$
else
ps -fT
fi
builtin set | command grep -a '^\(ZSH\|plugins\|TERM\|LC_\|LANG\|precmd\|chpwd\|preexec\|FPATH\|TTY\|DISPLAY\|PATH\)\|OMZ'
builtin echo
#TODO: Should this include `env` instead of or in addition to `export`?
builtin echo Exported:
builtin echo $(builtin export | command sed 's/=.*//')
builtin echo
builtin echo Locale:
command locale
builtin echo
# Zsh installation and configuration
builtin echo Zsh configuration:
builtin echo setopt: $(builtin setopt)
builtin echo
builtin echo zstyle:
builtin zstyle
builtin echo
builtin echo 'compaudit output:'
compaudit
builtin echo
builtin echo '$fpath directories:'
command ls -lad $fpath
builtin echo
# Oh-my-zsh installation
builtin echo oh-my-zsh installation:
command ls -ld ~/.z*
command ls -ld ~/.oh*
builtin echo
builtin echo oh-my-zsh git state:
(cd $ZSH && builtin echo "HEAD: $(git rev-parse HEAD)" && git remote -v && git status | command grep "[^[:space:]]")
if [[ $verbose -ge 1 ]]; then
(cd $ZSH && git reflog --date=default | command grep pull)
fi
builtin echo
if [[ -e $ZSH_CUSTOM ]]; then
local custom_dir=$ZSH_CUSTOM
if [[ -h $custom_dir ]]; then
custom_dir=$(cd $custom_dir && pwd -P)
fi
builtin echo "oh-my-zsh custom dir:"
builtin echo " $ZSH_CUSTOM ($custom_dir)"
(cd ${custom_dir:h} && command find ${custom_dir:t} -name .git -prune -o -print)
builtin echo
fi
# Key binding and terminal info
if [[ $verbose -ge 1 ]]; then
builtin echo "bindkey:"
builtin bindkey
builtin echo
builtin echo "infocmp:"
command infocmp -L
builtin echo
fi
# Configuration file info
local zdotdir=${ZDOTDIR:-$HOME}
builtin echo "Zsh configuration files:"
local cfgfile cfgfiles
# Some files for bash that zsh does not use are intentionally included
# to help with diagnosing behavior differences between bash and zsh
cfgfiles=( /etc/zshenv /etc/zprofile /etc/zshrc /etc/zlogin /etc/zlogout
$zdotdir/.zshenv $zdotdir/.zprofile $zdotdir/.zshrc $zdotdir/.zlogin $zdotdir/.zlogout
~/.zsh.pre-oh-my-zsh
/etc/bashrc /etc/profile ~/.bashrc ~/.profile ~/.bash_profile ~/.bash_logout )
command ls -lad $cfgfiles 2>&1
builtin echo
if [[ $verbose -ge 1 ]]; then
for cfgfile in $cfgfiles; do
_omz_diag_dump_echo_file_w_header $cfgfile
done
fi
builtin echo
builtin echo "Zsh compdump files:"
local dumpfile dumpfiles
command ls -lad $zdotdir/.zcompdump*
dumpfiles=( $zdotdir/.zcompdump*(N) )
if [[ $verbose -ge 2 ]]; then
for dumpfile in $dumpfiles; do
_omz_diag_dump_echo_file_w_header $dumpfile
done
fi
}
function _omz_diag_dump_check_core_commands() {
builtin echo "Core command check:"
local redefined name builtins externals
redefined=()
# All the zsh non-module builtin commands
# These are taken from the zsh reference manual for 5.0.2
# Commands from modules should not be included.
# (For back-compatibility, if any of these are newish, they should be removed,
# or at least made conditional on the version of the current running zsh.)
# "history" is also excluded because OMZ is known to redefine that
builtins=( alias autoload bg bindkey break builtin bye cd chdir command
comparguments compcall compctl compdescribe compfiles compgroups compquote comptags
comptry compvalues continue declare dirs disable disown echo echotc echoti emulate
enable eval exec exit export false fc fg float functions getln getopts hash
integer jobs kill let limit local log logout noglob popd print printf
pushd pushln pwd r read readonly rehash return sched set setopt shift
source suspend test times trap true ttyctl type typeset ulimit umask unalias
unfunction unhash unlimit unset unsetopt vared wait whence where which zcompile
zle zmodload zparseopts zregexparse zstyle )
builtins_fatal=( builtin command local )
externals=( zsh )
for name in $builtins; do
if [[ $(builtin whence -w $name) != "$name: builtin" ]]; then
builtin echo "builtin '$name' has been redefined"
builtin which $name
redefined+=$name
fi
done
for name in $externals; do
if [[ $(builtin whence -w $name) != "$name: command" ]]; then
builtin echo "command '$name' has been redefined"
builtin which $name
redefined+=$name
fi
done
if [[ -n "$redefined" ]]; then
builtin echo "SOME CORE COMMANDS HAVE BEEN REDEFINED: $redefined"
else
builtin echo "All core commands are defined normally"
fi
}
function _omz_diag_dump_echo_file_w_header() {
local file=$1
if [[ ( -f $file || -h $file ) ]]; then
builtin echo "========== $file =========="
if [[ -h $file ]]; then
builtin echo "========== ( => ${file:A} ) =========="
fi
command cat $file
builtin echo "========== end $file =========="
builtin echo
elif [[ -d $file ]]; then
builtin echo "File '$file' is a directory"
elif [[ ! -e $file ]]; then
builtin echo "File '$file' does not exist"
else
command ls -lad "$file"
fi
}
function _omz_diag_dump_os_specific_version() {
local osname osver version_file version_files
case "$OSTYPE" in
darwin*)
osname=$(command sw_vers -productName)
osver=$(command sw_vers -productVersion)
builtin echo "OS Version: $osname $osver build $(sw_vers -buildVersion)"
;;
cygwin)
command systeminfo | command head -4 | command tail -2
;;
esac
if builtin which lsb_release >/dev/null; then
builtin echo "OS Release: $(command lsb_release -s -d)"
fi
version_files=( /etc/*-release(N) /etc/*-version(N) /etc/*_version(N) )
for version_file in $version_files; do
builtin echo "$version_file:"
command cat "$version_file"
builtin echo
done
}

View file

@ -15,6 +15,22 @@ function take() {
cd $1 cd $1
} }
function open_command() {
local open_cmd
# define the open command
case "$OSTYPE" in
darwin*) open_cmd="open" ;;
cygwin*) open_cmd="cygstart" ;;
linux*) open_cmd="xdg-open" ;;
*) echo "Platform $OSTYPE not supported"
return 1
;;
esac
nohup $open_cmd "$@" &>/dev/null
}
# #
# Get the value of an alias. # Get the value of an alias.
# #
@ -73,3 +89,135 @@ function env_default() {
env | grep -q "^$1=" && return 0 env | grep -q "^$1=" && return 0
export "$1=$2" && return 3 export "$1=$2" && return 3
} }
# Required for $langinfo
zmodload zsh/langinfo
# URL-encode a string
#
# Encodes a string using RFC 2396 URL-encoding (%-escaped).
# See: https://www.ietf.org/rfc/rfc2396.txt
#
# By default, reserved characters and unreserved "mark" characters are
# not escaped by this function. This allows the common usage of passing
# an entire URL in, and encoding just special characters in it, with
# the expectation that reserved and mark characters are used appropriately.
# The -r and -m options turn on escaping of the reserved and mark characters,
# respectively, which allows arbitrary strings to be fully escaped for
# embedding inside URLs, where reserved characters might be misinterpreted.
#
# Prints the encoded string on stdout.
# Returns nonzero if encoding failed.
#
# Usage:
# omz_urlencode [-r] [-m] <string>
#
# -r causes reserved characters (;/?:@&=+$,) to be escaped
#
# -m causes "mark" characters (_.!~*''()-) to be escaped
#
# -P causes spaces to be encoded as '%20' instead of '+'
function omz_urlencode() {
emulate -L zsh
zparseopts -D -E -a opts r m P
local in_str=$1
local url_str=""
local spaces_as_plus
if [[ -z $opts[(r)-P] ]]; then spaces_as_plus=1; fi
local str="$in_str"
# URLs must use UTF-8 encoding; convert str to UTF-8 if required
local encoding=$langinfo[CODESET]
local safe_encodings
safe_encodings=(UTF-8 utf8 US-ASCII)
if [[ -z ${safe_encodings[(r)$encoding]} ]]; then
str=$(echo -E "$str" | iconv -f $encoding -t UTF-8)
if [[ $? != 0 ]]; then
echo "Error converting string from $encoding to UTF-8" >&2
return 1
fi
fi
# Use LC_CTYPE=C to process text byte-by-byte
local i byte ord LC_ALL=C
export LC_ALL
local reserved=';/?:@&=+$,'
local mark='_.!~*''()-'
local dont_escape="[A-Za-z0-9"
if [[ -z $opts[(r)-r] ]]; then
dont_escape+=$reserved
fi
# $mark must be last because of the "-"
if [[ -z $opts[(r)-m] ]]; then
dont_escape+=$mark
fi
dont_escape+="]"
# Implemented to use a single printf call and avoid subshells in the loop,
# for performance (primarily on Windows).
local url_str=""
for (( i = 1; i <= ${#str}; ++i )); do
byte="$str[i]"
if [[ "$byte" =~ "$dont_escape" ]]; then
url_str+="$byte"
else
if [[ "$byte" == " " && -n $spaces_as_plus ]]; then
url_str+="+"
else
ord=$(( [##16] #byte ))
url_str+="%$ord"
fi
fi
done
echo -E "$url_str"
}
# URL-decode a string
#
# Decodes a RFC 2396 URL-encoded (%-escaped) string.
# This decodes the '+' and '%' escapes in the input string, and leaves
# other characters unchanged. Does not enforce that the input is a
# valid URL-encoded string. This is a convenience to allow callers to
# pass in a full URL or similar strings and decode them for human
# presentation.
#
# Outputs the encoded string on stdout.
# Returns nonzero if encoding failed.
#
# Usage:
# omz_urldecode <urlstring> - prints decoded string followed by a newline
function omz_urldecode {
emulate -L zsh
local encoded_url=$1
# Work bytewise, since URLs escape UTF-8 octets
local caller_encoding=$langinfo[CODESET]
local LC_ALL=C
export LC_ALL
# Change + back to ' '
local tmp=${encoded_url:gs/+/ /}
# Protect other escapes to pass through the printf unchanged
tmp=${tmp:gs/\\/\\\\/}
# Handle %-escapes by turning them into `\xXX` printf escapes
tmp=${tmp:gs/%/\\x/}
local decoded
eval "decoded=\$'$tmp'"
# Now we have a UTF-8 encoded string in the variable. We need to re-encode
# it if caller is in a non-UTF-8 locale.
local safe_encodings
safe_encodings=(UTF-8 utf8 US-ASCII)
if [[ -z ${safe_encodings[(r)$caller_encoding]} ]]; then
decoded=$(echo -E "$decoded" | iconv -f UTF-8 -t $caller_encoding)
if [[ $? != 0 ]]; then
echo "Error converting string from UTF-8 to $caller_encoding" >&2
return 1
fi
fi
echo -E "$decoded"
}

View file

@ -36,7 +36,10 @@ git_remote_status() {
ahead=$(command git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l) ahead=$(command git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l)
behind=$(command git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l) behind=$(command git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l)
if [ $ahead -gt 0 ] && [ $behind -eq 0 ] if [ $ahead -eq 0 ] && [ $behind -eq 0 ]
then
echo "$ZSH_THEME_GIT_PROMPT_EQUAL_REMOTE"
elif [ $ahead -gt 0 ] && [ $behind -eq 0 ]
then then
git_remote_status="$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE" git_remote_status="$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE"
git_remote_status_detailed="$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE_COLOR$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE$((ahead))%{$reset_color%}" git_remote_status_detailed="$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE_COLOR$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE$((ahead))%{$reset_color%}"

View file

@ -7,6 +7,9 @@
# (In screen, only short_tab_title is used) # (In screen, only short_tab_title is used)
# Limited support for Apple Terminal (Terminal can't set window and tab separately) # Limited support for Apple Terminal (Terminal can't set window and tab separately)
function title { function title {
emulate -L zsh
setopt prompt_subst
[[ "$EMACS" == *term* ]] && return [[ "$EMACS" == *term* ]] && return
# if $2 is unset use $1 as default # if $2 is unset use $1 as default
@ -23,9 +26,14 @@ function title {
ZSH_THEME_TERM_TAB_TITLE_IDLE="%15<..<%~%<<" #15 char left truncated PWD ZSH_THEME_TERM_TAB_TITLE_IDLE="%15<..<%~%<<" #15 char left truncated PWD
ZSH_THEME_TERM_TITLE_IDLE="%n@%m: %~" ZSH_THEME_TERM_TITLE_IDLE="%n@%m: %~"
# Avoid duplication of directory in terminals with independent dir display
if [[ $TERM_PROGRAM == Apple_Terminal ]]; then
ZSH_THEME_TERM_TITLE_IDLE="%n@%m"
fi
# Runs before showing the prompt # Runs before showing the prompt
function omz_termsupport_precmd { function omz_termsupport_precmd {
emulate -L zsh
if [[ $DISABLE_AUTO_TITLE == true ]]; then if [[ $DISABLE_AUTO_TITLE == true ]]; then
return return
fi fi
@ -35,15 +43,15 @@ function omz_termsupport_precmd {
# Runs before executing the command # Runs before executing the command
function omz_termsupport_preexec { function omz_termsupport_preexec {
emulate -L zsh
if [[ $DISABLE_AUTO_TITLE == true ]]; then if [[ $DISABLE_AUTO_TITLE == true ]]; then
return return
fi fi
emulate -L zsh
setopt extended_glob setopt extended_glob
# cmd name only, or if this is sudo or ssh, the next cmd # cmd name only, or if this is sudo or ssh, the next cmd
local CMD=${1[(wr)^(*=*|sudo|ssh|rake|-*)]:gs/%/%%} local CMD=${1[(wr)^(*=*|sudo|ssh|mosh|rake|-*)]:gs/%/%%}
local LINE="${2:gs/%/%%}" local LINE="${2:gs/%/%%}"
title '$CMD' '%100>...>$LINE%<<' title '$CMD' '%100>...>$LINE%<<'
@ -53,14 +61,28 @@ precmd_functions+=(omz_termsupport_precmd)
preexec_functions+=(omz_termsupport_preexec) preexec_functions+=(omz_termsupport_preexec)
# Runs before showing the prompt, to update the current directory in Terminal.app # Keep Apple Terminal.app's current working directory updated
function omz_termsupport_cwd { # Based on this answer: http://superuser.com/a/315029
# Notify Terminal.app of current directory using undocumented OSC sequence # With extra fixes to handle multibyte chars and non-UTF-8 locales
# found in OS X 10.9 and 10.10's /etc/bashrc
if [[ $TERM_PROGRAM == Apple_Terminal ]] && [[ -z $INSIDE_EMACS ]]; then if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then
local PWD_URL="file://$HOSTNAME${PWD// /%20}"
printf '\e]7;%s\a' "$PWD_URL" # Emits the control sequence to notify Terminal.app of the cwd
fi function update_terminalapp_cwd() {
emulate -L zsh
# Identify the directory using a "file:" scheme URL, including
# the host name to disambiguate local vs. remote paths.
# Percent-encode the pathname.
local URL_PATH=$(omz_urlencode -P $PWD)
[[ $? != 0 ]] && return 1
local PWD_URL="file://$HOST$URL_PATH"
# Undocumented Terminal.app-specific control sequence
printf '\e]7;%s\a' $PWD_URL
} }
precmd_functions+=(omz_termsupport_cwd) # Use a precmd hook instead of a chpwd hook to avoid contaminating output
precmd_functions+=(update_terminalapp_cwd)
# Run once to get initial cwd set
update_terminalapp_cwd
fi

View file

@ -11,8 +11,11 @@ then
# otherwise, leave ls as is, because NetBSD's ls doesn't support -G # otherwise, leave ls as is, because NetBSD's ls doesn't support -G
gls --color -d . &>/dev/null 2>&1 && alias ls='gls --color=tty' gls --color -d . &>/dev/null 2>&1 && alias ls='gls --color=tty'
elif [[ "$(uname -s)" == "OpenBSD" ]]; then elif [[ "$(uname -s)" == "OpenBSD" ]]; then
# On OpenBSD, test if "colorls" is installed (this one supports colors); # On OpenBSD, "gls" (ls from GNU coreutils) and "colorls" (ls from base,
# otherwise, leave ls as is, because OpenBSD's ls doesn't support -G # with color and multibyte support) are available from ports. "colorls"
# will be installed on purpose and can't be pulled in by installing
# coreutils, so prefer it to "gls".
gls --color -d . &>/dev/null 2>&1 && alias ls='gls --color=tty'
colorls -G -d . &>/dev/null 2>&1 && alias ls='colorls -G' colorls -G -d . &>/dev/null 2>&1 && alias ls='colorls -G'
else else
ls --color -d . &>/dev/null 2>&1 && alias ls='ls --color=tty' || alias ls='ls -G' ls --color -d . &>/dev/null 2>&1 && alias ls='ls --color=tty' || alias ls='ls -G'

View file

@ -8,6 +8,9 @@ fi
# add a function path # add a function path
fpath=($ZSH/functions $ZSH/completions $fpath) fpath=($ZSH/functions $ZSH/completions $fpath)
# Load all stock functions (from $fpath files) called below.
autoload -U compaudit compinit
# Set ZSH_CUSTOM to the path where your custom config files # Set ZSH_CUSTOM to the path where your custom config files
# and plugins exists, or else we will use the default custom/ # and plugins exists, or else we will use the default custom/
if [[ -z "$ZSH_CUSTOM" ]]; then if [[ -z "$ZSH_CUSTOM" ]]; then
@ -29,11 +32,6 @@ for config_file ($ZSH/lib/*.zsh); do
source $config_file source $config_file
done done
# Load all of your custom configurations from custom/
for config_file ($ZSH_CUSTOM/*.zsh(N)); do
source $config_file
done
unset config_file
is_plugin() { is_plugin() {
local base_dir=$1 local base_dir=$1
@ -64,9 +62,14 @@ if [ -z "$ZSH_COMPDUMP" ]; then
ZSH_COMPDUMP="${ZDOTDIR:-${HOME}}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}" ZSH_COMPDUMP="${ZDOTDIR:-${HOME}}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}"
fi fi
# Load and run compinit # If completion insecurities exist, warn the user without enabling completions.
autoload -U compinit if ! compaudit &>/dev/null; then
compinit -i -d "${ZSH_COMPDUMP}" # This function resides in the "lib/compfix.zsh" script sourced above.
handle_completion_insecurities
# Else, enable and cache completions to the desired file.
else
compinit -d "${ZSH_COMPDUMP}"
fi
# Load all of the plugins that were defined in ~/.zshrc # Load all of the plugins that were defined in ~/.zshrc
for plugin ($plugins); do for plugin ($plugins); do
@ -77,6 +80,12 @@ for plugin ($plugins); do
fi fi
done done
# Load all of your custom configurations from custom/
for config_file ($ZSH_CUSTOM/*.zsh(N)); do
source $config_file
done
unset config_file
# Load the theme # Load the theme
if [ "$ZSH_THEME" = "random" ]; then if [ "$ZSH_THEME" = "random" ]; then
themes=($ZSH/themes/*zsh-theme) themes=($ZSH/themes/*zsh-theme)

View file

@ -1,6 +1,8 @@
## atom ## atom
Plugin for Atom, a cross platform text and code editor, available for Linux, Mac OS X, and Windows. This plugin makes "at" a useful function for invoking the Atom Editor.
Originally by Github user [aforty](https://github.com/aforty) for OSX, modified to alias 'at' to 'atom' for Linux, since atom already works on the terminal for Linux, and calling 'at' in a non-OSX environment should still work.
### Requirements ### Requirements
@ -10,8 +12,12 @@ Plugin for Atom, a cross platform text and code editor, available for Linux, Mac
* If `at` command is called without an argument, launch Atom * If `at` command is called without an argument, launch Atom
* If `at` is passed a directory, `cd` to it and open it in Atom * If `at` is passed a directory, open it in Atom
* If `at` is passed a file, open it in Atom * If `at` is passed a file, open it in Atom
* if `att` command is called, it is equivalent to `at .`, opening the current folder in Atom ### Examples
* Open the current dir in atom: `at .`
* Open another dir in atom: `at path/to/folder`
* Open a file: `at filename.extension`

View file

@ -1,3 +1,8 @@
# Gets OS Type
unamestr=$(uname -s)
# If OSX
if [[ "$unamestr" == 'Darwin' ]]; then
local _atom_paths > /dev/null 2>&1 local _atom_paths > /dev/null 2>&1
_atom_paths=( _atom_paths=(
"$HOME/Applications/Atom.app" "$HOME/Applications/Atom.app"
@ -10,5 +15,8 @@ for _atom_path in $_atom_paths; do
break break
fi fi
done done
# If Linux
alias att='at .' elif [[ "$unamestr" == 'Linux' ]]; then
# Alerts the user if 'atom' is not a found command.
type atom >/dev/null 2>&1 && alias at="atom" || { echo >&2 "You have enabled the atom oh-my-zsh plugin on Linux, but atom is not a recognized command. Please make sure you have it installed before using this plugin."; }
fi

View file

@ -15,7 +15,7 @@ if [ $commands[autojump] ]; then # check if autojump is installed
. /usr/local/share/autojump/autojump.zsh . /usr/local/share/autojump/autojump.zsh
elif [ -f /opt/local/etc/profile.d/autojump.zsh ]; then # mac os x with ports elif [ -f /opt/local/etc/profile.d/autojump.zsh ]; then # mac os x with ports
. /opt/local/etc/profile.d/autojump.zsh . /opt/local/etc/profile.d/autojump.zsh
elif [ $commands[brew] -a -f `brew --prefix`/etc/autojump.zsh ]; then # mac os x with brew elif [ $commands[brew] -a -f `brew --prefix`/etc/autojump.sh ]; then # mac os x with brew
. `brew --prefix`/etc/autojump.zsh . `brew --prefix`/etc/autojump.sh
fi fi
fi fi

View file

@ -11,11 +11,16 @@ export AWS_HOME=~/.aws
function agp { function agp {
echo $AWS_DEFAULT_PROFILE echo $AWS_DEFAULT_PROFILE
} }
function asp { function asp {
local rprompt=${RPROMPT/<aws:$(agp)>/}
export AWS_DEFAULT_PROFILE=$1 export AWS_DEFAULT_PROFILE=$1
export AWS_PROFILE=$1 export AWS_PROFILE=$1
export RPROMPT="<aws:$AWS_DEFAULT_PROFILE>$RPROMPT"
export RPROMPT="<aws:$AWS_DEFAULT_PROFILE>$rprompt"
} }
function aws_profiles { function aws_profiles {
reply=($(grep profile $AWS_HOME/config|sed -e 's/.*profile \([a-zA-Z0-9_-]*\).*/\1/')) reply=($(grep profile $AWS_HOME/config|sed -e 's/.*profile \([a-zA-Z0-9_-]*\).*/\1/'))
} }

View file

@ -11,31 +11,38 @@ autoload -Uz add-zsh-hook || { print "can't add zsh hook!"; return }
## definitions ## ## definitions ##
if ! (type bgnotify_formatted | grep -q 'function'); then if ! (type bgnotify_formatted | grep -q 'function'); then ## allow custom function override
function bgnotify_formatted { function bgnotify_formatted { ## args: (exit_status, command, elapsed_seconds)
## exit_status, command, elapsed_time elapsed="$(( $3 % 60 ))s"
[ $1 -eq 0 ] && title="#win (took $3 s)" || title="#fail (took $3 s)" (( $3 >= 60 )) && elapsed="$((( $3 % 3600) / 60 ))m $elapsed"
bgnotify "$title" "$2" (( $3 >= 3600 )) && elapsed="$(( $3 / 3600 ))h $elapsed"
[ $1 -eq 0 ] && bgnotify "#win (took $elapsed)" "$2" || bgnotify "#fail (took $elapsed)" "$2"
} }
fi fi
currentWindowId () { currentWindowId () {
if hash osascript 2>/dev/null; then #osx if hash osascript 2>/dev/null; then #osx
osascript -e 'tell application (path to frontmost application as text) to id of front window' 2&> /dev/null || echo "0" osascript -e 'tell application (path to frontmost application as text) to id of front window' 2&> /dev/null || echo "0"
elif hash notify-send 2>/dev/null; then #ubuntu! elif (hash notify-send 2>/dev/null || hash kdialog 2>/dev/null); then #ubuntu!
xprop -root | awk '/NET_ACTIVE_WINDOW/ { print $5; exit }' xprop -root 2> /dev/null | awk '/NET_ACTIVE_WINDOW/{print $5;exit} END{exit !$5}' || echo "0"
else else
echo $EPOCHSECONDS #fallback for windows echo $EPOCHSECONDS #fallback for windows
fi fi
} }
bgnotify () { bgnotify () { ## args: (title, subtitle)
if hash terminal-notifier 2>/dev/null; then #osx if hash terminal-notifier 2>/dev/null; then #osx
terminal-notifier -message "$2" -title "$1" [[ "$TERM_PROGRAM" == 'iTerm.app' ]] && term_id='com.googlecode.iterm2';
[[ "$TERM_PROGRAM" == 'Apple_Terminal' ]] && term_id='com.apple.terminal';
## now call terminal-notifier, (hopefully with $term_id!)
[ -z "$term_id" ] && terminal-notifier -message "$2" -title "$1" >/dev/null ||
terminal-notifier -message "$2" -title "$1" -activate "$term_id" -sender "$term_id" >/dev/null
elif hash growlnotify 2>/dev/null; then #osx growl elif hash growlnotify 2>/dev/null; then #osx growl
growlnotify -m "$1" "$2" growlnotify -m "$1" "$2"
elif hash notify-send 2>/dev/null; then #ubuntu! elif hash notify-send 2>/dev/null; then #ubuntu gnome!
notify-send "$1" "$2" notify-send "$1" "$2"
elif hash kdialog 2>/dev/null; then #ubuntu kde!
kdialog -title "$1" --passivepopup "$2" 5
elif hash notifu 2>/dev/null; then #cygwyn support! elif hash notifu 2>/dev/null; then #cygwyn support!
notifu /m "$2" /p "$1" notifu /m "$2" /p "$1"
fi fi
@ -46,7 +53,7 @@ bgnotify () {
bgnotify_begin() { bgnotify_begin() {
bgnotify_timestamp=$EPOCHSECONDS bgnotify_timestamp=$EPOCHSECONDS
bgnotify_lastcmd=$1 bgnotify_lastcmd="$1"
bgnotify_windowid=$(currentWindowId) bgnotify_windowid=$(currentWindowId)
} }
@ -63,5 +70,8 @@ bgnotify_end() {
bgnotify_timestamp=0 #reset it to 0! bgnotify_timestamp=0 #reset it to 0!
} }
## only enable if a local (non-ssh) connection
if [ -z "$SSH_CLIENT" ] && [ -z "$SSH_TTY" ]; then
add-zsh-hook preexec bgnotify_begin add-zsh-hook preexec bgnotify_begin
add-zsh-hook precmd bgnotify_end add-zsh-hook precmd bgnotify_end
fi

View file

@ -1,10 +1,49 @@
#compdef cap #compdef shipit
#autoload #autoload
# Added `shipit` because `cap` is a reserved word. `cap` completion doesn't work.
# http://zsh.sourceforge.net/Doc/Release/Zsh-Modules.html#The-zsh_002fcap-Module
local curcontext="$curcontext" state line ret=1
local -a _configs
_arguments -C \
'1: :->cmds' \
'2:: :->args' && ret=0
_cap_tasks() {
if [[ -f config/deploy.rb || -f Capfile ]]; then if [[ -f config/deploy.rb || -f Capfile ]]; then
if [[ ! -f .cap_tasks~ || config/deploy.rb -nt .cap_tasks~ ]]; then if [[ ! -f .cap_tasks~ ]]; then
echo "\nGenerating .cap_tasks~..." > /dev/stderr shipit -v --tasks | sed 's/\(\[\)\(.*\)\(\]\)/\2:/' | awk '{command=$2; $1=$2=$3=""; gsub(/^[ \t\r\n]+/, "", $0); gsub(":", "\\:", command); print command"["$0"]"}' > .cap_tasks~
cap -v --tasks | grep '#' | cut -d " " -f 2 > .cap_tasks~
fi fi
compadd `cat .cap_tasks~`
OLD_IFS=$IFS
IFS=$'\n'
_values 'cap commands' $(< .cap_tasks~)
IFS=$OLD_IFS
# zmodload zsh/mapfile
# _values ${(f)mapfile[.cap_tasks~]}
fi fi
}
_cap_stages() {
compadd $(find config/deploy -name \*.rb | cut -d/ -f3 | sed s:.rb::g)
}
case $state in
cmds)
# check if it uses multistage
if [[ -d config/deploy ]]; then
_cap_stages
else
_cap_tasks
fi
ret=0
;;
args)
_cap_tasks
ret=0
;;
esac
return ret

View file

@ -0,0 +1,11 @@
# Added `shipit` because `cap` is a reserved word. `cap` completion doesn't work.
# http://zsh.sourceforge.net/Doc/Release/Zsh-Modules.html#The-zsh_002fcap-Module
func shipit() {
if [ -f Gemfile ]
then
bundle exec cap $*
else
cap $*
fi
}

View file

@ -45,11 +45,11 @@ _source_from_omz_settings() {
zstyle -s :omz:plugins:chruby path _chruby_path zstyle -s :omz:plugins:chruby path _chruby_path
zstyle -s :omz:plugins:chruby auto _chruby_auto zstyle -s :omz:plugins:chruby auto _chruby_auto
if ${_chruby_path} && [[ -r ${_chruby_path} ]]; then if [[ -r ${_chruby_path} ]]; then
source ${_chruby_path} source ${_chruby_path}
fi fi
if ${_chruby_auto} && [[ -r ${_chruby_auto} ]]; then if [[ -r ${_chruby_auto} ]]; then
source ${_chruby_auto} source ${_chruby_auto}
fi fi
} }

View file

@ -0,0 +1,82 @@
#compdef codeclimate
_codeclimate_all_engines() {
engines_all=(`codeclimate engines:list | tail -n +2 | gawk '{ print $2 }' | gawk -F: '{ print $1 }'`)
}
_codeclimate_installed_engines() {
_codeclimate_all_engines
engines_installed=()
if [ -e .codeclimate.yml ]
then
for engine in $engines_all
do
if grep -q $engine ".codeclimate.yml"
then
engines_installed+=$engine
fi
done
fi
}
_codeclimate_not_installed_engines() {
_codeclimate_all_engines
engines_not_installed=()
if [ -e .codeclimate.yml ]
then
for engine in $engines_all
do
if ! grep -q $engine ".codeclimate.yml"
then
engines_not_installed+=$engine
fi
done
fi
}
local curcontext="$curcontext" state line ret=1
local expl
local -a engines_all engines_installed engines_not_installed
_arguments \
'1: :->cmds' \
'*:: :->args' && ret=0
case $state in
cmds)
_values "bundle command" \
"analyze[Analyze all relevant files in the current working directory]" \
"console[Start an interactive session providing access to the classes within the CLI]" \
"engines\:disable[Prevents the engine from being used in this project]" \
"engines\:enable[This engine will be run the next time your project is analyzed]" \
"engines\:install[Compares the list of engines in your .codeclimate.yml file to those that are currently installed, then installs any missing engines]" \
"engines\:list[Lists all available engines in the Code Climate Docker Hub]" \
"engines\:remove[Removes an engine from your .codeclimate.yml file]" \
"help[Displays a list of commands that can be passed to the Code Climate CLI]" \
"init[Generates a new .codeclimate.yml file in the current working directory]" \
"validate-config[Validates the .codeclimate.yml file in the current working directory]" \
"version[Displays the current version of the Code Climate CLI]"
ret=0
;;
args)
case $line[1] in
engines:enable)
_codeclimate_not_installed_engines
_wanted engines_not_installed expl 'not installed engines' compadd -a engines_not_installed ;;
engines:disable|engines:remove)
_codeclimate_installed_engines
_wanted engines_installed expl 'installed engines' compadd -a engines_installed ;;
analyze)
_arguments \
'-f:Output Format:(text json)'
ret=0
;;
esac
;;
esac
return ret

View file

@ -2,11 +2,11 @@
# compile a string of coffeescript and print to output # compile a string of coffeescript and print to output
cf () { cf () {
coffee -peb $1 coffee -peb "$1"
} }
# compile & copy to clipboard # compile & copy to clipboard
cfc () { cfc () {
cf $1 | pbcopy cf "$1" | pbcopy
} }
# compile from pasteboard & print # compile from pasteboard & print

View file

@ -49,7 +49,8 @@ function push_future() {
} }
# Called by zsh when directory changes # Called by zsh when directory changes
function chpwd() { chpwd_functions+=(chpwd_dirhistory)
function chpwd_dirhistory() {
push_past $PWD push_past $PWD
# If DIRHISTORY_CD is not set... # If DIRHISTORY_CD is not set...
if [[ -z "${DIRHISTORY_CD+x}" ]]; then if [[ -z "${DIRHISTORY_CD+x}" ]]; then

View file

@ -11,7 +11,8 @@ if [[ -f ${dirstack_file} ]] && [[ ${#dirstack[*]} -eq 0 ]] ; then
[[ -d $dirstack[1] ]] && cd $dirstack[1] && cd $OLDPWD [[ -d $dirstack[1] ]] && cd $dirstack[1] && cd $OLDPWD
fi fi
chpwd() { chpwd_functions+=(chpwd_dirpersist)
chpwd_dirpersist() {
if (( $DIRSTACKSIZE <= 0 )) || [[ -z $dirstack_file ]]; then return; fi if (( $DIRSTACKSIZE <= 0 )) || [[ -z $dirstack_file ]]; then return; fi
local -ax my_stack local -ax my_stack
my_stack=( ${PWD} ${dirstack} ) my_stack=( ${PWD} ${dirstack} )

View file

@ -1 +1,5 @@
# Docker-compose plugin for oh my zsh # Docker-compose plugin for oh my zsh
A copy of the completion script from the [docker-compose](1) git repo.
[1]:[https://github.com/docker/compose/blob/master/contrib/completion/zsh/_docker-compose]

View file

@ -0,0 +1,308 @@
#compdef docker-compose
# Description
# -----------
# zsh completion for docker-compose
# https://github.com/sdurrheimer/docker-compose-zsh-completion
# -------------------------------------------------------------------------
# Version
# -------
# 0.1.0
# -------------------------------------------------------------------------
# Authors
# -------
# * Steve Durrheimer <s.durrheimer@gmail.com>
# -------------------------------------------------------------------------
# Inspiration
# -----------
# * @albers docker-compose bash completion script
# * @felixr docker zsh completion script : https://github.com/felixr/docker-zsh-completion
# -------------------------------------------------------------------------
# For compatibility reasons, Compose and therefore its completion supports several
# stack compositon files as listed here, in descending priority.
# Support for these filenames might be dropped in some future version.
__docker-compose_compose_file() {
local file
for file in docker-compose.y{,a}ml fig.y{,a}ml ; do
[ -e $file ] && {
echo $file
return
}
done
echo docker-compose.yml
}
# Extracts all service names from docker-compose.yml.
___docker-compose_all_services_in_compose_file() {
local already_selected
local -a services
already_selected=$(echo ${words[@]} | tr " " "|")
awk -F: '/^[a-zA-Z0-9]/{print $1}' "${compose_file:-$(__docker-compose_compose_file)}" 2>/dev/null | grep -Ev "$already_selected"
}
# All services, even those without an existing container
__docker-compose_services_all() {
services=$(___docker-compose_all_services_in_compose_file)
_alternative "args:services:($services)"
}
# All services that have an entry with the given key in their docker-compose.yml section
___docker-compose_services_with_key() {
local already_selected
local -a buildable
already_selected=$(echo ${words[@]} | tr " " "|")
# flatten sections to one line, then filter lines containing the key and return section name.
awk '/^[a-zA-Z0-9]/{printf "\n"};{printf $0;next;}' "${compose_file:-$(__docker-compose_compose_file)}" 2>/dev/null | awk -F: -v key=": +$1:" '$0 ~ key {print $1}' 2>/dev/null | grep -Ev "$already_selected"
}
# All services that are defined by a Dockerfile reference
__docker-compose_services_from_build() {
buildable=$(___docker-compose_services_with_key build)
_alternative "args:buildable services:($buildable)"
}
# All services that are defined by an image
__docker-compose_services_from_image() {
pullable=$(___docker-compose_services_with_key image)
_alternative "args:pullable services:($pullable)"
}
__docker-compose_get_services() {
local kind expl
declare -a running stopped lines args services
docker_status=$(docker ps > /dev/null 2>&1)
if [ $? -ne 0 ]; then
_message "Error! Docker is not running."
return 1
fi
kind=$1
shift
[[ $kind = (stopped|all) ]] && args=($args -a)
lines=(${(f)"$(_call_program commands docker ps ${args})"})
services=(${(f)"$(_call_program commands docker-compose 2>/dev/null ${compose_file:+-f $compose_file} ${compose_project:+-p $compose_project} ps -q)"})
# Parse header line to find columns
local i=1 j=1 k header=${lines[1]}
declare -A begin end
while (( $j < ${#header} - 1 )) {
i=$(( $j + ${${header[$j,-1]}[(i)[^ ]]} - 1))
j=$(( $i + ${${header[$i,-1]}[(i) ]} - 1))
k=$(( $j + ${${header[$j,-1]}[(i)[^ ]]} - 2))
begin[${header[$i,$(($j-1))]}]=$i
end[${header[$i,$(($j-1))]}]=$k
}
lines=(${lines[2,-1]})
# Container ID
local line s name
local -a names
for line in $lines; do
if [[ $services == *"${line[${begin[CONTAINER ID]},${end[CONTAINER ID]}]%% ##}"* ]]; then
names=(${(ps:,:)${${line[${begin[NAMES]},-1]}%% *}})
for name in $names; do
s="${${name%_*}#*_}:${(l:15:: :::)${${line[${begin[CREATED]},${end[CREATED]}]/ ago/}%% ##}}"
s="$s, ${line[${begin[CONTAINER ID]},${end[CONTAINER ID]}]%% ##}"
s="$s, ${${${line[$begin[IMAGE],$end[IMAGE]]}/:/\\:}%% ##}"
if [[ ${line[${begin[STATUS]},${end[STATUS]}]} = Exit* ]]; then
stopped=($stopped $s)
else
running=($running $s)
fi
done
fi
done
[[ $kind = (running|all) ]] && _describe -t services-running "running services" running
[[ $kind = (stopped|all) ]] && _describe -t services-stopped "stopped services" stopped
}
__docker-compose_stoppedservices() {
__docker-compose_get_services stopped "$@"
}
__docker-compose_runningservices() {
__docker-compose_get_services running "$@"
}
__docker-compose_services () {
__docker-compose_get_services all "$@"
}
__docker-compose_caching_policy() {
oldp=( "$1"(Nmh+1) ) # 1 hour
(( $#oldp ))
}
__docker-compose_commands () {
local cache_policy
zstyle -s ":completion:${curcontext}:" cache-policy cache_policy
if [[ -z "$cache_policy" ]]; then
zstyle ":completion:${curcontext}:" cache-policy __docker-compose_caching_policy
fi
if ( [[ ${+_docker_compose_subcommands} -eq 0 ]] || _cache_invalid docker_compose_subcommands) \
&& ! _retrieve_cache docker_compose_subcommands;
then
local -a lines
lines=(${(f)"$(_call_program commands docker-compose 2>&1)"})
_docker_compose_subcommands=(${${${lines[$((${lines[(i)Commands:]} + 1)),${lines[(I) *]}]}## #}/ ##/:})
_store_cache docker_compose_subcommands _docker_compose_subcommands
fi
_describe -t docker-compose-commands "docker-compose command" _docker_compose_subcommands
}
__docker-compose_subcommand () {
local -a _command_args
integer ret=1
case "$words[1]" in
(build)
_arguments \
'--no-cache[Do not use cache when building the image]' \
'*:services:__docker-compose_services_from_build' && ret=0
;;
(help)
_arguments ':subcommand:__docker-compose_commands' && ret=0
;;
(kill)
_arguments \
'-s[SIGNAL to send to the container. Default signal is SIGKILL.]:signal:_signals' \
'*:running services:__docker-compose_runningservices' && ret=0
;;
(logs)
_arguments \
'--no-color[Produce monochrome output.]' \
'*:services:__docker-compose_services_all' && ret=0
;;
(migrate-to-labels)
_arguments \
'(-):Recreate containers to add labels' && ret=0
;;
(port)
_arguments \
'--protocol=-[tcp or udap (defaults to tcp)]:protocol:(tcp udp)' \
'--index=-[index of the container if there are mutiple instances of a service (defaults to 1)]:index: ' \
'1:running services:__docker-compose_runningservices' \
'2:port:_ports' && ret=0
;;
(ps)
_arguments \
'-q[Only display IDs]' \
'*:services:__docker-compose_services_all' && ret=0
;;
(pull)
_arguments \
'--allow-insecure-ssl[Allow insecure connections to the docker registry]' \
'*:services:__docker-compose_services_from_image' && ret=0
;;
(rm)
_arguments \
'(-f --force)'{-f,--force}"[Don't ask to confirm removal]" \
'-v[Remove volumes associated with containers]' \
'*:stopped services:__docker-compose_stoppedservices' && ret=0
;;
(run)
_arguments \
'--allow-insecure-ssl[Allow insecure connections to the docker registry]' \
'-d[Detached mode: Run container in the background, print new container name.]' \
'--entrypoint[Overwrite the entrypoint of the image.]:entry point: ' \
'*-e[KEY=VAL Set an environment variable (can be used multiple times)]:environment variable KEY=VAL: ' \
'(-u --user)'{-u,--user=-}'[Run as specified username or uid]:username or uid:_users' \
"--no-deps[Don't start linked services.]" \
'--rm[Remove container after run. Ignored in detached mode.]' \
"--service-ports[Run command with the service's ports enabled and mapped to the host.]" \
'-T[Disable pseudo-tty allocation. By default `docker-compose run` allocates a TTY.]' \
'(-):services:__docker-compose_services' \
'(-):command: _command_names -e' \
'*::arguments: _normal' && ret=0
;;
(scale)
_arguments '*:running services:__docker-compose_runningservices' && ret=0
;;
(start)
_arguments '*:stopped services:__docker-compose_stoppedservices' && ret=0
;;
(stop|restart)
_arguments \
'(-t --timeout)'{-t,--timeout}"[Specify a shutdown timeout in seconds. (default: 10)]:seconds: " \
'*:running services:__docker-compose_runningservices' && ret=0
;;
(up)
_arguments \
'--allow-insecure-ssl[Allow insecure connections to the docker registry]' \
'-d[Detached mode: Run containers in the background, print new container names.]' \
'--no-color[Produce monochrome output.]' \
"--no-deps[Don't start linked services.]" \
"--no-recreate[If containers already exist, don't recreate them.]" \
"--no-build[Don't build an image, even if it's missing]" \
'(-t --timeout)'{-t,--timeout}"[Specify a shutdown timeout in seconds. (default: 10)]:seconds: " \
"--x-smart-recreate[Only recreate containers whose configuration or image needs to be updated. (EXPERIMENTAL)]" \
'*:services:__docker-compose_services_all' && ret=0
;;
(version)
_arguments \
"--short[Shows only Compose's version number.]" && ret=0
;;
(*)
_message 'Unknown sub command'
esac
return ret
}
_docker-compose () {
# Support for subservices, which allows for `compdef _docker docker-shell=_docker_containers`.
# Based on /usr/share/zsh/functions/Completion/Unix/_git without support for `ret`.
if [[ $service != docker-compose ]]; then
_call_function - _$service
return
fi
local curcontext="$curcontext" state line ret=1
typeset -A opt_args
_arguments -C \
'(- :)'{-h,--help}'[Get help]' \
'--verbose[Show more output]' \
'(- :)'{-v,--version}'[Print version and exit]' \
'(-f --file)'{-f,--file}'[Specify an alternate docker-compose file (default: docker-compose.yml)]:file:_files -g "*.yml"' \
'(-p --project-name)'{-p,--project-name}'[Specify an alternate project name (default: directory name)]:project name:' \
'(-): :->command' \
'(-)*:: :->option-or-argument' && ret=0
local counter=1
#local compose_file compose_project
while [ $counter -lt ${#words[@]} ]; do
case "${words[$counter]}" in
-f|--file)
(( counter++ ))
compose_file="${words[$counter]}"
;;
-p|--project-name)
(( counter++ ))
compose_project="${words[$counter]}"
;;
*)
;;
esac
(( counter++ ))
done
case $state in
(command)
__docker-compose_commands && ret=0
;;
(option-or-argument)
curcontext=${curcontext%:*:*}:docker-compose-$words[1]:
__docker-compose_subcommand && ret=0
;;
esac
return ret
}
_docker-compose "$@"

View file

@ -1,14 +0,0 @@
# Authors:
# https://github.com/tristola
#
# Docker-compose related zsh aliases
# Aliases ###################################################################
alias dcup='docker-compose up'
alias dcb='docker-compose build'
alias dcrm='docker-compose rm'
alias dcps='docker-compose ps'
alias dcstop='docker-compose stop'
alias dcrestart='docker-compose restart'

View file

@ -27,7 +27,7 @@ __docker_all_containers() {
# output a selectable list of all docker images # output a selectable list of all docker images
__docker_images() { __docker_images() {
declare -a img_cmd declare -a img_cmd
img_cmd=($(docker images | awk 'NR>1{print $1}')) img_cmd=($(docker images | awk 'NR>1{print $1}'| sed 's/:/\\:/g'))
_describe 'images' img_cmd _describe 'images' img_cmd
} }

View file

@ -1,8 +1,8 @@
# Ember-cli # Ember CLI
**Maintainer:**[BilalBudhani](http://www.github.com/BilalBudhani) **Maintainers:** [BilalBudhani](http://www.github.com/BilalBudhani), [eubenesa](http://www.github.com/eubenesa)
Ember-cli (http://www.ember-cli.com/) Ember CLI (http://www.ember-cli.com/)
### List of Aliases ### List of Aliases
@ -15,9 +15,6 @@ Alias | Ember-CLI command
**eg** | *ember generate* **eg** | *ember generate*
**eh** | *ember help* **eh** | *ember help*
**ein** | *ember init* **ein** | *ember init*
**eia** | *ember install:addon*
**eib** | *ember install:bower*
**ein** | *ember install:npm*
**ei** | *ember install* **ei** | *ember install*
**et** | *ember test* **et** | *ember test*
**eu** | *ember update* **eu** | *ember update*

View file

@ -1,5 +1,5 @@
# Ember ClI # Ember CLI
# visit http://www.ember-cli.com/ to view user guid # Visit http://www.ember-cli.com/ to view user guide
alias es='ember serve' alias es='ember serve'
alias ea='ember addon' alias ea='ember addon'
@ -8,9 +8,6 @@ alias ed='ember destroy'
alias eg='ember generate' alias eg='ember generate'
alias eh='ember help' alias eh='ember help'
alias ein='ember init' alias ein='ember init'
alias eia='ember install:addon'
alias eib='ember install:bower'
alias ein='ember install:npm'
alias ei='ember install' alias ei='ember install'
alias et='ember test' alias et='ember test'
alias eu='ember update' alias eu='ember update'

135
plugins/emoji/README.md Normal file
View file

@ -0,0 +1,135 @@
# emoji plugin
Support for conveniently working with Unicode emoji in Zsh.
## Features
This plugin provides support for working with Unicode emoji characters in `zsh` using human-readable identifiers. It provides global variables which map emoji names to the actual characters, country names to their flags, and some named groupings of emoji. It also provides associated functions for displaying them.
#### Variables
Variable | Description
----------------- | --------------------------------
$emoji | Maps emoji names to characters
$emoji_flags | Maps country names to flag characters (using region indicators)
$emoji_groups | Named groups of emoji. Keys are group names; values are whitespace-separated lists of character names
You may define new emoji groups at run time by modifying `$emoji_groups`. The special group name `all` is reserved for use by the plugin. You should not modify `$emoji` or `$emoji_flags`.
#### Functions
Function | Description
---------------- | -------------------------------
random_emoji | Prints a random emoji character
display_emoji | Displays emoji, along with their names
## Usage and Examples
To output a specific emoji, use:
```
$> echo $emoji[<name>]
```
E.g.:
```
$> echo $emoji[mouse_face]
```
To output a random emoji, use:
```
$> random_emoji
```
To output a random emoji from a particular group, use:
```
$> random_emoji <group>
```
E.g.:
```
$> random_emoji fruits
$> random_emoji animals
$> random_emoji vehicles
$> random_emoji faces
```
The defined group names can be found with `echo ${(k)emoji_groups}`.
To list all available emoji with their names, use:
```
$> display_emoji
$> display_emoji fruits
$> display_emoji animals
$> display_emoji vehicles
$> display_emoji faces
```
To use emoji in a prompt:
```
PROMPT="$emoji[penguin] > ""
PROMPT='$(random_emoji fruits) > '
surfer=$emoji[surfer]
PROMPT="$surfer > "
```
## Technical Details
The emoji names and codes are sourced from Unicode Technical Report \#51, which provides information on emoji support in Unicode. It can be found at http://www.unicode.org/reports/tr51/index.html.
The group definitions are added by this OMZ plugin. They are not based on external definitions. (As far as I can tell. -apjanke)
The values in the `$emoji*` maps are the emoji characters themselves, not escape sequences or other forms that require interpretation. They can be used in any context and do not require escape sequence support from commands like `echo` or `print`.
The emoji in the main `$emoji` map are standalone character sequences which can all be output on their own, without worrying about combining characters. The values may actually be multi-code-point sequences, instead of a single code point, and may include combining characters in those sequences. But they're arranged so their effects do not extend beyond that sequence.
The exception to this is the skin tone variation selectors. These are included in the main `$emoji` map because they can be displayed on their own, as well as used as combining characters. (If they follow a character that is not one of the emoji characters they combine with, they are displayed as color swatches.)
## Experimental Features
This defines some additional variables and functions, but these are experimental and subject to change at any time. You shouldn't rely on them being available. They're mostly for the use of emoji plugin developers to help decide what to include in future revisions.
Variables:
Variable | Description
----------------- | --------------------------------
$emoji2 | Auxiliary and combining characters
$emoji_skintone | Skin tone modifiers (from Unicode 8.0)
#### Skin Tone Variation Selection
This includes experimental support for the skin tone Variation Selectors introduced with Unicode 8.0, which let you select different skin tones for emoji involving humans.
NOTE: This really is experimental. The skin tone selectors are a relatively new feature and may not be supported by all systems. And the support in this plugin is a work in progress. It may not work in all places. In fact, I haven't gotten it to work anywhere yet. -apjanke
The "variation selectors" are combining characters which change the appearance of the preceding character. A variation selector character can be output immediately following a human emoji to change its skin tone color. You can also output a variation selector on its own to display a color swatch of that skin tone.
The `$emoji_skintone` associative array maps skin tone IDs to the variation selector characters. To use one, output it immediately following a smiley or other human emoji.
```
echo "$emoji[smiling_face_with_open_mouth]$emoji_skintone[4]"
```
Note that `$emoji_skintone` is an associative array, and its keys are the *names* of "Fitzpatrick Skin Type" groups, not linear indexes into a normal array. The names are `1_2`, `3`, `4`, `5`, and `6`. (Types 1 and 2 are combined into a single color.) See the [Diversity section in Unicode TR 51](http://www.unicode.org/reports/tr51/index.html#Diversity) for details.
## TODO
These are things that could be enhanced in future revisions of the plugin.
* Incorporate CLDR data for ordering and groupings
* Short :bracket: style names (from gemoji)
* Incorporate `gemoji` data
* Country codes for flags
* ZWJ combining function?
#### Gemoji support
The [gemoji project](https://github.com/github/gemoji) seems to be the de facto main source for short names and other emoji-related metadata that isn't included in the official Unicode reports. (I'm saying this just from looking at the google results for "emoji short names" and related searches. -apjanke)
If this plugin is updated to provide short names, CLDR sorting data, and similar stuff, it should probably be changed to use the Gemoji project, and the `update_emoji.pl` script be rewritten in Ruby so it can use the Gemoji library directly instead of parsing its data files.
This does *not* mean that it should use Gemoji at run time. None of the `zsh` plugin stuff should call Gemoji or Ruby code. Rather, the "build time" `update_emoji.pl` script should be rewritten to use Gemoji to generate a pure-native-`zsh` character definition file which would be checked in to the repo and can be called by OMZ users without having Gemoji installed.
#### ZWJ combining function
One of the newer features of Unicode emoji is the ability to use the "Zero-Width Joiner" character to compose multiple emoji characters in to a single "emoji ligature" glyph. For example, this is [how Apple supports "family" emoji with various genders and skin tones](http://www.unicode.org/reports/tr51/index.html#ZWJ_Sequences).
These are a pain to write out (and probably worse to read), and it might be convenient to have a couple functions for concisely composing them, if wider support for them appears.

File diff suppressed because it is too large Load diff

1308
plugins/emoji/emoji-data.txt Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,288 @@
# emoji plugin
#
# Makes emoji support available within ZSH
#
# See the README for documentation.
_omz_emoji_plugin_dir="${0:h}"
() {
local LC_ALL=en_US.UTF-8
typeset -gAH emoji_groups
typeset -gAH emoji_con
typeset -gAH emoji2
typeset -gAH emoji_skintone
source "$_omz_emoji_plugin_dir/emoji-char-definitions.zsh"
unset _omz_emoji_plugin_dir
# These additional emoji are not in the definition file, but are useful in conjunction with it
# This is a combinin character that can be placed after any other character to surround
# it in a "keycap" symbol.
# The digits 0-9 are already in the emoji table as keycap_digit_<N>, keycap_ten, etc.
# It's unclear whether this should be in the $emoji array, because those characters are all ones
# which can be displayed on their own.
#emoji[combining_enclosing_keycap]="\U20E3"
emoji[regional_indicator_symbol_letter_d_regional_indicator_symbol_letter_e]=$'\xF0\x9F\x87\xA9\xF0\x9F\x87\xAA'
emoji[regional_indicator_symbol_letter_g_regional_indicator_symbol_letter_b]=$'\xF0\x9F\x87\xAC\xF0\x9F\x87\xA7'
emoji[regional_indicator_symbol_letter_c_regional_indicator_symbol_letter_n]=$'\xF0\x9F\x87\xA8\xF0\x9F\x87\xB3'
emoji[regional_indicator_symbol_letter_j_regional_indicator_symbol_letter_p]=$'\xF0\x9F\x87\xAF\xF0\x9F\x87\xB5'
emoji[regional_indicator_symbol_letter_k_regional_indicator_symbol_letter_r]=$'\xF0\x9F\x87\xB0\xF0\x9F\x87\xB7'
emoji[regional_indicator_symbol_letter_f_regional_indicator_symbol_letter_r]=$'\xF0\x9F\x87\xAB\xF0\x9F\x87\xB7'
emoji[regional_indicator_symbol_letter_e_regional_indicator_symbol_letter_s]=$'\xF0\x9F\x87\xAA\xF0\x9F\x87\xB8'
emoji[regional_indicator_symbol_letter_i_regional_indicator_symbol_letter_t]=$'\xF0\x9F\x87\xAE\xF0\x9F\x87\xB9'
emoji[regional_indicator_symbol_letter_u_regional_indicator_symbol_letter_s]=$'\xF0\x9F\x87\xBA\xF0\x9F\x87\xB8'
emoji[regional_indicator_symbol_letter_r_regional_indicator_symbol_letter_u]=$'\xF0\x9F\x87\xB7\xF0\x9F\x87\xBA'
# Nonstandard alias names
emoji[vulcan_salute]=$'\U1F596'
# Emoji combining and auxiliary characters
# "Variation Selectors" for controlling text vs emoji style presentation
# These apply to the immediately preceding character
emoji2[text_style]=$'\UFE0E'
emoji2[emoji_style]=$'\UFE0F'
# Joiner that indicates a single combined-form glyph (ligature) should be used
emoji2[zero_width_joiner]=$'\U200D'
# Skin tone modifiers
emoji2[emoji_modifier_fitzpatrick_type_1_2]=$'\U1F3FB'
emoji2[emoji_modifier_fitzpatrick_type_3]=$'\U1F3FC'
emoji2[emoji_modifier_fitzpatrick_type_4]=$'\U1F3FD'
emoji2[emoji_modifier_fitzpatrick_type_5]=$'\U1F3FE'
emoji2[emoji_modifier_fitzpatrick_type_6]=$'\U1F3FF'
# Various other combining characters. (Incomplete list; I selected ones that sound useful)
emoji2[combining_enclosing_circle]=$'\U20DD'
emoji2[combining_enclosing_square]=$'\U20DE'
emoji2[combining_enclosing_diamond]=$'\U20DF'
emoji2[combining_enclosing_circle_backslash]=$'\U20E0'
emoji2[combining_enclosing_screen]=$'\U20E2'
emoji2[combining_enclosing_keycap]=$'\U20E3'
emoji2[combining_enclosing_upward_pointing_triangle]=$'\U20E4'
# Easier access to skin tone modifiers
emoji_skintone[1_2]=$'\U1F3FB'
emoji_skintone[3]=$'\U1F3FC'
emoji_skintone[4]=$'\U1F3FD'
emoji_skintone[5]=$'\U1F3FE'
emoji_skintone[6]=$'\U1F3FF'
# Emoji groups
# These are stored in a single associative array, $emoji_groups, to avoid cluttering up the global
# namespace, and to allow adding additional group definitions at run time.
# The keys are the group names, and the values are whitespace-separated lists of emoji character names.
emoji_groups[fruits]="
tomato
aubergine
grapes
melon
watermelon
tangerine
banana
pineapple
red_apple
green_apple
peach
cherries
strawberry
lemon
pear
"
emoji_groups[vehicles]="
airplane
rocket
railway_car
high_speed_train
high_speed_train_with_bullet_nose
bus
ambulance
fire_engine
police_car
taxi
automobile
recreational_vehicle
delivery_truck
ship
speedboat
bicycle
helicopter
steam_locomotive
train
light_rail
tram
oncoming_bus
trolleybus
minibus
oncoming_police_car
oncoming_taxi
oncoming_automobile
articulated_lorry
tractor
monorail
mountain_railway
suspension_railway
mountain_cableway
aerial_tramway
rowboat
bicyclist
mountain_bicyclist
sailboat
"
emoji_groups[animals]="
snail
snake
horse
sheep
monkey
chicken
boar
elephant
octopus
spiral_shell
bug
ant
honeybee
lady_beetle
fish
tropical_fish
blowfish
turtle
hatching_chick
baby_chick
front_facing_baby_chick
bird
penguin
koala
poodle
bactrian_camel
dolphin
mouse_face
cow_face
tiger_face
rabbit_face
cat_face
dragon_face
spouting_whale
horse_face
monkey_face
dog_face
pig_face
frog_face
hamster_face
wolf_face
bear_face
panda_face
rat
mouse
ox
water_buffalo
cow
tiger
leopard
rabbit
cat
dragon
crocodile
whale
ram
goat
rooster
dog
pig
dromedary_camel
"
emoji_groups[faces]="
grinning_face_with_smiling_eyes
face_with_tears_of_joy
smiling_face_with_open_mouth
smiling_face_with_open_mouth_and_smiling_eyes
smiling_face_with_open_mouth_and_cold_sweat
smiling_face_with_open_mouth_and_tightly_closed_eyes
winking_face
smiling_face_with_smiling_eyes
face_savouring_delicious_food
relieved_face
smiling_face_with_heart_shaped_eyes
smirking_face
unamused_face
face_with_cold_sweat
pensive_face
confounded_face
face_throwing_a_kiss
kissing_face_with_closed_eyes
face_with_stuck_out_tongue_and_winking_eye
face_with_stuck_out_tongue_and_tightly_closed_eyes
disappointed_face
angry_face
pouting_face
crying_face
persevering_face
face_with_look_of_triumph
disappointed_but_relieved_face
fearful_face
weary_face
sleepy_face
tired_face
loudly_crying_face
face_with_open_mouth_and_cold_sweat
face_screaming_in_fear
astonished_face
flushed_face
dizzy_face
face_with_medical_mask
"
}
# Prints a random emoji character
#
# random_emoji [group]
#
function random_emoji() {
local group=$1
local names
if [[ -z "$group" || "$group" == "all" ]]; then
names=(${(k)emoji})
else
names=(${=emoji_groups[$group]})
fi
local list_size=${#names}
[[ $list_size -eq 0 ]] && return 1
local random_index=$(( ( RANDOM % $list_size ) + 1 ))
local name=${names[$random_index]}
echo ${emoji[$name]}
}
# Displays a listing of emoji with their names
#
# display_emoji [group]
#
function display_emoji() {
local group=$1
local names
if [[ -z "$group" || "$group" == "all" ]]; then
names=(${(k)emoji})
else
names=(${=emoji_groups[$group]})
fi
# The extra spaces in output here are a hack for readability, since some
# terminals treat these emoji chars as single-width.
for i in $names; do
printf '%s ' "$emoji[$i]"
done
print
for i in $names; do
echo "${emoji[$i]} = $i"
done
}

View file

@ -0,0 +1,113 @@
#!/usr/bin/perl -w
#
# update_emoji.pl
#
# This script generates the emoji.plugin.zsh emoji definitions from the Unicode
# character data for the emoji characters.
#
# The data file can be found at http://unicode.org/Public/emoji/latest/emoji-data.txt
# as referenced in Unicode TR51 (http://www.unicode.org/reports/tr51/index.html).
#
# This is known to work with the data file from version 1.0. It may not work with later
# versions if the format changes. In particular, this reads line comments to get the
# emoji character name and unicode version.
#
# Country names have punctuation and other non-letter characters removed from their name,
# to avoid possible complications with having to escape the strings when using them as
# array subscripts. The definition file seems to use some combining characters like accents
# that get stripped during this process.
use strict;
use warnings;
use 5.010;
use autodie;
use Path::Class;
use File::Copy;
# Parse definitions out of the data file and convert
sub process_emoji_data_file {
my ( $infile, $outfilename ) = @_;
my $file = file($infile);
my $outfile = file($outfilename);
my $outfilebase = $outfile->basename();
my $tempfilename = "$outfilename.tmp";
my $tempfile = file($tempfilename);
my $outfh = $tempfile->openw();
$outfh->print("
# $outfilebase - Emoji character definitions for oh-my-zsh emoji plugin
#
# This file is auto-generated by update_emoji.pl. Do not edit it manually.
#
# This contains the definition for:
# \$emoji - which maps character names to Unicode characters
# \$emoji_flags - maps country names to Unicode flag characters using region indicators
# Main emoji
typeset -gAH emoji
# National flags
typeset -gAH emoji_flags
# Combining modifiers
typeset -gAH emoji_mod
");
my $fh = $file->openr();
my $line_num = 0;
while ( my $line = $fh->getline() ) {
$line_num++;
$_ = $line;
# Skip all-comment lines (from the header) and blank lines
# (But don't strip comments on normal lines; we need to parse those for
# the emoji names.)
next if /^\s*#/ or /^\s*$/;
if (/^(\S.*?\S)\s*;\s*(\w+)\s*;\s*(\w+)\s*;\s*(\w+)\s*;\s*(\w.*?)\s*#\s*V(\S+)\s\(.*?\)\s*(\w.*\S)\s*$/) {
my ($code, $style, $level, $modifier_status, $sources, $version, $keycap_name)
= ($1, $2, $3, $4, $5, $6, $7);
#print "code=$code style=$style level=$level modifier_status=$modifier_status sources=$sources version=$version name=$keycap_name\n";
my @code_points = split /\s+/, $code;
my @sources = split /\s+/, $sources;
my $flag_country = "";
if ( $keycap_name =~ /^flag for (\S.*?)\s*$/) {
$flag_country = $1;
}
my $zsh_code = join '', map { "\\U$_" } @code_points;
# Convert keycap names to valid associative array names that do not require any
# quoting. Works fine for most stuff, but is clumsy for flags.
my $omz_name = lc($keycap_name);
$omz_name =~ s/[^A-Za-z0-9]/_/g;
my $zsh_flag_country = $flag_country;
$zsh_flag_country =~ s/[^\p{Letter}]/_/g;
if ($flag_country) {
$outfh->print("emoji_flags[$zsh_flag_country]=\$'$zsh_code'\n");
} else {
$outfh->print("emoji[$omz_name]=\$'$zsh_code'\n");
}
# Modifiers are included in both the main set and their separate map,
# because they have a standalone representation as a color swatch.
if ( $modifier_status eq "modifier" ) {
$outfh->print("emoji_mod[$omz_name]=\$'$zsh_code'\n");
}
} else {
die "Failed parsing line $line_num: '$_'";
}
}
$fh->close();
$outfh->print("\n");
$outfh->close();
move($tempfilename, $outfilename)
or die "Failed moving temp file to $outfilename: $!";
}
my $datafile = "emoji-data.txt";
my $zsh_def_file = "emoji-char-definitions.zsh";
process_emoji_data_file($datafile, $zsh_def_file);
print "Updated definition file $zsh_def_file\n";

View file

@ -0,0 +1,43 @@
# ------------------------------------------------------------------------------
# FILE: emotty.plugin.zsh
# DESCRIPTION: Return an emoji for the current $TTY number.
# AUTHOR: Alexis Hildebrandt (afh[at]surryhill.net)
# VERSION: 1.0.0
# DEPENDS: emoji plugin
#
# There are different sets of emoji characters available, to choose a different
# set export emotty_set to the name of the set you would like to use, e.g.:
# % export emotty_set=nature
# ------------------------------------------------------------------------------
typeset -gAH _emotty_sets
local _emotty_plugin_dir="${0:h}"
source "$_emotty_plugin_dir/emotty_stellar_set.zsh"
source "$_emotty_plugin_dir/emotty_floral_set.zsh"
source "$_emotty_plugin_dir/emotty_zodiac_set.zsh"
source "$_emotty_plugin_dir/emotty_nature_set.zsh"
source "$_emotty_plugin_dir/emotty_emoji_set.zsh"
source "$_emotty_plugin_dir/emotty_love_set.zsh"
unset _emotty_plugin_dir
emotty_default_set=emoji
function emotty() {
# Use emotty set defined by user, fallback to default
local emotty=${_emotty_sets[${emotty_set:-$emotty_default_set}]}
# Parse $TTY number, normalizing it to an emotty set index
(( tty = (${TTY##/dev/ttys} % ${#${=emotty}}) + 1 ))
local character_name=${${=emotty}[tty]}
echo "${emoji[${character_name}]}${emoji2[emoji_style]}"
}
function display_emotty() {
local name=$1
for i in ${=_emotty_sets[$name]}; do
printf "${emoji[$i]}${emoji2[emoji_style]} "
done
print
for i in ${=_emotty_sets[$name]}; do
print "${emoji[$i]}${emoji2[emoji_style]} = $i"
done
}

View file

@ -0,0 +1,24 @@
#!/usr/bin/env zsh
# vim:ft=zsh ts=2 sw=2 sts=2
_emotty_sets[emoji]="
crystal_ball
ghost
jack_o_lantern
see_no_evil_monkey
hear_no_evil_monkey
speak_no_evil_monkey
smiling_cat_face_with_open_mouth
extraterrestrial_alien
rocket
billiards
bomb
pill
japanese_symbol_for_beginner
direct_hit
cyclone
diamond_shape_with_a_dot_inside
sparkle
eight_spoked_asterisk
eight_pointed_black_star
"

View file

@ -0,0 +1,18 @@
#!/usr/bin/env zsh
# vim:ft=zsh ts=2 sw=2 sts=2
_emotty_sets[floral]="
hibiscus
cherry_blossom
blossom
sunflower
bouquet
tulip
rose
four_leaf_clover
seedling
herb
palm_tree
evergreen_tree
deciduous_tree
"

View file

@ -0,0 +1,34 @@
#!/usr/bin/env zsh
# vim:ft=zsh ts=2 sw=2 sts=2
# Note: The heavy_black_heart emoji requires $emoji2[emoji_style]
# to be rendered as the emoji red heart.
_emotty_sets[love]="
green_heart
blue_heart
purple_heart
yellow_heart
heavy_black_heart
broken_heart
heart_with_arrow
heart_with_ribbon
sparkling_heart
two_hearts
revolving_hearts
growing_heart
beating_heart
heart_decoration
couple_with_heart
kiss
man_and_woman_holding_hands
two_women_holding_hands
two_men_holding_hands
kiss_mark
smiling_face_with_heart_shaped_eyes
kissing_face
face_throwing_a_kiss
kissing_face_with_smiling_eyes
kissing_face_with_closed_eyes
smiling_cat_face_with_heart_shaped_eyes
kissing_cat_face_with_closed_eyes
"

View file

@ -0,0 +1,58 @@
#!/usr/bin/env zsh
# vim:ft=zsh ts=2 sw=2 sts=2
_emotty_sets[nature]="
mouse_face
hamster_face
rabbit_face
dog_face
cat_face
tiger_face
bear_face
monkey_face
koala
panda_face
chicken
baby_chick
bird
penguin
cow_face
pig_face
frog_face
boar
wolf_face
horse_face
snail
bug
ant
honeybee
lady_beetle
spouting_whale
dolphin
octopus
fish
tropical_fish
snake
turtle
lemon
tangerine
peach
mushroom
tomato
strawberry
red_apple
cherries
grapes
aubergine
watermelon
banana
pineapple
melon
pear
green_apple
ear_of_maize
sunflower
seedling
herb
four_leaf_clover
"

View file

@ -0,0 +1,25 @@
#!/usr/bin/env zsh
# vim:ft=zsh ts=2 sw=2 sts=2
# NOTE: The following emoji show as $'character' in the title
# white_medium_star
# sparkles
# dizzy_symbol
_emotty_sets[stellar]="
full_moon_symbol
waning_gibbous_moon_symbol
waning_crescent_moon_symbol
last_quarter_moon_symbol
new_moon_symbol
new_moon_with_face
waxing_crescent_moon_symbol
first_quarter_moon_symbol
waxing_gibbous_moon_symbol
full_moon_with_face
sun_with_face
glowing_star
crescent_moon
first_quarter_moon_with_face
last_quarter_moon_with_face
"

View file

@ -0,0 +1,29 @@
#!/usr/bin/env zsh
# vim:ft=zsh ts=2 sw=2 sts=2
_emotty_sets[zodiac]="
aries
taurus
gemini
cancer
leo
virgo
libra
scorpius
sagittarius
capricorn
aquarius
pisces
rat
ox
tiger
rabbit
dragon
snake
horse
goat
monkey
rooster
dog
pig
"

View file

@ -0,0 +1,14 @@
# Use Ctrl-Z to switch back to Vim
I frequently need to execute random command in my shell. To achieve it I pause
Vim by pressing Ctrl-z, type command and press fg<Enter> to switch back to Vim.
The fg part really hurt sme. I just wanted to hit Ctrl-z once again to get back
to Vim. I could not find a solution, so I developed one on my own that
works wonderfully with ZSH
Source: http://sheerun.net/2014/03/21/how-to-boost-your-vim-productivity/
Credits:
- original idea by @sheerun
- added to OMZ by @mbologna

View file

@ -0,0 +1,12 @@
fancy-ctrl-z () {
if [[ $#BUFFER -eq 0 ]]; then
BUFFER="fg"
zle accept-line
else
zle push-input
zle clear-screen
fi
}
zle -N fancy-ctrl-z
bindkey '^Z' fancy-ctrl-z

View file

@ -5,7 +5,7 @@ if [ $commands[fasd] ]; then # check if fasd is installed
fi fi
source "$fasd_cache" source "$fasd_cache"
unset fasd_cache unset fasd_cache
alias v='f -e vim'
alias o='a -e open'
fi
alias v='f -e vim'
alias o='a -e open_command'
fi

View file

@ -1,6 +1,7 @@
# start fbterm automatically in /dev/tty* # start fbterm automatically in /dev/tty*
if [[ $(tty|grep -o '/dev/tty') = /dev/tty ]] ; then if (( ${+commands[fbterm]} )); then
fbterm if [[ "$TTY" = /dev/tty* ]] ; then
exit fbterm && exit
fi
fi fi

View file

@ -1,74 +1,60 @@
## Rationale ## ## Introduction ##
> Searches for your Frontend contents more easier > Searches for your frontend web development made easier
## Instalation ## ## Installation ##
Open your `~/.zshrc` file and enable the `frontend-search` plugin:
Open your `.zshrc` file and load `frontend-search` plugin ```zsh
plugins=( ... frontend-search)
```bash
...
plugins=( <your-plugins-list>... frontend-search)
...
``` ```
## Commands ## ## Usage ##
All command searches are accept only in format You can use the frontend-search plugin in these two forms:
* `frontend <search-content> <search-term>` * `frontend <context> <term> [more terms if you want]`
* `<context> <term> [more terms if you want]`
The search content are For example, these two are equivalent:
* `jquery <api.jquery.com>` ```zsh
* `mdn <developer.mozilla.org>` $ frontend angularjs dependency injection
* `compass <compass-style.org>` $ angularjs dependency injection
* `html5please <html5please.com>` ```
* `caniuse <caniuse.com>`
* `aurajs <aurajs.com>`
* `dartlang <api.dartlang.org/apidocs/channels/stable/dartdoc-viewer>`
* `lodash <search>`
* `qunit <api.qunitjs.com>`
* `fontello <fontello.com>`
* `bootsnipp <bootsnipp.com>`
* `cssflow <cssflow.com>`
* `codepen <codepen.io>`
* `unheap <www.unheap.com>`
* `bem <google.com/search?as_q=<search-term>&as_sitesearch=bem.info>`
* `smacss <google.com/search?as_q=<search-term>&as_sitesearch=smacss.com>`
* `angularjs <google.com/search?as_q=<search-term>&as_sitesearch=angularjs.org>`
* `reactjs <google.com/search?as_q=<search-term>&as_sitesearch=facebook.github.io/react>`
* `emberjs <emberjs.com>`
* `stackoverflow <stackoverflow.com>`
Available search contexts are:
## Aliases ## | context | URL |
|---------------|--------------------------------------------------------------------------|
| angularjs | `https://google.com/search?as_sitesearch=angularjs.org&as_q=` |
| aurajs | `http://aurajs.com/api/#stq=` |
| bem | `https://google.com/search?as_sitesearch=bem.info&as_q=` |
| bootsnipp | `http://bootsnipp.com/search?q=` |
| caniuse | `http://caniuse.com/#search=` |
| codepen | `http://codepen.io/search?q=` |
| compass | `http://compass-style.org/search?q=` |
| cssflow | `http://www.cssflow.com/search?q=` |
| dartlang | `https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart:` |
| emberjs | `http://emberjs.com/api/#stp=1&stq=` |
| fontello | `http://fontello.com/#search=` |
| html5please | `http://html5please.com/#` |
| jquery | `https://api.jquery.com/?s=` |
| lodash | `https://devdocs.io/lodash/index#` |
| mdn | `https://developer.mozilla.org/search?q=` |
| npmjs | `https://www.npmjs.com/search?q=` |
| qunit | `https://api.qunitjs.com/?s=` |
| reactjs | `https://google.com/search?as_sitesearch=facebook.github.io/react&as_q=` |
| smacss | `https://google.com/search?as_sitesearch=smacss.com&as_q=` |
| stackoverflow | `http://stackoverflow.com/search?q=` |
| unheap | `http://www.unheap.com/?s=` |
There are a few aliases presented as well: If you want to have another context, open an Issue and tell us!
* `jquery` A shorthand for `frontend jquery`
* `mdn` A shorthand for `frontend mdn`
* `compass` A shorthand for `frontend compass`
* `html5please` A shorthand for `frontend html5please`
* `caniuse` A shorthand for `frontend caniuse`
* `aurajs` A shorthand for `frontend aurajs`
* `dartlang` A shorthand for `frontend dartlang`
* `lodash` A shorthand for `frontend lodash`
* `qunit` A shorthand for `frontend qunit`
* `fontello` A shorthand for `frontend fontello`
* `bootsnipp` A shorthand for `frontend bootsnipp`
* `cssflow` A shorthand for `frontend cssflow`
* `codepen` A shorthand for `frontend codepen`
* `unheap` A shorthand for `frontend unheap`
* `bem` A shorthand for `frontend bem`
* `smacss` A shorthand for `frontend smacss`
* `angularjs` A shorthand for `frontend angularjs`
* `reactjs` A shorthand for `frontend reactjs`
* `emberjs` A shorthand for `frontend emberjs`
* `stackoverflow` A shorthand for `frontend stackoverflow`
## Author ## Author
@ -77,5 +63,3 @@ There are a few aliases presented as well:
+ <https://plus.google.com/+WilsonMendes> + <https://plus.google.com/+WilsonMendes>
+ <https://twitter.com/willmendesneto> + <https://twitter.com/willmendesneto>
+ <http://github.com/willmendesneto> + <http://github.com/willmendesneto>
New features comming soon.

View file

@ -37,6 +37,7 @@ function _frontend() {
'reactjs: Search in React website' 'reactjs: Search in React website'
'emberjs: Search in Ember website' 'emberjs: Search in Ember website'
'stackoverflow: Search in StackOverflow website' 'stackoverflow: Search in StackOverflow website'
'npmjs: Search in NPMJS website'
) )
_arguments -C \ _arguments -C \
@ -110,6 +111,9 @@ function _frontend() {
stackoverflow) stackoverflow)
_describe -t points "Warp points" frontend_points && ret=0 _describe -t points "Warp points" frontend_points && ret=0
;; ;;
npmjs)
_describe -t points "Warp points" frontend_points && ret=0
;;
esac esac
;; ;;
esac esac

View file

@ -1,158 +1,91 @@
# frontend from terminal alias angularjs='frontend angularjs'
function frontend() {
# get the open command
local open_cmd
if [[ $(uname -s) == 'Darwin' ]]; then
open_cmd='open'
else
open_cmd='xdg-open'
fi
# no keyword provided, simply show how call methods
if [[ $# -le 1 ]]; then
echo "Please provide a search-content and a search-term for app.\nEx:\nfrontend <search-content> <search-term>\n"
return 1
fi
# check whether the search engine is supported
if [[ ! $1 =~ '(jquery|mdn|compass|html5please|caniuse|aurajs|dartlang|qunit|fontello|bootsnipp|cssflow|codepen|unheap|bem|smacss|angularjs|reactjs|emberjs|stackoverflow)' ]];
then
echo "Search valid search content $1 not supported."
echo "Valid contents: (formats 'frontend <search-content>' or '<search-content>')"
echo "* jquery"
echo "* mdn"
echo "* compass"
echo "* html5please"
echo "* caniuse"
echo "* aurajs"
echo "* dartlang"
echo "* lodash"
echo "* qunit"
echo "* fontello"
echo "* bootsnipp"
echo "* cssflow"
echo "* codepen"
echo "* unheap"
echo "* bem"
echo "* smacss"
echo "* angularjs"
echo "* reactjs"
echo "* emberjs"
echo "* stackoverflow"
echo ""
return 1
fi
local url="http://"
local query=""
case "$1" in
"jquery")
url="${url}api.jquery.com"
url="${url}/?s=$2" ;;
"mdn")
url="${url}developer.mozilla.org"
url="${url}/search?q=$2" ;;
"compass")
url="${url}compass-style.org"
url="${url}/search?q=$2" ;;
"html5please")
url="${url}html5please.com"
url="${url}/#$2" ;;
"caniuse")
url="${url}caniuse.com"
url="${url}/#search=$2" ;;
"aurajs")
url="${url}aurajs.com"
url="${url}/api/#stq=$2" ;;
"dartlang")
url="${url}api.dartlang.org/apidocs/channels/stable/dartdoc-viewer"
url="${url}/dart-$2" ;;
"qunit")
url="${url}api.qunitjs.com"
url="${url}/?s=$2" ;;
"fontello")
url="${url}fontello.com"
url="${url}/#search=$2" ;;
"bootsnipp")
url="${url}bootsnipp.com"
url="${url}/search?q=$2" ;;
"cssflow")
url="${url}cssflow.com"
url="${url}/search?q=$2" ;;
"codepen")
url="${url}codepen.io"
url="${url}/search?q=$2" ;;
"unheap")
url="${url}www.unheap.com"
url="${url}/?s=$2" ;;
"bem")
url="${url}google.com"
url="${url}/search?as_q=$2&as_sitesearch=bem.info" ;;
"smacss")
url="${url}google.com"
url="${url}/search?as_q=$2&as_sitesearch=smacss.com" ;;
"angularjs")
url="${url}google.com"
url="${url}/search?as_q=$2&as_sitesearch=angularjs.org" ;;
"reactjs")
url="${url}google.com"
url="${url}/search?as_q=$2&as_sitesearch=facebook.github.io/react" ;;
"emberjs")
url="${url}emberjs.com"
url="${url}/api/#stq=$2&stp=1" ;;
"stackoverflow")
url="${url}stackoverflow.com"
url="${url}/search?q=$2" ;;
*) echo "INVALID PARAM!"
return ;;
esac
echo "$url"
$open_cmd "$url"
}
# javascript
alias jquery='frontend jquery'
alias mdn='frontend mdn'
# pre processors frameworks
alias compassdoc='frontend compass'
# important links
alias html5please='frontend html5please'
alias caniuse='frontend caniuse'
# components and libraries
alias aurajs='frontend aurajs' alias aurajs='frontend aurajs'
alias dartlang='frontend dartlang' alias bem='frontend bem'
alias lodash='frontend lodash'
#tests
alias qunit='frontend qunit'
#fonts
alias fontello='frontend fontello'
# snippets
alias bootsnipp='frontend bootsnipp' alias bootsnipp='frontend bootsnipp'
alias cssflow='frontend cssflow' alias caniuse='frontend caniuse'
alias codepen='frontend codepen' alias codepen='frontend codepen'
alias compass='frontend compass'
alias cssflow='frontend cssflow'
alias dartlang='frontend dartlang'
alias emberjs='frontend emberjs'
alias fontello='frontend fontello'
alias html5please='frontend html5please'
alias jquery='frontend jquery'
alias lodash='frontend lodash'
alias mdn='frontend mdn'
alias npmjs='frontend npmjs'
alias qunit='frontend qunit'
alias reactjs='frontend reactjs'
alias smacss='frontend smacss'
alias stackoverflow='frontend stackoverflow'
alias unheap='frontend unheap' alias unheap='frontend unheap'
# css architecture function frontend() {
alias bem='frontend bem' emulate -L zsh
alias smacss='frontend smacss'
# frameworks # define search context URLS
alias angularjs='frontend angularjs' typeset -A urls
alias reactjs='frontend reactjs' urls=(
alias emberjs='frontend emberjs' angularjs 'https://google.com/search?as_sitesearch=angularjs.org&as_q='
aurajs 'http://aurajs.com/api/#stq='
bem 'https://google.com/search?as_sitesearch=bem.info&as_q='
bootsnipp 'http://bootsnipp.com/search?q='
caniuse 'http://caniuse.com/#search='
codepen 'http://codepen.io/search?q='
compass 'http://compass-style.org/search?q='
cssflow 'http://www.cssflow.com/search?q='
dartlang 'https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart:'
emberjs 'http://emberjs.com/api/#stp=1&stq='
fontello 'http://fontello.com/#search='
html5please 'http://html5please.com/#'
jquery 'https://api.jquery.com/?s='
lodash 'https://devdocs.io/lodash/index#'
mdn 'https://developer.mozilla.org/search?q='
npmjs 'https://www.npmjs.com/search?q='
qunit 'https://api.qunitjs.com/?s='
reactjs 'https://google.com/search?as_sitesearch=facebook.github.io/react&as_q='
smacss 'https://google.com/search?as_sitesearch=smacss.com&as_q='
stackoverflow 'http://stackoverflow.com/search?q='
unheap 'http://www.unheap.com/?s='
)
# search websites # show help for command list
alias stackoverflow='frontend stackoverflow' if [[ $# -lt 2 ]]
then
print -P "Usage: frontend %Ucontext%u %Uterm%u [...%Umore%u] (or just: %Ucontext%u %Uterm%u [...%Umore%u])"
print -P ""
print -P "%Uterm%u and what follows is what will be searched for in the %Ucontext%u website,"
print -P "and %Ucontext%u is one of the following:"
print -P ""
print -P " angularjs, aurajs, bem, bootsnipp, caniuse, codepen, compass, cssflow,"
print -P " dartlang, emberjs, fontello, html5please, jquery, lodash, mdn, npmjs,"
print -P " qunit, reactjs, smacss, stackoverflow, unheap"
print -P ""
print -P "For example: frontend npmjs mocha (or just: npmjs mocha)."
print -P ""
return 1
fi
# check whether the search context is supported
if [[ -z "$urls[$1]" ]]
then
echo "Search context \"$1\" currently not supported."
echo ""
echo "Valid contexts are:"
echo ""
echo " angularjs, aurajs, bem, bootsnipp, caniuse, codepen, compass, cssflow, "
echo " dartlang, emberjs, fontello, html5please, jquery, lodash, mdn, npmjs, "
echo " qunit, reactjs, smacss, stackoverflow, unheap"
echo ""
return 1
fi
# build search url:
# join arguments passed with '+', then append to search context URL
# TODO substitute for proper urlencode method
url="${urls[$1]}${(j:+:)@[2,-1]}"
echo "Opening $url ..."
open_command "$url"
}

View file

@ -3,19 +3,20 @@
# Description # Description
# ----------- # -----------
# #
# Completion script for git-extras (http://github.com/visionmedia/git-extras). # Completion script for git-extras (http://github.com/tj/git-extras).
# #
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Authors # Authors
# ------- # -------
# #
# * Alexis GRIMALDI (https://github.com/agrimaldi) # * Alexis GRIMALDI (https://github.com/agrimaldi)
# * spacewander (https://github.com/spacewander)
# #
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Inspirations # Inspirations
# ----------- # -----------
# #
# * git-extras (http://github.com/visionmedia/git-extras) # * git-extras (http://github.com/tj/git-extras)
# * git-flow-completion (http://github.com/bobthecow/git-flow-completion) # * git-flow-completion (http://github.com/bobthecow/git-flow-completion)
# #
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@ -30,10 +31,21 @@ __git_command_successful () {
} }
__git_commits() {
declare -A commits
git log --oneline -15 | sed 's/\([[:alnum:]]\{7\}\) /\1:/' | while read commit
do
hash=$(echo $commit | cut -d':' -f1)
commits[$hash]="$commit"
done
local ret=1
_describe -t commits commit commits && ret=0
}
__git_tag_names() { __git_tag_names() {
local expl local expl
declare -a tag_names declare -a tag_names
tag_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/tags 2>/dev/null)"}#refs/tags/}) tag_names=(${${(f)"$(_call_program tags git for-each-ref --format='"%(refname)"' refs/tags 2>/dev/null)"}#refs/tags/})
__git_command_successful || return __git_command_successful || return
_wanted tag-names expl tag-name compadd $* - $tag_names _wanted tag-names expl tag-name compadd $* - $tag_names
} }
@ -47,31 +59,27 @@ __git_branch_names() {
_wanted branch-names expl branch-name compadd $* - $branch_names _wanted branch-names expl branch-name compadd $* - $branch_names
} }
__git_specific_branch_names() {
__git_feature_branch_names() {
local expl local expl
declare -a branch_names declare -a branch_names
branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads/feature 2>/dev/null)"}#refs/heads/feature/}) branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads/"$1" 2>/dev/null)"}#refs/heads/$1/})
__git_command_successful || return __git_command_successful || return
_wanted branch-names expl branch-name compadd $* - $branch_names _wanted branch-names expl branch-name compadd $* - $branch_names
} }
__git_feature_branch_names() {
__git_specific_branch_names 'feature'
}
__git_refactor_branch_names() { __git_refactor_branch_names() {
local expl __git_specific_branch_names 'refactor'
declare -a branch_names
branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads/refactor 2>/dev/null)"}#refs/heads/refactor/})
__git_command_successful || return
_wanted branch-names expl branch-name compadd $* - $branch_names
} }
__git_bug_branch_names() { __git_bug_branch_names() {
local expl __git_specific_branch_names 'bug'
declare -a branch_names
branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads/bug 2>/dev/null)"}#refs/heads/bug/})
__git_command_successful || return
_wanted branch-names expl branch-name compadd $* - $branch_names
} }
@ -92,6 +100,35 @@ __git_author_names() {
_wanted author-names expl author-name compadd $* - $author_names _wanted author-names expl author-name compadd $* - $author_names
} }
# subcommands
_git-bug() {
local curcontext=$curcontext state line ret=1
declare -A opt_args
_arguments -C \
': :->command' \
'*:: :->option-or-argument' && ret=0
case $state in
(command)
declare -a commands
commands=(
'finish:merge bug into the current branch'
)
_describe -t commands command commands && ret=0
;;
(option-or-argument)
curcontext=${curcontext%:*}-$line[1]:
case $line[1] in
(finish)
_arguments -C \
':branch-name:__git_bug_branch_names'
;;
esac
esac
}
_git-changelog() { _git-changelog() {
_arguments \ _arguments \
@ -99,11 +136,6 @@ _git-changelog() {
} }
_git-effort() {
_arguments \
'--above[ignore file with less than x commits]' \
}
_git-contrib() { _git-contrib() {
_arguments \ _arguments \
@ -135,6 +167,11 @@ _git-delete-tag() {
} }
_git-effort() {
_arguments \
'--above[ignore file with less than x commits]'
}
_git-extras() { _git-extras() {
local curcontext=$curcontext state line ret=1 local curcontext=$curcontext state line ret=1
declare -A opt_args declare -A opt_args
@ -154,20 +191,7 @@ _git-extras() {
esac esac
_arguments \ _arguments \
'(-v --version)'{-v,--version}'[show current version]' \ '(-v --version)'{-v,--version}'[show current version]'
}
_git-graft() {
_arguments \
':src-branch-name:__git_branch_names' \
':dest-branch-name:__git_branch_names'
}
_git-squash() {
_arguments \
':branch-name:__git_branch_names'
} }
@ -199,6 +223,25 @@ _git-feature() {
} }
_git-graft() {
_arguments \
':src-branch-name:__git_branch_names' \
':dest-branch-name:__git_branch_names'
}
_git-ignore() {
_arguments -C \
'(--local -l)'{--local,-l}'[show local gitignore]' \
'(--global -g)'{--global,-g}'[show global gitignore]'
}
_git-missing() {
_arguments \
':first-branch-name:__git_branch_names' \
':second-branch-name:__git_branch_names'
}
_git-refactor() { _git-refactor() {
local curcontext=$curcontext state line ret=1 local curcontext=$curcontext state line ret=1
declare -A opt_args declare -A opt_args
@ -227,59 +270,62 @@ _git-refactor() {
} }
_git-bug() { _git-squash() {
local curcontext=$curcontext state line ret=1 _arguments \
declare -A opt_args ':branch-name:__git_branch_names'
}
_arguments -C \ _git-summary() {
': :->command' \ _arguments '--line[summarize with lines other than commits]'
'*:: :->option-or-argument' && ret=0 __git_commits
case $state in
(command)
declare -a commands
commands=(
'finish:merge bug into the current branch'
)
_describe -t commands command commands && ret=0
;;
(option-or-argument)
curcontext=${curcontext%:*}-$line[1]:
case $line[1] in
(finish)
_arguments -C \
':branch-name:__git_bug_branch_names'
;;
esac
esac
} }
_git-undo(){
_arguments -C \
'(--soft -s)'{--soft,-s}'[only rolls back the commit but changes remain un-staged]' \
'(--hard -h)'{--hard,-h}'[wipes your commit(s)]'
}
zstyle ':completion:*:*:git:*' user-commands \ zstyle ':completion:*:*:git:*' user-commands \
alias:'define, search and show aliases' \
archive-file:'export the current HEAD of the git repository to a archive' \
back:'undo and stage latest commits' \
bug:'create a bug branch' \
changelog:'populate changelog file with commits since the previous tag' \ changelog:'populate changelog file with commits since the previous tag' \
commits-since:'list commits since a given date' \
contrib:'display author contributions' \ contrib:'display author contributions' \
count:'count commits' \ count:'count commits' \
create-branch:'create local and remote branch' \
delete-branch:'delete local and remote branch' \ delete-branch:'delete local and remote branch' \
delete-merged-brancees:'delete merged branches'\
delete-submodule:'delete submodule' \ delete-submodule:'delete submodule' \
delete-tag:'delete local and remote tag' \ delete-tag:'delete local and remote tag' \
extras:'git-extras' \
graft:'merge commits from source branch to destination branch' \
squash:'merge commits from source branch into the current one as a single commit' \
feature:'create a feature branch' \
refactor:'create a refactor branch' \
bug:'create a bug branch' \
summary:'repository summary' \
effort:'display effort statistics' \ effort:'display effort statistics' \
repl:'read-eval-print-loop' \ extras:'git-extras' \
commits-since:'list commits since a given date' \ feature:'create a feature branch' \
release:'release commit with the given tag' \ fork:'fork a repo on github' \
alias:'define, search and show aliases' \ fresh-branch:'create empty local branch' \
gh-pages:'create the GitHub Pages branch' \
graft:'merge commits from source branch to destination branch' \
ignore:'add patterns to .gitignore' \ ignore:'add patterns to .gitignore' \
info:'show info about the repository' \ info:'show info about the repository' \
create-branch:'create local and remote branch' \
fresh-branch:'create empty local branch' \
undo:'remove the latest commit' \
setup:'setup a git repository' \
touch:'one step creation of new files' \
obliterate:'Completely remove a file from the repository, including past commits and tags' \
local-commits:'list unpushed commits on the local branch' \ local-commits:'list unpushed commits on the local branch' \
lock:'lock a file excluded from version control' \
locked:'ls files that have been locked' \
missing:'show commits missing from another branch' \
pr:'checks out a pull request locally' \
rebase-patch:'rebases a patch' \
refactor:'create a refactor branch' \
release:'commit, tag and push changes to the repository' \
rename-tag:'rename a tag' \
repl:'read-eval-print-loop' \
reset-file:'reset one file' \
root:'show path of root' \
setup:'setup a git repository' \
show-tree:'show branch tree of commit history' \
squash:'merge commits from source branch into the current one as a single commit' \
summary:'repository summary' \
touch:'one step creation of new files' \
undo:'remove the latest commit' \
unlock:'unlock a file excluded from version control'

View file

@ -21,7 +21,7 @@
# #
#Alias #Alias
alias gf='git flow' alias gfl='git flow'
alias gcd='git checkout develop' alias gcd='git checkout develop'
alias gch='git checkout hotfix' alias gch='git checkout hotfix'
alias gcr='git checkout release' alias gcr='git checkout release'

View file

@ -1,57 +1,92 @@
# ZSH Git Prompt Plugin from: # ZSH Git Prompt Plugin from:
# http://github.com/olivierverdier/zsh-git-prompt # http://github.com/olivierverdier/zsh-git-prompt
#
export __GIT_PROMPT_DIR=$ZSH/plugins/git-prompt
# Allow for functions in the prompt. __GIT_PROMPT_DIR="${0:A:h}"
setopt PROMPT_SUBST
## Enable auto-execution of functions. ## Hook function definitions
typeset -ga preexec_functions function chpwd_update_git_vars() {
typeset -ga precmd_functions update_current_git_vars
typeset -ga chpwd_functions }
# Append git functions needed for prompt.
preexec_functions+='preexec_update_git_vars'
precmd_functions+='precmd_update_git_vars'
chpwd_functions+='chpwd_update_git_vars'
## Function definitions
function preexec_update_git_vars() { function preexec_update_git_vars() {
case "$2" in case "$2" in
git*) git*|hub*|gh*|stg*)
__EXECUTED_GIT_COMMAND=1 __EXECUTED_GIT_COMMAND=1
;; ;;
esac esac
} }
function precmd_update_git_vars() { function precmd_update_git_vars() {
if [ -n "$__EXECUTED_GIT_COMMAND" ]; then if [ -n "$__EXECUTED_GIT_COMMAND" ] || [ ! -n "$ZSH_THEME_GIT_PROMPT_CACHE" ]; then
update_current_git_vars update_current_git_vars
unset __EXECUTED_GIT_COMMAND unset __EXECUTED_GIT_COMMAND
fi fi
} }
function chpwd_update_git_vars() { chpwd_functions+=(chpwd_update_git_vars)
update_current_git_vars precmd_functions+=(precmd_update_git_vars)
} preexec_functions+=(preexec_update_git_vars)
## Function definitions
function update_current_git_vars() { function update_current_git_vars() {
unset __CURRENT_GIT_STATUS unset __CURRENT_GIT_STATUS
local gitstatus="$__GIT_PROMPT_DIR/gitstatus.py" local gitstatus="$__GIT_PROMPT_DIR/gitstatus.py"
_GIT_STATUS=`python ${gitstatus}` _GIT_STATUS=$(python ${gitstatus} 2>/dev/null)
__CURRENT_GIT_STATUS=("${(f)_GIT_STATUS}") __CURRENT_GIT_STATUS=("${(@s: :)_GIT_STATUS}")
GIT_BRANCH=$__CURRENT_GIT_STATUS[1]
GIT_AHEAD=$__CURRENT_GIT_STATUS[2]
GIT_BEHIND=$__CURRENT_GIT_STATUS[3]
GIT_STAGED=$__CURRENT_GIT_STATUS[4]
GIT_CONFLICTS=$__CURRENT_GIT_STATUS[5]
GIT_CHANGED=$__CURRENT_GIT_STATUS[6]
GIT_UNTRACKED=$__CURRENT_GIT_STATUS[7]
} }
function prompt_git_info() { git_super_status() {
precmd_update_git_vars
if [ -n "$__CURRENT_GIT_STATUS" ]; then if [ -n "$__CURRENT_GIT_STATUS" ]; then
echo "(%{${fg[red]}%}$__CURRENT_GIT_STATUS[1]%{${fg[default]}%}$__CURRENT_GIT_STATUS[2]%{${fg[magenta]}%}$__CURRENT_GIT_STATUS[3]%{${fg[default]}%})" STATUS="$ZSH_THEME_GIT_PROMPT_PREFIX$ZSH_THEME_GIT_PROMPT_BRANCH$GIT_BRANCH%{${reset_color}%}"
if [ "$GIT_BEHIND" -ne "0" ]; then
STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_BEHIND$GIT_BEHIND%{${reset_color}%}"
fi
if [ "$GIT_AHEAD" -ne "0" ]; then
STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_AHEAD$GIT_AHEAD%{${reset_color}%}"
fi
STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_SEPARATOR"
if [ "$GIT_STAGED" -ne "0" ]; then
STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_STAGED$GIT_STAGED%{${reset_color}%}"
fi
if [ "$GIT_CONFLICTS" -ne "0" ]; then
STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_CONFLICTS$GIT_CONFLICTS%{${reset_color}%}"
fi
if [ "$GIT_CHANGED" -ne "0" ]; then
STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_CHANGED$GIT_CHANGED%{${reset_color}%}"
fi
if [ "$GIT_UNTRACKED" -ne "0" ]; then
STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNTRACKED%{${reset_color}%}"
fi
if [ "$GIT_CHANGED" -eq "0" ] && [ "$GIT_CONFLICTS" -eq "0" ] && [ "$GIT_STAGED" -eq "0" ] && [ "$GIT_UNTRACKED" -eq "0" ]; then
STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_CLEAN"
fi
STATUS="$STATUS%{${reset_color}%}$ZSH_THEME_GIT_PROMPT_SUFFIX"
echo "$STATUS"
fi fi
} }
# Default values for the appearance of the prompt.
ZSH_THEME_GIT_PROMPT_PREFIX="("
ZSH_THEME_GIT_PROMPT_SUFFIX=")"
ZSH_THEME_GIT_PROMPT_SEPARATOR="|"
ZSH_THEME_GIT_PROMPT_BRANCH="%{$fg_bold[magenta]%}"
ZSH_THEME_GIT_PROMPT_STAGED="%{$fg[red]%}%{●%G%}"
ZSH_THEME_GIT_PROMPT_CONFLICTS="%{$fg[red]%}%{✖%G%}"
ZSH_THEME_GIT_PROMPT_CHANGED="%{$fg[blue]%}%{✚%G%}"
ZSH_THEME_GIT_PROMPT_BEHIND="%{↓%G%}"
ZSH_THEME_GIT_PROMPT_AHEAD="%{↑%G%}"
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{…%G%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg_bold[green]%}%{✔%G%}"
# Set the prompt. # Set the prompt.
#PROMPT='%B%m%~%b$(prompt_git_info) %# ' RPROMPT='$(git_super_status)'
# for a right prompt:
#RPROMPT='%b$(prompt_git_info)'
RPROMPT='$(prompt_git_info)'

View file

@ -1,82 +1,84 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 -*- from __future__ import print_function
from subprocess import Popen, PIPE
import re
# change those symbols to whatever you prefer
symbols = {
'ahead of': '',
'behind': '',
'staged': '',
'changed': '',
'untracked': '',
'clean': '',
'unmerged': '',
'sha1': ':'
}
output, error = Popen(
['git', 'status'], stdout=PIPE, stderr=PIPE, universal_newlines=True).communicate()
if error:
import sys import sys
sys.exit(0) import re
lines = output.splitlines() import shlex
from subprocess import Popen, PIPE, check_output
behead_re = re.compile(
r"^# Your branch is (ahead of|behind) '(.*)' by (\d+) commit")
diverge_re = re.compile(r"^# and have (\d+) and (\d+) different")
status = ''
staged = re.compile(r'^# Changes to be committed:$', re.MULTILINE)
changed = re.compile(r'^# Changed but not updated:$', re.MULTILINE)
untracked = re.compile(r'^# Untracked files:$', re.MULTILINE)
unmerged = re.compile(r'^# Unmerged paths:$', re.MULTILINE)
def execute(*command): def get_tagname_or_hash():
out, err = Popen(stdout=PIPE, stderr=PIPE, *command).communicate() """return tagname if exists else hash"""
if not err: cmd = 'git log -1 --format="%h%d"'
nb = len(out.splitlines()) output = check_output(shlex.split(cmd)).decode('utf-8').strip()
hash_, tagname = None, None
# get hash
m = re.search('\(.*\)$', output)
if m:
hash_ = output[:m.start()-1]
# get tagname
m = re.search('tag: .*[,\)]', output)
if m:
tagname = 'tags/' + output[m.start()+len('tag: '): m.end()-1]
if tagname:
return tagname
elif hash_:
return hash_
return None
# `git status --porcelain --branch` can collect all information
# branch, remote_branch, untracked, staged, changed, conflicts, ahead, behind
po = Popen(['git', 'status', '--porcelain', '--branch'], stdout=PIPE, stderr=PIPE)
stdout, sterr = po.communicate()
if po.returncode != 0:
sys.exit(0) # Not a git repository
# collect git status information
untracked, staged, changed, conflicts = [], [], [], []
ahead, behind = 0, 0
status = [(line[0], line[1], line[2:]) for line in stdout.decode('utf-8').splitlines()]
for st in status:
if st[0] == '#' and st[1] == '#':
if re.search('Initial commit on', st[2]):
branch = st[2].split(' ')[-1]
elif re.search('no branch', st[2]): # detached status
branch = get_tagname_or_hash()
elif len(st[2].strip().split('...')) == 1:
branch = st[2].strip()
else: else:
nb = '?' # current and remote branch info
return nb branch, rest = st[2].strip().split('...')
if len(rest.split(' ')) == 1:
if staged.search(output): # remote_branch = rest.split(' ')[0]
nb = execute( pass
['git', 'diff', '--staged', '--name-only', '--diff-filter=ACDMRT'])
status += '%s%s' % (symbols['staged'], nb)
if unmerged.search(output):
nb = execute(['git', 'diff', '--staged', '--name-only', '--diff-filter=U'])
status += '%s%s' % (symbols['unmerged'], nb)
if changed.search(output):
nb = execute(['git', 'diff', '--name-only', '--diff-filter=ACDMRT'])
status += '%s%s' % (symbols['changed'], nb)
if untracked.search(output):
status += symbols['untracked']
if status == '':
status = symbols['clean']
remote = ''
bline = lines[0]
if bline.find('Not currently on any branch') != -1:
branch = symbols['sha1'] + Popen([
'git',
'rev-parse',
'--short',
'HEAD'], stdout=PIPE).communicate()[0][:-1]
else: else:
branch = bline.split(' ')[-1] # ahead or behind
bstatusline = lines[1] divergence = ' '.join(rest.split(' ')[1:])
match = behead_re.match(bstatusline) divergence = divergence.lstrip('[').rstrip(']')
if match: for div in divergence.split(', '):
remote = symbols[match.groups()[0]] if 'ahead' in div:
remote += match.groups()[2] ahead = int(div[len('ahead '):].strip())
elif lines[2:]: elif 'behind' in div:
div_match = diverge_re.match(lines[2]) behind = int(div[len('behind '):].strip())
if div_match: elif st[0] == '?' and st[1] == '?':
remote = "{behind}{1}{ahead of}{0}".format( untracked.append(st)
*div_match.groups(), **symbols) else:
if st[1] == 'M':
changed.append(st)
if st[0] == 'U':
conflicts.append(st)
elif st[0] != ' ':
staged.append(st)
print('\n'.join([branch, remote, status])) out = ' '.join([
branch,
str(ahead),
str(behind),
str(len(staged)),
str(len(conflicts)),
str(len(changed)),
str(len(untracked)),
])
print(out, end='')

View file

@ -68,10 +68,12 @@ alias gc!='git commit -v --amend'
alias gca='git commit -v -a' alias gca='git commit -v -a'
alias gca!='git commit -v -a --amend' alias gca!='git commit -v -a --amend'
alias gcan!='git commit -v -a -s --no-edit --amend' alias gcan!='git commit -v -a -s --no-edit --amend'
alias gcam='git commit -a -m'
alias gcb='git checkout -b' alias gcb='git checkout -b'
alias gcf='git config --list' alias gcf='git config --list'
alias gcl='git clone --recursive' alias gcl='git clone --recursive'
alias gclean='git reset --hard && git clean -dfx' alias gclean='git clean -fd'
alias gpristine='git reset --hard && git clean -dfx'
alias gcm='git checkout master' alias gcm='git checkout master'
alias gcmsg='git commit -m' alias gcmsg='git commit -m'
alias gco='git checkout' alias gco='git checkout'

View file

@ -29,7 +29,10 @@ if [[ -x "${commands[gwhoami]}" ]]; then
'gunexpand' 'guniq' 'gunlink' 'guptime' 'gusers' 'gvdir' 'gwc' 'gwho' 'gunexpand' 'guniq' 'gunlink' 'guptime' 'gusers' 'gvdir' 'gwc' 'gwho'
'gwhoami' 'gyes') 'gwhoami' 'gyes')
# Not part of coreutils, installed separately. # findutils
gcmds+=('gfind' 'gxargs' 'glocate')
# Not part of either coreutils or findutils, installed separately.
gcmds+=('gsed' 'gtar' 'gtime') gcmds+=('gsed' 'gtar' 'gtime')
for gcmd in "${gcmds[@]}"; do for gcmd in "${gcmds[@]}"; do

View file

@ -54,23 +54,42 @@ __go_tool_complete() {
'-installsuffix[suffix to add to package directory]:suffix' '-installsuffix[suffix to add to package directory]:suffix'
'-tags[list of build tags to consider satisfied]:tags' '-tags[list of build tags to consider satisfied]:tags'
) )
__go_list() { __go_packages() {
local expl importpaths local gopaths
declare -a importpaths declare -a gopaths
importpaths=($(go list ${words[$CURRENT]}... 2>/dev/null)) gopaths=("${(s/:/)$(go env GOPATH)}")
_wanted importpaths expl 'import paths' compadd "$@" - "${importpaths[@]}" gopaths+=("$(go env GOROOT)")
for p in $gopaths; do
_path_files -W "$p/src" -/
done
}
__go_identifiers() {
compadd $(godoc -templates $ZSH/plugins/golang/templates ${words[-2]} 2> /dev/null)
} }
case ${words[2]} in case ${words[2]} in
clean|doc) doc)
_arguments -s -w : '*:importpaths:__go_list' _arguments -s -w \
"-c[symbol matching honors case (paths not affected)]" \
"-cmd[show symbols with package docs even if package is a command]" \
"-u[show unexported symbols as well as exported]" \
"2:importpaths:__go_packages" \
":next identifiers:__go_identifiers"
;;
clean)
_arguments -s -w \
"-i[remove the corresponding installed archive or binary (what 'go install' would create)]" \
"-n[print the remove commands it would execute, but not run them]" \
"-r[apply recursively to all the dependencies of the packages named by the import paths]" \
"-x[print remove commands as it executes them]" \
"*:importpaths:__go_packages"
;; ;;
fix|fmt|list|vet) fix|fmt|list|vet)
_alternative ':importpaths:__go_list' ':files:_path_files -g "*.go"' _alternative ':importpaths:__go_packages' ':files:_path_files -g "*.go"'
;; ;;
install) install)
_arguments -s -w : ${build_flags[@]} \ _arguments -s -w : ${build_flags[@]} \
"-v[show package names]" \ "-v[show package names]" \
'*:importpaths:__go_list' '*:importpaths:__go_packages'
;; ;;
get) get)
_arguments -s -w : \ _arguments -s -w : \
@ -81,7 +100,7 @@ __go_tool_complete() {
${build_flags[@]} \ ${build_flags[@]} \
"-v[show package names]" \ "-v[show package names]" \
"-o[output file]:file:_files" \ "-o[output file]:file:_files" \
"*:args:{ _alternative ':importpaths:__go_list' ':files:_path_files -g \"*.go\"' }" "*:args:{ _alternative ':importpaths:__go_packages' ':files:_path_files -g \"*.go\"' }"
;; ;;
test) test)
_arguments -s -w : \ _arguments -s -w : \
@ -103,7 +122,7 @@ __go_tool_complete() {
"-cpuprofile[write CPU profile to file]:file:_files" \ "-cpuprofile[write CPU profile to file]:file:_files" \
"-memprofile[write heap profile to file]:file:_files" \ "-memprofile[write heap profile to file]:file:_files" \
"-memprofilerate[set heap profiling rate]:number" \ "-memprofilerate[set heap profiling rate]:number" \
"*:args:{ _alternative ':importpaths:__go_list' ':files:_path_files -g \"*.go\"' }" "*:args:{ _alternative ':importpaths:__go_packages' ':files:_path_files -g \"*.go\"' }"
;; ;;
help) help)
_values "${commands[@]}" \ _values "${commands[@]}" \

View file

@ -0,0 +1,29 @@
{{with .PDoc}}{{/*
Constants
---------------------------------------
*/}}{{with .Consts}}{{range .}}{{range .Names}}{{.}} {{end}}{{end}}{{end}}{{/*
Variables
---------------------------------------
*/}}{{with .Vars}}{{range .}}{{range .Names}}{{.}} {{end}}{{end}}{{end}}{{/*
Functions
---------------------------------------
*/}}{{with .Funcs}}{{range .}}{{ .Name }} {{end}}{{end}}{{/*
Types
---------------------------------------
*/}}{{with .Types}}{{range .}}{{ $TypeName := .Name }}{{ $TypeName }} {{/*
*/}}{{range .Methods}}{{ $TypeName }}.{{.Name}} {{end}}{{/*
*/}}{{range .Funcs}}{{.Name}} {{end}}{{/*
*/}}{{range .Consts}}{{range .Names}}{{.}} {{end}}{{end}}{{/*
*/}}{{range .Vars}}{{range .Names}}{{.}} {{end}}{{end}}{{end}}{{end}}{{end}}

View file

View file

@ -82,7 +82,7 @@ _gradlew_tasks () {
if [ in_gradle ]; then if [ in_gradle ]; then
_gradle_arguments _gradle_arguments
if _gradle_does_task_list_need_generating; then if _gradle_does_task_list_need_generating; then
gradlew tasks --all | grep "^[ ]*[a-zA-Z0-9:]*\ -\ " | sed "s/ - .*$//" | sed "s/[\ ]*//" > .gradletasknamecache ./gradlew tasks --all | grep "^[ ]*[a-zA-Z0-9:]*\ -\ " | sed "s/ - .*$//" | sed "s/[\ ]*//" > .gradletasknamecache
fi fi
compadd -X "==== Gradlew Tasks ====" `cat .gradletasknamecache` compadd -X "==== Gradlew Tasks ====" `cat .gradletasknamecache`
fi fi

View file

@ -0,0 +1,29 @@
#!/usr/bin/env zsh
#
# gulp-autocompletion-zsh
#
# Autocompletion for your gulp.js tasks
#
# Copyright(c) 2014 André König <andre.koenig@posteo.de>
# MIT Licensed
#
#
# André König
# Github: https://github.com/akoenig
# Twitter: https://twitter.com/caiifr
#
#
# Grabs all available tasks from the `gulpfile.js`
# in the current directory.
#
function $$gulp_completion() {
compls=$(grep -Eo "gulp.task\(('(([a-zA-Z0-9]|-)*)',)" gulpfile.js 2>/dev/null | grep -Eo "'(([a-zA-Z0-9]|-)*)'" | sed s/"'"//g | sort)
completions=(${=compls})
compadd -- $completions
}
compdef $$gulp_completion gulp

View file

@ -143,5 +143,6 @@ _arguments \
$_command_args \ $_command_args \
'(--app)--app[the app name]' \ '(--app)--app[the app name]' \
'(--remote)--remote[the remote name]' \ '(--remote)--remote[the remote name]' \
'(--help)--help[help about the current command]' \
&& return 0 && return 0

64
plugins/jira/README.md Normal file
View file

@ -0,0 +1,64 @@
# Jira plugin #
CLI support for JIRA interaction
## Description ##
This plugin provides command line tools for interacting with Atlassian's [JIRA](https://www.atlassian.com/software/jira) bug tracking software.
The interaction is all done through the web. No local installation of JIRA is necessary.
In this document, "JIRA" refers to the JIRA issue tracking server, and `jira` refers to the command this plugin supplies.
## Usage ##
This plugin supplies one command, `jira`, through which all its features are exposed. Most forms of this command open a JIRA page in your web browser.
```
jira # performs the default action
jira new # opens a new issue
jira dashboard # opens your JIRA dashboard
jira reported [username] # queries for issues reported by a user
jira assigned [username] # queries for issues assigned to a user
jira ABC-123 # opens an existing issue
jira ABC-123 m # opens an existing issue for adding a comment
```
#### Debugging usage ####
These calling forms are for developers' use, and may change at any time.
```
jira dumpconfig # displays the effective configuration
```
## Setup ##
The URL for your JIRA instance is set by `$JIRA_URL` or a `.jira_url` file.
Add a `.jira-url` file in the base of your project. You can also set `$JIRA_URL` in your `~/.zshrc` or put a `.jira-url` in your home directory. A `.jira-url` in the current directory takes precedence, so you can make per-project customizations.
The same goes with `.jira-prefix` and `$JIRA_PREFIX`. These control the prefix added to all issue IDs, which differentiates projects within a JIRA instance.
For example:
```
cd to/my/project
echo "https://jira.atlassian.com" >> .jira-url
```
(Note: The current implementation only looks in the current directory for `.jira-url` and `.jira-prefix`, not up the path, so if you are in a subdirectory of your project, it will fall back to your default JIRA URL. This will probably change in the future though.)
### Variables ###
* `$JIRA_URL` - Your JIRA instance's URL
* `$JIRA_NAME` - Your JIRA username; used as the default user for `assigned`/`reported` searches
* `$JIRA_PREFIX` - Prefix added to issue ID arguments
* `$JIRA_RAPID_BOARD` - Set to `true` if you use Rapid Board
* `$JIRA_DEFAULT_ACTION` - Action to do when `jira` is called with no arguments; defaults to "new"
### Browser ###
Your default web browser, as determined by how `open_command` handles `http://` URLs, is used for interacting with the JIRA instance. If you change your system's URL handler associations, it will change the browser that `jira` uses.

22
plugins/jira/_jira Normal file
View file

@ -0,0 +1,22 @@
#compdef jira
#autoload
local -a _1st_arguments
_1st_arguments=(
'new:create a new issue'
'dashboard:open the dashboard'
'reported:search for issues reported by a user'
'assigned:search for issues assigned to a user'
'dumpconfig:display effective jira configuration'
)
_arguments -C \
':command:->command' \
'*::options:->options'
case $state in
(command)
_describe -t commands "jira subcommand" _1st_arguments
return
;;
esac

View file

@ -1,97 +1,102 @@
# To use: add a .jira-url file in the base of your project # CLI support for JIRA interaction
# You can also set JIRA_URL in your .zshrc or put .jira-url in your home directory
# .jira-url in the current directory takes precedence
# #
# If you use Rapid Board, set: # See README.md for details
#JIRA_RAPID_BOARD="true"
# in you .zshrc
#
# Setup: cd to/my/project
# echo "https://name.jira.com" >> .jira-url
# Usage: jira # opens a new issue
# jira ABC-123 # Opens an existing issue
open_jira_issue () {
local open_cmd
if [[ "$OSTYPE" = darwin* ]]; then
open_cmd='open'
else
open_cmd='xdg-open'
fi
if [ -f .jira-url ]; then : ${JIRA_DEFAULT_ACTION:=new}
function jira() {
emulate -L zsh
local action=${1:=$JIRA_DEFAULT_ACTION}
local jira_url jira_prefix
if [[ -f .jira-url ]]; then
jira_url=$(cat .jira-url) jira_url=$(cat .jira-url)
elif [ -f ~/.jira-url ]; then elif [[ -f ~/.jira-url ]]; then
jira_url=$(cat ~/.jira-url) jira_url=$(cat ~/.jira-url)
elif [[ "x$JIRA_URL" != "x" ]]; then elif [[ -n "${JIRA_URL}" ]]; then
jira_url=$JIRA_URL jira_url=${JIRA_URL}
else else
echo "JIRA url is not specified anywhere." _jira_url_help
return 1 return 1
fi fi
if [ -f .jira-prefix ]; then if [[ -f .jira-prefix ]]; then
jira_prefix=$(cat .jira-prefix) jira_prefix=$(cat .jira-prefix)
elif [ -f ~/.jira-prefix ]; then elif [[ -f ~/.jira-prefix ]]; then
jira_prefix=$(cat ~/.jira-prefix) jira_prefix=$(cat ~/.jira-prefix)
elif [[ -n "${JIRA_PREFIX}" ]]; then
jira_prefix=${JIRA_PREFIX}
else else
jira_prefix="" jira_prefix=""
fi fi
if [ -z "$1" ]; then
if [[ $action == "new" ]]; then
echo "Opening new issue" echo "Opening new issue"
$open_cmd "${jira_url}/secure/CreateIssue!default.jspa" open_command "${jira_url}/secure/CreateIssue!default.jspa"
elif [[ "$1" = "assigned" || "$1" = "reported" ]]; then elif [[ "$action" == "assigned" || "$action" == "reported" ]]; then
jira_query $@ _jira_query $@
elif [[ "$action" == "dashboard" ]]; then
echo "Opening dashboard"
open_command "${jira_url}/secure/Dashboard.jspa"
elif [[ "$action" == "dumpconfig" ]]; then
echo "JIRA_URL=$jira_url"
echo "JIRA_PREFIX=$jira_prefix"
echo "JIRA_NAME=$JIRA_NAME"
echo "JIRA_RAPID_BOARD=$JIRA_RAPID_BOARD"
echo "JIRA_DEFAULT_ACTION=$JIRA_DEFAULT_ACTION"
else else
local addcomment='' # Anything that doesn't match a special action is considered an issue name
local issue_arg=$action
local issue="${jira_prefix}${issue_arg}"
local url_fragment=''
if [[ "$2" == "m" ]]; then if [[ "$2" == "m" ]]; then
addcomment="#add-comment" url_fragment="#add-comment"
echo "Add comment to issue #$1" echo "Add comment to issue #$issue"
else else
echo "Opening issue #$1" echo "Opening issue #$issue"
fi fi
if [[ "$JIRA_RAPID_BOARD" == "true" ]]; then
if [[ "x$JIRA_RAPID_BOARD" = "xtrue" ]]; then open_command "${jira_url}/issues/${issue}${url_fragment}"
$open_cmd "$jira_url/issues/$jira_prefix$1$addcomment"
else else
$open_cmd "$jira_url/browse/$jira_prefix$1$addcomment" open_command "${jira_url}/browse/${issue}${url_fragment}"
fi fi
fi fi
} }
jira_name () { function _jira_url_help() {
if [[ -z "$1" ]]; then cat << EOF
if [[ "x${JIRA_NAME}" != "x" ]]; then error: JIRA URL is not specified anywhere.
jira_name=${JIRA_NAME}
else Valid options, in order of precedence:
echo "JIRA_NAME not specified" .jira-url file
return 1 \$HOME/.jira-url file
fi \$JIRA_URL environment variable
else EOF
jira_name=$@
fi
} }
jira_query () { function _jira_query() {
verb="$1" emulate -L zsh
if [[ "${verb}" = "reported" ]]; then local verb="$1"
local jira_name lookup preposition query
if [[ "${verb}" == "reported" ]]; then
lookup=reporter lookup=reporter
preposition=by preposition=by
elif [[ "${verb}" = "assigned" ]]; then elif [[ "${verb}" == "assigned" ]]; then
lookup=assignee lookup=assignee
preposition=to preposition=to
else else
echo "not a valid lookup $verb" echo "error: not a valid lookup: $verb" >&2
return 1 return 1
fi fi
shift 1 jira_name=${2:=$JIRA_NAME}
jira_name $@ if [[ -z $jira_name ]]; then
if [[ $? = 1 ]]; then echo "error: JIRA_NAME not specified" >&2
return 1 return 1
fi fi
echo "Browsing issues ${verb} ${preposition} ${jira_name}" echo "Browsing issues ${verb} ${preposition} ${jira_name}"
$open_cmd "${jira_url}/secure/IssueNavigator.jspa?reset=true&jqlQuery=${lookup}+%3D+%22${jira_name}%22+AND+resolution+%3D+unresolved+ORDER+BY+priority+DESC%2C+created+ASC" query="${lookup}+%3D+%22${jira_name}%22+AND+resolution+%3D+unresolved+ORDER+BY+priority+DESC%2C+created+ASC"
open_command "${jira_url}/secure/IssueNavigator.jspa?reset=true&jqlQuery=${query}"
} }
alias jira='open_jira_issue'

View file

@ -8,7 +8,8 @@ mkdir -p $ZSH_CACHE_DIR
cache_file="$ZSH_CACHE_DIR/last-working-dir" cache_file="$ZSH_CACHE_DIR/last-working-dir"
# Updates the last directory once directory is changed. # Updates the last directory once directory is changed.
function chpwd() { chpwd_functions+=(chpwd_last_working_dir)
function chpwd_last_working_dir() {
# Use >| in case noclobber is set to avoid "file exists" error # Use >| in case noclobber is set to avoid "file exists" error
pwd >| "$cache_file" pwd >| "$cache_file"
} }

View file

@ -9,7 +9,7 @@ open_lighthouse_ticket () {
else else
lighthouse_url=$(cat .lighthouse-url); lighthouse_url=$(cat .lighthouse-url);
echo "Opening ticket #$1"; echo "Opening ticket #$1";
`open $lighthouse_url/tickets/$1`; open_command "$lighthouse_url/tickets/$1";
fi fi
} }

27
plugins/man/man.zsh Normal file
View file

@ -0,0 +1,27 @@
# ------------------------------------------------------------------------------
# Author
# ------
#
# * Jerry Ling<jerryling315@gmail.com>
#
# ------------------------------------------------------------------------------
# Usgae
# -----
#
# man will be inserted before the command
#
# ------------------------------------------------------------------------------
man-command-line() {
[[ -z $BUFFER ]] && zle up-history
[[ $BUFFER != man\ * ]] && LBUFFER="man $LBUFFER"
}
zle -N man-command-line
# Defined shortcut keys: [Esc]man
bindkey "\e"man man-command-line
# ------------------------------------------------------------------------------
# Also, you might want to use man-preview included in 'osx' plugin
# just substitute "man" in the function with "man-preview" after you included OS X in
# the .zshrc

View file

@ -0,0 +1,34 @@
# ------------------------------------------------------------------------------
# FILE: n98-magerun.plugin.zsh
# DESCRIPTION: oh-my-zsh n98-magerun plugin file. Adapted from composer plugin
# AUTHOR: Andrew Dwyer (andrewrdwyer at gmail dot com)
# VERSION: 1.0.0
# ------------------------------------------------------------------------------
# n98-magerun basic command completion
_n98_magerun_get_command_list () {
$_comp_command1 --no-ansi | sed "1,/Available commands/d" | awk '/^ +[a-z\-:]+/ { print $1 }'
}
_n98_magerun () {
_arguments '1: :->command' '*:optional arg:_files'
case $state in
command)
compadd $(_n98_magerun_get_command_list)
;;
*)
esac
}
compdef _n98_magerun n98-magerun.phar
compdef _n98_magerun n98-magerun
# Aliases
alias n98='n98-magerun.phar'
alias mage='n98-magerun.phar'
alias magefl='n98-magerun.phar cache:flush'
# Install n98-magerun into the current directory
alias mage-get='wget https://raw.github.com/netz98/n98-magerun/master/n98-magerun.phar'

View file

@ -1,13 +1,5 @@
# Open the node api for your current version to the optional section. # Open the node api for your current version to the optional section.
# TODO: Make the section part easier to use. # TODO: Make the section part easier to use.
function node-docs { function node-docs {
# get the open command open_command "http://nodejs.org/docs/$(node --version)/api/all.html#all_$1"
local open_cmd
if [[ "$OSTYPE" = darwin* ]]; then
open_cmd='open'
else
open_cmd='xdg-open'
fi
$open_cmd "http://nodejs.org/docs/$(node --version)/api/all.html#all_$1"
} }

View file

@ -12,3 +12,6 @@ alias npmS="npm i -S "
# Install and save to dev-dependencies in your package.json # Install and save to dev-dependencies in your package.json
# npmd is used by https://github.com/dominictarr/npmd # npmd is used by https://github.com/dominictarr/npmd
alias npmD="npm i -D " alias npmD="npm i -D "
# Execute command from node_modules folder based on current directory
# i.e npmE gulp
alias npmE='PATH="$(npm bin)":"$PATH"'

View file

@ -5,29 +5,35 @@
# VERSION: 1.1.0 # VERSION: 1.1.0
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
function tab() { function _omz_osx_get_frontmost_app() {
local command="cd \\\"$PWD\\\"; clear; " local the_app=$(
(( $# > 0 )) && command="${command}; $*"
the_app=$(
osascript 2>/dev/null <<EOF osascript 2>/dev/null <<EOF
tell application "System Events" tell application "System Events"
name of first item of (every process whose frontmost is true) name of first item of (every process whose frontmost is true)
end tell end tell
EOF EOF
) )
echo "$the_app"
[[ "$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' ]] && { function tab() {
osascript 2>/dev/null <<EOF # Must not have trailing semicolon, for iTerm compatibility
local command="cd \\\"$PWD\\\"; clear"
(( $# > 0 )) && command="${command}; $*"
local the_app=$(_omz_osx_get_frontmost_app)
if [[ "$the_app" == 'Terminal' ]]; then
# Discarding stdout to quash "tab N of window id XXX" output
osascript >/dev/null <<EOF
tell application "System Events"
tell process "Terminal" to keystroke "t" using command down
end tell
tell application "Terminal" to do script "${command}" in front window
EOF
elif [[ "$the_app" == 'iTerm' ]]; then
osascript <<EOF
tell application "iTerm" tell application "iTerm"
set current_terminal to current terminal set current_terminal to current terminal
tell current_terminal tell current_terminal
@ -35,29 +41,27 @@ EOF
set current_session to current session set current_session to current session
tell current_session tell current_session
write text "${command}" write text "${command}"
keystroke return
end tell end tell
end tell end tell
end tell end tell
EOF EOF
}
else
echo "tab: unsupported terminal app: $the_app"
false
fi
} }
function vsplit_tab() { function vsplit_tab() {
local command="cd \\\"$PWD\\\"" local command="cd \\\"$PWD\\\"; clear"
(( $# > 0 )) && command="${command}; $*" (( $# > 0 )) && command="${command}; $*"
the_app=$( local the_app=$(_omz_osx_get_frontmost_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" == 'iTerm' ]] && { if [[ "$the_app" == 'iTerm' ]]; then
osascript 2>/dev/null <<EOF osascript <<EOF
tell application "iTerm" to activate -- tell application "iTerm" to activate
tell application "System Events" tell application "System Events"
tell process "iTerm" tell process "iTerm"
@ -65,26 +69,24 @@ EOF
click click
end tell end tell
end tell end tell
keystroke "${command}; clear;" keystroke "${command} \n"
keystroke return
end tell end tell
EOF EOF
}
else
echo "$0: unsupported terminal app: $the_app" >&2
false
fi
} }
function split_tab() { function split_tab() {
local command="cd \\\"$PWD\\\"" local command="cd \\\"$PWD\\\"; clear"
(( $# > 0 )) && command="${command}; $*" (( $# > 0 )) && command="${command}; $*"
the_app=$( local the_app=$(_omz_osx_get_frontmost_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" == 'iTerm' ]] && { if [[ "$the_app" == 'iTerm' ]]; then
osascript 2>/dev/null <<EOF osascript 2>/dev/null <<EOF
tell application "iTerm" to activate tell application "iTerm" to activate
@ -94,11 +96,15 @@ EOF
click click
end tell end tell
end tell end tell
keystroke "${command}; clear;" keystroke "${command} \n"
keystroke return
end tell end tell
EOF EOF
}
else
echo "$0: unsupported terminal app: $the_app" >&2
false
fi
} }
function pfd() { function pfd() {

View file

@ -54,10 +54,12 @@ alias rdrs='rake db:reset'
alias rdtc='rake db:test:clone' alias rdtc='rake db:test:clone'
alias rdtp='rake db:test:prepare' alias rdtp='rake db:test:prepare'
alias rdmtc='rake db:migrate db:test:clone' alias rdmtc='rake db:migrate db:test:clone'
alias rlc='rake log:clear' alias rlc='rake log:clear'
alias rn='rake notes' alias rn='rake notes'
alias rr='rake routes' alias rr='rake routes'
alias rrg='rake routes | grep'
alias rt='rake test'
# legacy stuff # legacy stuff
alias sstat='thin --stats "/thin/stats" start' alias sstat='thin --stats "/thin/stats" start'

View file

@ -18,8 +18,6 @@ if [[ -x `which curl` ]]; then
W=$(echo "$Q" | sed -e 's/.*\/quotes\///g' -e 's/<.*//g' -e 's/.*">//g') W=$(echo "$Q" | sed -e 's/.*\/quotes\///g' -e 's/<.*//g' -e 's/.*">//g')
if [ "$W" -a "$TXT" ]; then if [ "$W" -a "$TXT" ]; then
echo "${WHO_COLOR}${W}${COLON_COLOR}: ${TEXT_COLOR}${TXT}${END_COLOR}" echo "${WHO_COLOR}${W}${COLON_COLOR}: ${TEXT_COLOR}${TXT}${END_COLOR}"
else
quote
fi fi
} }
#quote #quote

View file

@ -2,14 +2,11 @@ _homebrew-installed() {
type brew &> /dev/null type brew &> /dev/null
} }
_rbenv-from-homebrew-installed() {
brew --prefix rbenv &> /dev/null
}
FOUND_RBENV=0 FOUND_RBENV=0
rbenvdirs=("$HOME/.rbenv" "/usr/local/rbenv" "/opt/rbenv" "/usr/local/opt/rbenv") rbenvdirs=("$HOME/.rbenv" "/usr/local/rbenv" "/opt/rbenv" "/usr/local/opt/rbenv")
if _homebrew-installed && _rbenv-from-homebrew-installed ; then if _homebrew-installed && rbenv_homebrew_path=$(brew --prefix rbenv 2>/dev/null); then
rbenvdirs=($(brew --prefix rbenv) "${rbenvdirs[@]}") rbenvdirs=($rbenv_homebrew_path "${rbenvdirs[@]}")
unset rbenv_homebrew_path
fi fi
for rbenvdir in "${rbenvdirs[@]}" ; do for rbenvdir in "${rbenvdirs[@]}" ; do

View file

@ -61,11 +61,11 @@ function gems {
local current_ruby=`rvm-prompt i v p` local current_ruby=`rvm-prompt i v p`
local current_gemset=`rvm-prompt g` local current_gemset=`rvm-prompt g`
gem list $@ | sed \ gem list $@ | sed -E \
-Ee "s/\([0-9, \.]+( .+)?\)/$fg[blue]&$reset_color/g" \ -e "s/\([0-9, \.]+( .+)?\)/$fg[blue]&$reset_color/g" \
-Ee "s|$(echo $rvm_path)|$fg[magenta]\$rvm_path$reset_color|g" \ -e "s|$(echo $rvm_path)|$fg[magenta]\$rvm_path$reset_color|g" \
-Ee "s/$current_ruby@global/$fg[yellow]&$reset_color/g" \ -e "s/$current_ruby@global/$fg[yellow]&$reset_color/g" \
-Ee "s/$current_ruby$current_gemset$/$fg[green]&$reset_color/g" -e "s/$current_ruby$current_gemset$/$fg[green]&$reset_color/g"
} }
function _rvm_completion { function _rvm_completion {

7
plugins/scw/README.md Normal file
View file

@ -0,0 +1,7 @@
## Scaleway CLI autocomplete plugin
[scw](https://github.com/scaleway/scaleway-cli): Manage Bare Metal servers from Command Line (as easily as with Docker)
- Adds autocomplete options for all `scw` commands.
Maintainer : Manfred Touron ([@moul](https://github.com/moul))

333
plugins/scw/_scw Normal file
View file

@ -0,0 +1,333 @@
#compdef scw
#
# zsh completion for scw (http://scaleway.com)
#
# Inspired by https://github.com/felixr/docker-zsh-completion
__scw_get_servers() {
local expl
declare -a servers
servers=(${(f)"$(_call_program commands scw _completion servers-names)"})
_describe -t servers "servers" servers
}
__scw_stoppedservers() {
__scw_get_servers
}
__scw_runningservers() {
__scw_get_servers
}
__scw_servers () {
__scw_get_servers
}
__scw_images () {
local expl
declare -a images
images=(${(f)"$(_call_program commands scw _completion images-names)"})
_describe -t images "images" images
}
__scw_images_and_snapshots () {
__scw_images
__scw_snapshots
}
__scw_snapshots () {
local expl
declare -a snapshots
snapshots=(${(f)"$(_call_program commands scw _completion --prefix snapshots-names)"})
_describe -t snapshots "snapshots" snapshots
}
__scw_bootscripts () {
local expl
declare -a bootscripts
bootscripts=(${(f)"$(_call_program commands scw _completion bootscripts-names)"})
_describe -t bootscripts "bootscripts" bootscripts
}
__scw_tags() {
__scw_images
}
__scw_repositories_with_tags() {
__scw_images
}
__scw_search() {
# declare -a scwsearch
local cache_policy
zstyle -s ":completion:${curcontext}:" cache-policy cache_policy
if [[ -z "$cache_policy" ]]; then
zstyle ":completion:${curcontext}:" cache-policy __scw_caching_policy
fi
local searchterm cachename
searchterm="${words[$CURRENT]%/}"
cachename=_scw-search-$searchterm
local expl
local -a result
if ( [[ ${(P)+cachename} -eq 0 ]] || _cache_invalid ${cachename#_} ) \
&& ! _retrieve_cache ${cachename#_}; then
_message "Searching for ${searchterm}..."
result=(${${${(f)"$(_call_program commands scw search ${searchterm})"}%% *}[2,-1]})
_store_cache ${cachename#_} result
fi
_wanted scwsearch expl 'available images' compadd -a result
}
__scw_caching_policy()
{
oldp=( "$1"(Nmh+1) ) # 1 hour
(( $#oldp ))
}
__scw_repositories () {
__scw_images
}
__scw_commands () {
# local -a _scw_subcommands
local cache_policy
zstyle -s ":completion:${curcontext}:" cache-policy cache_policy
if [[ -z "$cache_policy" ]]; then
zstyle ":completion:${curcontext}:" cache-policy __scw_caching_policy
fi
if ( [[ ${+_scw_subcommands} -eq 0 ]] || _cache_invalid scw_subcommands) \
&& ! _retrieve_cache scw_subcommands;
then
local -a lines
lines=(${(f)"$(_call_program commands scw 2>&1)"})
_scw_subcommands=(${${${lines[$((${lines[(i)Commands:]} + 1)),${lines[(I) *]}]}## #}/ ##/:})
_scw_subcommands=($_scw_subcommands 'help:Show help for a command')
_store_cache scw_subcommands _scw_subcommands
fi
_describe -t scw-commands "scw command" _scw_subcommands
}
__scw_subcommand () {
local -a _command_args
case "$words[1]" in
(attach)
_arguments \
'--no-stdin[Do not attach stdin]' \
':servers:__scw_runningservers'
;;
(commit)
_arguments \
{-v,--volume=0}'[Volume slot]:volume: ' \
':server:__scw_servers' \
':repository:__scw_repositories_with_tags'
;;
(cp)
_arguments \
':server:->server' \
':hostpath:_files'
case $state in
(server)
if compset -P '*:'; then
_files
else
__scw_servers -qS ":"
fi
;;
esac
;;
(exec)
local state ret
_arguments \
{-T,--timeout=0}'[Set timeout values to seconds]' \
{-w,--wait}'[Wait for SSH to be ready]' \
':servers:__scw_runningservers' \
'*::command:->anycommand' && ret=0
case $state in
(anycommand)
shift 1 words
(( CURRENT-- ))
_normal
;;
esac
return ret
;;
(history)
_arguments \
'--no-trunc[Do not truncate output]' \
{-q,--quiet}'[Only show numeric IDs]' \
'*:images:__scw_images'
;;
(images)
_arguments \
{-a,--all}'[Show all images]' \
'--no-trunc[Do not truncate output]' \
{-q,--quiet}'[Only show numeric IDs]' \
':repository:__scw_repositories'
;;
(info)
;;
(inspect)
_arguments \
{-f,--format=-}'[Format the output using the given go template]:template: ' \
'*:servers:__scw_servers'
;;
(kill)
_arguments \
'*:servers:__scw_runningservers'
;;
(login)
_arguments \
{-o,--organization=-}'[Organization]:organization: ' \
{-t,--token=-}'[Token]:token: ' \
':server: '
;;
(logout)
_arguments \
':server: '
;;
(logs)
_arguments \
'*:servers:__scw_servers'
;;
(port)
_arguments \
'1:servers:__scw_runningservers' \
'2:port:_ports'
;;
(start)
_arguments \
{-T,--timeout=0}'[Set timeout values to seconds]' \
{-w,--wait}'[Wait for SSH to be ready]' \
'*:servers:__scw_stoppedservers'
;;
(rm)
_arguments \
'*:servers:__scw_stoppedservers'
;;
(rmi)
_arguments \
'*:images:__scw_images'
;;
(restart)
_arguments \
'*:servers:__scw_runningservers'
;;
(stop)
_arguments \
{-t,--terminate}'[Stop and trash a server with its volumes]' \
{-w,--wait}'[Synchronous stop. Wait for server to be stopped]' \
'*:servers:__scw_runningservers'
;;
(top)
_arguments \
'1:servers:__scw_runningservers' \
'(-)*:: :->ps-arguments'
case $state in
(ps-arguments)
_ps
;;
esac
;;
(ps)
_arguments \
{-a,--all}'[Show all servers. Only running servers are shown by default]' \
{-l,--latest}'[Show only the latest created server]' \
'-n[Show n last created servers, include non-running one]:n:(1 5 10 25 50)' \
'--no-trunc[Do not truncate output]' \
{-q,--quiet}'[Only show numeric IDs]'
;;
(tag)
_arguments \
{-f,--force}'[force]'\
':image:__scw_images'\
':repository:__scw_repositories_with_tags'
;;
(create|run)
_arguments \
{-a,--attach}'[Attach to stdin, stdout or stderr]' \
'*'{-e,--environment=-}'[Set environment variables]:environment variable: ' \
'--name=-[Server name]:name: ' \
'--bootscript=-[Assign a bootscript]:bootscript:__scw_bootscripts ' \
'*-v[Bind mount a volume]:volume: '\
'(-):images:__scw_images_and_snapshots' \
'(-):command: _command_names -e' \
'*::arguments: _normal'
case $state in
(link)
if compset -P '*:'; then
_wanted alias expl 'Alias' compadd -E ""
else
__scw_runningservers -qS ":"
fi
;;
esac
;;
(rename)
_arguments \
':old name:__scw_servers' \
':new name: '
;;
(search)
_arguments \
'--no-trunc[Do not truncate output]' \
':term: '
;;
(wait)
_arguments '*:servers:__scw_runningservers'
;;
(help)
_arguments ':subcommand:__scw_commands'
;;
(*)
_message 'Unknown sub command'
esac
}
_scw () {
# Support for subservices, which allows for `compdef _scw scw-shell=_scw_servers`.
# Based on /usr/share/zsh/functions/Completion/Unix/_git without support for `ret`.
if [[ $service != scw ]]; then
_call_function - _$service
return
fi
local curcontext="$curcontext" state line
typeset -A opt_args
_arguments -C \
'-H[tcp://host:port to bind/connect to]:socket: ' \
'(-): :->command' \
'(-)*:: :->option-or-argument'
if (( CURRENT == 1 )); then
fi
case $state in
(command)
__scw_commands
;;
(option-or-argument)
curcontext=${curcontext%:*:*}:scw-$words[1]:
__scw_subcommand
;;
esac
}
_scw "$@"
# Local Variables:
# mode: Shell-Script
# sh-indentation: 4
# indent-tabs-mode: nil
# sh-basic-offset: 4
# End:
# vim: ft=zsh sw=4 ts=4 et

25
plugins/spring/README.md Normal file
View file

@ -0,0 +1,25 @@
# Spring Boot oh-my-zsh plugin
oh-my-zsh Spring Boot plugin
## Spring Boot autocomplete plugin
- Adds autocomplete options for all spring boot commands.
## Manual Install
$ cd ~/.oh-my-zsh/plugins
$ git clone git@github.com:linux-china/oh-my-zsh-spring-boot-plugin.git spring
Adjust your .zshrc file and add spring to plugins=(...)
## Tips
* Install Spring Cloud plugin: spring install org.springframework.cloud:spring-cloud-cli:1.0.2.RELEASE
## Reference
* Spring Boot: http://projects.spring.io/spring-boot/
* Spring Boot CLI: http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#cli
Maintainer : linux_china ([@linux_china](https://twitter.com/linux_china))

29
plugins/spring/_spring Normal file
View file

@ -0,0 +1,29 @@
#compdef spring 'spring'
#autoload
_spring() {
local cword
let cword=CURRENT-1
local hints
hints=()
local reply
while read -r line; do
reply=`echo "$line" | awk '{printf $1 ":"; for (i=2; i<NF; i++) printf $i " "; print $NF}'`
hints+=("$reply")
done < <(spring hint ${cword} ${words[*]})
if ((cword == 1)) {
_describe -t commands 'commands' hints
return 0
}
_describe -t options 'options' hints
_files
return 0
}
_spring "$@"

View file

@ -0,0 +1,37 @@
function _stack_commands() {
local ret=1 state
_arguments ':subcommand:->subcommand' && ret=0
case $state in
subcommand)
subcommands=(
"build:Build the project(s) in this directory/configuration"
"install:Build executables and install to a user path"
"test:Build and test the project(s) in this directory/configuration"
"bench:Build and benchmark the project(s) in this directory/configuration"
"haddock:Generate haddocks for the project(s) in this directory/configuration"
"new:Create a brand new project"
"init:Initialize a stack project based on one or more stack packages"
"solver:Use a dependency solver to try and determine missing extra-deps"
"setup:Get the appropriate ghc for your project"
"path:Print out handy path information"
"unpack:Unpack one or more packages locally"
"update:Update the package index"
"upgrade:Upgrade to the latest stack (experimental)"
"upload:Upload a package to Hackage"
"dot:Visualize your project's dependency graph using Graphviz dot"
"exec:Execute a command"
"ghc:Run ghc"
"ghci:Run ghci in the context of project(s)"
"ide:Run ide-backend-client with the correct arguments"
"runghc:Run runghc"
"clean:Clean the local packages"
"docker:Subcommands specific to Docker use"
)
_describe -t subcommands 'stack subcommands' subcommands && ret=0
esac
return ret
}
compdef _stack_commands stack

View file

@ -14,7 +14,11 @@
sudo-command-line() { sudo-command-line() {
[[ -z $BUFFER ]] && zle up-history [[ -z $BUFFER ]] && zle up-history
[[ $BUFFER != sudo\ * ]] && LBUFFER="sudo $LBUFFER" if [[ $BUFFER == sudo\ * ]]; then
LBUFFER="${LBUFFER#sudo }"
else
LBUFFER="sudo $LBUFFER"
fi
} }
zle -N sudo-command-line zle -N sudo-command-line
# Defined shortcut keys: [Esc] [Esc] # Defined shortcut keys: [Esc] [Esc]

View file

@ -1,16 +1,17 @@
# vim:ft=zsh ts=2 sw=2 sts=2 # vim:ft=zsh ts=2 sw=2 sts=2
# #
function svn_prompt_info() { function svn_prompt_info() {
local _DISPLAY
if in_svn; then if in_svn; then
if [ "x$SVN_SHOW_BRANCH" = "xtrue" ]; then if [ "x$SVN_SHOW_BRANCH" = "xtrue" ]; then
unset SVN_SHOW_BRANCH unset SVN_SHOW_BRANCH
_DISPLAY=$(svn_get_branch_name) _DISPLAY=$(svn_get_branch_name)
else else
_DISPLAY=$(svn_get_repo_name) _DISPLAY=$(svn_get_repo_name)
_DISPLAY=$(omz_urldecode "${_DISPLAY}")
fi fi
echo "$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_PREFIX\ echo "$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_PREFIX\
$ZSH_THEME_REPO_NAME_COLOR$_DISPLAY$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_SUFFIX$ZSH_PROMPT_BASE_COLOR$(svn_dirty)$(svn_dirty_pwd)$ZSH_PROMPT_BASE_COLOR" $ZSH_THEME_REPO_NAME_COLOR$_DISPLAY$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_SUFFIX$ZSH_PROMPT_BASE_COLOR$(svn_dirty)$(svn_dirty_pwd)$ZSH_PROMPT_BASE_COLOR"
unset _DISPLAY
fi fi
} }
@ -30,7 +31,7 @@ function svn_get_repo_name() {
} }
function svn_get_branch_name() { function svn_get_branch_name() {
_DISPLAY=$( local _DISPLAY=$(
svn info 2> /dev/null | \ svn info 2> /dev/null | \
awk -F/ \ awk -F/ \
'/^URL:/ { \ '/^URL:/ { \
@ -49,7 +50,6 @@ function svn_get_branch_name() {
else else
echo $_DISPLAY echo $_DISPLAY
fi fi
unset _DISPLAY
} }
function svn_get_rev_nr() { function svn_get_rev_nr() {
@ -60,7 +60,7 @@ function svn_get_rev_nr() {
function svn_dirty_choose() { function svn_dirty_choose() {
if in_svn; then if in_svn; then
root=`svn info 2> /dev/null | sed -n 's/^Working Copy Root Path: //p'` local root=`svn info 2> /dev/null | sed -n 's/^Working Copy Root Path: //p'`
if $(svn status $root 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'); then if $(svn status $root 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'); then
# Grep exits with 0 when "One or more lines were selected", return "dirty". # Grep exits with 0 when "One or more lines were selected", return "dirty".
echo $1 echo $1
@ -77,7 +77,7 @@ function svn_dirty() {
function svn_dirty_choose_pwd () { function svn_dirty_choose_pwd () {
if in_svn; then if in_svn; then
root=$PWD local root=$PWD
if $(svn status $root 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'); then if $(svn status $root 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'); then
# Grep exits with 0 when "One or more lines were selected", return "dirty". # Grep exits with 0 when "One or more lines were selected", return "dirty".
echo $1 echo $1

View file

@ -5,7 +5,7 @@ _symfony_console () {
} }
_symfony2_get_command_list () { _symfony2_get_command_list () {
`_symfony_console` --no-ansi | sed "1,/Available commands/d" | awk '/^ ?[a-z]+/ { print $1 }' `_symfony_console` --no-ansi | sed "1,/Available commands/d" | awk '/^ ?[^ ]+ / { print $1 }'
} }
_symfony2 () { _symfony2 () {

View file

@ -140,12 +140,16 @@ d0() {
# gather external ip address # gather external ip address
geteip() { geteip() {
curl http://ifconfig.me curl -s -S https://icanhazip.com
} }
# determine local IP address # determine local IP address
getip() { getip() {
if (( ${+commands[ip]} )); then
ip addr | grep "inet " | grep -v '127.0.0.1' | awk '{print $2}'
else
ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}' ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'
fi
} }
# Clear zombie processes # Clear zombie processes

View file

@ -1,11 +1,12 @@
user_commands=( user_commands=(
list-units is-active status show help list-unit-files list-units is-active status show help list-unit-files
is-enabled list-jobs show-environment) is-enabled list-jobs show-environment cat)
sudo_commands=( sudo_commands=(
start stop reload restart try-restart isolate kill start stop reload restart try-restart isolate kill
reset-failed enable disable reenable preset mask unmask reset-failed enable disable reenable preset mask unmask
link load cancel set-environment unset-environment) link load cancel set-environment unset-environment
edit)
for c in $user_commands; do; alias sc-$c="systemctl $c"; done for c in $user_commands; do; alias sc-$c="systemctl $c"; done
for c in $sudo_commands; do; alias sc-$c="sudo systemctl $c"; done for c in $sudo_commands; do; alias sc-$c="sudo systemctl $c"; done

View file

@ -0,0 +1,13 @@
# taskwarrior
This plugin adds smart tab completion for [TaskWarrior](http://taskwarrior.org/).
It uses the zsh tab completion script (`_task`) shipped with TaskWarrior for the
completion definitions.
The latest version pulled in from the official project is of January 1st, 2015.
## Examples
Typing `task [TAB]` will give you a list of commands, `task 66[TAB]` shows a
list of available modifications for that task, etcetera.

View file

@ -1,9 +1,6 @@
#compdef task #compdef task
# zsh completion for taskwarrior
# #
# taskwarrior - a command line task list manager. # Copyright 2010 - 2015 Johannes Schlatow
#
# Copyright 2010 - 2011 Johannes Schlatow
# Copyright 2009 P.C. Shyamshankar # Copyright 2009 P.C. Shyamshankar
# #
# Permission is hereby granted, free of charge, to any person obtaining a copy # Permission is hereby granted, free of charge, to any person obtaining a copy
@ -30,6 +27,7 @@ typeset -g _task_cmds _task_projects _task_tags _task_config _task_modifiers
_task_projects=($(task _projects)) _task_projects=($(task _projects))
_task_tags=($(task _tags)) _task_tags=($(task _tags))
_task_ids=($(task _ids)) _task_ids=($(task _ids))
_task_zshids=( ${(f)"$(task _zshids)"} )
_task_config=($(task _config)) _task_config=($(task _config))
_task_columns=($(task _columns)) _task_columns=($(task _columns))
_task_modifiers=( _task_modifiers=(
@ -50,11 +48,19 @@ _task_conjunctions=(
'and' \ 'and' \
'or' \ 'or' \
'xor' \ 'xor' \
'\)' '\)' \
'\(' '\(' \
'<' \
'<=' \
'=' \
'!=' \
'>=' \
'>'
) )
_task_cmds=($(task _commands)) _task_cmds=($(task _commands; task _aliases))
_task_zshcmds=( ${(f)"$(task _zshcommands)"} ) _task_zshcmds=( ${(f)"$(task _zshcommands)"} sentinel:sentinel:sentinel )
_task_aliases=($(task _aliases))
_task() { _task() {
_arguments -s -S \ _arguments -s -S \
@ -89,11 +95,13 @@ _regex_words values 'task dates' \
'soww:Start of work week' \ 'soww:Start of work week' \
'socw:Start of calendar week' \ 'socw:Start of calendar week' \
'som:Start of month' \ 'som:Start of month' \
'soq:Start of quarter' \
'soy:Start of year' \ 'soy:Start of year' \
'eow:End of week' \ 'eow:End of week' \
'eoww:End of work week' \ 'eoww:End of work week' \
'eocw:End of calendar week' \ 'eocw:End of calendar week' \
'eom:End of month' \ 'eom:End of month' \
'eoq:End of quarter' \
'eoy:End of year' \ 'eoy:End of year' \
'mon:Monday' \ 'mon:Monday' \
'tue:Tuesday'\ 'tue:Tuesday'\
@ -101,7 +109,16 @@ _regex_words values 'task dates' \
'thu:Thursday' \ 'thu:Thursday' \
'fri:Friday' \ 'fri:Friday' \
'sat:Saturday' \ 'sat:Saturday' \
'sun:Sunday' 'sun:Sunday' \
'good*friday:Good Friday' \
'easter:Easter' \
'eastermonday:Easter Monday' \
'ascension:Ascension' \
'pentecost:Pentecost' \
'midsommar:Midsommar' \
'midsommarafton:Midsommarafton' \
'later:Later' \
'someday:Some Day'
_task_dates=("$reply[@]") _task_dates=("$reply[@]")
local -a _task_reldates local -a _task_reldates
@ -121,6 +138,10 @@ task_dates=(
\) \)
) )
local -a task_zshids
_regex_words values 'task IDs' $_task_zshids
task_zshids=("$reply[@]")
_regex_words values 'task frequencies' \ _regex_words values 'task frequencies' \
'daily:Every day' \ 'daily:Every day' \
'day:Every day' \ 'day:Every day' \
@ -128,7 +149,7 @@ _regex_words values 'task frequencies' \
'weekly:Every week' \ 'weekly:Every week' \
'biweekly:Every two weeks' \ 'biweekly:Every two weeks' \
'fortnight:Every two weeks' \ 'fortnight:Every two weeks' \
+ 'monthly:Every month' \ 'monthly:Every month' \
'quarterly:Every three months' \ 'quarterly:Every three months' \
'semiannual:Every six months' \ 'semiannual:Every six months' \
'annual:Every year' \ 'annual:Every year' \
@ -154,20 +175,25 @@ task_freqs=(
# attributes # attributes
local -a task_attributes local -a task_attributes
_regex_words -t ':' default 'task attributes' \ _regex_words -t ':' default 'task attributes' \
'des*cription:Task description text' \
'status:Status of task - pending, completed, deleted, waiting' \
'pro*ject:Project name:$task_projects' \ 'pro*ject:Project name:$task_projects' \
'du*e:Due date:$task_dates' \
'wa*it:Date until task becomes pending:$task_dates' \
're*cur:Recurrence frequency:$task_freqs' \
'pri*ority:priority:$task_priorities' \ 'pri*ority:priority:$task_priorities' \
'un*til:Recurrence end date:$task_dates' \ 'du*e:Due date:$task_dates' \
'fg:Foreground color' \ 're*cur:Recurrence frequency:$task_freqs' \
'bg:Background color' \ 'un*til:Expiration date:$task_dates' \
'li*mit:Desired number of rows in report' 'li*mit:Desired number of rows in report' \
'wa*it:Date until task becomes pending:$task_dates' \
'ent*ry:Date task was created:$task_dates' \
'end:Date task was completed/deleted:$task_dates' \
'st*art:Date task was started:$task_dates' \
'sc*heduled:Date task is scheduled to start:$task_dates' \
'dep*ends:Other tasks that this task depends upon:$task_zshids'
task_attributes=("$reply[@]") task_attributes=("$reply[@]")
args=( args=(
\( "$task_attributes[@]" \| \( "$task_attributes[@]" \|
\( /'(project|due|wait|recur|priority|until|fg|bg|limit).'/- \( /$'[^:]#:'/ ":default:modifiers:compadd -S ':' -a _task_modifiers" \) \) \| \( /'(project|description|status|entry|end|start|scheduled|depends|due|wait|recur|priority|until|limit).'/- \( /$'[^:]#:'/ ":default:modifiers:compadd -S ':' -a _task_modifiers" \) \) \|
\( /'(rc).'/- \( /$'[^:]#:'/ ":arguments:config:compadd -S ':' -a _task_config" \) \) \| \( /'(rc).'/- \( /$'[^:]#:'/ ":arguments:config:compadd -S ':' -a _task_config" \) \) \|
\( /'(+|-)'/- \( /"$word"/ ":values:remove tag:compadd -a _task_tags" \) \) \| \( /'(+|-)'/- \( /"$word"/ ":values:remove tag:compadd -a _task_tags" \) \) \|
\( /"$word"/ \) \( /"$word"/ \)
@ -186,27 +212,6 @@ _task_filter() {
_describe -t default 'task conjunctions' _task_conjunctions _describe -t default 'task conjunctions' _task_conjunctions
} }
# merge completion
(( $+functions[_task_merge] )) ||
_task_merge() {
# TODO match URIs in .taskrc
_files
}
# push completion
(( $+functions[_task_push] )) ||
_task_push() {
# TODO match URIs in .taskrc
_files
}
# pull completion
(( $+functions[_task_pull] )) ||
_task_pull() {
# TODO match URIs in .taskrc
_files
}
# execute completion # execute completion
(( $+functions[_task_execute] )) || (( $+functions[_task_execute] )) ||
_task_execute() { _task_execute() {
@ -219,6 +224,34 @@ _task_id() {
_describe -t values 'task IDs' _task_zshids _describe -t values 'task IDs' _task_zshids
} }
# subcommand-only function
(( $+functions[_task_subcommands] )) ||
_task_subcommands() {
local -a subcommands
local _zshcmd
local cmd category desc
local lastcategory=''
# The list is sorted by category, in the right order.
for _zshcmd in "$_task_zshcmds[@]"; do
# Parse out the three fields
cmd=${_zshcmd%%:*}
category=${${_zshcmd#*:}%%:*}
desc=${_zshcmd#*:*:}
# Present each category as soon as the first entry in the *next* category
# is seen.
if [[ $category != $lastcategory && -n $lastcategory ]]; then
_describe -t ${lastcategory}-commands "task ${lastcategory} command" subcommands
subcommands=()
fi
# Log the subcommand; we will process it in some future iteration.
subcommands+=( "$cmd:$desc" )
lastcategory=$category
done
}
## first level completion => task sub-command completion ## first level completion => task sub-command completion
(( $+functions[_task_default] )) || (( $+functions[_task_default] )) ||
_task_default() { _task_default() {
@ -240,11 +273,12 @@ _task_default() {
# update IDs # update IDs
_task_zshids=( ${(f)"$(task _zshids)"} ) _task_zshids=( ${(f)"$(task _zshids)"} )
_describe -t commands 'task command' _task_zshcmds _task_subcommands
_describe -t values 'task IDs' _task_zshids _describe -t tasks 'task IDs' _task_zshids
_describe -t aliases 'task aliases' _task_aliases
_call_function ret _task_filter _call_function ret _task_filter
return ret return ret
} }
_task _task "$@"

View file

@ -1,17 +1,3 @@
################################################################################
# Author: Pete Clark
# Email: pete[dot]clark[at]gmail[dot]com
# Version: 0.1 (05/24/2011)
# License: WTFPL<http://sam.zoy.org/wtfpl/>
#
# This oh-my-zsh plugin adds smart tab completion for
# TaskWarrior<http://taskwarrior.org/>. It uses the zsh tab completion
# script (_task) distributed with TaskWarrior for the completion definitions.
#
# Typing task [tabtab] will give you a list of current tasks, task 66[tabtab]
# gives a list of available modifications for that task, etc.
################################################################################
zstyle ':completion:*:*:task:*' verbose yes zstyle ':completion:*:*:task:*' verbose yes
zstyle ':completion:*:*:task:*:descriptions' format '%U%B%d%b%u' zstyle ':completion:*:*:task:*:descriptions' format '%U%B%d%b%u'

View file

@ -1,39 +1,6 @@
# Set Apple Terminal.app resume directory # This file is intentionally empty.
# based on this answer: http://superuser.com/a/315029 #
# 2012-10-26: (javageek) Changed code using the updated answer # The terminalapp plugin is deprecated and may be removed in a future release.
# Its functionality has been folded in to the core lib/termsupport.zsh, which
# Tell the terminal about the working directory whenever it changes. # is loaded for all users. You can remove terminalapp from your $plugins list
if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then # once all your systems are updated to the current version of Oh My Zsh.
update_terminal_cwd() {
# Identify the directory using a "file:" scheme URL, including
# the host name to disambiguate local vs. remote paths.
# Percent-encode the pathname.
local URL_PATH=''
{
# Use LANG=C to process text byte-by-byte.
local i ch hexch LANG=C
for ((i = 1; i <= ${#PWD}; ++i)); do
ch="$PWD[i]"
if [[ "$ch" =~ [/._~A-Za-z0-9-] ]]; then
URL_PATH+="$ch"
else
hexch=$(printf "%02X" "'$ch")
URL_PATH+="%$hexch"
fi
done
}
local PWD_URL="file://$HOST$URL_PATH"
#echo "$PWD_URL" # testing
printf '\e]7;%s\a' "$PWD_URL"
}
# Register the function so it is called whenever the working
# directory changes.
autoload add-zsh-hook
add-zsh-hook precmd update_terminal_cwd
# Tell the terminal about the initial directory.
update_terminal_cwd
fi

View file

@ -0,0 +1,11 @@
## atom
Plugin for Terraform, a tool from Hashicorp for managing infrastructure safely and efficiently.
### Requirements
* [Terraform](https://terraform.io/)
### Usage
* Type `terraform` into your prompt and hit `TAB` to see available completion options

View file

@ -0,0 +1,177 @@
#compdef terraform
local -a _terraform_cmds
_terraform_cmds=(
'apply:Builds or changes infrastructure'
'destroy:Destroy Terraform-managed infrastructure'
'get:Download and install modules for the configuration'
'graph:Create a visual graph of Terraform resources'
'init:Initializes Terraform configuration from a module'
'output:Read an output from a state file'
'plan:Generate and show an execution plan'
'pull:Refreshes the local state copy from the remote server'
'push:Uploads the local state to the remote server'
'refresh:Update local state file against real resources'
'remote:Configures remote state management'
'show:Inspect Terraform state or plan'
'taint:Manually forcing a destroy and recreate on the next plan/apply'
'version:Prints the Terraform version'
)
__apply() {
_arguments \
'-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]' \
'-input=[(true) Ask for input for variables if not directly set.]' \
'-no-color[If specified, output will not contain any color.]' \
'-refresh=[(true) Update state prior to checking for differences. This has no effect if a plan file is given to apply.]' \
'-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]' \
'-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]' \
'-target=[(resource) A Resource Address to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]' \
'-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
'-var-file=[(path) Set variables in the Terraform configuration from a file. If "terraform.tfvars" is present, it will be automatically loaded if this flag is not specified.]'
}
__destroy() {
_arguments \
'-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]' \
'-force[If set, then the destroy confirmation will not be shown.]' \
'-input=[(true) Ask for input for variables if not directly set.]' \
'-no-color[If specified, output will not contain any color.]' \
'-refresh=[(true) Update state prior to checking for differences. This has no effect if a plan file is given to apply.]' \
'-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]' \
'-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]' \
'-target=[(resource) Instead of affecting "dependencies" will instead also destroy any resources that depend on the target(s) specified.]' \
'-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
'-var-file=[(path) Set variables in the Terraform configuration from a file. If "terraform.tfvars" is present, it will be automatically loaded if this flag is not specified.]'
}
__get() {
_arguments \
'-update=[(false) If true, modules already downloaded will be checked for updates and updated if necessary.]'
}
__graph() {
_arguments \
'-draw-cycles[Highlight any cycles in the graph with colored edges. This helps when diagnosing cycle errors.]' \
'-module-depth=[(n) The maximum depth to expand modules. By default this is zero, which will not expand modules at all.]' \
'-verbose[Generate a verbose, "worst-case" graph, with all nodes for potential operations in place.]'
}
__init() {
_arguments \
'-address=[(url) URL of the remote storage server. Required for HTTP backend, optional for Atlas and Consul.]' \
'-access-token=[(token) Authentication token for state storage server. Required for Atlas backend, optional for Consul.]' \
'-backend=[(atlas) Specifies the type of remote backend. Must be one of Atlas, Consul, or HTTP. Defaults to atlas.]' \
'-name=[(name) Name of the state file in the state storage server. Required for Atlas backend.]' \
'-path=[(path) Path of the remote state in Consul. Required for the Consul backend.]'
}
__output() {
_arguments \
'-state=[(path) Path to the state file to read. Defaults to "terraform.tfstate".]' \
'-module=[(module_name) The module path which has needed output. By default this is the root path. Other modules can be specified by a period-separated list.]'
}
__plan() {
_arguments \
'-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with" .backup" extension. Set to "-" to disable backup.]' \
'-destroy[If set, a plan will be generated to destroy all resources managed by the given configuration and state.]' \
'-detailed-exitcode[Return a detailed exit code when the command exits. When provided, this argument changes the exit codes and their meanings to provide more granular information about what the resulting plan contains]' \
'-input=[(true) Ask for input for variables if not directly set.]' \
'-module-depth=[(n) Specifies the depth of modules to show in the output. This does not affect the plan itself, only the output shown. By default, this is zero. -1 will expand all.]' \
'-no-color[If specified, output will not contain any color.]' \
'-out=[(path) Write a plan file to the given path. This can be used as input to the "apply" command.]' \
'-refresh=[(true) Update state prior to checking for differences.]' \
'-state=[(statefile) Path to a Terraform state file to use to look up Terraform-managed resources. By default it will use the state "terraform.tfstate" if it exists.]' \
'-target=[(resource) A Resource Address to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]' \
'-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
'-var-file=[(path) Set variables in the Terraform configuration from a file. If "terraform.tfvars" is present, it will be automatically loaded if this flag is not specified.]'
}
__push() {
_arguments \
'-atlas-address=[(url) An alternate address to an Atlas instance. Defaults to https://atlas.hashicorp.com.]' \
'-upload-modules=[(true) If true (default), then the modules being used are all locked at their current checkout and uploaded completely to Atlas. This prevents Atlas from running terraform get for you.]' \
'-name=[(name) Name of the infrastructure configuration in Atlas. The format of this is: "username/name" so that you can upload configurations not just to your account but to other accounts and organizations. This setting can also be set in the configuration in the Atlas section.]' \
'-no-color[Disables output with coloring]' \
'-overwrite=[(foo) Marks a specific variable to be updated on Atlas. Normally, if a variable is already set in Atlas, Terraform will not send the local value (even if it is different). This forces it to send the local value to Atlas. This flag can be repeated multiple times.]' \
'-token=[(token) Atlas API token to use to authorize the upload. If blank or unspecified, the ATLAS_TOKEN environmental variable will be used.]' \
'-var=[("foo=bar") Set the value of a variable for the Terraform configuration.]' \
'-var-file=[(foo) Set the value of variables using a variable file.]' \
'-vcs=[(true) If true (default), then Terraform will detect if a VCS is in use, such as Git, and will only upload files that are comitted to version control. If no version control system is detected, Terraform will upload all files in path (parameter to the command).]'
}
__refresh() {
_arguments \
'-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]' \
'-no-color[If specified, output will not contain any color.]' \
'-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]' \
'-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]' \
'-target=[(resource) A Resource Address to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]' \
'-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
'-var-file=[(path) Set variables in the Terraform configuration from a file. If "terraform.tfvars" is present, it will be automatically loaded if this flag is not specified.]'
}
__remote() {
_arguments \
'-address=[(url) URL of the remote storage server. Required for HTTP backend, optional for Atlas and Consul.]' \
'-access-token=[(token) Authentication token for state storage server. Required for Atlas backend, optional for Consul.]' \
'-backend=[(atlas) Specifies the type of remote backend. Must be one of Atlas, Consul, or HTTP. Defaults to atlas.]' \
'-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]' \
'-disable[Disables remote state management and migrates the state to the -state path.]' \
'-name=[(name) Name of the state file in the state storage server. Required for Atlas backend.]' \
'-path=[(path) Path of the remote state in Consul. Required for the Consul backend.]' \
'-pull=[(true) Controls if the remote state is pulled before disabling. This defaults to true to ensure the latest state is cached before disabling.]' \
'-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]'
}
__show() {
_arguments \
'-module-depth=[(n) The maximum depth to expand modules. By default this is zero, which will not expand modules at all.]' \
'-no-color[If specified, output will not contain any color.]'
}
__taint() {
_arguments \
'-allow-missing[If specified, the command will succeed (exit code 0) even if the resource is missing.]' \
'-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]' \
'-module=[(path) The module path where the resource lives. By default this will be root. Child modules can be specified by names. Ex. "consul" or "consul.vpc" (nested modules).]' \
'-no-color[If specified, output will not contain any color.]' \
'-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]' \
'-state-out=[(path) Path to write updated state file. By default, the "-state" path will be used.]'
}
_arguments '*:: :->command'
if (( CURRENT == 1 )); then
_describe -t commands "terraform command" _terraform_cmds
return
fi
local -a _command_args
case "$words[1]" in
apply)
__apply ;;
destroy)
__destroy ;;
get)
__get ;;
graph)
__graph ;;
init)
__init ;;
output)
__output ;;
plan)
__plan ;;
push)
__push ;;
refresh)
__refresh ;;
remote)
__remote ;;
show)
__show ;;
taint)
__taint ;;
esac

View file

@ -0,0 +1,9 @@
# The Fuck
[The Fuck](https://github.com/nvbn/thefuck) plugin — magnificent app which corrects your previous console command.
## Usage
Press `ESC` twice to correct previous console command.
## Notes
`Esc`-`Esc` key binding conflicts with [sudo](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/sudo) plugin.

View file

@ -0,0 +1,17 @@
if [[ -z $commands[thefuck] ]]; then
echo 'thefuck is not installed, you should "pip install thefuck" first'
return -1
fi
# Register alias
eval "$(thefuck --alias)"
fuck-command-line() {
local FUCK="$(THEFUCK_REQUIRE_CONFIRMATION=0 thefuck $(fc -ln -1 | tail -n 1) 2> /dev/null)"
[[ -z $FUCK ]] && echo -n -e "\a" && return
BUFFER=$FUCK
zle end-of-line
}
zle -N fuck-command-line
# Defined shortcut keys: [Esc] [Esc]
bindkey "\e\e" fuck-command-line

View file

@ -3,6 +3,7 @@
# https://github.com/dbb # https://github.com/dbb
# https://github.com/Mappleconfusers # https://github.com/Mappleconfusers
# Nicolas Jonas nextgenthemes.com # Nicolas Jonas nextgenthemes.com
# https://github.com/loctauxphilippe
# #
# Debian, Ubuntu and friends related zsh aliases and functions for zsh # Debian, Ubuntu and friends related zsh aliases and functions for zsh
@ -28,6 +29,7 @@ compdef _ppap ppap='sudo ppa-purge'
alias ag='sudo apt-get' # age - but without sudo alias ag='sudo apt-get' # age - but without sudo
alias aga='sudo apt-get autoclean' # aac alias aga='sudo apt-get autoclean' # aac
alias agar='sudo apt-get autoremove'
alias agb='sudo apt-get build-dep' # abd alias agb='sudo apt-get build-dep' # abd
alias agc='sudo apt-get clean' # adc alias agc='sudo apt-get clean' # adc
alias agd='sudo apt-get dselect-upgrade' # ads alias agd='sudo apt-get dselect-upgrade' # ads
@ -38,9 +40,11 @@ alias agu='sudo apt-get update' # ad
alias agud='sudo apt-get update && sudo apt-get dist-upgrade' #adu alias agud='sudo apt-get update && sudo apt-get dist-upgrade' #adu
alias agug='sudo apt-get upgrade' # ag alias agug='sudo apt-get upgrade' # ag
alias aguu='sudo apt-get update && sudo apt-get upgrade' #adg alias aguu='sudo apt-get update && sudo apt-get upgrade' #adg
alias agar='sudo apt-get autoremove'
compdef _ag ag='sudo apt-get' compdef _ag ag='sudo apt-get'
compdef _aga aga='sudo apt-get autoclean' compdef _aga aga='sudo apt-get autoclean'
compdef _agar agar='sudo apt-get autoremove'
compdef _agb agb='sudo apt-get build-dep' compdef _agb agb='sudo apt-get build-dep'
compdef _agc agc='sudo apt-get clean' compdef _agc agc='sudo apt-get clean'
compdef _agd agd='sudo apt-get dselect-upgrade' compdef _agd agd='sudo apt-get dselect-upgrade'
@ -51,6 +55,7 @@ compdef _agu agu='sudo apt-get update'
compdef _agud agud='sudo apt-get update && sudo apt-get dist-upgrade' compdef _agud agud='sudo apt-get update && sudo apt-get dist-upgrade'
compdef _agug agug='sudo apt-get upgrade' compdef _agug agug='sudo apt-get upgrade'
compdef _aguu aguu='sudo apt-get update && sudo apt-get upgrade' compdef _aguu aguu='sudo apt-get update && sudo apt-get upgrade'
compdef _agar agar='sudo apt-get autoremove'
# Remove ALL kernel images and headers EXCEPT the one in use # Remove ALL kernel images and headers EXCEPT the one in use
alias kclean='sudo aptitude remove -P ?and(~i~nlinux-(ima|hea) \ alias kclean='sudo aptitude remove -P ?and(~i~nlinux-(ima|hea) \
@ -65,7 +70,7 @@ alias mydeb='time dpkg-buildpackage -rfakeroot -us -uc'
# apt-add-repository with automatic install/upgrade of the desired package # apt-add-repository with automatic install/upgrade of the desired package
# Usage: aar ppa:xxxxxx/xxxxxx [packagename] # Usage: aar ppa:xxxxxx/xxxxxx [packagename]
# If packagename is not given as 2nd arument the function will ask for it and guess the defaupt by taking # If packagename is not given as 2nd argument the function will ask for it and guess the default by taking
# the part after the / from the ppa name wich is sometimes the right name for the package you want to install # the part after the / from the ppa name wich is sometimes the right name for the package you want to install
aar() { aar() {
if [ -n "$2" ]; then if [ -n "$2" ]; then

View file

@ -6,37 +6,45 @@
local -a _1st_arguments local -a _1st_arguments
_1st_arguments=( _1st_arguments=(
'box:Box commands' 'box:Box commands'
'connect:Connects to a shared, remote Vagrant environment' 'connect:Connects to a remotely shared Vagrant environment'
'destroy:Destroys the vagrant environment' 'destroy:Destroys the vagrant environment'
'docker-logs:Shows Docker logs' 'docker-logs:Outputs the logs from the Docker container'
'docker-run:Run one-off commands against a Docker container' 'docker-run:Run a one-off command in the context of a container'
'global-status:Reports the status of all active Vagrant environments on the system' 'global-status:Reports the status of all active Vagrant environments on the system'
'halt:Halts the currently running vagrant environment' 'halt:Halts the currently running vagrant environment'
'help:Shows the help for a subcommand'
'init:[box_name] [box_url] Initializes current folder for Vagrant usage' 'init:[box_name] [box_url] Initializes current folder for Vagrant usage'
'list-commands:Outputs all available Vagrant subcommands, even non-primary ones'
'login:Authenticates against a Vagrant Cloud server to access protected boxes' 'login:Authenticates against a Vagrant Cloud server to access protected boxes'
'package:Packages a vagrant environment for distribution' 'package:Packages a vagrant environment for distribution'
'plugin:Plugin commands' 'plugin:Plugin commands'
'provision:Run the provisioner' 'provision:Run the provisioner'
'push:Deploys code in this environment to a configured destination'
'rdp:Connects to machine via RDP'
'reload:Reload the vagrant environment' 'reload:Reload the vagrant environment'
'resume:Resumes a suspend vagrant environment' 'resume:Resumes a suspend vagrant environment'
'share:Shares the Vagrant environment and allows remote access' 'rsync:Syncs rsync synced folders to remote machine'
'rsync-auto:Syncs rsync synced folders automatically when files change'
'share:Shares your Vagrant environment with anyone in the world'
'ssh:SSH into the currently running environment' 'ssh:SSH into the currently running environment'
'ssh-config:outputs .ssh/config valid syntax for connecting to this environment via ssh' 'ssh-config:Outputs .ssh/config valid syntax for connecting to this environment via ssh'
'status:Shows the status of the current Vagrant environment' 'status:Shows the status of the current Vagrant environment'
'suspend:Suspends the currently running vagrant environment' 'suspend:Suspends the currently running vagrant environment'
'up:Creates the vagrant environment' 'up:Creates the vagrant environment'
'version:Prints the currently installed Vagrant version and checks for new updates' 'version:Prints current and latest Vagrant version'
'--help:[TASK] Describe available tasks or one specific task' '--help:[TASK] Describe available tasks or one specific task'
'--version:Prints the Vagrant version information' '--version:Prints the Vagrant version information'
) )
local -a _box_arguments local -a _box_arguments
_box_arguments=( _box_arguments=(
'add:NAME URI Add a box to the system' 'add:ADDRESS Adds a box to the system'
'help:COMMAND Describe subcommands or one specific subcommand' 'help:COMMAND List subcommands'
'list:Lists all installed boxes' 'list:Lists all installed boxes'
'remove:NAME Remove a box from the system' 'outdated:Checks if a box has newer version'
'repackage:NAME Repackage an installed box into a `.box` file.' 'remove:NAME Removes a box from the system'
'repackage:NAME PROVIDER VERSION Repackages an installed box into a `.box` file'
'update:Updates box to a newer version, if available'
) )
__task_list () __task_list ()

View file

@ -4,17 +4,6 @@
# Derek Wyatt (derek@{myfirstnamemylastname}.org # Derek Wyatt (derek@{myfirstnamemylastname}.org
# #
function resolveFile
{
if [ -f "$1" ]; then
echo $(readlink -f "$1")
elif [[ "${1#/}" == "$1" ]]; then
echo "$PWD/$1"
else
echo $1
fi
}
function callvim function callvim
{ {
if [[ $# == 0 ]]; then if [[ $# == 0 ]]; then
@ -48,13 +37,10 @@ EOH
if [[ ${before#:} != $before && ${before%<cr>} == $before ]]; then if [[ ${before#:} != $before && ${before%<cr>} == $before ]]; then
before="$before<cr>" before="$before<cr>"
fi fi
local files="" local files
for f in $@ if [[ $# -gt 0 ]]; then
do # absolute path of files resolving symlinks (:A) and quoting special chars (:q)
files="$files $(resolveFile $f)" files=':args! '"${@:A:q}<cr>"
done
if [[ -n $files ]]; then
files=':args! '"$files<cr>"
fi fi
cmd="$before$files$after" cmd="$before$files$after"
gvim --remote-send "$cmd" gvim --remote-send "$cmd"

View file

@ -14,32 +14,38 @@ elif [[ -f "/etc/bash_completion.d/virtualenvwrapper" ]]; then
source "/etc/bash_completion.d/virtualenvwrapper" source "/etc/bash_completion.d/virtualenvwrapper"
} }
else else
print "zsh virtualenvwrapper plugin: Cannot find ${virtualenvwrapper}.\n"\ print "[oh-my-zsh] virtualenvwrapper plugin: Cannot find ${virtualenvwrapper}.\n"\
"Please install with \`pip install virtualenvwrapper\`" >&2 "Please install with \`pip install virtualenvwrapper\`" >&2
return return
fi fi
if ! type workon &>/dev/null; then if ! type workon &>/dev/null; then
print "zsh virtualenvwrapper plugin: shell function 'workon' not defined.\n"\ print "[oh-my-zsh] virtualenvwrapper plugin: shell function 'workon' not defined.\n"\
"Please check ${virtualenvwrapper}" >&2 "Please check ${virtualenvwrapper}" >&2
return return
fi fi
if [[ "$WORKON_HOME" == "" ]]; then if [[ "$WORKON_HOME" == "" ]]; then
print "\$WORKON_HOME is not defined so ZSH plugin virtualenvwrapper will not work" >&2 print "[oh-my-zsh] \$WORKON_HOME is not defined so plugin virtualenvwrapper will not work" >&2
return return
fi fi
if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then
# Automatically activate Git projects' virtual environments based on the # Automatically activate Git projects or other customized virtualenvwrapper projects based on the
# directory name of the project. Virtual environment name can be overridden # directory name of the project. Virtual environment name can be overridden
# by placing a .venv file in the project root with a virtualenv name in it # by placing a .venv file in the project root with a virtualenv name in it.
function workon_cwd { function workon_cwd {
if [ ! $WORKON_CWD ]; then if [[ -z "$WORKON_CWD" ]]; then
WORKON_CWD=1 local WORKON_CWD=1
# Check if this is a Git repo # Check if this is a Git repo
local GIT_REPO_ROOT=""
local GIT_TOPLEVEL="$(git rev-parse --show-toplevel 2> /dev/null)"
if [[ $? == 0 ]]; then
GIT_REPO_ROOT="$GIT_TOPLEVEL"
fi
# Get absolute path, resolving symlinks # Get absolute path, resolving symlinks
PROJECT_ROOT="${PWD:A}" local PROJECT_ROOT="${PWD:A}"
while [[ "$PROJECT_ROOT" != "/" && ! -e "$PROJECT_ROOT/.venv" ]]; do while [[ "$PROJECT_ROOT" != "/" && ! -e "$PROJECT_ROOT/.venv" \
&& ! -d "$PROJECT_ROOT/.git" && "$PROJECT_ROOT" != "$GIT_REPO_ROOT" ]]; do
PROJECT_ROOT="${PROJECT_ROOT:h}" PROJECT_ROOT="${PROJECT_ROOT:h}"
done done
if [[ "$PROJECT_ROOT" == "/" ]]; then if [[ "$PROJECT_ROOT" == "/" ]]; then
@ -47,7 +53,7 @@ if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then
fi fi
# Check for virtualenv name override # Check for virtualenv name override
if [[ -f "$PROJECT_ROOT/.venv" ]]; then if [[ -f "$PROJECT_ROOT/.venv" ]]; then
ENV_NAME=`cat "$PROJECT_ROOT/.venv"` ENV_NAME="$(cat "$PROJECT_ROOT/.venv")"
elif [[ -f "$PROJECT_ROOT/.venv/bin/activate" ]];then elif [[ -f "$PROJECT_ROOT/.venv/bin/activate" ]];then
ENV_NAME="$PROJECT_ROOT/.venv" ENV_NAME="$PROJECT_ROOT/.venv"
elif [[ "$PROJECT_ROOT" != "." ]]; then elif [[ "$PROJECT_ROOT" != "." ]]; then
@ -69,8 +75,6 @@ if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then
# Note: this only happens if the virtualenv was activated automatically # Note: this only happens if the virtualenv was activated automatically
deactivate && unset CD_VIRTUAL_ENV deactivate && unset CD_VIRTUAL_ENV
fi fi
unset PROJECT_ROOT
unset WORKON_CWD
fi fi
} }

View file

@ -1,27 +1,27 @@
function vundle-init () { function vundle-init () {
if [ ! -d ~/.vim/bundle/vundle/ ] if [ ! -d ~/.vim/bundle/Vundle.vim/ ]
then then
mkdir -p ~/.vim/bundle/vundle/ mkdir -p ~/.vim/bundle/Vundle.vim/
fi fi
if [ ! -d ~/.vim/bundle/vundle/.git ] && [ ! -f ~/.vim/bundle/vundle/.git ] if [ ! -d ~/.vim/bundle/Vundle.vim/.git ] && [ ! -f ~/.vim/bundle/Vundle.vim/.git ]
then then
git clone http://github.com/gmarik/vundle.git ~/.vim/bundle/vundle git clone git://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
echo "\n\tRead about vim configuration for vundle at https://github.com/gmarik/vundle\n" echo "\n\tRead about vim configuration for vundle at https://github.com/VundleVim/Vundle.vim\n"
fi fi
} }
function vundle () { function vundle () {
vundle-init vundle-init
vim -c "execute \"PluginInstall\" | q | q" vim -c "execute \"PluginInstall\" | qa"
} }
function vundle-update () { function vundle-update () {
vundle-init vundle-init
vim -c "execute \"PluginInstall!\" | q | q" vim -c "execute \"PluginInstall!\" | qa"
} }
function vundle-clean () { function vundle-clean () {
vundle-init vundle-init
vim -c "execute \"PluginClean!\" | q | q" vim -c "execute \"PluginClean!\" | qa"
} }

View file

@ -12,18 +12,9 @@ function web_search() {
duckduckgo "https://www.duckduckgo.com/?q=" duckduckgo "https://www.duckduckgo.com/?q="
yandex "https://yandex.ru/yandsearch?text=" yandex "https://yandex.ru/yandsearch?text="
github "https://github.com/search?q=" github "https://github.com/search?q="
baidu "https://www.baidu.com/s?wd="
) )
# define the open command
case "$OSTYPE" in
darwin*) open_cmd="open" ;;
cygwin*) open_cmd="cygstart" ;;
linux*) open_cmd="xdg-open" ;;
*) echo "Platform $OSTYPE not supported"
return 1
;;
esac
# check whether the search engine is supported # check whether the search engine is supported
if [[ -z "$urls[$1]" ]]; then if [[ -z "$urls[$1]" ]]; then
echo "Search engine $1 not supported." echo "Search engine $1 not supported."
@ -41,7 +32,7 @@ function web_search() {
url="${(j://:)${(s:/:)urls[$1]}[1,2]}" url="${(j://:)${(s:/:)urls[$1]}[1,2]}"
fi fi
nohup $open_cmd "$url" &>/dev/null open_command "$url"
} }
@ -51,6 +42,7 @@ alias yahoo='web_search yahoo'
alias ddg='web_search duckduckgo' alias ddg='web_search duckduckgo'
alias yandex='web_search yandex' alias yandex='web_search yandex'
alias github='web_search github' alias github='web_search github'
alias baidu='web_search baidu'
#add your own !bang searches here #add your own !bang searches here
alias wiki='web_search duckduckgo \!w' alias wiki='web_search duckduckgo \!w'

84
plugins/xcode/README.md Normal file
View file

@ -0,0 +1,84 @@
# Xcode
## Description
This plugin provides a few utilities that can help you on your daily use of Xcode and iOS development.
To start using it, add the `xcode` plugin to your `plugins` array in `~/.zshrc`:
```zsh
plugins=(... xcode)
```
## Aliases
| Alias | Description | Command |
|-------|------------------------------------------|------------------------------------------------|
| xcb | Build Xcode projects and workspaces | xcodebuild |
| xcdd | Purge all temporary build information | rm -rf ~/Library/Developer/Xcode/DerivedData/* |
| xcp | Show currently selected Xcode directory | xcode-select --print-path |
| xcsel | Select different Xcode directory by path | sudo xcode-select --switch |
## Functions
### `xc`
Opens the current directory in Xcode as an Xcode project. This will open one of the `.xcworkspace` and `.xcodeproj` files that it can find in the current working directory.
Returns 1 if it didn't find any relevant files.
### `simulator`
Opens the iOS Simulator from your command line, dependent on whichever is the active developer directory for Xcode. (That is, it respects the `xcsel` setting.)
### `xcselv`
Selects different Xcode installations by version name. This is like `xcsel`, except it takes just a version name as an argument instead of the full path to the Xcode installation. Uses the naming conventions described below.
* `xcselv <version>` selects a version
* Example: `xcselv 6.2`
* `xcselv default` selects the default unversioned `Applications/Xcode.app`
* `xcselv` with no argument lists the available Xcode versions in a human-readable format
* `xcselv -l` lists the installed Xcode versions
* `xcselv -L` lists the installed Xcode versions in a short version-name-only format
* `xcselv -p` prints info about the active Xcode version
* `xcselv -h` prints a help message
The option parsing for `xcselv` is naive. Options may not be combined, and only the first option is recognized.
## Multiple Xcode Versions
The `xcselv` command provides support for switching between different Xcode installations using just a version number. Different Xcode versions are identified by file naming conventions.
### Versioned Xcode Naming Conventions
Apple does not seem to explicitly define or provide tooling support for a naming convention or other organizational mechanism for managing versioned Xcode installations. Apple seems to have released beta versions with both `Xcode<version>.app` and `Xcode-<version>.app` style names in the past, and both styles show up in forum and blog discussions.
We've adopted the following naming convention:
* Versioned Xcode installations are identified by the name `Xcode-<version>` or `Xcode<version>`.
* The `-` separating `"Xcode"` and the version name is optional, and may be replaced by a space.
* The versioned name may be applied to the `Xcode.app` itself, or a subdirectory underneath `Applications/` containing it.
* You cannot version both the `Xcode.app` filename itself and the containing subfolder.
* Thus, all of the following are equivalent.
* `Applications/Xcode-<version>.app`
* `Applications/Xcode-<version>/Xcode.app`
* `Applications/Xcode<version>.app`
* `Applications/Xcode <version>.app`
* `Applications/Xcode <version>/Xcode.app`
* Both the system `/Applications/` and user `$HOME/Applications/` directories are searched.
* The user's `$HOME/Applications/` takes precedence over `/Applications` for a given version.
* If multiple naming variants within the same `Applications/` folder indicate the same version (for example, `Xcode-3.2.1.app`, `Xcode3.2.1.app`, and `Xcode-3.2.1/Xcode.app`), the precedence order is unspecified and implementation-dependent.
* The `<version>` may be any string that is valid in a filename.
* The special version name `"default"` refers to the "default" unversioned Xcode at `Applications/Xcode.app` (in either `/Applications/` or `$HOME/Applications/`).
* Version names may not start with ``"-"`` or whitespace.
The restrictions on the naming convention may need to be tightened in the future. In particular, if there are other well-known applications whose names begin with the string `"Xcode"`, the strings allowed for `<version>` may need to be restricted to avoid colliding with other applications. If there's evidence that one of these naming techniques is strongly favored either in practice or by Apple, we may tighten the naming convention to favor it.
## Caveats
Using `xcsel` or `xcselv` to select an Xcode that is installed under your `$HOME` may break things for other users, depending on your system setup. We let you do this anyway because some people run OS X as effectively single-user, or have open permissions so this will work. You could also use `$DEVELOPER_DIR` as an alternative to `xcsel` that is scoped to the current user or session, instead of a global setting.
This does not verify that the version name in the Xcode filename matches the actual version of that binary. It is the user's responsibility to get the names right.

19
plugins/xcode/_xcselv Normal file
View file

@ -0,0 +1,19 @@
#compdef xcselv
#autoload
function _xcselv_compl_list_versions() {
_omz_xcode_list_versions short
}
_arguments \
'(-l -L -p)-h[prints a help message]' \
'(-L -p -h)-l[lists installed Xcode versions]' \
'(-l -p -h)-L[lists installed Xcode versions (long form)]' \
'(-h -l -L)-p[prints active Xcode version]' \
&& ret=0
local _xcode_versions
_xcode_versions=($(_xcselv_compl_list_versions))
_describe -t _xcode_versions 'version' _xcode_versions
return 1

View file

@ -1,25 +1,185 @@
#xc function courtesy of http://gist.github.com/subdigital/5420709
function xc {
xcode_proj=`ls | grep "\.xc" | sort -r | head -1`
if [[ `echo -n $xcode_proj | wc -m` == 0 ]]
then
echo "No xcworkspace/xcodeproj file found in the current directory."
else
echo "Found $xcode_proj"
open "$xcode_proj"
fi
}
function xcsel {
sudo xcode-select --switch "$*"
}
alias xcb='xcodebuild' alias xcb='xcodebuild'
alias xcp='xcode-select --print-path'
alias xcdd='rm -rf ~/Library/Developer/Xcode/DerivedData/*' alias xcdd='rm -rf ~/Library/Developer/Xcode/DerivedData/*'
alias xcp='xcode-select --print-path'
alias xcsel='sudo xcode-select --switch'
if [[ -d $(xcode-select -p)/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app ]]; then # original author: @subdigital
alias simulator='open $(xcode-select -p)/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app' # source: http://gist.github.com/subdigital/5420709
function xc {
local xcode_proj
xcode_proj=(*.{xcworkspace,xcodeproj}(N))
if [[ ${#xcode_proj} -eq 0 ]]; then
echo "No xcworkspace/xcodeproj file found in the current directory."
return 1
else else
alias simulator='open $(xcode-select -p)/Applications/iOS\ Simulator.app' echo "Found ${xcode_proj[1]}"
open "${xcode_proj[1]}"
fi fi
}
# "XCode-SELect by Version" - select Xcode by just version number
# Uses naming convention:
# - different versions of Xcode are named Xcode-<version>.app or stored
# in a folder named Xcode-<version>
# - the special version name "default" refers to the "default" Xcode.app with no suffix
function xcselv {
emulate -L zsh
if [[ $# == 0 ]]; then
echo "xcselv: error: no option or argument given" >&2
echo "xcselv: see 'xcselv -h' for help" >&2
return 1
elif [[ $1 == "-p" ]]; then
_omz_xcode_print_active_version
return
elif [[ $1 == "-l" ]]; then
_omz_xcode_list_versions
return
elif [[ $1 == "-L" ]]; then
_omz_xcode_list_versions short
return
elif [[ $1 == "-h" ]]; then
_omz_xcode_print_xcselv_usage
return 0
elif [[ $1 == -* && $1 != "-" ]]; then
echo "xcselv: error: unrecognized option: $1" >&2
echo "xcselv: see 'xcselv -h' for help" >&2
return 1
fi
# Main case: "xcselv <version>" to select a version
local version=$1
local -A xcode_versions
_omz_xcode_locate_versions
if [[ -z ${xcode_versions[$version]} ]]; then
echo "xcselv: error: Xcode version '$version' not found" >&2
return 1
fi
app="${xcode_versions[$version]}"
echo "selecting Xcode $version: $app"
xcsel "$app"
}
function _omz_xcode_print_xcselv_usage {
cat << EOF >&2
Usage:
xcselv <version>
xcselv [options]
Options:
<version> set the active Xcode version
-h print this help message and exit
-p print the active Xcode version
-l list installed Xcode versions (long human-readable form)
-L list installed Xcode versions (short form, version names only)
EOF
}
# Parses the Xcode version from a filename based on our conventions
# Only meaningful when called from other _omz_xcode functions
function _omz_xcode_parse_versioned_file {
local file=$1
local basename=${app:t}
local dir=${app:h}
local parent=${dir:t}
#echo "parent=$parent basename=$basename verstr=$verstr ver=$ver" >&2
local verstr
if [[ $parent == Xcode* ]]; then
if [[ $basename == "Xcode.app" ]]; then
# "Xcode-<version>/Xcode.app" format
verstr=$parent
else
# Both file and parent dir are versioned. Reject.
return 1;
fi
elif [[ $basename == Xcode*.app ]]; then
# "Xcode-<version>.app" format
verstr=${basename:r}
else
# Invalid naming pattern
return 1;
fi
local ver=${verstr#Xcode}
ver=${ver#[- ]}
if [[ -z $ver ]]; then
# Unversioned "default" installation location
ver="default"
fi
print -- "$ver"
}
# Print the active version, using xcselv's notion of versions
function _omz_xcode_print_active_version {
emulate -L zsh
local -A xcode_versions
local versions version active_path
_omz_xcode_locate_versions
active_path=$(xcode-select -p)
active_path=${active_path%%/Contents/Developer*}
versions=(${(kni)xcode_versions})
for version ($versions); do
if [[ "${xcode_versions[$version]}" == $active_path ]]; then
printf "%s (%s)\n" $version $active_path
return
fi
done
printf "%s (%s)\n" "<unknown>" $active_path
}
# Locates all the installed versions of Xcode on this system, for this
# plugin's internal use.
# Populates the $xcode_versions associative array variable
# Caller should local-ize $xcode_versions with `local -A xcode_versions`
function _omz_xcode_locate_versions {
emulate -L zsh
local -a app_dirs
local app_dir apps app xcode_ver
# In increasing precedence order:
app_dirs=(/Applications $HOME/Applications)
for app_dir ($app_dirs); do
apps=( $app_dir/Xcode*.app(N) $app_dir/Xcode*/Xcode.app(N) )
for app ($apps); do
xcode_ver=$(_omz_xcode_parse_versioned_file $app)
if [[ $? != 0 ]]; then
continue
fi
xcode_versions[$xcode_ver]=$app
done
done
}
function _omz_xcode_list_versions {
emulate -L zsh
local -A xcode_versions
_omz_xcode_locate_versions
local width=1 width_i versions do_short=0
if [[ $1 == "short" ]]; then
do_short=1
fi
versions=(${(kni)xcode_versions})
for version ($versions); do
if [[ $#version > $width ]]; then
width=$#version;
fi
done
for version ($versions); do
if [[ $do_short == 1 ]]; then
printf "%s\n" $version
else
printf "%-${width}s -> %s\n" "$version" "${xcode_versions[$version]}"
fi
done
}
function simulator {
local devfolder
devfolder="$(xcode-select -p)"
# Xcode ≤ 5.x
if [[ -d "${devfolder}/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app" ]]; then
open "${devfolder}/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app"
# Xcode ≥ 6.x
else
open "${devfolder}/Applications/iOS Simulator.app"
fi
}

View file

@ -7,6 +7,9 @@
# #
# In order for this theme to render correctly, you will need a # In order for this theme to render correctly, you will need a
# [Powerline-patched font](https://github.com/Lokaltog/powerline-fonts). # [Powerline-patched font](https://github.com/Lokaltog/powerline-fonts).
# Make sure you have a recent version: the code points that Powerline
# uses changed in 2012, and older versions will display incorrectly,
# in confusing ways.
# #
# In addition, I recommend the # In addition, I recommend the
# [Solarized theme](https://github.com/altercation/solarized/) and, if you're # [Solarized theme](https://github.com/altercation/solarized/) and, if you're
@ -27,12 +30,21 @@
CURRENT_BG='NONE' CURRENT_BG='NONE'
# Fix odd char on mac # Special Powerline characters
if [[ `uname` == 'Darwin' ]]; then
SEGMENT_SEPARATOR='\ue0b0' () {
else local LC_ALL="" LC_CTYPE="en_US.UTF-8"
SEGMENT_SEPARATOR='' # NOTE: This segment separator character is correct. In 2012, Powerline changed
fi # the code points they use for their special characters. This is the new code point.
# If this is not working for you, you probably have an old version of the
# Powerline-patched fonts installed. Download and install the new version.
# Do not submit PRs to change this unless you have reviewed the Powerline code point
# history and have new information.
# This is defined using a Unicode escape sequence so it is unambiguously readable, regardless of
# what font the user is viewing this source code in. Do not replace the
# escape sequence with a single literal character.
SEGMENT_SEPARATOR=$'\ue0b0' # 
}
# Begin a segment # Begin a segment
# Takes two arguments, background and foreground. Both can be omitted, # Takes two arguments, background and foreground. Both can be omitted,
@ -73,12 +85,18 @@ prompt_context() {
# Git: branch/detached head, dirty status # Git: branch/detached head, dirty status
prompt_git() { prompt_git() {
local PL_BRANCH_CHAR
() {
local LC_ALL="" LC_CTYPE="en_US.UTF-8"
PL_BRANCH_CHAR=$'\ue0a0' # 
}
local ref dirty mode repo_path local ref dirty mode repo_path
repo_path=$(git rev-parse --git-dir 2>/dev/null) repo_path=$(git rev-parse --git-dir 2>/dev/null)
if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
dirty=$(parse_git_dirty) dirty=$(parse_git_dirty)
ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git show-ref --head -s --abbrev |head -n1 2> /dev/null)" ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git rev-parse --short HEAD 2> /dev/null)"
if [[ -n $dirty ]]; then if [[ -n $dirty ]]; then
prompt_segment yellow black prompt_segment yellow black
else else
@ -104,7 +122,7 @@ prompt_git() {
zstyle ':vcs_info:*' formats ' %u%c' zstyle ':vcs_info:*' formats ' %u%c'
zstyle ':vcs_info:*' actionformats ' %u%c' zstyle ':vcs_info:*' actionformats ' %u%c'
vcs_info vcs_info
echo -n "${ref/refs\/heads\// }${vcs_info_msg_0_%% }${mode}" echo -n "${ref/refs\/heads\//$PL_BRANCH_CHAR }${vcs_info_msg_0_%% }${mode}"
fi fi
} }

Some files were not shown because too many files have changed in this diff Show more