Commit 93b4a6c0 authored by Andrew Janke's avatar Andrew Janke
Browse files

Merge branch 'master' into osx-fix-tab-for-iterm

Conflicts:
	plugins/osx/osx.plugin.zsh
parents 689b5ab3 0532860c
...@@ -5,7 +5,7 @@ _symfony_console () { ...@@ -5,7 +5,7 @@ _symfony_console () {
} }
_symfony2_get_command_list () { _symfony2_get_command_list () {
`_symfony_console` --no-ansi | sed "1,/Available commands/d" | awk '/^ ?[a-z]+/ { print $1 }' `_symfony_console` --no-ansi | sed "1,/Available commands/d" | awk '/^ ?[^ ]+ / { print $1 }'
} }
_symfony2 () { _symfony2 () {
......
...@@ -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
## 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
......
...@@ -14,43 +14,50 @@ elif [[ -f "/etc/bash_completion.d/virtualenvwrapper" ]]; then ...@@ -14,43 +14,50 @@ 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's 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
PROJECT_ROOT=`pwd` local GIT_REPO_ROOT=""
while [[ "$PROJECT_ROOT" != "/" && ! -e "$PROJECT_ROOT/.venv" ]]; do local GIT_TOPLEVEL="$(git rev-parse --show-toplevel 2> /dev/null)"
PROJECT_ROOT=`realpath $PROJECT_ROOT/..` if [[ $? == 0 ]]; then
GIT_REPO_ROOT="$GIT_TOPLEVEL"
fi
# Get absolute path, resolving symlinks
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 done
if [[ "$PROJECT_ROOT" == "/" ]]; then if [[ "$PROJECT_ROOT" == "/" ]]; then
PROJECT_ROOT="." PROJECT_ROOT="."
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
ENV_NAME=`basename "$PROJECT_ROOT"` ENV_NAME="${PROJECT_ROOT:t}"
else else
ENV_NAME="" ENV_NAME=""
fi fi
...@@ -68,8 +75,6 @@ if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then ...@@ -68,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
} }
......
This diff is collapsed.
This diff is collapsed.
...@@ -13,7 +13,7 @@ patches: <patches|join( → )|pre_applied(%{$fg[yellow]%})|post_applied(%{$reset ...@@ -13,7 +13,7 @@ patches: <patches|join( → )|pre_applied(%{$fg[yellow]%})|post_applied(%{$reset
} }
function box_name { function box_name {
[ -f ~/.box-name ] && cat ~/.box-name || echo ${SHORT_HOST:-HOST} [ -f ~/.box-name ] && cat ~/.box-name || echo ${SHORT_HOST:-$HOST}
} }
PROMPT=' PROMPT='
......
...@@ -21,7 +21,7 @@ function prompt_char { ...@@ -21,7 +21,7 @@ function prompt_char {
} }
function box_name { function box_name {
[ -f ~/.box-name ] && cat ~/.box-name || echo ${SHORT_HOST:-HOST} [ -f ~/.box-name ] && cat ~/.box-name || echo ${SHORT_HOST:-$HOST}
} }
......
...@@ -17,7 +17,7 @@ function prompt_char { ...@@ -17,7 +17,7 @@ function prompt_char {
} }
function box_name { function box_name {
[ -f ~/.box-name ] && cat ~/.box-name || echo ${SHORT_HOST:-HOST} [ -f ~/.box-name ] && cat ~/.box-name || echo ${SHORT_HOST:-$HOST}
} }
local ruby_env='' local ruby_env=''
......
This diff is collapsed.
This diff is collapsed.
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