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
# svcat
This plugin provides completion for the [Kubernetes service catalog cli](https://github.com/kubernetes-incubator/service-catalog).
To use it, add `svcat` to the plugins array in your zshrc file.
```
plugins=(... svcat)
```
# Autocompletion for svcat.
#
if [ $commands[svcat] ]; then
source <(svcat completion zsh)
fi
...@@ -16,30 +16,30 @@ function svn_prompt_info() { ...@@ -16,30 +16,30 @@ function svn_prompt_info() {
if [[ -n $repo_need_upgrade ]]; then if [[ -n $repo_need_upgrade ]]; then
printf '%s%s%s%s%s%s%s\n' \ printf '%s%s%s%s%s%s%s\n' \
$ZSH_PROMPT_BASE_COLOR \ "$ZSH_PROMPT_BASE_COLOR" \
$ZSH_THEME_SVN_PROMPT_PREFIX \ "$ZSH_THEME_SVN_PROMPT_PREFIX" \
$ZSH_PROMPT_BASE_COLOR \ "$ZSH_PROMPT_BASE_COLOR" \
$repo_need_upgrade \ "$repo_need_upgrade" \
$ZSH_PROMPT_BASE_COLOR \ "$ZSH_PROMPT_BASE_COLOR" \
$ZSH_THEME_SVN_PROMPT_SUFFIX \ "$ZSH_THEME_SVN_PROMPT_SUFFIX" \
$ZSH_PROMPT_BASE_COLOR "$ZSH_PROMPT_BASE_COLOR"
else else
printf '%s%s%s %s%s:%s%s%s%s%s' \ printf '%s%s%s%s %s%s%s:%s%s%s%s' \
$ZSH_PROMPT_BASE_COLOR \ "$ZSH_PROMPT_BASE_COLOR" \
$ZSH_THEME_SVN_PROMPT_PREFIX \ "$ZSH_THEME_SVN_PROMPT_PREFIX" \
\ \
"$(svn_status_info $info)" \ "$(svn_status_info $info)" \
$ZSH_PROMPT_BASE_COLOR \ "$ZSH_PROMPT_BASE_COLOR" \
\ \
$ZSH_THEME_BRANCH_NAME_COLOR \ "$ZSH_THEME_BRANCH_NAME_COLOR" \
$(svn_current_branch_name $info) \ "$(svn_current_branch_name $info)" \
$ZSH_PROMPT_BASE_COLOR \ "$ZSH_PROMPT_BASE_COLOR" \
\ \
$(svn_current_revision $info) \ "$(svn_current_revision $info)" \
$ZSH_PROMPT_BASE_COLOR \ "$ZSH_PROMPT_BASE_COLOR" \
\ \
$ZSH_THEME_SVN_PROMPT_SUFFIX \ "$ZSH_THEME_SVN_PROMPT_SUFFIX" \
$ZSH_PROMPT_BASE_COLOR "$ZSH_PROMPT_BASE_COLOR"
fi fi
} }
...@@ -63,11 +63,12 @@ function svn_current_revision() { ...@@ -63,11 +63,12 @@ function svn_current_revision() {
function svn_status_info() { function svn_status_info() {
local svn_status_string="$ZSH_THEME_SVN_PROMPT_CLEAN" local svn_status_string="$ZSH_THEME_SVN_PROMPT_CLEAN"
local svn_status="$(svn status 2> /dev/null)"; local svn_status="$(svn status 2> /dev/null)";
if command grep -E '^\s*A' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_ADDITIONS:-+}"; fi if command grep -E '^\s*A' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_ADDITIONS:-+}"; fi
if command grep -E '^\s*D' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_DELETIONS:-}"; fi if command grep -E '^\s*D' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_DELETIONS:-}"; fi
if command grep -E '^\s*M' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_MODIFICATIONS:-}"; fi if command grep -E '^\s*M' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_MODIFICATIONS:-}"; fi
if command grep -E '^\s*[R~]' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_REPLACEMENTS:-}"; fi if command grep -E '^\s*[R~]' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_REPLACEMENTS:-}"; fi
if command grep -E '^\s*\?' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_UNTRACKED:-?}"; fi if command grep -E '^\s*\?' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_UNTRACKED:-?}"; fi
if command grep -E '^\s*[CI!L]' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_DIRTY:-'!'}"; fi if command grep -E '^\s*[CI!L]' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_DIRTY:-!}"; fi
echo $svn_status_string echo $svn_status_string
} }
# `svn` plugin
This plugin adds some utility functions to display additional information regarding your current
svn repository. See https://subversion.apache.org/ for the full svn documentation.
To use it, add `svn` to your plugins array:
```zsh
plugins=(... svn)
```
## Functions
| Command | Description |
|:----------------------|:--------------------------------------------|
| `svn_prompt_info` | Shows svn prompt in themes |
| `in_svn` | Checks if we're in an svn repository |
| `svn_get_repo_name` | Get repository name |
| `svn_get_branch_name` | Get branch name (see [caveats](#caveats)) |
| `svn_get_rev_nr` | Get revision number |
| `svn_dirty` | Checks if there are changes in the svn repo |
## Caveats
The plugin expects the first directory to be the current branch / tag / trunk. So it returns
the first path element if you don't use branches.
## Usage on themes
To use this in the `agnoster` theme follow these instructions:
1. Enable the svn plugin
2. Add the following lines to your `zshrc` file:
```shell
prompt_svn() {
local rev branch
if in_svn; then
rev=$(svn_get_rev_nr)
branch=$(svn_get_branch_name)
if [[ $(svn_dirty_choose_pwd 1 0) -eq 1 ]]; then
prompt_segment yellow black
echo -n "$rev@$branch"
echo -n "±"
else
prompt_segment green black
echo -n "$rev@$branch"
fi
fi
}
```
3. Override the agnoster `build_prompt()` function:
```zsh
build_prompt() {
RETVAL=$?
prompt_status
prompt_context
prompt_dir
prompt_git
prompt_svn
prompt_end
}
```
# vim:ft=zsh ts=2 sw=2 sts=2 svn_prompt_info() {
#
function svn_prompt_info() {
local _DISPLAY local _DISPLAY
if in_svn; then if in_svn; then
if [ "x$SVN_SHOW_BRANCH" = "xtrue" ]; then if [[ "$SVN_SHOW_BRANCH" = true ]]; then
unset SVN_SHOW_BRANCH unset SVN_SHOW_BRANCH
_DISPLAY=$(svn_get_branch_name) _DISPLAY=$(svn_get_branch_name)
else else
...@@ -16,23 +14,20 @@ $ZSH_THEME_REPO_NAME_COLOR$_DISPLAY$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_S ...@@ -16,23 +14,20 @@ $ZSH_THEME_REPO_NAME_COLOR$_DISPLAY$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_S
} }
function in_svn() { in_svn() {
if $(svn info >/dev/null 2>&1); then svn info >/dev/null 2>&1
return 0
fi
return 1
} }
function svn_get_repo_name() { svn_get_repo_name() {
if in_svn; then if in_svn; then
svn info | sed -n 's/Repository\ Root:\ .*\///p' | read SVN_ROOT LANG=C svn info | sed -n 's/^Repository\ Root:\ .*\///p' | read SVN_ROOT
svn info | sed -n "s/URL:\ .*$SVN_ROOT\///p" LANG=C svn info | sed -n "s/^URL:\ .*$SVN_ROOT\///p"
fi fi
} }
function svn_get_branch_name() { svn_get_branch_name() {
local _DISPLAY=$( local _DISPLAY=$(
svn info 2> /dev/null | \ LANG=C svn info 2> /dev/null | \
awk -F/ \ awk -F/ \
'/^URL:/ { \ '/^URL:/ { \
for (i=0; i<=NF; i++) { \ for (i=0; i<=NF; i++) { \
...@@ -44,24 +39,28 @@ function svn_get_branch_name() { ...@@ -44,24 +39,28 @@ function svn_get_branch_name() {
} \ } \
}' }'
) )
if [ "x$_DISPLAY" = "x" ]; then if [[ -z "$_DISPLAY" ]]; then
svn_get_repo_name svn_get_repo_name
else else
echo $_DISPLAY echo $_DISPLAY
fi fi
} }
function svn_get_rev_nr() { svn_get_rev_nr() {
if in_svn; then if in_svn; then
svn info 2> /dev/null | sed -n 's/Revision:\ //p' LANG=C svn info 2> /dev/null | sed -n 's/Revision:\ //p'
fi fi
} }
function svn_dirty_choose() { svn_dirty() {
svn_dirty_choose $ZSH_THEME_SVN_PROMPT_DIRTY $ZSH_THEME_SVN_PROMPT_CLEAN
}
svn_dirty_choose() {
if in_svn; then if in_svn; then
local root=`svn info 2> /dev/null | sed -n 's/^Working Copy Root Path: //p'` local root=$(LANG=C svn info 2> /dev/null | sed -n 's/^Working Copy Root Path: //p')
if $(svn status $root 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'); then if svn status $root 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'; then
# Grep exits with 0 when "One or more lines were selected", return "dirty". # Grep exits with 0 when "One or more lines were selected", return "dirty".
echo $1 echo $1
else else
...@@ -71,14 +70,13 @@ function svn_dirty_choose() { ...@@ -71,14 +70,13 @@ function svn_dirty_choose() {
fi fi
} }
function svn_dirty() { svn_dirty_pwd () {
svn_dirty_choose $ZSH_THEME_SVN_PROMPT_DIRTY $ZSH_THEME_SVN_PROMPT_CLEAN svn_dirty_choose_pwd $ZSH_THEME_SVN_PROMPT_DIRTY_PWD $ZSH_THEME_SVN_PROMPT_CLEAN_PWD
} }
function svn_dirty_choose_pwd () { svn_dirty_choose_pwd () {
if in_svn; then if in_svn; then
local root=$PWD if svn status "$PWD" 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'; then
if $(svn status $root 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'); then
# Grep exits with 0 when "One or more lines were selected", return "dirty". # Grep exits with 0 when "One or more lines were selected", return "dirty".
echo $1 echo $1
else else
...@@ -87,9 +85,3 @@ function svn_dirty_choose_pwd () { ...@@ -87,9 +85,3 @@ function svn_dirty_choose_pwd () {
fi fi
fi fi
} }
function svn_dirty_pwd () {
svn_dirty_choose_pwd $ZSH_THEME_SVN_PROMPT_DIRTY_PWD $ZSH_THEME_SVN_PROMPT_CLEAN_PWD
}
# Swift Package Manager
## Description
This plugin provides a few utilities that make you faster on your daily work with the [Swift Package Manager](https://github.com/apple/swift-package-manager), as well as autocompletion for Swift 5.1.
To start using it, add the `swiftpm` plugin to your `plugins` array in `~/.zshrc`:
```zsh
plugins=(... swiftpm)
```
## Aliases
| Alias | Description | Command |
|-------|-------------------------------------|------------------------------------|
| `spi` | Initialize a new package | `swift package init` |
| `spf` | Fetch package dependencies | `swift package fetch` |
| `spu` | Update package dependencies | `swift package update` |
| `spx` | Generates an Xcode project | `swift package generate-xcodeproj` |
| `sps` | Print the resolved dependency graph | `swift package show-dependencies` |
| `spd` | Print parsed Package.swift as JSON | `swift package dump-package` |
#compdef swift
local context state state_descr line
typeset -A opt_args
_swift() {
_arguments -C \
'(- :)--help[prints the synopsis and a list of the most commonly used commands]: :->arg' \
'(-): :->command' \
'(-)*:: :->arg' && return
case $state in
(command)
local tools
tools=(
'build:build sources into binary products'
'run:build and run an executable product'
'package:perform operations on Swift packages'
'test:build and run tests'
)
_alternative \
'tools:common:{_describe "tool" tools }' \
'compiler: :_swift_compiler' && _ret=0
;;
(arg)
case ${words[1]} in
(build)
_swift_build
;;
(run)
_swift_run
;;
(package)
_swift_package
;;
(test)
_swift_test
;;
(*)
_swift_compiler
;;
esac
;;
esac
}
_swift_dependency() {
local dependencies
dependencies=( $(swift package completion-tool list-dependencies) )
_describe '' dependencies
}
_swift_executable() {
local executables
executables=( $(swift package completion-tool list-executables) )
_describe '' executables
}
# Generates completions for swift build
#
# In the final compdef file, set the following file header:
#
# #compdef _swift_build
# local context state state_descr line
# typeset -A opt_args
_swift_build() {
arguments=(
"-Xcc[Pass flag through to all C compiler invocations]:Pass flag through to all C compiler invocations: "
"-Xswiftc[Pass flag through to all Swift compiler invocations]:Pass flag through to all Swift compiler invocations: "
"-Xlinker[Pass flag through to all linker invocations]:Pass flag through to all linker invocations: "
"-Xcxx[Pass flag through to all C++ compiler invocations]:Pass flag through to all C++ compiler invocations: "
"(--configuration -c)"{--configuration,-c}"[Build with configuration (debug|release) ]: :{_values '' 'debug[build with DEBUG configuration]' 'release[build with RELEASE configuration]'}"
"--build-path[Specify build/cache directory ]:Specify build/cache directory :_files"
"(--chdir -C)"{--chdir,-C}"[]: :_files"
"--package-path[Change working directory before any other operation]:Change working directory before any other operation:_files"
"--sanitize[Turn on runtime checks for erroneous behavior]: :{_values '' 'address[enable Address sanitizer]' 'thread[enable Thread sanitizer]' 'undefined[enable Undefined Behavior sanitizer]'}"
"--disable-prefetching[]"
"--skip-update[Skip updating dependencies from their remote during a resolution]"
"--disable-sandbox[Disable using the sandbox when executing subprocesses]"
"--disable-package-manifest-caching[Disable caching Package.swift manifests]"
"--version[]"
"--destination[]: :_files"
"(--verbose -v)"{--verbose,-v}"[Increase verbosity of informational output]"
"--no-static-swift-stdlib[Do not link Swift stdlib statically \[default\]]"
"--static-swift-stdlib[Link Swift stdlib statically]"
"--force-resolved-versions[]"
"--disable-automatic-resolution[Disable automatic resolution if Package.resolved file is out-of-date]"
"--enable-index-store[Enable indexing-while-building feature]"
"--disable-index-store[Disable indexing-while-building feature]"
"--enable-pubgrub-resolver[\[Experimental\] Enable the new Pubgrub dependency resolver]"
"--enable-parseable-module-interfaces[]"
"--trace-resolver[]"
"(--jobs -j)"{--jobs,-j}"[The number of jobs to spawn in parallel during the build process]:The number of jobs to spawn in parallel during the build process: "
"--enable-test-discovery[Enable test discovery on platforms without Objective-C runtime]"
"--build-tests[Build both source and test targets]"
"--product[Build the specified product]:Build the specified product: "
"--target[Build the specified target]:Build the specified target: "
"--show-bin-path[Print the binary output path]"
)
_arguments $arguments && return
}
# Generates completions for swift run
#
# In the final compdef file, set the following file header:
#
# #compdef _swift_run
# local context state state_descr line
# typeset -A opt_args
_swift_run() {
arguments=(
":The executable to run:_swift_executable"
"-Xcc[Pass flag through to all C compiler invocations]:Pass flag through to all C compiler invocations: "
"-Xswiftc[Pass flag through to all Swift compiler invocations]:Pass flag through to all Swift compiler invocations: "
"-Xlinker[Pass flag through to all linker invocations]:Pass flag through to all linker invocations: "
"-Xcxx[Pass flag through to all C++ compiler invocations]:Pass flag through to all C++ compiler invocations: "
"(--configuration -c)"{--configuration,-c}"[Build with configuration (debug|release) ]: :{_values '' 'debug[build with DEBUG configuration]' 'release[build with RELEASE configuration]'}"
"--build-path[Specify build/cache directory ]:Specify build/cache directory :_files"
"(--chdir -C)"{--chdir,-C}"[]: :_files"
"--package-path[Change working directory before any other operation]:Change working directory before any other operation:_files"
"--sanitize[Turn on runtime checks for erroneous behavior]: :{_values '' 'address[enable Address sanitizer]' 'thread[enable Thread sanitizer]' 'undefined[enable Undefined Behavior sanitizer]'}"
"--disable-prefetching[]"
"--skip-update[Skip updating dependencies from their remote during a resolution]"
"--disable-sandbox[Disable using the sandbox when executing subprocesses]"
"--disable-package-manifest-caching[Disable caching Package.swift manifests]"
"--version[]"
"--destination[]: :_files"
"(--verbose -v)"{--verbose,-v}"[Increase verbosity of informational output]"
"--no-static-swift-stdlib[Do not link Swift stdlib statically \[default\]]"
"--static-swift-stdlib[Link Swift stdlib statically]"
"--force-resolved-versions[]"
"--disable-automatic-resolution[Disable automatic resolution if Package.resolved file is out-of-date]"
"--enable-index-store[Enable indexing-while-building feature]"
"--disable-index-store[Disable indexing-while-building feature]"
"--enable-pubgrub-resolver[\[Experimental\] Enable the new Pubgrub dependency resolver]"
"--enable-parseable-module-interfaces[]"
"--trace-resolver[]"
"(--jobs -j)"{--jobs,-j}"[The number of jobs to spawn in parallel during the build process]:The number of jobs to spawn in parallel during the build process: "
"--enable-test-discovery[Enable test discovery on platforms without Objective-C runtime]"
"--skip-build[Skip building the executable product]"
"--build-tests[Build both source and test targets]"
"--repl[Launch Swift REPL for the package]"
)
_arguments $arguments && return
}
# Generates completions for swift package
#
# In the final compdef file, set the following file header:
#
# #compdef _swift_package
# local context state state_descr line
# typeset -A opt_args
_swift_package() {
arguments=(
"-Xcc[Pass flag through to all C compiler invocations]:Pass flag through to all C compiler invocations: "
"-Xswiftc[Pass flag through to all Swift compiler invocations]:Pass flag through to all Swift compiler invocations: "
"-Xlinker[Pass flag through to all linker invocations]:Pass flag through to all linker invocations: "
"-Xcxx[Pass flag through to all C++ compiler invocations]:Pass flag through to all C++ compiler invocations: "
"(--configuration -c)"{--configuration,-c}"[Build with configuration (debug|release) ]: :{_values '' 'debug[build with DEBUG configuration]' 'release[build with RELEASE configuration]'}"
"--build-path[Specify build/cache directory ]:Specify build/cache directory :_files"
"(--chdir -C)"{--chdir,-C}"[]: :_files"
"--package-path[Change working directory before any other operation]:Change working directory before any other operation:_files"
"--sanitize[Turn on runtime checks for erroneous behavior]: :{_values '' 'address[enable Address sanitizer]' 'thread[enable Thread sanitizer]' 'undefined[enable Undefined Behavior sanitizer]'}"
"--disable-prefetching[]"
"--skip-update[Skip updating dependencies from their remote during a resolution]"
"--disable-sandbox[Disable using the sandbox when executing subprocesses]"
"--disable-package-manifest-caching[Disable caching Package.swift manifests]"
"--version[]"
"--destination[]: :_files"
"(--verbose -v)"{--verbose,-v}"[Increase verbosity of informational output]"
"--no-static-swift-stdlib[Do not link Swift stdlib statically \[default\]]"
"--static-swift-stdlib[Link Swift stdlib statically]"
"--force-resolved-versions[]"
"--disable-automatic-resolution[Disable automatic resolution if Package.resolved file is out-of-date]"
"--enable-index-store[Enable indexing-while-building feature]"
"--disable-index-store[Disable indexing-while-building feature]"
"--enable-pubgrub-resolver[\[Experimental\] Enable the new Pubgrub dependency resolver]"
"--enable-parseable-module-interfaces[]"
"--trace-resolver[]"
"(--jobs -j)"{--jobs,-j}"[The number of jobs to spawn in parallel during the build process]:The number of jobs to spawn in parallel during the build process: "
"--enable-test-discovery[Enable test discovery on platforms without Objective-C runtime]"
'(-): :->command'
'(-)*:: :->arg'
)
_arguments $arguments && return
case $state in
(command)
local modes
modes=(
'completion-tool:Completion tool (for shell completions)'
'dump-package:Print parsed Package.swift as JSON'
'describe:Describe the current package'
'clean:Delete build artifacts'
'show-dependencies:Print the resolved dependency graph'
'init:Initialize a new package'
'unedit:Remove a package from editable mode'
'tools-version:Manipulate tools version of the current package'
'fetch:'
'resolve:Resolve package dependencies'
'reset:Reset the complete cache/build directory'
'generate-xcodeproj:Generates an Xcode project'
'edit:Put a package in editable mode'
'config:Manipulate configuration of the package'
'update:Update package dependencies'
)
_describe "mode" modes
;;
(arg)
case ${words[1]} in
(completion-tool)
_swift_package_completion-tool
;;
(dump-package)
_swift_package_dump-package
;;
(describe)
_swift_package_describe
;;
(clean)
_swift_package_clean
;;
(show-dependencies)
_swift_package_show-dependencies
;;
(init)
_swift_package_init
;;
(unedit)
_swift_package_unedit
;;
(tools-version)
_swift_package_tools-version
;;
(fetch)
_swift_package_fetch
;;
(resolve)
_swift_package_resolve
;;
(reset)
_swift_package_reset
;;
(generate-xcodeproj)
_swift_package_generate-xcodeproj
;;
(edit)
_swift_package_edit
;;
(config)
_swift_package_config
;;
(update)
_swift_package_update
;;
esac
;;
esac
}
_swift_package_completion-tool() {
arguments=(
": :{_values '' 'generate-bash-script[generate Bash completion script]' 'generate-zsh-script[generate Bash completion script]' 'list-dependencies[list all dependencies' names]' 'list-executables[list all executables' names]'}"
)
_arguments $arguments && return
}
_swift_package_dump-package() {
arguments=(
)
_arguments $arguments && return
}
_swift_package_describe() {
arguments=(
"--type[json|text]: :{_values '' 'text[describe using text format]' 'json[describe using JSON format]'}"
)
_arguments $arguments && return
}
_swift_package_clean() {
arguments=(
)
_arguments $arguments && return
}
_swift_package_show-dependencies() {
arguments=(
"--format[text|dot|json|flatlist]: :{_values '' 'text[list dependencies using text format]' 'dot[list dependencies using dot format]' 'json[list dependencies using JSON format]'}"
)
_arguments $arguments && return
}
_swift_package_init() {
arguments=(
"--type[empty|library|executable|system-module|manifest]: :{_values '' 'empty[generates an empty project]' 'library[generates project for a dynamic library]' 'executable[generates a project for a cli executable]' 'system-module[generates a project for a system module]'}"
"--name[Provide custom package name]:Provide custom package name: "
)
_arguments $arguments && return
}
_swift_package_unedit() {
arguments=(
":The name of the package to unedit:_swift_dependency"
"--force[Unedit the package even if it has uncommited and unpushed changes.]"
)
_arguments $arguments && return
}
_swift_package_tools-version() {
arguments=(
"--set[Set tools version of package to the given value]:Set tools version of package to the given value: "
"--set-current[Set tools version of package to the current tools version in use]"
)
_arguments $arguments && return
}
_swift_package_fetch() {
arguments=(
)
_arguments $arguments && return
}
_swift_package_resolve() {
arguments=(
":The name of the package to resolve:_swift_dependency"
"--version[The version to resolve at]:The version to resolve at: "
"--branch[The branch to resolve at]:The branch to resolve at: "
"--revision[The revision to resolve at]:The revision to resolve at: "
)
_arguments $arguments && return
}
_swift_package_reset() {
arguments=(
)
_arguments $arguments && return
}
_swift_package_generate-xcodeproj() {
arguments=(
"--xcconfig-overrides[Path to xcconfig file]:Path to xcconfig file:_files"
"--enable-code-coverage[Enable code coverage in the generated project]"
"--output[Path where the Xcode project should be generated]:Path where the Xcode project should be generated:_files"
"--legacy-scheme-generator[Use the legacy scheme generator]"
"--watch[Watch for changes to the Package manifest to regenerate the Xcode project]"
"--skip-extra-files[Do not add file references for extra files to the generated Xcode project]"
)
_arguments $arguments && return
}
_swift_package_edit() {
arguments=(
":The name of the package to edit:_swift_dependency"
"--revision[The revision to edit]:The revision to edit: "
"--branch[The branch to create]:The branch to create: "
"--path[Create or use the checkout at this path]:Create or use the checkout at this path:_files"
)
_arguments $arguments && return
}
_swift_package_config() {
arguments=(
'(-): :->command'
'(-)*:: :->arg'
)
_arguments $arguments && return
case $state in
(command)
local modes
modes=(
'unset-mirror:Remove an existing mirror'
'get-mirror:Print mirror configuration for the given package dependency'
'set-mirror:Set a mirror for a dependency'
)
_describe "mode" modes
;;
(arg)
case ${words[1]} in
(unset-mirror)
_swift_package_config_unset-mirror
;;
(get-mirror)
_swift_package_config_get-mirror
;;
(set-mirror)
_swift_package_config_set-mirror
;;
esac
;;
esac
}
_swift_package_config_unset-mirror() {
arguments=(
"--package-url[The package dependency url]:The package dependency url: "
"--mirror-url[The mirror url]:The mirror url: "
)
_arguments $arguments && return
}
_swift_package_config_get-mirror() {
arguments=(
"--package-url[The package dependency url]:The package dependency url: "
)
_arguments $arguments && return
}
_swift_package_config_set-mirror() {
arguments=(
"--package-url[The package dependency url]:The package dependency url: "
"--mirror-url[The mirror url]:The mirror url: "
)
_arguments $arguments && return
}
_swift_package_update() {
arguments=(
)
_arguments $arguments && return
}
# Generates completions for swift test
#
# In the final compdef file, set the following file header:
#
# #compdef _swift_test
# local context state state_descr line
# typeset -A opt_args
_swift_test() {
arguments=(
"-Xcc[Pass flag through to all C compiler invocations]:Pass flag through to all C compiler invocations: "
"-Xswiftc[Pass flag through to all Swift compiler invocations]:Pass flag through to all Swift compiler invocations: "
"-Xlinker[Pass flag through to all linker invocations]:Pass flag through to all linker invocations: "
"-Xcxx[Pass flag through to all C++ compiler invocations]:Pass flag through to all C++ compiler invocations: "
"(--configuration -c)"{--configuration,-c}"[Build with configuration (debug|release) ]: :{_values '' 'debug[build with DEBUG configuration]' 'release[build with RELEASE configuration]'}"
"--build-path[Specify build/cache directory ]:Specify build/cache directory :_files"
"(--chdir -C)"{--chdir,-C}"[]: :_files"
"--package-path[Change working directory before any other operation]:Change working directory before any other operation:_files"
"--sanitize[Turn on runtime checks for erroneous behavior]: :{_values '' 'address[enable Address sanitizer]' 'thread[enable Thread sanitizer]' 'undefined[enable Undefined Behavior sanitizer]'}"
"--disable-prefetching[]"
"--skip-update[Skip updating dependencies from their remote during a resolution]"
"--disable-sandbox[Disable using the sandbox when executing subprocesses]"
"--disable-package-manifest-caching[Disable caching Package.swift manifests]"
"--version[]"
"--destination[]: :_files"
"(--verbose -v)"{--verbose,-v}"[Increase verbosity of informational output]"
"--no-static-swift-stdlib[Do not link Swift stdlib statically \[default\]]"
"--static-swift-stdlib[Link Swift stdlib statically]"
"--force-resolved-versions[]"
"--disable-automatic-resolution[Disable automatic resolution if Package.resolved file is out-of-date]"
"--enable-index-store[Enable indexing-while-building feature]"
"--disable-index-store[Disable indexing-while-building feature]"
"--enable-pubgrub-resolver[\[Experimental\] Enable the new Pubgrub dependency resolver]"
"--enable-parseable-module-interfaces[]"
"--trace-resolver[]"
"(--jobs -j)"{--jobs,-j}"[The number of jobs to spawn in parallel during the build process]:The number of jobs to spawn in parallel during the build process: "
"--enable-test-discovery[Enable test discovery on platforms without Objective-C runtime]"
"--skip-build[Skip building the test target]"
"(--list-tests -l)"{--list-tests,-l}"[Lists test methods in specifier format]"
"--generate-linuxmain[Generate LinuxMain.swift entries for the package]"
"--parallel[Run the tests in parallel.]"
"--num-workers[Number of tests to execute in parallel.]:Number of tests to execute in parallel.: "
"(--specifier -s)"{--specifier,-s}"[]: : "
"--xunit-output[]: :_files"
"--filter[Run test cases matching regular expression, Format: <test-target>.<test-case> or <test-target>.<test-case>/<test>]:Run test cases matching regular expression, Format: <test-target>.<test-case> or <test-target>.<test-case>/<test>: "
"--enable-code-coverage[Test with code coverage enabled]"
)
_arguments $arguments && return
}
_swift_compiler() {
}
_swift
# Some aliases to make your life with the Swift Package Manager faster ✌️
alias spi='swift package init'
alias spf='swift package fetch'
alias spu='swift package update'
alias spx='swift package generate-xcodeproj'
alias sps='swift package show-dependencies'
alias spd='swift package dump-package'
# Symfony
This plugin provides completion for [Symfony](https://symfony.com/).
To use it add symfony to the plugins array in your zshrc file.
```bash
plugins=(... symfony)
```
# Symfony2
This plugin provides completion for [Symfony 2](https://symfony.com/), as well as aliases for frequent Symfony commands.
To use it add symfony2 to the plugins array in your zshrc file.
```bash
plugins=(... symfony2)
```
## Aliases
| Alias | Command | Description |
|---------------|------------------------------|-------------------------------|
| `sf` | php app/console | Start the symfony console |
| `sfcl` | sf cache:clear | Clear the cache |
| `sfsr` | sf server:run | Run the dev server |
| `sfcw` | sf cache:warmup | Use the Bundles warmer |
| `sfroute` | sf debug:router | Show the different routes |
| `sfcontainer` | sf debug:contaner | List the different services |
| `sfgb` | sf generate:bundle | Generate a bundle |
| `sfgc` | sf generate:controller | Generate a controller |
| `sfgcom` | sf generate:command | Generate a command |
| `sfge` | sf doctrine:generate:entity | Generate an entity |
| `sfsu` | sf doctrine:schema:update | Update the schema in Database |
| `sfdc` | sf doctrine:database:create | Create the Database |
| `sfdev` | sf --env=dev | Update environment to `dev` |
| `sfprod` | sf --env=prod | Update environment to `prod` |
...@@ -25,5 +25,10 @@ alias sfcw='sf cache:warmup' ...@@ -25,5 +25,10 @@ alias sfcw='sf cache:warmup'
alias sfroute='sf debug:router' alias sfroute='sf debug:router'
alias sfcontainer='sf debug:container' alias sfcontainer='sf debug:container'
alias sfgb='sf generate:bundle' alias sfgb='sf generate:bundle'
alias sfgc='sf generate:controller'
alias sfgcom='sf generate:command'
alias sfge='sf doctrine:generate:entity'
alias sfsu='sf doctrine:schema:update'
alias sfdc='sf doctrine:database:create'
alias sfdev='sf --env=dev' alias sfdev='sf --env=dev'
alias sfprod='sf --env=prod' alias sfprod='sf --env=prod'
# Systemadmin plugin
This plugin adds a series of aliases and functions which make a System Administrator's life easier.
To use it, add `systemadmin` to the plugins array in your zshrc file:
```zsh
plugins=(... systemadmin)
```
## Aliases
| Alias | Command | Description |
|---------|------------------------------------------------------------------------|--------------------------------------------------------------------|
| ping | `ping -c 5` | Sends only 5 ICMP Messages |
| clr | `clear; echo Currently logged in on $TTY, as $USER in directory $PWD.` | Clears the screen and prints the current user, TTY, and directory |
| path | `print -l $path` | Displays PATH with each entry on a separate line |
| mkdir | `mkdir -pv` | Automatically create parent directories and display verbose output |
| psmem | `ps -e -orss=,args= \| sort -b -k1,1n` | Display the processes using the most memory |
| psmem10 | `ps -e -orss=,args= \| sort -b -k1,1n \| head -10` | Display the top 10 processes using the most memory |
| pscpu | `ps -e -o pcpu,cpu,nice,state,cputime,args \|sort -k1 -nr` | Display the top processes using the most CPU |
| pscpu10 | `ps -e -o pcpu,cpu,nice,state,cputime,args \|sort -k1 -nr \| head -10` | Display the top 10 processes using the most CPU |
| hist10 | `print -l ${(o)history%% *} \| uniq -c \| sort -nr \| head -n 10` | Display the top 10 most used commands in the history |
## Functions
| Function | Description |
|-------------|-----------------------------------------------------------------------------------------------------------------------|
| dls | List only directories in the current directory |
| psgrep | List all processes that match the pattern input after the command |
| killit | Kills any process that matches a regular expression passed to it |
| tree | List contents of directories in a tree-like format (if tree isn't installed) |
| sortcons | Sort connections by state |
| con80 | View all 80 Port Connections |
| sortconip | On the connected IP sorted by the number of connections |
| req20 | List the top 20 requests on port 80 |
| http20 | List the top 20 connections to port 80 based on tcpdump data |
| timewait20 | List the top 20 time_wait connections |
| syn20 | List the top 20 SYN connections |
| port_pro | Output all processes according to the port number |
| accessip10 | List the top 10 accesses to the ip address in the nginx/access.log file or another log file if specified |
| visitpage20 | List the top 20 most visited files or pages in the nginx/access.log file or another log file if specified |
| consume100 | List the 100 most time-consuming Page lists (more than 60 seconds) as well as the corresponding number of occurrences |
| webtraffic | List website traffic statistics in GB from tne nginx/access.log file or another log file if specified |
| c404 | List statistics on 404 connections in the nginx/access.log file or another log file if specified |
| httpstatus | List statistics based on http status in the nginx/access.log file or another log file if specified |
| d0 | Delete 0 byte files recursively in the current directory or another if specified |
| geteip | Gather information regarding an external IP address using [icanhazip.com](https://icanhazip.com) |
| getip | Determine the local IP Address with `ip addr` or `ifconfig` |
| clrz | Clear zombie processes |
| conssec | Show number of concurrent connections per second based on ngnix/access.log file or another log file if specified |
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
# ----------- # -----------
# #
# This is one for the system administrator, operation and maintenance. # This is one for the system administrator, operation and maintenance.
# Some of which come from http://justinlilly.com/dotfiles/zsh.html
# #
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Authors # Authors
...@@ -13,14 +12,6 @@ ...@@ -13,14 +12,6 @@
# #
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
function retval() {
if [[ -z $1 ]];then
echo '.'
else
echo $1
fi
}
function retlog() { function retlog() {
if [[ -z $1 ]];then if [[ -z $1 ]];then
echo '/var/log/nginx/access.log' echo '/var/log/nginx/access.log'
...@@ -30,8 +21,8 @@ function retlog() { ...@@ -30,8 +21,8 @@ function retlog() {
} }
alias ping='ping -c 5' alias ping='ping -c 5'
alias clr='clear;echo "Currently logged in on $(tty), as $USER in directory $PWD."' alias clr='clear; echo Currently logged in on $TTY, as $USER in directory $PWD.'
alias path='echo -e ${PATH//:/\\n}' alias path='print -l $path'
alias mkdir='mkdir -pv' alias mkdir='mkdir -pv'
# get top process eating memory # get top process eating memory
alias psmem='ps -e -orss=,args= | sort -b -k1,1n' alias psmem='ps -e -orss=,args= | sort -b -k1,1n'
...@@ -44,10 +35,10 @@ alias hist10='print -l ${(o)history%% *} | uniq -c | sort -nr | head -n 10' ...@@ -44,10 +35,10 @@ alias hist10='print -l ${(o)history%% *} | uniq -c | sort -nr | head -n 10'
# directory LS # directory LS
dls () { dls () {
ls -l | grep "^d" | awk '{ print $9 }' | tr -d "/" print -l *(/)
} }
psgrep() { psgrep() {
ps aux | grep "$(retval $1)" | grep -v grep ps aux | grep "${1:-.}" | grep -v grep
} }
# Kills any process that matches a regexp passed to it # Kills any process that matches a regexp passed to it
killit() { killit() {
...@@ -55,10 +46,10 @@ killit() { ...@@ -55,10 +46,10 @@ killit() {
} }
# list contents of directories in a tree-like format # list contents of directories in a tree-like format
if [ -z "\${which tree}" ]; then if ! (( $+commands[tree] )); then
tree () { tree () {
find $@ -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g' find $@ -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'
} }
fi fi
# Sort connection state # Sort connection state
...@@ -98,7 +89,7 @@ syn20() { ...@@ -98,7 +89,7 @@ syn20() {
# Printing process according to the port number # Printing process according to the port number
port_pro() { port_pro() {
netstat -ntlp | grep "$(retval $1)" | awk '{print $7}' | cut -d/ -f1 netstat -ntlp | grep "${1:-.}" | awk '{print $7}' | cut -d/ -f1
} }
# top10 of gain access to the ip address # top10 of gain access to the ip address
...@@ -135,7 +126,7 @@ httpstatus() { ...@@ -135,7 +126,7 @@ httpstatus() {
# Delete 0 byte file # Delete 0 byte file
d0() { d0() {
find "$(retval $1)" -type f -size 0 -exec rm -rf {} \; find "${1:-.}" -type f -size 0 -exec rm -rf {} \;
} }
# gather external ip address # gather external ip address
...@@ -143,12 +134,12 @@ geteip() { ...@@ -143,12 +134,12 @@ geteip() {
curl -s -S https://icanhazip.com curl -s -S https://icanhazip.com
} }
# determine local IP address # determine local IP address(es)
getip() { getip() {
if (( ${+commands[ip]} )); then if (( ${+commands[ip]} )); then
ip addr | grep "inet " | grep -v '127.0.0.1' | awk '{print $2}' ip addr | awk '/inet /{print $2}' | command grep -v 127.0.0.1
else else
ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}' ifconfig | awk '/inet /{print $2}' | command grep -v 127.0.0.1
fi fi
} }
......
# Systemd plugin
The systemd plugin provides many useful aliases for systemd.
To use it, add systemd to the plugins array of your zshrc file:
```
plugins=(... systemd)
```
## Aliases
| Alias | Command | Description |
|:-----------------------|:-----------------------------------|:-----------------------------------------------------------------|
| `sc-list-units` | `systemctl list-units` | List all units systemd has in memory |
| `sc-is-active` | `systemctl is-active` | Show whether a unit is active |
| `sc-status` | `systemctl status` | Show terse runtime status information about one or more units |
| `sc-show` | `systemctl show` | Show properties of units, jobs, or the manager itself |
| `sc-help` | `systemctl help` | Show man page of units |
| `sc-list-unit-files` | `systemctl list-unit-files` | List unit files installed on the system |
| `sc-is-enabled` | `systemctl is-enabled` | Checks whether any of the specified unit files are enabled |
| `sc-list-jobs` | `systemctl list-jobs` | List jobs that are in progress |
| `sc-show-environment` | `systemctl show-environment` | Dump the systemd manager environment block |
| `sc-cat` | `systemctl cat` | Show backing files of one or more units |
| `sc-list-timers` | `systemctl list-timers` | List timer units currently in memory |
| **Aliases with sudo** |
| `sc-start` | `sudo systemctl start` | Start Unit(s) |
| `sc-stop` | `sudo systemctl stop` | Stop Unit(s) |
| `sc-reload` | `sudo systemctl reload` | Reload Unit(s) |
| `sc-restart` | `sudo systemctl restart` | Restart Unit(s) |
| `sc-try-restart` | `sudo systemctl try-restart` | Restart Unit(s) |
| `sc-isolate` | `sudo systemctl isolate` | Start a unit and its dependencies and stop all others |
| `sc-kill` | `sudo systemctl kill` | Kill unit(s) |
| `sc-reset-failed` | `sudo systemctl reset-failed` | Reset the "failed" state of the specified units, |
| `sc-enable` | `sudo systemctl enable` | Enable unit(s) |
| `sc-disable` | `sudo systemctl disable` | Disable unit(s) |
| `sc-reenable` | `sudo systemctl reenable` | Reenable unit(s) |
| `sc-preset` | `sudo systemctl preset` | Reset the enable/disable status one or more unit files |
| `sc-mask` | `sudo systemctl mask` | Mask unit(s) |
| `sc-unmask` | `sudo systemctl unmask` | Unmask unit(s) |
| `sc-link` | `sudo systemctl link` | Link a unit file into the unit file search path |
| `sc-load` | `sudo systemctl load` | Load unit(s) |
| `sc-cancel` | `sudo systemctl cancel` | Cancel job(s) |
| `sc-set-environment` | `sudo systemctl set-environment` | Set one or more systemd manager environment variables |
| `sc-unset-environment` | `sudo systemctl unset-environment` | Unset one or more systemd manager environment variables |
| `sc-edit` | `sudo systemctl edit` | Edit a drop-in snippet or a whole replacement file with `--full` |
| `sc-enable-now` | `sudo systemctl enable --now` | Enable and start unit(s) |
| `sc-disable-now` | `sudo systemctl disable --now` | Disable and stop unit(s) |
| `sc-mask-now` | `sudo systemctl mask --now` | Mask and stop unit(s) |
### User aliases
You can use the above aliases as `--user` by using the prefix `scu` instead of `sc`.
For example: `scu-list-units` will be aliased to `systemctl --user list-units`.
...@@ -10,7 +10,13 @@ sudo_commands=( ...@@ -10,7 +10,13 @@ sudo_commands=(
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
for c in $user_commands; do; alias scu-$c="systemctl --user $c"; done
for c in $sudo_commands; do; alias scu-$c="systemctl --user $c"; done
alias sc-enable-now="sc-enable --now" alias sc-enable-now="sc-enable --now"
alias sc-disable-now="sc-disable --now" alias sc-disable-now="sc-disable --now"
alias sc-mask-now="sc-mask --now" alias sc-mask-now="sc-mask --now"
alias scu-enable-now="scu-enable --now"
alias scu-disable-now="scu-disable --now"
alias scu-mask-now="scu-mask --now"
# taskwarrior # taskwarrior
This plugin adds smart tab completion for [TaskWarrior](http://taskwarrior.org/). This plugin adds smart tab completion for [TaskWarrior](https://taskwarrior.org/).
It uses the zsh tab completion script (`_task`) shipped with TaskWarrior for the It uses the zsh tab completion script (`_task`) shipped with TaskWarrior for the
completion definitions. completion definitions.
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE. # SOFTWARE.
# #
# http://www.opensource.org/licenses/mit-license.php # https://www.opensource.org/licenses/mit-license.php
# #
typeset -g _task_cmds _task_projects _task_tags _task_config _task_modifiers typeset -g _task_cmds _task_projects _task_tags _task_config _task_modifiers
_task_projects=($(task _projects)) _task_projects=($(task _projects))
......
# This file is intentionally empty.
#
# The terminalapp plugin is deprecated and may be removed in a future release.
# Its functionality has been folded in to the core lib/termsupport.zsh, which
# is loaded for all users. You can remove terminalapp from your $plugins list
# once all your systems are updated to the current version of Oh My Zsh.
# Terminitor plugin
This plugin adds completions for the [Terminitor](https://github.com/achiurizo/terminitor) development workflow setup tool.
To use it, add `terminitor` to the plugins array in your zshrc file:
```zsh
plugins=(... terminitor)
```
## atom ## Terraform oh-my-zsh plugin
Plugin for Terraform, a tool from Hashicorp for managing infrastructure safely and efficiently. Plugin for Terraform, a tool from Hashicorp for managing infrastructure safely and efficiently.
Current as of Terraform v0.11.7
### Requirements ### Requirements
* [Terraform](https://terraform.io/) * [Terraform](https://terraform.io/)
### Usage ### Usage
To use it, add `terraform` to the plugins array of your `~/.zshrc` file:
```shell
plugins=(... terraform)
```
* Type `terraform` into your prompt and hit `TAB` to see available completion options * Type `terraform` into your prompt and hit `TAB` to see available completion options
### Expanding ZSH prompt with current Terraform workspace name
If you want to get current Terraform workspace name in your ZSH prompt open
your .zsh-theme file and in a chosen place insert:
```shell
PROMPT=$'%{$fg[white]%}$(tf_prompt_info)%{$reset_color%} '
```
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