Commit 18ef1ee6 authored by Dawid Ferenczy's avatar Dawid Ferenczy
Browse files

Merge remote-tracking branch 'robbyrussell/master'

parents eafd5f32 192de6bc
...@@ -246,3 +246,5 @@ _task_default() { ...@@ -246,3 +246,5 @@ _task_default() {
return ret return ret
} }
_task
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
# TaskWarrior<http://taskwarrior.org/>. It uses the zsh tab completion # TaskWarrior<http://taskwarrior.org/>. It uses the zsh tab completion
# script (_task) distributed with TaskWarrior for the completion definitions. # script (_task) distributed with TaskWarrior for the completion definitions.
# #
# Typing task[tabtab] will give you a list of current tasks, task 66[tabtab] # Typing task [tabtab] will give you a list of current tasks, task 66[tabtab]
# gives a list of available modifications for that task, etc. # gives a list of available modifications for that task, etc.
################################################################################ ################################################################################
......
## 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
## textastic
Plugin for Textastic, a text and code editor for Mac OS X
### Requirements
* [Textastic](http://www.textasticapp.com/mac.html)
### Usage
* If `tt` command is called without an argument, launch Textastic
* If `tt` is passed a directory, cd to it and open it in Textastic
* If `tt` is passed a file, open it in Textastic
#
# If the tt command is called without an argument, launch Textastic
# If tt is passed a directory, cd to it and open it in Textastic
# If tt is passed a file, open it in Textastic
#
function tt() {
if [[ -z "$1" ]]
then
open -a "textastic.app"
else
open -a "textastic.app" "$1"
if [[ -d "$1" ]]
then
cd "$1"
fi
fi
}
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
alias ta='tmux attach -t' alias ta='tmux attach -t'
alias ts='tmux new-session -s' alias ts='tmux new-session -s'
alias tl='tmux list-sessions' alias tl='tmux list-sessions'
alias tksv='tmux kill-server'
alias tkss='tmux kill-session -t'
# Only run if tmux is actually installed # Only run if tmux is actually installed
if which tmux &> /dev/null if which tmux &> /dev/null
......
...@@ -8,25 +8,29 @@ _arguments -C \ ...@@ -8,25 +8,29 @@ _arguments -C \
'1: :->cmds' \ '1: :->cmds' \
'2:: :->args' && ret=0 '2:: :->args' && ret=0
_configs=(${$(echo ~/.tmuxinator/*.yml):r:t})
case $state in case $state in
cmds) cmds)
_values "tmuxinator command" \ _values "tmuxinator command" \
"new[create a new project file and open it in your editor]" \
"start[start a tmux session using project's tmuxinator config]" \ "start[start a tmux session using project's tmuxinator config]" \
"open[create a new project file and open it in your editor]" \ "open[create a new project file and open it in your editor]" \
"copy[copy source_project project file to a new project called new_project]" \ "copy[copy source_project project file to a new project called new_project]" \
"delete[deletes the project called project_name]" \ "delete[deletes the project called project_name]" \
"debug[output the shell commands generated by a projet]" \
"implode[deletes all existing projects!]" \ "implode[deletes all existing projects!]" \
"list[list all existing projects]" \ "list[list all existing projects]" \
"doctor[look for problems in your configuration]" \ "doctor[look for problems in your configuration]" \
"help[shows this help document]" \ "help[shows this help document]" \
"version[shows tmuxinator version number]" "version[shows tmuxinator version number]" \
$_configs
ret=0 ret=0
;; ;;
args) args)
case $line[1] in case $line[1] in
start|open|copy|delete) start|open|copy|delete|debug)
_configs=(`find ~/.tmuxinator -name \*.yml | cut -d/ -f5 | sed s:.yml::g`) [[ -n "$_configs" ]] && _values 'configs' $_configs
_values 'configs' $_configs
ret=0 ret=0
;; ;;
esac esac
......
#compdef tugboat
#autoload
# Tugboat zsh autocompletion
local -a _commands
_commands=(
'add-key:[NAME] Upload an ssh public key.'
'authorize:Authorize a DigitalOcean account with tugboat.'
'create:[NAME] Create a droplet.'
'destroy:[FUZZY_NAME] Destroy a droplet.'
'destroy_image:[FUZZY_NAME] Destroy an image.'
'droplets:Retrieve a list of your droplets.'
'halt:[FUZZY_NAME] Shutdown a droplet.'
'help:[COMMAND] Describe commands or a specific command.'
'images:Retrieve a list of your images.'
'info:[FUZZY_NAME] [OPTIONS] Show a droplets information.'
'info_image:[FUZZY_NAME] [OPTIONS] Show an images information.'
'keys:Show available SSH keys.'
'password-reset:[FUZZY_NAME] Reset root password.'
'rebuild:[FUZZY_NAME] [IMAGE_NAME] Rebuild a droplet.'
'regions:Show regions.'
'resize:[FUZZY_NAME -s, --size=N] Resize a droplet.'
'restart:[FUZZY_NAME] Restart a droplet.'
'sizes:Show available droplet sizes.'
'snapshot:[SNAPSHOT_NAME] [FUZZY_NAME] [OPTIONS] Queue a snapshot of the droplet.'
'ssh:[FUZZY_NAME] SSH into a droplet.'
'start:[FUZZY_NAME] Start a droplet.'
'verify:Check your DigitalOcean credentials.'
'version:Show version.'
'wait:[FUZZY_NAME] Wait for a droplet to reach a state.'
)
local -a _create_arguments
_create_arguments=(
'-s:[--size=N] The size_id of the droplet'
'-i:[--image=N] The image_id of the droplet'
'-r:[--region=N] The region_id of the droplet'
'-k:[--keys=KEYS] A comma separated list of SSH key ids to add to the droplet'
'-p:[--private-networking] Enable private networking on the droplet'
'-b:[--backups-enabled] Enable backups on the droplet'
'-q:[--quiet]'
)
__task_list ()
{
local expl
declare -a tasks
arguments=(add-key authorize create destroy destroy_image droplets halt help images info info_image keys password-reset rebuild regions resize restart sizes snapshot ssh start verify version wait)
_wanted tasks expl 'help' compadd $arguments
}
__droplets_list ()
{
_wanted application expl 'command' compadd $(command tugboat droplets | cut -d " " -f1)
}
__tugboat-create ()
{
local curcontext="$curcontext" state line
typeset -A opt_args
_arguments -C \
':command:->command' \
'*::options:->options'
case $state in
(command)
_describe -t commands "gem subcommand" _create_arguments
return
;;
esac
}
local curcontext="$curcontext" state line
typeset -A opt_args
_arguments -C \
':command:->command' \
'*::options:->options'
case $state in
(command)
_describe -t commands "gem subcommand" _commands
return
;;
(options)
case $line[1] in
(help)
_arguments ':feature:__task_list'
;;
(ssh)
_arguments ':feature:__droplets_list'
;;
(create)
_arguments ':feature:__tugboat-create'
;;
esac
;;
esac
This plugin was created because the aliases in the debian plugin are inconsistent and hard to remember. Also this apt-priority detection that switched between apt-get and aptitude was dropped to keep it simpler. This plugin uses apt-get for everything but a few things that are only possible with aptitude I guess. Ubuntu does not have aptitude installed by default.
acs = Apt-Cache Search
acp = Apt-Cache Policy
ag = sudo Apt-Get
agi = sudo Apt-Get Install
agd = sudo Apt-Get Dselect-upgrade
By now you already can guess almost all aliases
There are two exeptions since ...
agu = sudo Apt-Get Update - we have ...
agug = sudo Apt-Get UpGrade - as the exeptional 4 letter alias for a single command.
afs = Apt-File Search --regexp - this has the regexp switch on without being represented in the alias, I guess this makes sense since the debian plugin has it, I never used that command.
Then there are the 2 other 4 letter aliases for combined commands, that are straight forward and easy to remember.
aguu = sudo Apt-Get Update && sudo apt-get Upgrade - better then adg or not?
agud = sudo Apt-Get Update && sudo apt-get Dist-upgrade
For a full list aliases and the functions just watch the plugins code https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/ubuntu/ubuntu.plugin.zsh, look at the comments if you want to switch from the debian plugin. Ubuntu, Mint and & co users will like the new aar function to install packages from ppas with a single command.
# Authors:
# https://github.com/AlexBio
# https://github.com/dbb
# https://github.com/Mappleconfusers
# Nicolas Jonas nextgenthemes.com
#
# Debian, Ubuntu and friends related zsh aliases and functions for zsh
alias acs='apt-cache search'
compdef _acs acs='apt-cache search'
alias afs='apt-file search --regexp'
compdef _afs afs='apt-file search --regexp'
# These are apt-get only
alias ags='apt-get source' # asrc
compdef _ags ags='apt-get source'
alias acp='apt-cache policy' # app
compdef _acp acp='apt-cache policy'
# superuser operations ######################################################
alias afu='sudo apt-file update'
compdef _afu afu='sudo apt-file update'
alias ppap='sudo ppa-purge'
compdef _ppap ppap='sudo ppa-purge'
alias ag='sudo apt-get' # age - but without sudo
alias aga='sudo apt-get autoclean' # aac
alias agb='sudo apt-get build-dep' # abd
alias agc='sudo apt-get clean' # adc
alias agd='sudo apt-get dselect-upgrade' # ads
alias agi='sudo apt-get install' # ai
alias agp='sudo apt-get purge' # ap
alias agr='sudo apt-get remove' # ar
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
compdef _ag ag='sudo apt-get'
compdef _aga aga='sudo apt-get autoclean'
compdef _agb agb='sudo apt-get build-dep'
compdef _agc agc='sudo apt-get clean'
compdef _agd agd='sudo apt-get dselect-upgrade'
compdef _agi agi='sudo apt-get install'
compdef _agp agp='sudo apt-get purge'
compdef _agr agr='sudo apt-get remove'
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'
# Remove ALL kernel images and headers EXCEPT the one in use
alias kclean='sudo aptitude remove -P ?and(~i~nlinux-(ima|hea) \
?not(~n`uname -r`))'
# Misc. #####################################################################
# print all installed packages
alias allpkgs='aptitude search -F "%p" --disable-columns ~i'
# Create a basic .deb package
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
# 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
PACKAGE=$2
else
read "PACKAGE?Type in the package name to install/upgrade with this ppa [${1##*/}]: "
fi
if [ -z "$PACKAGE" ]; then
PACKAGE=${1##*/}
fi
sudo apt-add-repository $1 && sudo apt-get update
sudo apt-get install $PACKAGE
}
# Prints apt history
# Usage:
# apt-history install
# apt-history upgrade
# apt-history remove
# apt-history rollback
# apt-history list
# Based On: http://linuxcommando.blogspot.com/2008/08/how-to-show-apt-log-history.html
apt-history () {
case "$1" in
install)
zgrep --no-filename 'install ' $(ls -rt /var/log/dpkg*)
;;
upgrade|remove)
zgrep --no-filename $1 $(ls -rt /var/log/dpkg*)
;;
rollback)
zgrep --no-filename upgrade $(ls -rt /var/log/dpkg*) | \
grep "$2" -A10000000 | \
grep "$3" -B10000000 | \
awk '{print $4"="$5}'
;;
list)
zcat $(ls -rt /var/log/dpkg*)
;;
*)
echo "Parameters:"
echo " install - Lists all packages that have been installed."
echo " upgrade - Lists all packages that have been upgraded."
echo " remove - Lists all packages that have been removed."
echo " rollback - Lists rollback information."
echo " list - Lists all contains of dpkg logs."
;;
esac
}
# Kernel-package building shortcut
kerndeb () {
# temporarily unset MAKEFLAGS ( '-j3' will fail )
MAKEFLAGS=$( print - $MAKEFLAGS | perl -pe 's/-j\s*[\d]+//g' )
print '$MAKEFLAGS set to '"'$MAKEFLAGS'"
appendage='-custom' # this shows up in $ (uname -r )
revision=$(date +"%Y%m%d") # this shows up in the .deb file name
make-kpkg clean
time fakeroot make-kpkg --append-to-version "$appendage" --revision \
"$revision" kernel_image kernel_headers
}
# List packages by size
function apt-list-packages {
dpkg-query -W --showformat='${Installed-Size} ${Package} ${Status}\n' | \
grep -v deinstall | \
sort -n | \
awk '{print $1" "$2}'
}
...@@ -6,19 +6,26 @@ ...@@ -6,19 +6,26 @@
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'
'destroy:Destroys the vagrant environment' 'destroy:Destroys the vagrant environment'
'docker-logs:Shows Docker logs'
'docker-run:Run one-off commands against a Docker container'
'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'
'init:[box_name] [box_url] Initializes current folder for Vagrant usage' 'init:[box_name] [box_url] Initializes current folder for Vagrant usage'
'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'
'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'
'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'
'--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'
) )
...@@ -49,7 +56,8 @@ __box_list () ...@@ -49,7 +56,8 @@ __box_list ()
__vm_list () __vm_list ()
{ {
_wanted application expl 'command' compadd $(command grep Vagrantfile -oe '^[^#]*\.vm\.define *:\([a-zA-Z0-9]\+\)' 2>/dev/null | cut -d: -f2) _wanted application expl 'command' compadd $(command grep Vagrantfile -oe '^[^#]*\.vm\.define *[:"]\([a-zA-Z0-9_-]\+\)' 2>/dev/null | awk '{print substr($2, 2)}')
_wanted application expl 'command' compadd $(command ls .vagrant/machines/ 2>/dev/null)
} }
__vagrant-box () __vagrant-box ()
...@@ -105,7 +113,7 @@ case $state in ...@@ -105,7 +113,7 @@ case $state in
(box) (box)
__vagrant-box __vagrant-box
;; ;;
(up|provision|package|destroy|reload|ssh|halt|resume|status) (up|provision|package|destroy|reload|ssh|ssh-config|halt|resume|status)
_arguments ':feature:__vm_list' _arguments ':feature:__vm_list'
esac esac
;; ;;
......
vi-mode
=======
This plugin increase `vi-like` zsh functionality.
Use `ESC` or `CTRL-[` to enter `Normal mode`.
History
-------
- `ctrl-p` : Previous command in history
- `ctrl-n` : Next command in history
- `/` : Search backward in history
- `n` : Repeat the last `/`
Mode indicators
---------------
*Normal mode* is indicated with red `<<<` mark at the right prompt, when it
wasn't defined by theme.
Vim edition
-----------
- `v` : Edit current command line in Vim
Movement
--------
- `$` : To the end of the line
- `^` : To the first non-blank character of the line
- `0` : To the first character of the line
- `w` : [count] words forward
- `W` : [count] WORDS forward
- `e` : Forward to the end of word [count] inclusive
- `E` : Forward to the end of WORD [count] inclusive
- `b` : [count] words backward
- `B` : [count] WORDS backward
- `t{char}` : Till before [count]'th occurrence of {char} to the right
- `T{char}` : Till before [count]'th occurrence of {char} to the left
- `f{char}` : To [count]'th occurrence of {char} to the right
- `F{char}` : To [count]'th occurrence of {char} to the left
- `;` : Repeat latest f, t, F or T [count] times
- `,` : Repeat latest f, t, F or T in opposite direction
Insertion
---------
- `i` : Insert text before the cursor
- `I` : Insert text before the first character in the line
- `a` : Append text after the cursor
- `A` : Append text at the end of the line
- `o` : Insert new command line below the current one
- `O` : Insert new command line above the current one
Delete and Insert
-----------------
- `ctrl-h` : While in *Insert mode*: delete character after the cursor
- `ctrl-w` : While in *Insert mode*: delete word after the cursor
- `d{motion}` : Delete text that {motion} moves over
- `dd` : Delete line
- `D` : Delete characters under the cursor until the end of the line
- `c{motion}` : Delete {motion} text and start insert
- `cc` : Delete line and start insert
- `C` : Delete to the end of the line and start insert
- `r{char}` : Replace the character under the cursor with {char}
- `R` : Enter replace mode: Each character replaces existing one
- `x` : Delete [count] characters under and after the cursor
- `X` : Delete [count] characters before the cursor
...@@ -14,6 +14,11 @@ function zle-keymap-select zle-line-init zle-line-finish { ...@@ -14,6 +14,11 @@ function zle-keymap-select zle-line-init zle-line-finish {
zle -R zle -R
} }
# Ensure that the prompt is redrawn when the terminal size changes.
TRAPWINCH() {
zle && { zle reset-prompt; zle -R }
}
zle -N zle-line-init zle -N zle-line-init
zle -N zle-line-finish zle -N zle-line-finish
zle -N zle-keymap-select zle -N zle-keymap-select
...@@ -26,6 +31,15 @@ bindkey -v ...@@ -26,6 +31,15 @@ bindkey -v
autoload -Uz edit-command-line autoload -Uz edit-command-line
bindkey -M vicmd 'v' edit-command-line bindkey -M vicmd 'v' edit-command-line
# allow ctrl-p, ctrl-n for navigate history (standard behaviour)
bindkey '^P' up-history
bindkey '^N' down-history
# allow ctrl-h, ctrl-w, ctrl-? for char and word deletion (standard behaviour)
bindkey '^?' backward-delete-char
bindkey '^h' backward-delete-char
bindkey '^w' backward-kill-word
# if mode indicator wasn't setup by theme, define default # if mode indicator wasn't setup by theme, define default
if [[ "$MODE_INDICATOR" == "" ]]; then if [[ "$MODE_INDICATOR" == "" ]]; then
MODE_INDICATOR="%{$fg_bold[red]%}<%{$fg[red]%}<<%{$reset_color%}" MODE_INDICATOR="%{$fg_bold[red]%}<%{$fg[red]%}<<%{$reset_color%}"
......
...@@ -9,7 +9,7 @@ function resolveFile ...@@ -9,7 +9,7 @@ function resolveFile
if [ -f "$1" ]; then if [ -f "$1" ]; then
echo $(readlink -f "$1") echo $(readlink -f "$1")
elif [[ "${1#/}" == "$1" ]]; then elif [[ "${1#/}" == "$1" ]]; then
echo "$(pwd)/$1" echo "$PWD/$1"
else else
echo $1 echo $1
fi fi
......
function virtualenv_prompt_info(){ function virtualenv_prompt_info(){
if [[ -n $VIRTUAL_ENV ]]; then [[ -n ${VIRTUAL_ENV} ]] || return
printf "%s[%s] " "%{${fg[yellow]}%}" ${${VIRTUAL_ENV}:t} echo "${ZSH_THEME_VIRTUALENV_PREFIX:=[}${VIRTUAL_ENV:t}${ZSH_THEME_VIRTUALENV_SUFFIX:=]}"
fi
} }
# disables prompt mangling in virtual_env/bin/activate # disables prompt mangling in virtual_env/bin/activate
......
virtualenvwrapper='virtualenvwrapper.sh' virtualenvwrapper='virtualenvwrapper.sh'
if (( $+commands[$virtualenvwrapper] )); then if (( $+commands[$virtualenvwrapper] )); then
source ${${virtualenvwrapper}:c} function {
setopt local_options
unsetopt equals
source ${${virtualenvwrapper}:c}
}
elif [[ -f "/etc/bash_completion.d/virtualenvwrapper" ]]; then
function {
setopt local_options
unsetopt equals
virtualenvwrapper="/etc/bash_completion.d/virtualenvwrapper"
source "/etc/bash_completion.d/virtualenvwrapper"
}
else
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 "[oh-my-zsh] virtualenvwrapper plugin: shell function 'workon' not defined.\n"\
"Please check ${virtualenvwrapper}" >&2
return
fi
if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then if [[ "$WORKON_HOME" == "" ]]; then
# Automatically activate Git projects's virtual environments based on the print "[oh-my-zsh] \$WORKON_HOME is not defined so plugin virtualenvwrapper will not work" >&2
# directory name of the project. Virtual environment name can be overridden return
# by placing a .venv file in the project root with a virtualenv name in it fi
function workon_cwd {
if [ ! $WORKON_CWD ]; then
WORKON_CWD=1
# Check if this is a Git repo
PROJECT_ROOT=`git rev-parse --show-toplevel 2> /dev/null`
if (( $? != 0 )); then
PROJECT_ROOT="."
fi
# Check for virtualenv name override
if [[ -f "$PROJECT_ROOT/.venv" ]]; then
ENV_NAME=`cat "$PROJECT_ROOT/.venv"`
elif [[ -f "$PROJECT_ROOT/.venv/bin/activate" ]];then
ENV_NAME="$PROJECT_ROOT/.venv"
elif [[ "$PROJECT_ROOT" != "." ]]; then
ENV_NAME=`basename "$PROJECT_ROOT"`
else
ENV_NAME=""
fi
if [[ "$ENV_NAME" != "" ]]; then
# Activate the environment only if it is not already active
if [[ "$VIRTUAL_ENV" != "$WORKON_HOME/$ENV_NAME" ]]; then
if [[ -e "$WORKON_HOME/$ENV_NAME/bin/activate" ]]; then
workon "$ENV_NAME" && export CD_VIRTUAL_ENV="$ENV_NAME"
elif [[ -e "$ENV_NAME/bin/activate" ]]; then
source $ENV_NAME/bin/activate && export CD_VIRTUAL_ENV="$ENV_NAME"
fi
fi
elif [ $CD_VIRTUAL_ENV ]; then
# We've just left the repo, deactivate the environment
# Note: this only happens if the virtualenv was activated automatically
deactivate && unset CD_VIRTUAL_ENV
fi
unset PROJECT_ROOT
unset WORKON_CWD
fi
}
# Append workon_cwd to the chpwd_functions array, so it will be called on cd if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then
# http://zsh.sourceforge.net/Doc/Release/Functions.html # Automatically activate Git projects or other customized virtualenvwrapper projects based on the
# TODO: replace with 'add-zsh-hook chpwd workon_cwd' when oh-my-zsh min version is raised above 4.3.4 # directory name of the project. Virtual environment name can be overridden
if (( ${+chpwd_functions} )); then # by placing a .venv file in the project root with a virtualenv name in it.
if (( $chpwd_functions[(I)workon_cwd] == 0 )); then function workon_cwd {
set -A chpwd_functions $chpwd_functions workon_cwd 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
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
PROJECT_ROOT="."
fi
# Check for virtualenv name override
if [[ -f "$PROJECT_ROOT/.venv" ]]; then
ENV_NAME="$(cat "$PROJECT_ROOT/.venv")"
elif [[ -f "$PROJECT_ROOT/.venv/bin/activate" ]];then
ENV_NAME="$PROJECT_ROOT/.venv"
elif [[ "$PROJECT_ROOT" != "." ]]; then
ENV_NAME="${PROJECT_ROOT:t}"
else
ENV_NAME=""
fi
if [[ "$ENV_NAME" != "" ]]; then
# Activate the environment only if it is not already active
if [[ "$VIRTUAL_ENV" != "$WORKON_HOME/$ENV_NAME" ]]; then
if [[ -e "$WORKON_HOME/$ENV_NAME/bin/activate" ]]; then
workon "$ENV_NAME" && export CD_VIRTUAL_ENV="$ENV_NAME"
elif [[ -e "$ENV_NAME/bin/activate" ]]; then
source $ENV_NAME/bin/activate && export CD_VIRTUAL_ENV="$ENV_NAME"
fi
fi fi
else elif [[ -n $CD_VIRTUAL_ENV && -n $VIRTUAL_ENV ]]; then
set -A chpwd_functions workon_cwd # We've just left the repo, deactivate the environment
# Note: this only happens if the virtualenv was activated automatically
deactivate && unset CD_VIRTUAL_ENV
fi
fi fi
}
# Append workon_cwd to the chpwd_functions array, so it will be called on cd
# http://zsh.sourceforge.net/Doc/Release/Functions.html
if ! (( $chpwd_functions[(I)workon_cwd] )); then
chpwd_functions+=(workon_cwd)
fi fi
else
print "zsh virtualenvwrapper plugin: Cannot find ${virtualenvwrapper}. Please install with \`pip install virtualenvwrapper\`."
fi fi
...@@ -4,7 +4,7 @@ function vundle-init () { ...@@ -4,7 +4,7 @@ function vundle-init () {
mkdir -p ~/.vim/bundle/vundle/ mkdir -p ~/.vim/bundle/vundle/
fi fi
if [ ! -d ~/.vim/bundle/vundle/.git/ ] if [ ! -d ~/.vim/bundle/vundle/.git ] && [ ! -f ~/.vim/bundle/vundle/.git ]
then then
git clone http://github.com/gmarik/vundle.git ~/.vim/bundle/vundle 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" echo "\n\tRead about vim configuration for vundle at https://github.com/gmarik/vundle\n"
...@@ -13,15 +13,15 @@ function vundle-init () { ...@@ -13,15 +13,15 @@ function vundle-init () {
function vundle () { function vundle () {
vundle-init vundle-init
vim -c "execute \"BundleInstall\" | q | q" vim -c "execute \"PluginInstall\" | qa"
} }
function vundle-update () { function vundle-update () {
vundle-init vundle-init
vim -c "execute \"BundleInstall!\" | q | q" vim -c "execute \"PluginInstall!\" | qa"
} }
function vundle-clean () { function vundle-clean () {
vundle-init vundle-init
vim -c "execute \"BundleClean!\" | q | q" vim -c "execute \"PluginClean!\" | qa"
} }
The MIT License (MIT)
Copyright (c) 2014 Markus Færevaag
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
\ No newline at end of file
## wd wd
==
[![Build Status](https://travis-ci.org/mfaerevaag/wd.png?branch=master)](https://travis-ci.org/mfaerevaag/wd)
`wd` (*warp directory*) lets you jump to custom directories in zsh, without using `cd`. Why? Because `cd` seems ineffecient when the folder is frequently visited or has a long path.
*NOTE*: If you are not using zsh, check out the `ruby` branch which has `wd` implemented as a gem.
### Setup
### oh-my-zsh
`wd` comes bundles with [oh-my-zshell](https://github.com/robbyrussell/oh-my-zsh)!
Just add the plugin in your `~/.zshrc` file:
plugins=(... wd)
#### Automatic
Run either in terminal:
* `curl -L https://github.com/mfaerevaag/wd/raw/master/install.sh | sh`
* `wget --no-check-certificate https://github.com/mfaerevaag/wd/raw/master/install.sh -O - | sh`
#### Manual
* Clone this repo to your liking
* Add `wd` function to `.zshrc` (or `.profile` etc.):
wd() {
. ~/path/to/cloned/repo/wd/wd.sh
}
* Install manpage. From `wd`'s base directory (requires root permissions):
# cp wd.1 /usr/share/man/man1/wd.1
# chmod 644 /usr/share/man/man1/wd.1
Note, when pulling and updating `wd`, you'll need to do this again in case of changes to the manpage.
#### Completion
If you're NOT using [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh) and you want to utelize the zsh-completion feature, you will also need to add the path to your `wd` installation (`~/bin/wd` if you used the automatic installer) to your `fpath`. E.g. in your `~/.zshrc`:
fpath=(~/path/to/wd $fpath)
Also, you may have to force a rebuild of `zcompdump` by running:
$ rm -f ~/.zcompdump; compinit
**Maintainer:** [mfaerevaag](https://github.com/mfaerevaag)
`wd` (warp directory) lets you jump to custom directories in zsh, without using cd. Why? Because cd seems ineffecient when the folder is frequently visited or has a long path. [Source](https://github.com/mfaerevaag/wd)
### Usage ### Usage
* Add warp point to current working directory: * Add warp point to current working directory:
wd add test $ wd add foo
If a warp point with the same name exists, use `add!` to overwrite it. If a warp point with the same name exists, use `add!` to overwrite it.
* From an other directory, warp to test with: Note, a warp point cannot contain colons, or only consist of only spaces and dots. The first will conflict in how `wd` stores the warp points, and the second will conflict other features, as below.
* From an other directory (not necessarily), warp to `foo` with:
wd test $ wd foo
* You can warp back to previous directory, and so on, with the puncticulation syntax: * You can warp back to previous directory, and so on, with this dot syntax:
wd .. $ wd ..
wd ... $ wd ...
This is a wrapper for the zsh `dirs` function. This is a wrapper for the zsh `dirs` function.
(You might need `setopt AUTO_PUSHD` in your `.zshrc` if you hare not using [oh-my-zshell](https://github.com/robbyrussell/oh-my-zsh)).
* Remove warp point test point: * Remove warp point test point:
wd rm test $ wd rm foo
* List all warp points (stored in `~/.warprc`):
* List warp points to current directory (stored in `~/.warprc`): $ wd list
wd show * List files in given warp point:
* List all warp points (stored in `~/.warprc`): $ wd ls foo
* Show path of given warp point:
$ wd path foo
* List warp points to current directory, or optionally, path to given warp point:
$ wd show
* Remove warp points to non-existent directories.
$ wd clean
Use `clean!` to not be prompted with confirmation (force).
* Print usage with no opts or the `help` argument:
$ wd help
* Print the running version of `wd`:
$ wd --version
* Specifically set the config file (default `~/.warprc`), which is useful when testing:
$ wd --config ./file <action>
* Force `exit` with return code after running. This is not default, as it will *exit your terminal*, though required when testing/debugging.
$ wd --debug <action>
* Silence all output:
$ wd --quiet <action>
### Testing
`wd` comes with a small test suite, run with [shunit2](https://code.google.com/p/shunit2/). This can be used to confirm that things are working as it should on your setup, or to demonstrate an issue.
To run, simply `cd` into the `test` directory and run the `tests.sh`.
$ ./tests.sh
### License
The project is licensed under the [MIT-license](https://github.com/mfaerevaag/wd/blob/master/LICENSE).
### Finally
If you have issues, feedback or improvements, don't hesitate to report it or submit a pull-request. In the case of an issue, we would much appreciate if you would include a failing test in `test/tests.sh`. Explanation on how to run the tests, read the section "Testing" in this README.
wd ls Credit to [altschuler](https://github.com/altschuler) for awesome idea.
* Print usage with no opts or the `help` argument. Hope you enjoy!
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