Commit e6ccd37b authored by Chris McCuller's avatar Chris McCuller
Browse files

Merge master (rebase being super annoying). Fix conflicts

parents 30ef8566 76a26a2a
......@@ -140,12 +140,16 @@ d0() {
# gather external ip address
geteip() {
curl http://ifconfig.me
curl -s -S https://icanhazip.com
}
# determine local IP address
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}'
fi
}
# Clear zombie processes
......
user_commands=(
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=(
start stop reload restart try-restart isolate kill
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 $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
# zsh completion for taskwarrior
#
# taskwarrior - a command line task list manager.
#
# Copyright 2010 - 2011 Johannes Schlatow
# Copyright 2010 - 2015 Johannes Schlatow
# Copyright 2009 P.C. Shyamshankar
#
# 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_tags=($(task _tags))
_task_ids=($(task _ids))
_task_zshids=( ${(f)"$(task _zshids)"} )
_task_config=($(task _config))
_task_columns=($(task _columns))
_task_modifiers=(
......@@ -50,11 +48,19 @@ _task_conjunctions=(
'and' \
'or' \
'xor' \
'\)'
'\('
'\)' \
'\(' \
'<' \
'<=' \
'=' \
'!=' \
'>=' \
'>'
)
_task_cmds=($(task _commands))
_task_zshcmds=( ${(f)"$(task _zshcommands)"} )
_task_cmds=($(task _commands; task _aliases))
_task_zshcmds=( ${(f)"$(task _zshcommands)"} sentinel:sentinel:sentinel )
_task_aliases=($(task _aliases))
_task() {
_arguments -s -S \
......@@ -89,11 +95,13 @@ _regex_words values 'task dates' \
'soww:Start of work week' \
'socw:Start of calendar week' \
'som:Start of month' \
'soq:Start of quarter' \
'soy:Start of year' \
'eow:End of week' \
'eoww:End of work week' \
'eocw:End of calendar week' \
'eom:End of month' \
'eoq:End of quarter' \
'eoy:End of year' \
'mon:Monday' \
'tue:Tuesday'\
......@@ -101,7 +109,16 @@ _regex_words values 'task dates' \
'thu:Thursday' \
'fri:Friday' \
'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[@]")
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' \
'daily:Every day' \
'day:Every day' \
......@@ -128,7 +149,7 @@ _regex_words values 'task frequencies' \
'weekly:Every week' \
'biweekly:Every two weeks' \
'fortnight:Every two weeks' \
+ 'monthly:Every month' \
'monthly:Every month' \
'quarterly:Every three months' \
'semiannual:Every six months' \
'annual:Every year' \
......@@ -154,20 +175,25 @@ task_freqs=(
# attributes
local -a 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' \
'pri*ority:priority:$task_priorities' \
'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' \
'un*til:Recurrence end date:$task_dates' \
'fg:Foreground color' \
'bg:Background color' \
'li*mit:Desired number of rows in report'
'un*til:Expiration date:$task_dates' \
'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[@]")
args=(
\( "$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" \) \) \|
\( /'(+|-)'/- \( /"$word"/ ":values:remove tag:compadd -a _task_tags" \) \) \|
\( /"$word"/ \)
......@@ -186,27 +212,6 @@ _task_filter() {
_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
(( $+functions[_task_execute] )) ||
_task_execute() {
......@@ -219,6 +224,34 @@ _task_id() {
_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
(( $+functions[_task_default] )) ||
_task_default() {
......@@ -240,11 +273,12 @@ _task_default() {
# update IDs
_task_zshids=( ${(f)"$(task _zshids)"} )
_describe -t commands 'task command' _task_zshcmds
_describe -t values 'task IDs' _task_zshids
_task_subcommands
_describe -t tasks 'task IDs' _task_zshids
_describe -t aliases 'task aliases' _task_aliases
_call_function ret _task_filter
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:*:descriptions' format '%U%B%d%b%u'
......
# Set Apple Terminal.app resume directory
# based on this answer: http://superuser.com/a/315029
# 2012-10-26: (javageek) Changed code using the updated answer
# Tell the terminal about the working directory whenever it changes.
if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then
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
# This file is intentionally empty.
#
# 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
# is loaded for all users. You can remove terminalapp from your $plugins list
# once all your systems are updated to the current version of Oh My Zsh.
## 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 @@
# https://github.com/dbb
# https://github.com/Mappleconfusers
# Nicolas Jonas nextgenthemes.com
# https://github.com/loctauxphilippe
#
# 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 aga='sudo apt-get autoclean' # aac
alias agar='sudo apt-get autoremove'
alias agb='sudo apt-get build-dep' # abd
alias agc='sudo apt-get clean' # adc
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 agug='sudo apt-get upgrade' # ag
alias aguu='sudo apt-get update && sudo apt-get upgrade' #adg
alias agar='sudo apt-get autoremove'
compdef _ag ag='sudo apt-get'
compdef _aga aga='sudo apt-get autoclean'
compdef _agar agar='sudo apt-get autoremove'
compdef _agb agb='sudo apt-get build-dep'
compdef _agc agc='sudo apt-get clean'
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 _agug agug='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
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
# 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
aar() {
if [ -n "$2" ]; then
......
......@@ -6,37 +6,45 @@
local -a _1st_arguments
_1st_arguments=(
'box:Box commands'
'connect:Connects to a shared, remote Vagrant environment'
'connect:Connects to a remotely shared Vagrant environment'
'destroy:Destroys the vagrant environment'
'docker-logs:Shows Docker logs'
'docker-run:Run one-off commands against a Docker container'
'docker-logs:Outputs the logs from the 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'
'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'
'list-commands:Outputs all available Vagrant subcommands, even non-primary ones'
'login:Authenticates against a Vagrant Cloud server to access protected boxes'
'package:Packages a vagrant environment for distribution'
'plugin:Plugin commands'
'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'
'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-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'
'suspend:Suspends the currently running 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'
'--version:Prints the Vagrant version information'
)
local -a _box_arguments
_box_arguments=(
'add:NAME URI Add a box to the system'
'help:COMMAND Describe subcommands or one specific subcommand'
'add:ADDRESS Adds a box to the system'
'help:COMMAND List subcommands'
'list:Lists all installed boxes'
'remove:NAME Remove a box from the system'
'repackage:NAME Repackage an installed box into a `.box` file.'
'outdated:Checks if a box has newer version'
'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 ()
......
......@@ -4,17 +4,6 @@
# 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
{
if [[ $# == 0 ]]; then
......@@ -48,13 +37,10 @@ EOH
if [[ ${before#:} != $before && ${before%<cr>} == $before ]]; then
before="$before<cr>"
fi
local files=""
for f in $@
do
files="$files $(resolveFile $f)"
done
if [[ -n $files ]]; then
files=':args! '"$files<cr>"
local files
if [[ $# -gt 0 ]]; then
# absolute path of files resolving symlinks (:A) and quoting special chars (:q)
files=':args! '"${@:A:q}<cr>"
fi
cmd="$before$files$after"
gvim --remote-send "$cmd"
......
......@@ -14,32 +14,38 @@ elif [[ -f "/etc/bash_completion.d/virtualenvwrapper" ]]; then
source "/etc/bash_completion.d/virtualenvwrapper"
}
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
return
fi
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
return
fi
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
fi
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
# 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 {
if [ ! $WORKON_CWD ]; then
WORKON_CWD=1
if [[ -z "$WORKON_CWD" ]]; then
local WORKON_CWD=1
# 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
PROJECT_ROOT="${PWD:A}"
while [[ "$PROJECT_ROOT" != "/" && ! -e "$PROJECT_ROOT/.venv" ]]; do
local PROJECT_ROOT="${PWD:A}"
while [[ "$PROJECT_ROOT" != "/" && ! -e "$PROJECT_ROOT/.venv" \
&& ! -d "$PROJECT_ROOT/.git" && "$PROJECT_ROOT" != "$GIT_REPO_ROOT" ]]; do
PROJECT_ROOT="${PROJECT_ROOT:h}"
done
if [[ "$PROJECT_ROOT" == "/" ]]; then
......@@ -47,7 +53,7 @@ if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then
fi
# Check for virtualenv name override
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
ENV_NAME="$PROJECT_ROOT/.venv"
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
deactivate && unset CD_VIRTUAL_ENV
fi
unset PROJECT_ROOT
unset WORKON_CWD
fi
}
......
function vundle-init () {
if [ ! -d ~/.vim/bundle/vundle/ ]
if [ ! -d ~/.vim/bundle/Vundle.vim/ ]
then
mkdir -p ~/.vim/bundle/vundle/
mkdir -p ~/.vim/bundle/Vundle.vim/
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
git clone http://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
echo "\n\tRead about vim configuration for vundle at https://github.com/gmarik/vundle\n"
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/VundleVim/Vundle.vim\n"
fi
}
function vundle () {
vundle-init
vim -c "execute \"PluginInstall\" | q | q"
vim -c "execute \"PluginInstall\" | qa"
}
function vundle-update () {
vundle-init
vim -c "execute \"PluginInstall!\" | q | q"
vim -c "execute \"PluginInstall!\" | qa"
}
function vundle-clean () {
vundle-init
vim -c "execute \"PluginClean!\" | q | q"
vim -c "execute \"PluginClean!\" | qa"
}
......@@ -12,18 +12,9 @@ function web_search() {
duckduckgo "https://www.duckduckgo.com/?q="
yandex "https://yandex.ru/yandsearch?text="
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
if [[ -z "$urls[$1]" ]]; then
echo "Search engine $1 not supported."
......@@ -41,7 +32,7 @@ function web_search() {
url="${(j://:)${(s:/:)urls[$1]}[1,2]}"
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 yandex='web_search yandex'
alias github='web_search github'
alias baidu='web_search baidu'
#add your own !bang searches here
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 {
xcode_proj=`ls | grep "\.xc" | sort -r | head -1`
if [[ `echo -n $xcode_proj | wc -m` == 0 ]]
then
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
echo "Found $xcode_proj"
open "$xcode_proj"
echo "Found ${xcode_proj[1]}"
open "${xcode_proj[1]}"
fi
}
function xcsel {
sudo xcode-select --switch "$*"
# "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"
}
alias xcb='xcodebuild'
alias xcp='xcode-select --print-path'
alias xcdd='rm -rf ~/Library/Developer/Xcode/DerivedData/*'
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
}
if [[ -d $(xcode-select -p)/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app ]]; then
alias simulator='open $(xcode-select -p)/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app'
else
alias simulator='open $(xcode-select -p)/Applications/iOS\ Simulator.app'
fi
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 @@
#
# In order for this theme to render correctly, you will need a
# [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
# [Solarized theme](https://github.com/altercation/solarized/) and, if you're
......@@ -27,12 +30,21 @@
CURRENT_BG='NONE'
# Fix odd char on mac
if [[ `uname` == 'Darwin' ]]; then
SEGMENT_SEPARATOR='\ue0b0'
else
SEGMENT_SEPARATOR=''
fi
# Special Powerline characters
() {
local LC_ALL="" LC_CTYPE="en_US.UTF-8"
# NOTE: This segment separator character is correct. In 2012, Powerline changed
# 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
# Takes two arguments, background and foreground. Both can be omitted,
......@@ -73,12 +85,18 @@ prompt_context() {
# Git: branch/detached head, dirty status
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
repo_path=$(git rev-parse --git-dir 2>/dev/null)
if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
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
prompt_segment yellow black
else
......@@ -104,7 +122,7 @@ prompt_git() {
zstyle ':vcs_info:*' formats ' %u%c'
zstyle ':vcs_info:*' actionformats ' %u%c'
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
}
......
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