Commit 96ff8614 authored by Andrew Janke's avatar Andrew Janke
Browse files

Merge branch 'master' into installer-cygwin-support-3

Conflicts:
	tools/install.sh
parents 502f08b5 76a26a2a
...@@ -140,12 +140,16 @@ d0() { ...@@ -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() {
ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}' 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}'
fi
} }
# Clear zombie processes # Clear zombie processes
......
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
# 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.
#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,31 +27,40 @@ typeset -g _task_cmds _task_projects _task_tags _task_config _task_modifiers ...@@ -30,31 +27,40 @@ 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=(
'before' \ 'before' \
'after' \ 'after' \
'none' \ 'none' \
'any' \ 'any' \
'is' \ 'is' \
'isnt' \ 'isnt' \
'has' \ 'has' \
'hasnt' \ 'hasnt' \
'startswith' \ 'startswith' \
'endswith' \ 'endswith' \
'word' \ 'word' \
'noword' 'noword'
) )
_task_conjunctions=( _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 \
...@@ -68,110 +74,130 @@ word=$'[^\0]#\0' ...@@ -68,110 +74,130 @@ word=$'[^\0]#\0'
# priorities # priorities
local -a task_priorities local -a task_priorities
_regex_words values 'task priorities' \ _regex_words values 'task priorities' \
'H:High' \ 'H:High' \
'M:Middle' \ 'M:Middle' \
'L:Low' 'L:Low'
task_priorities=("$reply[@]") task_priorities=("$reply[@]")
# projects # projects
local -a task_projects local -a task_projects
task_projects=( task_projects=(
/"$word"/ /"$word"/
":values:task projects:compadd -a _task_projects" ":values:task projects:compadd -a _task_projects"
) )
local -a _task_dates local -a _task_dates
_regex_words values 'task dates' \ _regex_words values 'task dates' \
'tod*ay:Today' \ 'tod*ay:Today' \
'yes*terday:Yesterday' \ 'yes*terday:Yesterday' \
'tom*orrow:Tomorrow' \ 'tom*orrow:Tomorrow' \
'sow:Start of week' \ 'sow:Start of week' \
'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' \
'soy:Start of year' \ 'soq:Start of quarter' \
'eow:End of week' \ 'soy:Start of year' \
'eoww:End of work week' \ 'eow:End of week' \
'eocw:End of calendar week' \ 'eoww:End of work week' \
'eom:End of month' \ 'eocw:End of calendar week' \
'eoy:End of year' \ 'eom:End of month' \
'mon:Monday' \ 'eoq:End of quarter' \
'tue:Tuesday'\ 'eoy:End of year' \
'wed:Wednesday' \ 'mon:Monday' \
'thu:Thursday' \ 'tue:Tuesday'\
'fri:Friday' \ 'wed:Wednesday' \
'sat:Saturday' \ 'thu:Thursday' \
'sun:Sunday' 'fri:Friday' \
'sat:Saturday' \
'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
_regex_words values 'task reldates' \ _regex_words values 'task reldates' \
'hrs:n hours' \ 'hrs:n hours' \
'day:n days' \ 'day:n days' \
'1st:first' \ '1st:first' \
'2nd:second' \ '2nd:second' \
'3rd:third' \ '3rd:third' \
'th:4th, 5th, etc.' \ 'th:4th, 5th, etc.' \
'wks:weeks' 'wks:weeks'
_task_reldates=("$reply[@]") _task_reldates=("$reply[@]")
task_dates=( task_dates=(
\( "$_task_dates[@]" \| \( "$_task_dates[@]" \|
\( /$'[0-9][0-9]#'/- \( "$_task_reldates[@]" \) \) \( /$'[0-9][0-9]#'/- \( "$_task_reldates[@]" \) \)
\) \)
) )
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' \
'weekdays:Every day skipping weekend days' \ 'weekdays:Every day skipping weekend days' \
'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' \
'yearly:Every year' \ 'yearly:Every year' \
'biannual:Every two years' \ 'biannual:Every two years' \
'biyearly:Every two years' 'biyearly:Every two years'
_task_freqs=("$reply[@]") _task_freqs=("$reply[@]")
local -a _task_frequencies local -a _task_frequencies
_regex_words values 'task frequencies' \ _regex_words values 'task frequencies' \
'd:days' \ 'd:days' \
'w:weeks' \ 'w:weeks' \
'q:quarters' \ 'q:quarters' \
'y:years' 'y:years'
_task_frequencies=("$reply[@]") _task_frequencies=("$reply[@]")
task_freqs=( task_freqs=(
\( "$_task_freqs[@]" \| \( "$_task_freqs[@]" \|
\( /$'[0-9][0-9]#'/- \( "$_task_frequencies[@]" \) \) \( /$'[0-9][0-9]#'/- \( "$_task_frequencies[@]" \) \)
\) \)
) )
# attributes # attributes
local -a task_attributes local -a task_attributes
_regex_words -t ':' default 'task attributes' \ _regex_words -t ':' default 'task attributes' \
'pro*ject:Project name:$task_projects' \ 'des*cription:Task description text' \
'du*e:Due date:$task_dates' \ 'status:Status of task - pending, completed, deleted, waiting' \
'wa*it:Date until task becomes pending:$task_dates' \ 'pro*ject:Project name:$task_projects' \
're*cur:Recurrence frequency:$task_freqs' \ 'pri*ority:priority:$task_priorities' \
'pri*ority:priority:$task_priorities' \ 'du*e:Due date:$task_dates' \
'un*til:Recurrence end date:$task_dates' \ 're*cur:Recurrence frequency:$task_freqs' \
'fg:Foreground color' \ 'un*til:Expiration date:$task_dates' \
'bg:Background color' \ '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"/ \)
\) \# \) \#
) )
_regex_arguments _task_attributes "${args[@]}" _regex_arguments _task_attributes "${args[@]}"
...@@ -180,43 +206,50 @@ _regex_arguments _task_attributes "${args[@]}" ...@@ -180,43 +206,50 @@ _regex_arguments _task_attributes "${args[@]}"
# filter completion # filter completion
(( $+functions[_task_filter] )) || (( $+functions[_task_filter] )) ||
_task_filter() { _task_filter() {
_task_attributes "$@" _task_attributes "$@"
# TODO complete conjunctions only if the previous word is a filter expression, i.e. attribute, ID, any non-command
_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 # TODO complete conjunctions only if the previous word is a filter expression, i.e. attribute, ID, any non-command
(( $+functions[_task_pull] )) || _describe -t default 'task conjunctions' _task_conjunctions
_task_pull() {
# TODO match URIs in .taskrc
_files
} }
# execute completion # execute completion
(( $+functions[_task_execute] )) || (( $+functions[_task_execute] )) ||
_task_execute() { _task_execute() {
_files _files
} }
# id-only completion # id-only completion
(( $+functions[_task_id] )) || (( $+functions[_task_id] )) ||
_task_id() { _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
...@@ -224,27 +257,28 @@ _task_id() { ...@@ -224,27 +257,28 @@ _task_id() {
_task_default() { _task_default() {
local cmd ret=1 local cmd ret=1
integer i=1 integer i=1
while (( i < $#words )) while (( i < $#words ))
do do
cmd="${_task_cmds[(r)$words[$i]]}" cmd="${_task_cmds[(r)$words[$i]]}"
if (( $#cmd )); then if (( $#cmd )); then
_call_function ret _task_${cmd} || _call_function ret _task_${cmd} ||
_call_function ret _task_filter || _call_function ret _task_filter ||
_message "No command remaining." _message "No command remaining."
return ret return ret
fi fi
(( i++ )) (( i++ ))
done done
# 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
_call_function ret _task_filter _describe -t aliases 'task aliases' _task_aliases
_call_function ret _task_filter
return ret
return ret
} }
_task _task "$@"
################################################################################
# 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'
......
# 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
## 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
#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
# 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.
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
...@@ -3,6 +3,7 @@ ...@@ -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' ...@@ -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 ...@@ -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' ...@@ -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' ...@@ -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
......
#compdef vagrant #compdef vagrant
#autoload #autoload
# vagrant zsh completion # vagrant zsh completion
...@@ -6,37 +6,45 @@ ...@@ -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 ()
...@@ -78,7 +86,7 @@ __vagrant-box () ...@@ -78,7 +86,7 @@ __vagrant-box ()
(options) (options)
case $line[1] in case $line[1] in
(repackage|remove) (repackage|remove)
_arguments ':feature:__box_list' _arguments ':feature:__box_list'
;; ;;
esac esac
;; ;;
...@@ -107,14 +115,14 @@ case $state in ...@@ -107,14 +115,14 @@ case $state in
(options) (options)
case $line[1] in case $line[1] in
(help) (help)
_arguments ':feature:__task_list' _arguments ':feature:__task_list'
;; ;;
(box) (box)
__vagrant-box __vagrant-box
;; ;;
(up|provision|package|destroy|reload|ssh|ssh-config|halt|resume|status) (up|provision|package|destroy|reload|ssh|ssh-config|halt|resume|status)
_arguments ':feature:__vm_list' _arguments ':feature:__vm_list'
esac esac
;; ;;
esac esac
...@@ -4,17 +4,6 @@ ...@@ -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 ...@@ -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"
......
...@@ -14,32 +14,38 @@ elif [[ -f "/etc/bash_completion.d/virtualenvwrapper" ]]; then ...@@ -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 ...@@ -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 ...@@ -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
} }
......
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"
} }
...@@ -12,18 +12,9 @@ function web_search() { ...@@ -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() { ...@@ -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' ...@@ -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'
......
# 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.
#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
#xc function courtesy of http://gist.github.com/subdigital/5420709 alias xcb='xcodebuild'
alias xcdd='rm -rf ~/Library/Developer/Xcode/DerivedData/*'
alias xcp='xcode-select --print-path'
alias xcsel='sudo xcode-select --switch'
# original author: @subdigital
# source: http://gist.github.com/subdigital/5420709
function xc { function xc {
xcode_proj=`ls | grep "\.xc" | sort -r | head -1` local xcode_proj
if [[ `echo -n $xcode_proj | wc -m` == 0 ]] xcode_proj=(*.{xcworkspace,xcodeproj}(N))
then
if [[ ${#xcode_proj} -eq 0 ]]; then
echo "No xcworkspace/xcodeproj file found in the current directory." echo "No xcworkspace/xcodeproj file found in the current directory."
return 1
else else
echo "Found $xcode_proj" echo "Found ${xcode_proj[1]}"
open "$xcode_proj" open "${xcode_proj[1]}"
fi fi
} }
function xcsel { # "XCode-SELect by Version" - select Xcode by just version number
sudo xcode-select --switch "$*" # 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"
} }
alias xcb='xcodebuild' function _omz_xcode_print_xcselv_usage {
alias xcp='xcode-select --print-path' cat << EOF >&2
alias xcdd='rm -rf ~/Library/Developer/Xcode/DerivedData/*' 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
if [[ -d $(xcode-select -p)/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app ]]; then local ver=${verstr#Xcode}
alias simulator='open $(xcode-select -p)/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app' ver=${ver#[- ]}
else if [[ -z $ver ]]; then
alias simulator='open $(xcode-select -p)/Applications/iOS\ Simulator.app' # Unversioned "default" installation location
fi 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
}
...@@ -7,6 +7,9 @@ ...@@ -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 @@ ...@@ -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() { ...@@ -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() { ...@@ -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
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment