Unverified Commit cad48e38 authored by Marc Cornellà's avatar Marc Cornellà Committed by GitHub
Browse files

Merge branch 'master' into fabric_task_description

parents 225425fe 40df67bc
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: (( $+commands[apt] )) && APT=apt || APT=apt-get
# https://github.com/AlexBio
# 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
alias acs='apt-cache search' alias acs='apt-cache search'
compdef _acs acs='apt-cache search'
alias afs='apt-file search --regexp' alias afs='apt-file search --regexp'
compdef _afs afs='apt-file search --regexp'
# These are apt-get only # These are apt/apt-get only
alias ags='apt-get source' # asrc alias ags="$APT source"
compdef _ags ags='apt-get source'
alias acp='apt-cache policy' # app alias acp='apt-cache policy'
compdef _acp acp='apt-cache policy'
#List all installed packages
alias agli='apt list --installed'
# List available updates only
alias aglu='apt list --upgradable'
# superuser operations ###################################################### # superuser operations ######################################################
alias afu='sudo apt-file update' alias afu='sudo apt-file update'
compdef _afu afu='sudo apt-file update'
alias ppap='sudo ppa-purge' alias ppap='sudo ppa-purge'
compdef _ppap ppap='sudo ppa-purge'
alias age="sudo $APT"
alias ag='sudo apt-get' # age - but without sudo alias aga="sudo $APT autoclean"
alias aga='sudo apt-get autoclean' # aac alias agb="sudo $APT build-dep"
alias agar='sudo apt-get autoremove' alias agc="sudo $APT clean"
alias agb='sudo apt-get build-dep' # abd alias agd="sudo $APT dselect-upgrade"
alias agc='sudo apt-get clean' # adc alias agi="sudo $APT install"
alias agd='sudo apt-get dselect-upgrade' # ads alias agp="sudo $APT purge"
alias agi='sudo apt-get install' # ai alias agr="sudo $APT remove"
alias agp='sudo apt-get purge' # ap alias agu="sudo $APT update"
alias agr='sudo apt-get remove' # ar alias agud="sudo $APT update && sudo $APT dist-upgrade"
alias agu='sudo apt-get update' # ad alias agug="sudo $APT upgrade"
alias agud='sudo apt-get update && sudo apt-get dist-upgrade' #adu alias aguu="sudo $APT update && sudo $APT upgrade"
alias agug='sudo apt-get upgrade' # ag alias agar="sudo $APT autoremove"
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'
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'
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) ?not(~n`uname -r`))'
?not(~n`uname -r`))'
# Misc. ##################################################################### # Misc. #####################################################################
# print all installed packages # print all installed packages
...@@ -71,20 +49,20 @@ alias mydeb='time dpkg-buildpackage -rfakeroot -us -uc' ...@@ -71,20 +49,20 @@ 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 argument the function will ask for it and guess the default 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 which is sometimes the right name for the package you want to install
aar() { aar() {
if [ -n "$2" ]; then if [ -n "$2" ]; then
PACKAGE=$2 PACKAGE=$2
else else
read "PACKAGE?Type in the package name to install/upgrade with this ppa [${1##*/}]: " read "PACKAGE?Type in the package name to install/upgrade with this ppa [${1##*/}]: "
fi fi
if [ -z "$PACKAGE" ]; then if [ -z "$PACKAGE" ]; then
PACKAGE=${1##*/} PACKAGE=${1##*/}
fi fi
sudo apt-add-repository $1 && sudo apt-get update sudo apt-add-repository $1 && sudo $APT update
sudo apt-get install $PACKAGE sudo $APT install $PACKAGE
} }
# Prints apt history # Prints apt history
...@@ -94,7 +72,7 @@ aar() { ...@@ -94,7 +72,7 @@ aar() {
# apt-history remove # apt-history remove
# apt-history rollback # apt-history rollback
# apt-history list # apt-history list
# Based On: http://linuxcommando.blogspot.com/2008/08/how-to-show-apt-log-history.html # Based On: https://linuxcommando.blogspot.com/2008/08/how-to-show-apt-log-history.html
apt-history () { apt-history () {
case "$1" in case "$1" in
install) install)
...@@ -110,7 +88,7 @@ apt-history () { ...@@ -110,7 +88,7 @@ apt-history () {
awk '{print $4"="$5}' awk '{print $4"="$5}'
;; ;;
list) list)
zcat $(ls -rt /var/log/dpkg*) zgrep --no-filename '' $(ls -rt /var/log/dpkg*)
;; ;;
*) *)
echo "Parameters:" echo "Parameters:"
...@@ -125,22 +103,22 @@ apt-history () { ...@@ -125,22 +103,22 @@ apt-history () {
# Kernel-package building shortcut # Kernel-package building shortcut
kerndeb () { kerndeb () {
# temporarily unset MAKEFLAGS ( '-j3' will fail ) # temporarily unset MAKEFLAGS ( '-j3' will fail )
MAKEFLAGS=$( print - $MAKEFLAGS | perl -pe 's/-j\s*[\d]+//g' ) MAKEFLAGS=$( print - $MAKEFLAGS | perl -pe 's/-j\s*[\d]+//g' )
print '$MAKEFLAGS set to '"'$MAKEFLAGS'" print '$MAKEFLAGS set to '"'$MAKEFLAGS'"
appendage='-custom' # this shows up in $ (uname -r ) appendage='-custom' # this shows up in $(uname -r)
revision=$(date +"%Y%m%d") # this shows up in the .deb file name revision=$(date +"%Y%m%d") # this shows up in the .deb file name
make-kpkg clean make-kpkg clean
time fakeroot make-kpkg --append-to-version "$appendage" --revision \ time fakeroot make-kpkg --append-to-version "$appendage" --revision \
"$revision" kernel_image kernel_headers "$revision" kernel_image kernel_headers
} }
# List packages by size # List packages by size
function apt-list-packages { function apt-list-packages {
dpkg-query -W --showformat='${Installed-Size} ${Package} ${Status}\n' | \ dpkg-query -W --showformat='${Installed-Size} ${Package} ${Status}\n' | \
grep -v deinstall | \ grep -v deinstall | \
sort -n | \ sort -n | \
awk '{print $1" "$2}' awk '{print $1" "$2}'
} }
# UFW plugin
This plugin adds completion for managing everybody's favorite Uncomplicated Firewall (UFW),
a simple interface for managing iptables. Learn more about [`UFW`](https://wiki.ubuntu.com/UncomplicatedFirewall).
To use it, add ufw to the plugins array of your zshrc file:
```
plugins=(... ufw)
```
Some of the commands include:
* `allow <port>/<optional: protocol>` add an allow rule
* `default` set default policy
* `delete <port>/<optional: protocol>` delete RULE
* `deny <port>/<optional: protocol>` add deny rule
* `disable` disables the firewall
* `enable` enables the firewall
#compdef ufw
#autoload
typeset -A opt_args
function _ufw_delete_rules {
if ufw status &> /dev/null ; then
ufw status numbered \
| perl -n -e'/\[ +(\d+)\] +([^ ].+)/ && print "\"$1\[$2\]\" "'
fi
}
function _ufw_app_profiles {
grep -rhoP "(?<=\[)[^\]]+" /etc/ufw/applications.d/ \
| awk '{ print "\""$0"\""}' \
| tr '\n' ' '
}
local -a _1st_arguments
_1st_arguments=(
'allow:add allow rule'
'app:Application profile commands'
'default:set default policy'
'delete:delete RULE'
'deny:add deny rule'
'disable:disables the firewall'
'enable:enables the firewall'
'insert:insert RULE at NUM'
'limit:add limit rule'
'logging:set logging to LEVEL'
'reject:add reject rule'
'reload:reloads firewall'
'reset:reset firewall'
'show:show firewall report'
'status:show firewall status'
'version:display version information'
)
local context state line curcontext="$curcontext"
_arguments -C \
'(--dry-run)--dry-run[dry run]' \
'1:: :->cmds' \
'2:: :->subcmds' \
'3:: :->subsubcmds' \
&& return 0
local rules
case "$state" in
(cmds)
_describe -t commands "ufw commands" _1st_arguments
return 0
;;
(subcmds)
case "$line[1]" in
(app)
_values 'app' \
'list[list application profiles]' \
'info[show information on PROFILE]' \
'update[update PROFILE]' \
'default[set default application policy]' \
&& ret=0
;;
(status)
_values 'status' \
'numbered[show firewall status as numbered list of RULES]' \
'verbose[show verbose firewall status]' \
&& ret=0
;;
(logging)
_values 'logging' \
'on' 'off' 'low' 'medium' 'high' 'full' \
&& ret=0
;;
(default)
_values 'default' \
'allow' 'deny' 'reject' \
&& ret=0
;;
(show)
_values 'show' \
'raw' 'builtins' 'before-rules' 'user-rules' 'after-rules' 'logging-rules' 'listening' 'added' \
&& ret=0
;;
(delete)
rules="$(_ufw_delete_rules)"
if [[ -n "$rules" ]] ; then
_values 'delete' \
${(Q)${(z)"$(_ufw_delete_rules)"}} \
&& ret=0
fi
;;
esac
;;
(subsubcmds)
case "$line[1]" in
(app)
case "$line[2]" in
(info|update)
_values 'profiles' \
${(Q)${(z)"$(_ufw_app_profiles)"}} \
&& ret=0
;;
esac
;;
(default)
_values 'default-direction' \
'incoming' 'outgoing' \
&& ret=0
;;
esac
esac
return
# URLTools plugin
This plugin provides two aliases to URL-encode and URL-decode strings.
To start using it, add the `urltools` plugin to your plugins array in `~/.zshrc`:
```zsh
plugins=(... urltools)
```
Original author: [Ian Chesal](https://github.com/ianchesal)
Original idea and aliases: [Ruslan Spivak](https://ruslanspivak.wordpress.com/2010/06/02/urlencode-and-urldecode-from-a-command-line/)
## Commands
| Command | Description |
| :---------- | :--------------------------- |
| `urlencode` | URL-encodes the given string |
| `urldecode` | URL-decodes the given string |
## Examples
```zsh
urlencode 'https://github.com/robbyrussell/oh-my-zsh/search?q=urltools&type=Code'
# returns https%3A%2F%2Fgithub.com%2Frobbyrussell%2Foh-my-zsh%2Fsearch%3Fq%3Durltools%26type%3DCode
urldecode 'https%3A%2F%2Fgithub.com%2Frobbyrussell%2Foh-my-zsh%2Fsearch%3Fq%3Durltools%26type%3DCode'
# returns https://github.com/robbyrussell/oh-my-zsh/search?q=urltools&type=Code
```
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# Adds handy command line aliases useful for dealing with URLs # Adds handy command line aliases useful for dealing with URLs
# #
# Taken from: # Taken from:
# http://ruslanspivak.com/2010/06/02/urlencode-and-urldecode-from-a-command-line/ # https://ruslanspivak.com/2010/06/02/urlencode-and-urldecode-from-a-command-line/
if [[ $(whence $URLTOOLS_METHOD) = "" ]]; then if [[ $(whence $URLTOOLS_METHOD) = "" ]]; then
URLTOOLS_METHOD="" URLTOOLS_METHOD=""
......
This plugin prompts the status of the Vagrant VMs. It supports single-host and
multi-host configurations as well.
Look inside the source for documentation about custom variables.
Alberto Re <alberto.re@gmail.com>
# vim:ft=zsh ts=2 sw=2 sts=2
#
# To display Vagrant infos on your prompt add the vagrant_prompt_info to the
# $PROMPT variable in your theme. Example:
#
# PROMPT='%{$fg[$NCOLOR]%}%B%n%b%{$reset_color%}:%{$fg[blue]%}%B%c/%b%{$reset_color%} $(vagrant_prompt_info)$(svn_prompt_info)$(git_prompt_info)%(!.#.$) '
#
# `vagrant_prompt_info` makes use of some custom variables. This is an example
# definition:
#
# ZSH_THEME_VAGRANT_PROMPT_PREFIX="%{$fg_bold[blue]%}["
# ZSH_THEME_VAGRANT_PROMPT_SUFFIX="%{$fg_bold[blue]%}]%{$reset_color%} "
# ZSH_THEME_VAGRANT_PROMPT_RUNNING="%{$fg_no_bold[green]%}●"
# ZSH_THEME_VAGRANT_PROMPT_POWEROFF="%{$fg_no_bold[red]%}●"
# ZSH_THEME_VAGRANT_PROMPT_SUSPENDED="%{$fg_no_bold[yellow]%}●"
# ZSH_THEME_VAGRANT_PROMPT_NOT_CREATED="%{$fg_no_bold[white]%}○"
function vagrant_prompt_info() {
test -d .vagrant && test -f Vagrantfile
if [[ "$?" == "0" ]]; then
statuses=$(vagrant status 2> /dev/null | grep -P "\w+\s+[\w\s]+\s\(\w+\)")
statuses=("${(f)statuses}")
printf '%s' $ZSH_THEME_VAGRANT_PROMPT_PREFIX
for vm_details in $statuses; do
vm_state=$(echo $vm_details | grep -o -E "saved|poweroff|not created|running")
if [[ "$vm_state" == "running" ]]; then
printf '%s' $ZSH_THEME_VAGRANT_PROMPT_RUNNING
elif [[ "$vm_state" == "saved" ]]; then
printf '%s' $ZSH_THEME_VAGRANT_PROMPT_SUSPENDED
elif [[ "$vm_state" == "not created" ]]; then
printf '%s' $ZSH_THEME_VAGRANT_PROMPT_NOT_CREATED
elif [[ "$vm_state" == "poweroff" ]]; then
printf '%s' $ZSH_THEME_VAGRANT_PROMPT_POWEROFF
fi
done
printf '%s' $ZSH_THEME_VAGRANT_PROMPT_SUFFIX
fi
}
# Vagrant plugin
This plugin adds autocompletion for [Vagrant](https://www.vagrantup.com/) commands, task names, box names and built-in handy documentation.
To use it, add `vagrant` to the plugins array in your zshrc file:
```zsh
plugins=(... vagrant)
```
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
local -a _1st_arguments local -a _1st_arguments
_1st_arguments=( _1st_arguments=(
'box:Box commands' 'box:Box commands'
'cloud:Manages everything related to Vagrant Cloud'
'connect:Connects to a remotely shared Vagrant environment' 'connect:Connects to a remotely shared Vagrant environment'
'destroy:Destroys the vagrant environment' 'destroy:Destroys the vagrant environment'
'docker-logs:Outputs the logs from the Docker container' 'docker-logs:Outputs the logs from the Docker container'
...@@ -18,11 +19,12 @@ _1st_arguments=( ...@@ -18,11 +19,12 @@ _1st_arguments=(
'login:Authenticates against a Vagrant Cloud server to access protected boxes' 'login:Authenticates against a Vagrant Cloud server to access protected boxes'
'package:Packages a vagrant environment for distribution' 'package:Packages a vagrant environment for distribution'
'plugin:Plugin commands' 'plugin:Plugin commands'
'port:Displays information about guest port mappings'
'provision:Run the provisioner' 'provision:Run the provisioner'
'push:Deploys code in this environment to a configured destination' 'push:Deploys code in this environment to a configured destination'
'rdp:Connects to machine via RDP' 'rdp:Connects to machine via RDP'
'reload:Reload the vagrant environment' 'reload:Reload the vagrant environment'
'resume:Resumes a suspend vagrant environment' 'resume:Resumes a suspended vagrant environment'
'rsync:Syncs rsync synced folders to remote machine' 'rsync:Syncs rsync synced folders to remote machine'
'rsync-auto:Syncs rsync synced folders automatically when files change' 'rsync-auto:Syncs rsync synced folders automatically when files change'
'share:Shares your Vagrant environment with anyone in the world' 'share:Shares your Vagrant environment with anyone in the world'
...@@ -33,6 +35,7 @@ _1st_arguments=( ...@@ -33,6 +35,7 @@ _1st_arguments=(
'suspend:Suspends the currently running vagrant environment' 'suspend:Suspends the currently running vagrant environment'
'snapshot:Used to manage snapshots with the guest machine' 'snapshot:Used to manage snapshots with the guest machine'
'up:Creates the vagrant environment' 'up:Creates the vagrant environment'
'validate:Validates the Vagrantfile'
'version:Prints current and latest Vagrant version' 'version:Prints current and latest Vagrant version'
'--help:[TASK] Describe available tasks or one specific task' '--help:[TASK] Describe available tasks or one specific task'
'--version:Prints the Vagrant version information' '--version:Prints the Vagrant version information'
...@@ -54,7 +57,7 @@ __task_list () ...@@ -54,7 +57,7 @@ __task_list ()
local expl local expl
declare -a tasks declare -a tasks
tasks=(box destroy halt init package provision reload resume ssh ssh_config status suspend up version) tasks=(box destroy halt init package port provision reload resume ssh ssh_config status suspend up version)
_wanted tasks expl 'help' compadd $tasks _wanted tasks expl 'help' compadd $tasks
} }
...@@ -81,7 +84,7 @@ __vagrant-box () ...@@ -81,7 +84,7 @@ __vagrant-box ()
case $state in case $state in
(command) (command)
_describe -t commands "gem subcommand" _box_arguments _describe -t commands "vagrant subcommand" _box_arguments
return return
;; ;;
...@@ -110,7 +113,7 @@ _arguments -C \ ...@@ -110,7 +113,7 @@ _arguments -C \
case $state in case $state in
(command) (command)
_describe -t commands "gem subcommand" _1st_arguments _describe -t commands "vagrant subcommand" _1st_arguments
return return
;; ;;
...@@ -123,7 +126,7 @@ case $state in ...@@ -123,7 +126,7 @@ case $state in
(box) (box)
__vagrant-box __vagrant-box
;; ;;
(up|provision|package|destroy|reload|ssh|ssh-config|halt|resume|status) (up|provision|port|package|destroy|reload|ssh|ssh-config|halt|resume|status)
_arguments ':feature:__vm_list' _arguments ':feature:__vm_list'
esac esac
;; ;;
......
## Vault (https://www.vaultproject.io) autocomplete plugin # Vault plugin
- Adds autocomplete options for all vault commands. Note: this plugin is deprecated. Use the [official autocompletion](https://www.vaultproject.io/docs/commands/index.html#autocompletion) instead.
####Show help for all commands -------
![General Help](http://i.imgur.com/yv5Db1r.png "Help for all commands")
Adds autocomplete options for all [vault](https://www.vaultproject.io) commands.
####Create new Vault token To use it, add `vault` to the plugins array in your zshrc file:
![Create token](http://i.imgur.com/xMegNgh.png "Create token")
```zsh
plugins=(... vault)
```
####Enable audit backends Crafted with <3 by Valentin Bud ([@valentinbud](https://twitter.com/valentinbud))
![Audit backends](http://i.imgur.com/fKLeiSF.png "Audit backends")
Crafted with <3 by Valentin Bud ([@valentinbud](https://twitter.com/valentinbud))
\ No newline at end of file
# Updates editor information when the keymap changes. # Updates editor information when the keymap changes.
function zle-keymap-select() { function zle-keymap-select() {
# update keymap variable for the prompt
VI_KEYMAP=$KEYMAP
zle reset-prompt zle reset-prompt
zle -R zle -R
} }
# Ensure that the prompt is redrawn when the terminal size changes. zle -N zle-keymap-select
TRAPWINCH() {
zle && zle -R function vi-accept-line() {
VI_KEYMAP=main
zle accept-line
} }
zle -N zle-keymap-select zle -N vi-accept-line
zle -N edit-command-line
bindkey -v bindkey -v
# use custom accept-line widget to update $VI_KEYMAP
bindkey -M vicmd '^J' vi-accept-line
bindkey -M vicmd '^M' vi-accept-line
# allow v to edit the command line (standard behaviour) # allow v to edit the command line (standard behaviour)
autoload -Uz edit-command-line autoload -Uz edit-command-line
zle -N 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) # allow ctrl-p, ctrl-n for navigate history (standard behaviour)
...@@ -28,8 +37,9 @@ bindkey '^?' backward-delete-char ...@@ -28,8 +37,9 @@ bindkey '^?' backward-delete-char
bindkey '^h' backward-delete-char bindkey '^h' backward-delete-char
bindkey '^w' backward-kill-word bindkey '^w' backward-kill-word
# allow ctrl-r to perform backward search in history # allow ctrl-r and ctrl-s to search the history
bindkey '^r' history-incremental-search-backward bindkey '^r' history-incremental-search-backward
bindkey '^s' history-incremental-search-forward
# allow ctrl-a and ctrl-e to move to beginning/end of line # allow ctrl-a and ctrl-e to move to beginning/end of line
bindkey '^a' beginning-of-line bindkey '^a' beginning-of-line
...@@ -41,7 +51,7 @@ if [[ "$MODE_INDICATOR" == "" ]]; then ...@@ -41,7 +51,7 @@ if [[ "$MODE_INDICATOR" == "" ]]; then
fi fi
function vi_mode_prompt_info() { function vi_mode_prompt_info() {
echo "${${KEYMAP/vicmd/$MODE_INDICATOR}/(main|viins)/}" echo "${${VI_KEYMAP/vicmd/$MODE_INDICATOR}/(main|viins)/}"
} }
# define right prompt, if it wasn't defined by a theme # define right prompt, if it wasn't defined by a theme
......
...@@ -8,10 +8,11 @@ function callvim ...@@ -8,10 +8,11 @@ function callvim
{ {
if [[ $# == 0 ]]; then if [[ $# == 0 ]]; then
cat <<EOH cat <<EOH
usage: callvim [-b cmd] [-a cmd] [file ... fileN] usage: callvim [-b cmd] [-a cmd] [-n name] [file ... fileN]
-b cmd Run this command in GVIM before editing the first file -b cmd Run this command in GVIM before editing the first file
-a cmd Run this command in GVIM after editing the first file -a cmd Run this command in GVIM after editing the first file
-n name Name of the GVIM server to connect to
file The file to edit file The file to edit
... fileN The other files to add to the argslist ... fileN The other files to add to the argslist
EOH EOH
...@@ -21,13 +22,16 @@ EOH ...@@ -21,13 +22,16 @@ EOH
local cmd="" local cmd=""
local before="<esc>" local before="<esc>"
local after="" local after=""
while getopts ":b:a:" option local name="GVIM"
while getopts ":b:a:n:" option
do do
case $option in case $option in
a) after="$OPTARG" a) after="$OPTARG"
;; ;;
b) before="$OPTARG" b) before="$OPTARG"
;; ;;
n) name="$OPTARG"
;;
esac esac
done done
shift $((OPTIND-1)) shift $((OPTIND-1))
...@@ -43,7 +47,7 @@ EOH ...@@ -43,7 +47,7 @@ EOH
files=':args! '"${@:A:q}<cr>" files=':args! '"${@:A:q}<cr>"
fi fi
cmd="$before$files$after" cmd="$before$files$after"
gvim --remote-send "$cmd" gvim --servername "$name" --remote-send "$cmd"
if typeset -f postCallVim > /dev/null; then if typeset -f postCallVim > /dev/null; then
postCallVim postCallVim
fi fi
......
# virtualenv
The plugin displays information of the created virtual container and allows background theming.
To use it, add `virtualenv` to the plugins array of your zshrc file:
```
plugins=(... virtualenv)
```
The plugin creates a `virtualenv_prompt_info` function that you can use in your theme, which displays
the basename of the current `$VIRTUAL_ENV`. It uses two variables to control how that is shown:
- `ZSH_THEME_VIRTUALENV_PREFIX`: sets the prefix of the VIRTUAL_ENV. Defaults to `[`.
- `ZSH_THEME_VIRTUALENV_SUFFIX`: sets the suffix of the VIRTUAL_ENV. Defaults to `]`.
# Virtualenvwrapper plugin
This plugin loads Python's [virtualenvwrapper](https://virtualenvwrapper.readthedocs.io/en/latest/) shell tools.
To use it, add `virtualenvwrapper` to the plugins array in your zshrc file:
```zsh
plugins=(... virtualenvwrapper)
```
## Usage
The plugin allows to automatically activate virtualenvs on cd into git repositories with a matching name:
```
➜ github $ cd ansible
(ansible) ➜ ansible git:(devel) $ cd docs
(ansible) ➜ docs git:(devel) $ cd ..
(ansible) ➜ ansible git:(devel) $ cd ..
➜ github $
```
We can override this by having a `.venv` file in the directory containing a differently named virtualenv:
```
➜ github $ cat ansible/.venv
myvirtualenv
➜ github $ cd ansible
(myvirtualenv) ➜ ansible git:(devel) $ cd ..
➜ github $
```
We can disable this behaviour by setting `DISABLE_VENV_CD=1` before Oh My Zsh is sourced:
```zsh
DISABLE_VENV_CD=1
plugins=(... virtualenvwrapper)
source $ZSH/oh-my-zsh.sh
```
virtualenvwrapper='virtualenvwrapper.sh' virtualenvwrapper='virtualenvwrapper.sh'
virtualenvwrapper_lazy='virtualenvwrapper_lazy.sh'
if (( $+commands[$virtualenvwrapper] )); then if (( $+commands[$virtualenvwrapper_lazy] )); then
function {
setopt local_options
unsetopt equals
virtualenvwrapper=${${virtualenvwrapper_lazy}:c}
source ${${virtualenvwrapper_lazy}:c}
[[ -z "$WORKON_HOME" ]] && WORKON_HOME="$HOME/.virtualenvs"
}
elif (( $+commands[$virtualenvwrapper] )); then
function { function {
setopt local_options setopt local_options
unsetopt equals unsetopt equals
source ${${virtualenvwrapper}:c} source ${${virtualenvwrapper}:c}
} }
elif [[ -f "/usr/local/bin/virtualenvwrapper.sh" ]]; then
function {
setopt local_options
unsetopt equals
virtualenvwrapper="/usr/local/bin/virtualenvwrapper.sh"
source "/usr/local/bin/virtualenvwrapper.sh"
}
elif [[ -f "/etc/bash_completion.d/virtualenvwrapper" ]]; then elif [[ -f "/etc/bash_completion.d/virtualenvwrapper" ]]; then
function { function {
setopt local_options setopt local_options
......
# VS code
This plugin makes interaction between the command line and the code editor easier.
To start using it, add the `vscode` plugin to your `plugins` array in `~/.zshrc`:
```zsh
plugins=(... vscode)
```
If you are using [Visual Studio Code Insiders](https://code.visualstudio.com/insiders/),
add the following line in the oh-my-zsh settings section (between the `ZSH_THEME` and
the `plugins=()` line). This will make the plugin use the Insiders version instead.
```zsh
ZSH_THEME=...
# Add this line to use code-insiders instead of code
VSCODE=code-insiders
plugins=(... vscode)
source $ZSH/oh-my-zsh.sh
```
## Common aliases
| Alias | Command | Description |
| ----------------------- | ------------------------------ | ----------------------------------------------------------------------------------------------------------- |
| vsc | code . | Open the current folder in VS code |
| vsca `dir` | code --add `dir` | Add folder(s) to the last active window |
| vscd `file` `file` | code --diff `file` `file` | Compare two files with each other. |
| vscg `file:line[:char]` | code --goto `file:line[:char]` | Open a file at the path on the specified line and character position. |
| vscn | code --new-window | Force to open a new window. |
| vscr | code --reuse-window | Force to open a file or folder in the last active window. |
| vscw | code --wait | Wait for the files to be closed before returning. |
| vscu `dir` | code --user-data-dir `dir` | Specifies the directory that user data is kept in. Can be used to open multiple distinct instances of Code. |
## Extensions aliases
| Alias | Command | Description |
| ----------------------- | ---------------------------------------------------------------- | --------------------------------- |
| vsced `dir` | code --extensions-dir `dir` | Set the root path for extensions. |
| vscie `id or vsix-path` | code --install-extension `extension-id> or <extension-vsix-path` | Installs an extension. |
| vscue `id or vsix-path` | code --uninstall-extension `id or vsix-path` | Uninstalls an extension. |
## Other options:
| Alias | Command | Description |
| ------------ | ------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| vscv | code --verbose | Print verbose output (implies --wait). |
| vscl `level` | code --log `level` | Log level to use. Default is 'info'. Allowed values are 'critical', 'error', 'warn', 'info', 'debug', 'trace', 'off'. |
| vscde | code --disable-extensions | Disable all installed extensions. |
# VScode zsh plugin
# author: https://github.com/MarsiBarsi
# Use main Visual Studio Code version by default
: ${VSCODE:=code}
alias vsc="$VSCODE ."
alias vsca="$VSCODE --add"
alias vscd="$VSCODE --diff"
alias vscg="$VSCODE --goto"
alias vscn="$VSCODE --new-window"
alias vscr="$VSCODE --reuse-window"
alias vscw="$VSCODE --wait"
alias vscu="$VSCODE --user-data-dir"
alias vsced="$VSCODE --extensions-dir"
alias vscie="$VSCODE --install-extension"
alias vscue="$VSCODE --uninstall-extension"
alias vscv="$VSCODE --verbose"
alias vscl="$VSCODE --log"
alias vscde="$VSCODE --disable-extensions"
# Vundle plugin
This plugin adds functions to control [vundle](https://github.com/VundleVim/Vundle.vim) plug-in manager for vim.
To use it, add `vundle` to the plugins array in your zshrc file:
```zsh
plugins=(... vundle)
```
## Functions
| Function | Usage | Description |
|---------------|-----------------|----------------------------------------------------------------------------|
| vundle-init | `vundle-init` | Install vundle by cloning git repository into ~/.vim folder |
| vundle | `vundle` | Install plugins set in .vimrc (equals `:PluginInstall`) |
| vundle-update | `vundle-update` | Update plugins set in .vimrc (equals `:PluginInstall!`) |
| vundle-clean | `vundle-clean` | Delete plugins that have been removed from .vimrc (equals `:PluginClean!`) |
...@@ -6,7 +6,7 @@ function vundle-init () { ...@@ -6,7 +6,7 @@ function vundle-init () {
if [ ! -d ~/.vim/bundle/Vundle.vim/.git ] && [ ! -f ~/.vim/bundle/Vundle.vim/.git ] if [ ! -d ~/.vim/bundle/Vundle.vim/.git ] && [ ! -f ~/.vim/bundle/Vundle.vim/.git ]
then then
git clone git://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim git clone https://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" echo "\n\tRead about vim configuration for vundle at https://github.com/VundleVim/Vundle.vim\n"
fi fi
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment