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

Merge remote-tracking branch 'robbyrussell/master'

parents eafd5f32 192de6bc
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# that the user has changed to in the past, and ALT-RIGHT undoes ALT-LEFT. # that the user has changed to in the past, and ALT-RIGHT undoes ALT-LEFT.
# #
dirhistory_past=(`pwd`) dirhistory_past=($PWD)
dirhistory_future=() dirhistory_future=()
export dirhistory_past export dirhistory_past
export dirhistory_future export dirhistory_future
...@@ -49,8 +49,9 @@ function push_future() { ...@@ -49,8 +49,9 @@ function push_future() {
} }
# Called by zsh when directory changes # Called by zsh when directory changes
function chpwd() { chpwd_functions+=(chpwd_dirhistory)
push_past `pwd` function chpwd_dirhistory() {
push_past $PWD
# If DIRHISTORY_CD is not set... # If DIRHISTORY_CD is not set...
if [[ -z "${DIRHISTORY_CD+x}" ]]; then if [[ -z "${DIRHISTORY_CD+x}" ]]; then
# ... clear future. # ... clear future.
...@@ -73,7 +74,7 @@ function dirhistory_back() { ...@@ -73,7 +74,7 @@ function dirhistory_back() {
pop_past cw pop_past cw
if [[ "" == "$cw" ]]; then if [[ "" == "$cw" ]]; then
# Someone overwrote our variable. Recover it. # Someone overwrote our variable. Recover it.
dirhistory_past=(`pwd`) dirhistory_past=($PWD)
return return
fi fi
......
...@@ -11,7 +11,8 @@ if [[ -f ${dirstack_file} ]] && [[ ${#dirstack[*]} -eq 0 ]] ; then ...@@ -11,7 +11,8 @@ if [[ -f ${dirstack_file} ]] && [[ ${#dirstack[*]} -eq 0 ]] ; then
[[ -d $dirstack[1] ]] && cd $dirstack[1] && cd $OLDPWD [[ -d $dirstack[1] ]] && cd $dirstack[1] && cd $OLDPWD
fi fi
chpwd() { chpwd_functions+=(chpwd_dirpersist)
chpwd_dirpersist() {
if (( $DIRSTACKSIZE <= 0 )) || [[ -z $dirstack_file ]]; then return; fi if (( $DIRSTACKSIZE <= 0 )) || [[ -z $dirstack_file ]]; then return; fi
local -ax my_stack local -ax my_stack
my_stack=( ${PWD} ${dirstack} ) my_stack=( ${PWD} ${dirstack} )
......
...@@ -2,59 +2,114 @@ ...@@ -2,59 +2,114 @@
typeset -ga nul_args typeset -ga nul_args
nul_args=( nul_args=(
'--verbosity=-[verbosity level; 0=minimal output, 1=normal output, 2=all output.]:Verbosity:((0\:minimal 1\:normal 2\:all))'
'--settings=-[the Python path to a settings module.]:file:_files' '--settings=-[the Python path to a settings module.]:file:_files'
'--pythonpath=-[a directory to add to the Python path.]::directory:_directories' '--pythonpath=-[a directory to add to the Python path.]:directory:_directories'
'--traceback[print traceback on exception.]' '--traceback[print traceback on exception.]'
"--no-color[Don't colorize the command output.]"
"--version[show program's version number and exit.]" "--version[show program's version number and exit.]"
{-h,--help}'[show this help message and exit.]' {-h,--help}'[show this help message and exit.]'
) )
_managepy-adminindex(){ typeset -ga start_args
start_args=(
'--template=-[The path or URL to load the template from.]:directory:_directories'
'--extension=-[The file extension(s) to render (default: "py").]'
'--name=-[The file name(s) to render.]:file:_files'
)
typeset -ga db_args
db_args=(
'--database=-[Nominates a database. Defaults to the "default" database.]'
)
typeset -ga noinput_args
noinput_args=(
'--noinput[tells Django to NOT prompt the user for input of any kind.]'
)
typeset -ga no_init_data_args
no_init_data_args=(
'--no-initial-data[Tells Django not to load any initial data after database synchronization.]'
)
typeset -ga tag_args
tag_args=(
'--tag=-[Run only checks labeled with given tag.]'
'--list-tags[List available tags.]'
)
_managepy-check(){
_arguments -s : \ _arguments -s : \
$nul_args \ $tag_args \
'*::directory:_directories' && ret=0 $nul_args && ret=0
}
_managepy-changepassword(){
_arguments -s : \
$db_args \
$nul_args && ret=0
} }
_managepy-createcachetable(){ _managepy-createcachetable(){
_arguments -s : \ _arguments -s : \
$db_args \
$nul_args && ret=0
}
_managepy-createsuperuser(){
_arguments -s : \
'--username=-[Specifies the login for the superuser.]' \
'--email=-[Specifies the email for the superuser.]' \
$noinput_args \
$db_args \
$nul_args && ret=0 $nul_args && ret=0
} }
_managepy-collectstatic(){ _managepy-collectstatic(){
_arguments -s : \ _arguments -s : \
'--link=-[Create a symbolic link to each file instead of copying.]:' \ '--link[Create a symbolic link to each file instead of copying.]' \
'--noinput=-[Do NOT prompt the user for input of any kind.]:' \ '--no-post-process[Do NOT post process collected files.]' \
'--no-post-process=-[Do NOT post process collected files.]:' \ '--ignore=-[Ignore files or directories matching this glob-style pattern. Use multiple times to ignore more.]' \
'--ignore=-[Ignore files or directories matching this glob-style pattern. Use multiple times to ignore more.]:' \ '--dry-run[Do everything except modify the filesystem.]' \
'--dry-run=-[Do everything except modify the filesystem.]:' \ '--clear[Clear the existing files using the storage before trying to copy or link the original file.]' \
'--clear=-[Clear the existing files using the storage before trying to copy or link the original file.]:' \ '--link[Create a symbolic link to each file instead of copying.]' \
'--link=-[Create a symbolic link to each file instead of copying.]:' \ '--no-default-ignore[Do not ignore the common private glob-style patterns "CVS", ".*" and "*~".]' \
'--no-default-ignore=-[Do not ignore the common private glob-style patterns "CVS", ".*" and "*~".]:' \ $noinput_args \
$nul_args && ret=0 $nul_args && ret=0
} }
_managepy-dbshell(){ _managepy-dbshell(){
_arguments -s : \ _arguments -s : \
$db_args \
$nul_args && ret=0 $nul_args && ret=0
} }
_managepy-diffsettings(){ _managepy-diffsettings(){
_arguments -s : \ _arguments -s : \
"--all[Display all settings, regardless of their value.]"
$nul_args && ret=0 $nul_args && ret=0
} }
_managepy-dumpdata(){ _managepy-dumpdata(){
_arguments -s : \ _arguments -s : \
'--format=-[specifies the output serialization format for fixtures.]:format:(json yaml xml)' \ '--format=-[Specifies the output serialization format for fixtures.]:format:(json yaml xml)' \
'--indent=-[specifies the indent level to use when pretty-printing output.]:' \ '--indent=-[Specifies the indent level to use when pretty-printing output.]' \
'--exclude=-[An app_label or app_label.ModelName to exclude (use multiple --exclude to exclude multiple apps/models).]' \
'--natural-foreign[Use natural foreign keys if they are available.]' \
'--natural-primary[Use natural primary keys if they are available.]' \
"--all[Use Django's base manager to dump all models stored in the database.]" \
'--pks=-[Only dump objects with given primary keys.]' \
$db_args \
$nul_args \ $nul_args \
'*::appname:_applist' && ret=0 '*::appname:_applist' && ret=0
} }
_managepy-flush(){ _managepy-flush(){
_arguments -s : \ _arguments -s : \
'--verbosity=-[verbosity level; 0=minimal output, 1=normal output, 2=all output.]:Verbosity:((0\:minimal 1\:normal 2\:all))' \ $no_init_data_args \
'--noinput[tells Django to NOT prompt the user for input of any kind.]' \ $db_args \
$noinput_args \
$nul_args && ret=0 $nul_args && ret=0
} }
...@@ -75,32 +130,61 @@ _managepy_cmds(){ ...@@ -75,32 +130,61 @@ _managepy_cmds(){
_managepy-inspectdb(){ _managepy-inspectdb(){
_arguments -s : \ _arguments -s : \
$db_args \
$nul_args && ret=0 $nul_args && ret=0
} }
_managepy-loaddata(){ _managepy-loaddata(){
_arguments -s : \ _arguments -s : \
'--verbosity=-[verbosity level; 0=minimal output, 1=normal output, 2=all output.]:Verbosity:((0\:minimal 1\:normal 2\:all))' \ '--ignorenonexistent[Ignores entries in the serialized data for fields that do not currently exist on the model.]' \
'--app=-[Only look for fixtures in the specified app.]:appname:_applist' \
'*::file:_files' \ '*::file:_files' \
$db_args \
$nul_args && ret=0 $nul_args && ret=0
} }
_managepy-reset(){ _managepy-makemessages(){
_arguments -s : \ _arguments -s : \
'--noinput[tells Django to NOT prompt the user for input of any kind.]' \ '--locale=-[Creates or updates the message files for the given locale(s) (e.g. pt_BR).]' \
'*::appname:_applist' \ '--domain=-[The domain of the message files (default: "django").]' \
'--all[Updates the message files for all existing locales.]' \
'--extension=-[The file extension(s) to examine (default: "html,txt", or "js" if the domain is "djangojs").]' \
'--symlinks[Follows symlinks to directories when examining source code and templates for translation strings.]' \
'--ignore=-[Ignore files or directories matching this glob-style pattern.]' \
"--no-default-ignore[Don't ignore the common glob-style patterns 'CVS', '.*', '*~' and '*.pyc'.]" \
"--no-wrap[Don't break long message lines into several lines.]" \
"--no-location[Don't write '#: filename:line' lines.]" \
'--no-obsolete[emove obsolete message strings.]' \
'--keep-pot[Keep .pot file after making messages.]' \
$nul_args && ret=0
}
_managepy-makemigrations(){
_arguments -s : \
'--dry-run[Just show what migrations would be made]' \
'--merge[Enable fixing of migration conflicts.]' \
'--empty[Create an empty migration.]' \
$noinput_args \
$nul_args && ret=0
}
_managepy-migrate(){
_arguments -s : \
'--fake[Mark migrations as run without actually running them]' \
'--list[Show a list of all known migrations and which are applied]' \
$no_init_data_args \
$noinput_args \
$db_args \
$nul_args && ret=0 $nul_args && ret=0
} }
_managepy-runfcgi(){ _managepy-runfcgi(){
local state local state
local fcgi_opts local fcgi_opts
fcgi_opts=( fcgi_opts=(
'protocol[fcgi, scgi, ajp, ... (default fcgi)]:protocol:(fcgi scgi ajp)' 'protocol[fcgi, scgi, ajp, ... (default fcgi)]:protocol:(fcgi scgi ajp)'
'host[hostname to listen on..]:' 'host[hostname to listen on..]:'
'port[port to listen on.]:' 'port[port to listen on.]:'
'socket[UNIX socket to listen on.]::file:_files' 'socket[UNIX socket to listen on.]:file:_files'
'method[prefork or threaded (default prefork)]:method:(prefork threaded)' 'method[prefork or threaded (default prefork)]:method:(prefork threaded)'
'maxrequests[number of requests a child handles before it is killed and a new child is forked (0 = no limit).]:' 'maxrequests[number of requests a child handles before it is killed and a new child is forked (0 = no limit).]:'
'maxspare[max number of spare processes / threads.]:' 'maxspare[max number of spare processes / threads.]:'
...@@ -112,7 +196,7 @@ _managepy-runfcgi(){ ...@@ -112,7 +196,7 @@ _managepy-runfcgi(){
'outlog[write stdout to this file.]:file:_files' 'outlog[write stdout to this file.]:file:_files'
'errlog[write stderr to this file.]:file:_files' 'errlog[write stderr to this file.]:file:_files'
) )
_arguments -s : \ _arguments -s : \
$nul_args \ $nul_args \
'*: :_values "FCGI Setting" $fcgi_opts' && ret=0 '*: :_values "FCGI Setting" $fcgi_opts' && ret=0
...@@ -120,71 +204,148 @@ _managepy-runfcgi(){ ...@@ -120,71 +204,148 @@ _managepy-runfcgi(){
_managepy-runserver(){ _managepy-runserver(){
_arguments -s : \ _arguments -s : \
'--noreload[tells Django to NOT use the auto-reloader.]' \ '--ipv6[Tells Django to use an IPv6 address.]' \
'--adminmedia[specifies the directory from which to serve admin media.]:directory:_files' \ '--nothreading[Tells Django to NOT use threading.]' \
'--noreload[Tells Django to NOT use the auto-reloader.]' \
'--nostatic[Tells Django to NOT automatically serve static files at STATIC_URL.]' \
'--insecure[Allows serving static files even if DEBUG is False.]' \
$nul_args && ret=0 $nul_args && ret=0
} }
_managepy-shell(){ _managepy-shell(){
_arguments -s : \ _arguments -s : \
'--plain[tells Django to use plain Python, not IPython.]' \ '--plain[Tells Django to use plain Python, not IPython.]' \
'--no-startup[When using plain Python, ignore the PYTHONSTARTUP environment variable and ~/.pythonrc.py script.]' \
'--interface=-[Specify an interactive interpreter interface.]:INTERFACE:((ipython bpython))' \
$nul_args && ret=0
}
_managepy-sql(){
_arguments -s : \
$db_args \
$nul_args && ret=0
}
_managepy-sqlall(){
_arguments -s : \
$db_args \
$nul_args && ret=0
}
_managepy-sqlclear(){
_arguments -s : \
$db_args \
$nul_args && ret=0
}
_managepy-sqlcustom(){
_arguments -s : \
$db_args \
$nul_args && ret=0
}
_managepy-dropindexes(){
_arguments -s : \
$db_args \
$nul_args && ret=0 $nul_args && ret=0
} }
_managepy-sql(){} _managepy-sqlflush(){
_managepy-sqlall(){} _arguments -s : \
_managepy-sqlclear(){} $db_args \
_managepy-sqlcustom(){} $nul_args && ret=0
_managepy-sqlflush(){} }
_managepy-sqlindexes(){}
_managepy-sqlinitialdata(){} _managepy-sqlindexes(){
_managepy-sqlreset(){} _arguments -s : \
_managepy-sqlsequencereset(){} $db_args \
_managepy-startapp(){} $nul_args && ret=0
}
_managepy-sqlinitialdata(){
_arguments -s : \
$nul_args && ret=0
}
_managepy-sqlsequencereset(){
_arguments -s : \
$db_args \
$nul_args && ret=0
}
_managepy-squashmigrations(){
_arguments -s : \
'--no-optimize[Do not try to optimize the squashed operations.]' \
$noinput_args \
$nul_args && ret=0
}
_managepy-startapp(){
_arguments -s : \
$start_args \
$nul_args && ret=0
}
_managepy-startproject(){
_arguments -s : \
$start_args \
$nul_args && ret=0
}
_managepy-syncdb() { _managepy-syncdb() {
_arguments -s : \ _arguments -s : \
'--verbosity=-[verbosity level; 0=minimal output, 1=normal output, 2=all output.]:Verbosity:((0\:minimal 1\:normal 2\:all))' \ $noinput_args \
'--noinput[tells Django to NOT prompt the user for input of any kind.]' \ $no_init_data_args \
$db_args \
$nul_args && ret=0 $nul_args && ret=0
} }
_managepy-test() { _managepy-test() {
_arguments -s : \ _arguments -s : \
'--verbosity=-[verbosity level; 0=minimal output, 1=normal output, 2=all output.]:Verbosity:((0\:minimal 1\:normal 2\:all))' \ '--failfast[Tells Django to stop running the test suite after first failed test.]' \
'--noinput[tells Django to NOT prompt the user for input of any kind.]' \ '--testrunner=-[Tells Django to use specified test runner class instead of the one specified by the TEST_RUNNER setting.]' \
'--liveserver=-[Overrides the default address where the live server (used with LiveServerTestCase) is expected to run from. The default value is localhost:8081.]' \
'--top-level-directory=-[Top level of project for unittest discovery.]' \
'--pattern=-[The test matching pattern. Defaults to test*.py.]:' \
$noinput_args \
'*::appname:_applist' \ '*::appname:_applist' \
$nul_args && ret=0 $nul_args && ret=0
} }
_managepy-testserver() { _managepy-testserver() {
_arguments -s : \ _arguments -s : \
'--verbosity=-[verbosity level; 0=minimal output, 1=normal output, 2=all output.]:Verbosity:((0\:minimal 1\:normal 2\:all))' \
'--addrport=-[port number or ipaddr:port to run the server on.]' \ '--addrport=-[port number or ipaddr:port to run the server on.]' \
'--ipv6[Tells Django to use an IPv6 address.]' \
$noinput_args \
'*::fixture:_files' \ '*::fixture:_files' \
$nul_args && ret=0 $nul_args && ret=0
} }
_managepy-validate() { _managepy-validate() {
_arguments -s : \ _arguments -s : \
$tag_args \
$nul_args && ret=0 $nul_args && ret=0
} }
_managepy-commands() { _managepy-commands() {
local -a commands local -a commands
commands=( commands=(
'adminindex:prints the admin-index template snippet for the given app name(s).' "changepassword:Change a user's password for django.contrib.auth."
'createcachetable:creates the table needed to use the SQL cache backend.' 'check:Checks the entire Django project for potential problems.'
'compilemessages:Compiles .po files to .mo files for use with builtin gettext support.'
'createcachetable:Creates the table needed to use the SQL cache backend.'
'createsuperuser:Used to create a superuser.'
'collectstatic:Collect static files in a single location.' 'collectstatic:Collect static files in a single location.'
'dbshell:runs the command-line client for the current DATABASE_ENGINE.' 'dbshell:Runs the command-line client for the current DATABASE_ENGINE.'
"diffsettings:displays differences between the current settings.py and Django's default settings." "diffsettings:Displays differences between the current settings.py and Django's default settings."
'dumpdata:Output the contents of the database as a fixture of the given format.' 'dumpdata:Output the contents of the database as a fixture of the given format.'
'flush:Executes ``sqlflush`` on the current database.' 'flush:Executes ``sqlflush`` on the current database.'
'help:manage.py help.' 'help:manage.py help.'
'inspectdb:Introspects the database tables in the given database and outputs a Django model module.' 'inspectdb:Introspects the database tables in the given database and outputs a Django model module.'
'loaddata:Installs the named fixture(s) in the database.' 'loaddata:Installs the named fixture(s) in the database.'
'reset:Executes ``sqlreset`` for the given app(s) in the current database.' 'makemessages:Runs over the entire source tree of the current directory and pulls out all strings marked for translation.'
'makemigrations:Creates new migration(s) for apps.'
'migrate:Updates database schema. Manages both apps with migrations and those without.'
'runfcgi:Run this project as a fastcgi (or some other protocol supported by flup) application,' 'runfcgi:Run this project as a fastcgi (or some other protocol supported by flup) application,'
'runserver:Starts a lightweight Web server for development.' 'runserver:Starts a lightweight Web server for development.'
'shell:Runs a Python interactive interpreter.' 'shell:Runs a Python interactive interpreter.'
...@@ -192,18 +353,20 @@ _managepy-commands() { ...@@ -192,18 +353,20 @@ _managepy-commands() {
'sqlall:Prints the CREATE TABLE, custom SQL and CREATE INDEX SQL statements for the given model module name(s).' 'sqlall:Prints the CREATE TABLE, custom SQL and CREATE INDEX SQL statements for the given model module name(s).'
'sqlclear:Prints the DROP TABLE SQL statements for the given app name(s).' 'sqlclear:Prints the DROP TABLE SQL statements for the given app name(s).'
'sqlcustom:Prints the custom table modifying SQL statements for the given app name(s).' 'sqlcustom:Prints the custom table modifying SQL statements for the given app name(s).'
'sqldropindexes:Prints the DROP INDEX SQL statements for the given model module name(s).'
'sqlflush:Returns a list of the SQL statements required to return all tables in the database to the state they were in just after they were installed.' 'sqlflush:Returns a list of the SQL statements required to return all tables in the database to the state they were in just after they were installed.'
'sqlindexes:Prints the CREATE INDEX SQL statements for the given model module name(s).' 'sqlindexes:Prints the CREATE INDEX SQL statements for the given model module name(s).'
"sqlinitialdata:RENAMED: see 'sqlcustom'" "sqlinitialdata:RENAMED: see 'sqlcustom'"
'sqlreset:Prints the DROP TABLE SQL, then the CREATE TABLE SQL, for the given app name(s).'
'sqlsequencereset:Prints the SQL statements for resetting sequences for the given app name(s).' 'sqlsequencereset:Prints the SQL statements for resetting sequences for the given app name(s).'
'squashmigrations:Squashes an existing set of migrations (from first until specified) into a single new one.'
"startapp:Creates a Django app directory structure for the given app name in this project's directory." "startapp:Creates a Django app directory structure for the given app name in this project's directory."
"startproject:Creates a Django project directory structure for the given project name in this current directory."
"syncdb:Create the database tables for all apps in INSTALLED_APPS whose tables haven't already been created." "syncdb:Create the database tables for all apps in INSTALLED_APPS whose tables haven't already been created."
'test:Runs the test suite for the specified applications, or the entire site if no apps are specified.' 'test:Runs the test suite for the specified applications, or the entire site if no apps are specified.'
'testserver:Runs a development server with data from the given fixture(s).' 'testserver:Runs a development server with data from the given fixture(s).'
'validate:Validates all installed models.' 'validate:Validates all installed models.'
) )
_describe -t commands 'manage.py command' commands && ret=0 _describe -t commands 'manage.py command' commands && ret=0
} }
...@@ -221,7 +384,7 @@ _applist() { ...@@ -221,7 +384,7 @@ _applist() {
_managepy() { _managepy() {
local curcontext=$curcontext ret=1 local curcontext=$curcontext ret=1
if ((CURRENT == 2)); then if ((CURRENT == 2)); then
_managepy-commands _managepy-commands
else else
...@@ -234,5 +397,6 @@ _managepy() { ...@@ -234,5 +397,6 @@ _managepy() {
compdef _managepy manage.py compdef _managepy manage.py
compdef _managepy django compdef _managepy django
compdef _managepy django-admin
compdef _managepy django-admin.py compdef _managepy django-admin.py
compdef _managepy django-manage compdef _managepy django-manage
# Docker-compose plugin for oh my zsh
A copy of the completion script from the [docker-compose](1) git repo.
[1]:[https://github.com/docker/compose/blob/master/contrib/completion/zsh/_docker-compose]
#compdef docker-compose
# Description
# -----------
# zsh completion for docker-compose
# https://github.com/sdurrheimer/docker-compose-zsh-completion
# -------------------------------------------------------------------------
# Version
# -------
# 0.1.0
# -------------------------------------------------------------------------
# Authors
# -------
# * Steve Durrheimer <s.durrheimer@gmail.com>
# -------------------------------------------------------------------------
# Inspiration
# -----------
# * @albers docker-compose bash completion script
# * @felixr docker zsh completion script : https://github.com/felixr/docker-zsh-completion
# -------------------------------------------------------------------------
# For compatibility reasons, Compose and therefore its completion supports several
# stack compositon files as listed here, in descending priority.
# Support for these filenames might be dropped in some future version.
__docker-compose_compose_file() {
local file
for file in docker-compose.y{,a}ml fig.y{,a}ml ; do
[ -e $file ] && {
echo $file
return
}
done
echo docker-compose.yml
}
# Extracts all service names from docker-compose.yml.
___docker-compose_all_services_in_compose_file() {
local already_selected
local -a services
already_selected=$(echo ${words[@]} | tr " " "|")
awk -F: '/^[a-zA-Z0-9]/{print $1}' "${compose_file:-$(__docker-compose_compose_file)}" 2>/dev/null | grep -Ev "$already_selected"
}
# All services, even those without an existing container
__docker-compose_services_all() {
services=$(___docker-compose_all_services_in_compose_file)
_alternative "args:services:($services)"
}
# All services that have an entry with the given key in their docker-compose.yml section
___docker-compose_services_with_key() {
local already_selected
local -a buildable
already_selected=$(echo ${words[@]} | tr " " "|")
# flatten sections to one line, then filter lines containing the key and return section name.
awk '/^[a-zA-Z0-9]/{printf "\n"};{printf $0;next;}' "${compose_file:-$(__docker-compose_compose_file)}" 2>/dev/null | awk -F: -v key=": +$1:" '$0 ~ key {print $1}' 2>/dev/null | grep -Ev "$already_selected"
}
# All services that are defined by a Dockerfile reference
__docker-compose_services_from_build() {
buildable=$(___docker-compose_services_with_key build)
_alternative "args:buildable services:($buildable)"
}
# All services that are defined by an image
__docker-compose_services_from_image() {
pullable=$(___docker-compose_services_with_key image)
_alternative "args:pullable services:($pullable)"
}
__docker-compose_get_services() {
local kind expl
declare -a running stopped lines args services
docker_status=$(docker ps > /dev/null 2>&1)
if [ $? -ne 0 ]; then
_message "Error! Docker is not running."
return 1
fi
kind=$1
shift
[[ $kind = (stopped|all) ]] && args=($args -a)
lines=(${(f)"$(_call_program commands docker ps ${args})"})
services=(${(f)"$(_call_program commands docker-compose 2>/dev/null ${compose_file:+-f $compose_file} ${compose_project:+-p $compose_project} ps -q)"})
# Parse header line to find columns
local i=1 j=1 k header=${lines[1]}
declare -A begin end
while (( $j < ${#header} - 1 )) {
i=$(( $j + ${${header[$j,-1]}[(i)[^ ]]} - 1))
j=$(( $i + ${${header[$i,-1]}[(i) ]} - 1))
k=$(( $j + ${${header[$j,-1]}[(i)[^ ]]} - 2))
begin[${header[$i,$(($j-1))]}]=$i
end[${header[$i,$(($j-1))]}]=$k
}
lines=(${lines[2,-1]})
# Container ID
local line s name
local -a names
for line in $lines; do
if [[ $services == *"${line[${begin[CONTAINER ID]},${end[CONTAINER ID]}]%% ##}"* ]]; then
names=(${(ps:,:)${${line[${begin[NAMES]},-1]}%% *}})
for name in $names; do
s="${${name%_*}#*_}:${(l:15:: :::)${${line[${begin[CREATED]},${end[CREATED]}]/ ago/}%% ##}}"
s="$s, ${line[${begin[CONTAINER ID]},${end[CONTAINER ID]}]%% ##}"
s="$s, ${${${line[$begin[IMAGE],$end[IMAGE]]}/:/\\:}%% ##}"
if [[ ${line[${begin[STATUS]},${end[STATUS]}]} = Exit* ]]; then
stopped=($stopped $s)
else
running=($running $s)
fi
done
fi
done
[[ $kind = (running|all) ]] && _describe -t services-running "running services" running
[[ $kind = (stopped|all) ]] && _describe -t services-stopped "stopped services" stopped
}
__docker-compose_stoppedservices() {
__docker-compose_get_services stopped "$@"
}
__docker-compose_runningservices() {
__docker-compose_get_services running "$@"
}
__docker-compose_services () {
__docker-compose_get_services all "$@"
}
__docker-compose_caching_policy() {
oldp=( "$1"(Nmh+1) ) # 1 hour
(( $#oldp ))
}
__docker-compose_commands () {
local cache_policy
zstyle -s ":completion:${curcontext}:" cache-policy cache_policy
if [[ -z "$cache_policy" ]]; then
zstyle ":completion:${curcontext}:" cache-policy __docker-compose_caching_policy
fi
if ( [[ ${+_docker_compose_subcommands} -eq 0 ]] || _cache_invalid docker_compose_subcommands) \
&& ! _retrieve_cache docker_compose_subcommands;
then
local -a lines
lines=(${(f)"$(_call_program commands docker-compose 2>&1)"})
_docker_compose_subcommands=(${${${lines[$((${lines[(i)Commands:]} + 1)),${lines[(I) *]}]}## #}/ ##/:})
_store_cache docker_compose_subcommands _docker_compose_subcommands
fi
_describe -t docker-compose-commands "docker-compose command" _docker_compose_subcommands
}
__docker-compose_subcommand () {
local -a _command_args
integer ret=1
case "$words[1]" in
(build)
_arguments \
'--no-cache[Do not use cache when building the image]' \
'*:services:__docker-compose_services_from_build' && ret=0
;;
(help)
_arguments ':subcommand:__docker-compose_commands' && ret=0
;;
(kill)
_arguments \
'-s[SIGNAL to send to the container. Default signal is SIGKILL.]:signal:_signals' \
'*:running services:__docker-compose_runningservices' && ret=0
;;
(logs)
_arguments \
'--no-color[Produce monochrome output.]' \
'*:services:__docker-compose_services_all' && ret=0
;;
(migrate-to-labels)
_arguments \
'(-):Recreate containers to add labels' && ret=0
;;
(port)
_arguments \
'--protocol=-[tcp or udap (defaults to tcp)]:protocol:(tcp udp)' \
'--index=-[index of the container if there are mutiple instances of a service (defaults to 1)]:index: ' \
'1:running services:__docker-compose_runningservices' \
'2:port:_ports' && ret=0
;;
(ps)
_arguments \
'-q[Only display IDs]' \
'*:services:__docker-compose_services_all' && ret=0
;;
(pull)
_arguments \
'--allow-insecure-ssl[Allow insecure connections to the docker registry]' \
'*:services:__docker-compose_services_from_image' && ret=0
;;
(rm)
_arguments \
'(-f --force)'{-f,--force}"[Don't ask to confirm removal]" \
'-v[Remove volumes associated with containers]' \
'*:stopped services:__docker-compose_stoppedservices' && ret=0
;;
(run)
_arguments \
'--allow-insecure-ssl[Allow insecure connections to the docker registry]' \
'-d[Detached mode: Run container in the background, print new container name.]' \
'--entrypoint[Overwrite the entrypoint of the image.]:entry point: ' \
'*-e[KEY=VAL Set an environment variable (can be used multiple times)]:environment variable KEY=VAL: ' \
'(-u --user)'{-u,--user=-}'[Run as specified username or uid]:username or uid:_users' \
"--no-deps[Don't start linked services.]" \
'--rm[Remove container after run. Ignored in detached mode.]' \
"--service-ports[Run command with the service's ports enabled and mapped to the host.]" \
'-T[Disable pseudo-tty allocation. By default `docker-compose run` allocates a TTY.]' \
'(-):services:__docker-compose_services' \
'(-):command: _command_names -e' \
'*::arguments: _normal' && ret=0
;;
(scale)
_arguments '*:running services:__docker-compose_runningservices' && ret=0
;;
(start)
_arguments '*:stopped services:__docker-compose_stoppedservices' && ret=0
;;
(stop|restart)
_arguments \
'(-t --timeout)'{-t,--timeout}"[Specify a shutdown timeout in seconds. (default: 10)]:seconds: " \
'*:running services:__docker-compose_runningservices' && ret=0
;;
(up)
_arguments \
'--allow-insecure-ssl[Allow insecure connections to the docker registry]' \
'-d[Detached mode: Run containers in the background, print new container names.]' \
'--no-color[Produce monochrome output.]' \
"--no-deps[Don't start linked services.]" \
"--no-recreate[If containers already exist, don't recreate them.]" \
"--no-build[Don't build an image, even if it's missing]" \
'(-t --timeout)'{-t,--timeout}"[Specify a shutdown timeout in seconds. (default: 10)]:seconds: " \
"--x-smart-recreate[Only recreate containers whose configuration or image needs to be updated. (EXPERIMENTAL)]" \
'*:services:__docker-compose_services_all' && ret=0
;;
(version)
_arguments \
"--short[Shows only Compose's version number.]" && ret=0
;;
(*)
_message 'Unknown sub command'
esac
return ret
}
_docker-compose () {
# Support for subservices, which allows for `compdef _docker docker-shell=_docker_containers`.
# Based on /usr/share/zsh/functions/Completion/Unix/_git without support for `ret`.
if [[ $service != docker-compose ]]; then
_call_function - _$service
return
fi
local curcontext="$curcontext" state line ret=1
typeset -A opt_args
_arguments -C \
'(- :)'{-h,--help}'[Get help]' \
'--verbose[Show more output]' \
'(- :)'{-v,--version}'[Print version and exit]' \
'(-f --file)'{-f,--file}'[Specify an alternate docker-compose file (default: docker-compose.yml)]:file:_files -g "*.yml"' \
'(-p --project-name)'{-p,--project-name}'[Specify an alternate project name (default: directory name)]:project name:' \
'(-): :->command' \
'(-)*:: :->option-or-argument' && ret=0
local counter=1
#local compose_file compose_project
while [ $counter -lt ${#words[@]} ]; do
case "${words[$counter]}" in
-f|--file)
(( counter++ ))
compose_file="${words[$counter]}"
;;
-p|--project-name)
(( counter++ ))
compose_project="${words[$counter]}"
;;
*)
;;
esac
(( counter++ ))
done
case $state in
(command)
__docker-compose_commands && ret=0
;;
(option-or-argument)
curcontext=${curcontext%:*:*}:docker-compose-$words[1]:
__docker-compose_subcommand && ret=0
;;
esac
return ret
}
_docker-compose "$@"
...@@ -4,14 +4,24 @@ ...@@ -4,14 +4,24 @@
# Requires: Docker installed # Requires: Docker installed
# Author: Azaan (@aeonazaan) # Author: Azaan (@aeonazaan)
# Updates: Bob Maerten (@bobmaerten) for Docker v0.9+ # Updates: Bob Maerten (@bobmaerten) for Docker v0.9+
# Paul van den Berg (@bergvandenp) for Docker v1.3+
# ----- Helper functions # ----- Helper functions
# Output a selectable list of all running docker containers # Output a selectable list of all running docker containers
__docker_containers() { __docker_containers() {
declare -a cont_cmd declare -a cont_cmd
cont_cmd=($(docker ps | awk 'NR>1{print $1":[CON("$1")"$2"("$3")]"}')) cont_cmd=($(docker ps | awk 'NR>1{print $NF":[CON("$1")"$2"("$3")]"}'))
_describe 'containers' cont_cmd if [[ 'X$cont_cmd' != 'X' ]]
_describe 'containers' cont_cmd
}
# Output a selectable list of all containers, even not running
__docker_all_containers() {
declare -a cont_cmd
cont_cmd=($(docker ps -a | awk 'NR>1{print $NF":[CON("$1")"$2"("$3")]"}'))
if [[ 'X$cont_cmd' != 'X' ]]
_describe 'containers' cont_cmd
} }
# output a selectable list of all docker images # output a selectable list of all docker images
...@@ -26,7 +36,7 @@ __docker_images() { ...@@ -26,7 +36,7 @@ __docker_images() {
# --------------------------- # ---------------------------
__attach() { __attach() {
_arguments \ _arguments \
'--no-stdin[Do not attach stdin]' \ '--no-stdin[Do not attach STDIN]' \
'--sig-proxy[Proxify all received signal to the process (even in non-tty mode)]' '--sig-proxy[Proxify all received signal to the process (even in non-tty mode)]'
__docker_containers __docker_containers
} }
...@@ -42,21 +52,64 @@ __build() { ...@@ -42,21 +52,64 @@ __build() {
__commit() { __commit() {
_arguments \ _arguments \
'(-a,--author=)'{-a,--author=}'[Author (eg. "John Hannibal Smith <hannibal@a-team.com>"]' \ '(-a,--author=)'{-a,--author=}'[Author (e.g. "John Hannibal Smith <hannibal@a-team.com>")]' \
'(-c,--change=)'{-c,--change=}'[Apply Dockerfile instruction to the created image]' \
'(-m,--message=)'{-m,--message=}'[Commit message]' \ '(-m,--message=)'{-m,--message=}'[Commit message]' \
'--run=[Config automatically applied when the image is run.]' '(-p,--pause=)'{-p,--pause=}'[Pause container during commit]' \
__docker_containers
} }
__cp() { __cp() {
__docker_containers __docker_containers
} }
__create() {
_arguments \
'(-P,--publish-all=)'{-P,--publish-all=}'[Publish all exposed ports to the host interfaces]' \
'(-a,--attach=)'{-a,--attach=}'[Attach to STDIN, STDOUT or STDERR]' \
'--add-host=[Add a custom host-to-IP mapping]' \
'--cap-add=[Add Linux capabilities]' \
'--cap-drop=[Drop Linux capabilities]' \
'--cpuset-cpus=[CPUs in which to allow execution (0-3, 0,1)]' \
'(-c,--cpu-shares=)'{-c,--cpu-shares=}'[CPU shares (relative weight)]' \
'--cidfile=[Write the container ID to the file]' \
'--device=[Add a host device to the container]' \
'--dns=[Set custom dns servers]' \
'--dns-search=[Set custom DNS search domains]' \
'(-e,--env=)'{-e,--env=}'[Set environment variables]' \
'--env-file=[Read in a file of environment variables]' \
'--entrypoint=[Overwrite the default entrypoint of the image]' \
'--expose=[Expose a port from the container without publishing it to your host]' \
'(-h,--hostname=)'{-h,--hostname=}'[Container host name]' \
'(-i,--interactive=)'{-i,--interactive=}'[Keep STDIN open even if not attached]' \
'--ipc=[IPC namespace to use]' \
'(-l,--label=)'{-l,--label=}'[Set meta data on a container]' \
'--link=[Add link to another container (name:alias)]' \
'--log-driver=[Logging driver for the container]' \
'--lxc-conf=[Add custom LXC options]' \
'--mac-address=[Container MAC address (e.g. 92:d0:c6:0a:29:33)]' \
'(-m,--memory=)'{-m,--memory=}'[Memory limit (format: <number><optional unit>, where unit = b, k, m or g)]' \
'--net=[Set the Network mode for the container]' \
'--name=[Assign a name to the container]' \
'--pid=[PID namespace to use]' \
'(-p,--publish=)'{-p,--publish=}'[Publish a container''s port to the host (format: ip:hostPort:containerPort/protocol)]' \
'--privileged=[Give extended privileges to this container]' \
'--restart=[Restart policy to apply when a container exits]' \
'--security-opt=[Security Options]' \
'--sig-proxy=[Proxify all received signal to the process (even in non-tty mode)]' \
'(-t,--tty=)'{-t,--tty=}'[Allocate a pseudo-tty]' \
'(-u,--user=)'{-u,--user=}'[Username or UID]' \
'--ulimit=[Ulimit options]' \
'(-v,--volume=)'{-v,--volume=}'[Bind mount a volume (e.g. -v /host:/container or -v /container)]' \
'--volumes-from=[Mount volumes from the specified container(s)]' \
'(-w,--workdir=)'{-w,--workdir=}'[Working directory inside the container]'
__docker_images
}
__diff() { __diff() {
__docker_containers __docker_containers
} }
__events() { __events() {
_arguments \ _arguments \
'--since=[Show previously created events and then stream.]' '--since=[Show previously created events and then stream.]'
} }
...@@ -90,17 +143,14 @@ __info() { ...@@ -90,17 +143,14 @@ __info() {
# no arguments # no arguments
} }
__insert() {
__docker_images
_arguments '*:files:_files'
}
__inspect() { __inspect() {
__docker_images __docker_images
__docker_containers __docker_all_containers
} }
__kill() { __kill() {
_arguments \
'(-s,--signal=)'{-s,--signal=}'[KILL Signal]'
__docker_containers __docker_containers
} }
...@@ -161,7 +211,7 @@ __rm() { ...@@ -161,7 +211,7 @@ __rm() {
'(-f,--force=)'{-f,--force=}'[Force removal of running container]' \ '(-f,--force=)'{-f,--force=}'[Force removal of running container]' \
'(-l,--link=)'{-l,--link=}'[Remove the specified link and not the underlying container]' \ '(-l,--link=)'{-l,--link=}'[Remove the specified link and not the underlying container]' \
'(-v,--volumes=)'{-v,--volumes=}'[Remove the volumes associated to the container]' '(-v,--volumes=)'{-v,--volumes=}'[Remove the volumes associated to the container]'
__docker_containers __docker_all_containers
} }
__rmi() { __rmi() {
...@@ -173,28 +223,43 @@ __rmi() { ...@@ -173,28 +223,43 @@ __rmi() {
__run() { __run() {
_arguments \ _arguments \
'(-P,--publish-all=)'{-P,--publish-all=}'[Publish all exposed ports to the host interfaces]' \ '(-P,--publish-all=)'{-P,--publish-all=}'[Publish all exposed ports to the host interfaces]' \
'(-a,--attach=)'{-a,--attach=}'[Attach to stdin, stdout or stderr.]' \ '(-a,--attach=)'{-a,--attach=}'[Attach to STDIN, STDOUT or STDERR]' \
'(-c,--cpu-shares=)'{-c,--cpu-shares=}': CPU shares (relative weight)]' \ '--add-host=[Add a custom host-to-IP mapping]' \
'--cap-add=[Add Linux capabilities]' \
'--cap-drop=[Drop Linux capabilities]' \
'--cpuset-cpus=[CPUs in which to allow execution (0-3, 0,1)]' \
'(-c,--cpu-shares=)'{-c,--cpu-shares=}'[CPU shares (relative weight)]' \
'--cidfile=[Write the container ID to the file]' \ '--cidfile=[Write the container ID to the file]' \
'(-d,--detach=)'{-d,--detach=}'[Detached mode: Run container in the background, print new container id]' \ '(-d,--detach=)'{-d,--detach=}'[Run container in the background, print new container id]' \
'--device=[Add a host device to the container]' \
'--dns=[Set custom dns servers]' \ '--dns=[Set custom dns servers]' \
'--dns-search=[Set custom DNS search domains]' \
'(-e,--env=)'{-e,--env=}'[Set environment variables]' \ '(-e,--env=)'{-e,--env=}'[Set environment variables]' \
'--env-file=[Read in a file of environment variables]' \
'--entrypoint=[Overwrite the default entrypoint of the image]' \ '--entrypoint=[Overwrite the default entrypoint of the image]' \
'--expose=[Expose a port from the container without publishing it to your host]' \ '--expose=[Expose a port from the container without publishing it to your host]' \
'(-h,--hostname=)'{-h,--hostname=}'[Container host name]' \ '(-h,--hostname=)'{-h,--hostname=}'[Container host name]' \
'(-i,--interactive=)'{-i,--interactive=}'[Keep stdin open even if not attached]' \ '(-i,--interactive=)'{-i,--interactive=}'[Keep STDIN open even if not attached]' \
'--ipc=[IPC namespace to use]' \
'(-l,--label=)'{-l,--label=}'[Set meta data on a container]' \
'--link=[Add link to another container (name:alias)]' \ '--link=[Add link to another container (name:alias)]' \
'--lxc-conf=[Add custom lxc options -lxc-conf="lxc.cgroup.cpuset.cpus = 0,1"]' \ '--log-driver=[Logging driver for the container]' \
'--lxc-conf=[Add custom LXC options]' \
'--mac-address=[Container MAC address (e.g. 92:d0:c6:0a:29:33)]' \
'(-m,--memory=)'{-m,--memory=}'[Memory limit (format: <number><optional unit>, where unit = b, k, m or g)]' \ '(-m,--memory=)'{-m,--memory=}'[Memory limit (format: <number><optional unit>, where unit = b, k, m or g)]' \
'(-n,--networking=)'{-n,--networking=}'[Enable networking for this container]' \ '--net=[Set the Network mode for the container]' \
'--name=[Assign a name to the container]' \ '--name=[Assign a name to the container]' \
'(-p,--publish=)'{-p,--publish=}'[Publish a container''s port to the host (format: ip:hostPort:containerPort | ip::containerPort | hostPort:containerPort) (use "docker port" to see the actual mapping)]' \ '--pid=[PID namespace to use]' \
'(-p,--publish=)'{-p,--publish=}'[Publish a container''s port to the host (format: ip:hostPort:containerPort/protocol)]' \
'--privileged=[Give extended privileges to this container]' \ '--privileged=[Give extended privileges to this container]' \
'--restart=[Restart policy to apply when a container exits]' \
'--rm=[Automatically remove the container when it exits (incompatible with -d)]' \ '--rm=[Automatically remove the container when it exits (incompatible with -d)]' \
'--security-opt=[Security Options]' \
'--sig-proxy=[Proxify all received signal to the process (even in non-tty mode)]' \ '--sig-proxy=[Proxify all received signal to the process (even in non-tty mode)]' \
'(-t,--tty=)'{-t,--tty=}'[Allocate a pseudo-tty]' \ '(-t,--tty=)'{-t,--tty=}'[Allocate a pseudo-tty]' \
'(-u,--user=)'{-u,--user=}'[Username or UID]' \ '(-u,--user=)'{-u,--user=}'[Username or UID]' \
'(-v,--volume=)'{-v,--volume=}'[Bind mount a volume (e.g. from the host: -v /host:/container, from docker: -v /container)]' \ '--ulimit=[Ulimit options]' \
'(-v,--volume=)'{-v,--volume=}'[Bind mount a volume (e.g. -v /host:/container or -v /container)]' \
'--volumes-from=[Mount volumes from the specified container(s)]' \ '--volumes-from=[Mount volumes from the specified container(s)]' \
'(-w,--workdir=)'{-w,--workdir=}'[Working directory inside the container]' '(-w,--workdir=)'{-w,--workdir=}'[Working directory inside the container]'
__docker_images __docker_images
...@@ -213,8 +278,12 @@ __save() { ...@@ -213,8 +278,12 @@ __save() {
__start() { __start() {
_arguments \ _arguments \
'(-a,--attach=)'{-a,--attach=}'[Attach container''s stdout/stderr and forward all signals to the process]' \ '(-a,--attach=)'{-a,--attach=}'[Attach container''s STDOUT/STDERR and forward all signals to the process]' \
'(-i,--interactive=)'{-i, --interactive=}'[Attach container''s stdin]' '(-i,--interactive=)'{-i,--interactive=}'[Attach container''s STDIN]'
__docker_all_containers
}
__stats() {
__docker_containers __docker_containers
} }
...@@ -238,6 +307,14 @@ __wait() { ...@@ -238,6 +307,14 @@ __wait() {
__docker_containers __docker_containers
} }
__exec() {
_arguments \
'(-d,--detach=)'{-d,--detach=}'[Detached mode: run command in the background]' \
'(-i,--interactive=)'{-i,--interactive=}'[Keep STDIN open even if not attached]' \
'(-t,--tty=)'{-t,--tty=}'[Allocate a pseudo-TTY]'
__docker_containers
}
# end commands --------- # end commands ---------
# ---------------------- # ----------------------
...@@ -247,6 +324,7 @@ _1st_arguments=( ...@@ -247,6 +324,7 @@ _1st_arguments=(
"build":"Build a container from a Dockerfile" "build":"Build a container from a Dockerfile"
"commit":"Create a new image from a container's changes" "commit":"Create a new image from a container's changes"
"cp":"Copy files/folders from the containers filesystem to the host path" "cp":"Copy files/folders from the containers filesystem to the host path"
"create":"Create new container without running it"
"diff":"Inspect changes on a container's filesystem" "diff":"Inspect changes on a container's filesystem"
"events":"Get real time events from the server" "events":"Get real time events from the server"
"export":"Stream the contents of a container as a tar archive" "export":"Stream the contents of a container as a tar archive"
...@@ -254,7 +332,6 @@ _1st_arguments=( ...@@ -254,7 +332,6 @@ _1st_arguments=(
"images":"List images" "images":"List images"
"import":"Create a new filesystem image from the contents of a tarball" "import":"Create a new filesystem image from the contents of a tarball"
"info":"Display system-wide information" "info":"Display system-wide information"
"insert":"Insert a file in an image"
"inspect":"Return low-level information on a container" "inspect":"Return low-level information on a container"
"kill":"Kill a running container" "kill":"Kill a running container"
"load":"Load an image from a tar archive" "load":"Load an image from a tar archive"
...@@ -271,11 +348,13 @@ _1st_arguments=( ...@@ -271,11 +348,13 @@ _1st_arguments=(
"save":"Save an image to a tar archive" "save":"Save an image to a tar archive"
"search":"Search for an image in the docker index" "search":"Search for an image in the docker index"
"start":"Start a stopped container" "start":"Start a stopped container"
"stats":"Display a live stream of one or more containers' resource usage statistics"
"stop":"Stop a running container" "stop":"Stop a running container"
"tag":"Tag an image into a repository" "tag":"Tag an image into a repository"
"top":"Lookup the running processes of a container" "top":"Lookup the running processes of a container"
"version":"Show the docker version information" "version":"Show the docker version information"
"wait":"Block until a container stops, then print its exit code" "wait":"Block until a container stops, then print its exit code"
"exec":"Run a task inside a running container"
) )
_arguments '*:: :->command' _arguments '*:: :->command'
...@@ -295,6 +374,8 @@ case "$words[1]" in ...@@ -295,6 +374,8 @@ case "$words[1]" in
__commit ;; __commit ;;
cp) cp)
__cp ;; __cp ;;
create)
__create ;;
diff) diff)
__diff ;; __diff ;;
events) events)
...@@ -309,8 +390,6 @@ case "$words[1]" in ...@@ -309,8 +390,6 @@ case "$words[1]" in
__import ;; __import ;;
info) info)
__info ;; __info ;;
insert)
__insert ;;
inspect) inspect)
__inspect ;; __inspect ;;
kill) kill)
...@@ -341,6 +420,8 @@ case "$words[1]" in ...@@ -341,6 +420,8 @@ case "$words[1]" in
__save ;; __save ;;
search) search)
__search ;; __search ;;
stats)
__stats ;;
start) start)
__start ;; __start ;;
stop) stop)
...@@ -353,4 +434,6 @@ case "$words[1]" in ...@@ -353,4 +434,6 @@ case "$words[1]" in
__version ;; __version ;;
wait) wait)
__wait ;; __wait ;;
exec)
__exec ;;
esac esac
# Ember-cli
**Maintainer:** [BilalBudhani](http://www.github.com/BilalBudhani)
Ember-cli (http://www.ember-cli.com/)
### List of Aliases
alias es='ember serve'
alias ea='ember addon'
alias eb='ember build'
alias ed='ember destroy'
alias eg='ember generate'
alias eh='ember help'
alias ein='ember init'
alias eia='ember install:addon'
alias eib='ember install:bower'
alias ein='ember install:npm'
alias ei='ember install'
alias et='ember test'
alias eu='ember update'
alias ev='ember version'
# Ember ClI
# visit http://www.ember-cli.com/ to view user guid
alias es='ember serve'
alias ea='ember addon'
alias eb='ember build'
alias ed='ember destroy'
alias eg='ember generate'
alias eh='ember help'
alias ein='ember init'
alias eia='ember install:addon'
alias eib='ember install:bower'
alias ein='ember install:npm'
alias ei='ember install'
alias et='ember test'
alias eu='ember update'
# version
alias ev='ember version'
...@@ -8,21 +8,25 @@ ...@@ -8,21 +8,25 @@
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
function emoji-clock() { function emoji-clock() {
hour=$(date '+%I') # Add 15 minutes to the current time and save the value as $minutes.
minutes=$(date '+%M') (( minutes = $(date '+%M') + 15 ))
(( hour = $(date '+%I') + minutes / 60 ))
# make sure minutes and hours don't exceed 60 nor 12 respectively
(( minutes %= 60 )); (( hour %= 12 ))
case $hour in case $hour in
01) clock="🕐"; [ $minutes -ge 30 ] && clock="🕜";; 0) clock="🕛"; [ $minutes -ge 30 ] && clock="🕧";;
02) clock="🕑"; [ $minutes -ge 30 ] && clock="🕝";; 1) clock="🕐"; [ $minutes -ge 30 ] && clock="🕜";;
03) clock="🕒"; [ $minutes -ge 30 ] && clock="🕞";; 2) clock="🕑"; [ $minutes -ge 30 ] && clock="🕝";;
04) clock="🕓"; [ $minutes -ge 30 ] && clock="🕟";; 3) clock="🕒"; [ $minutes -ge 30 ] && clock="🕞";;
05) clock="🕔"; [ $minutes -ge 30 ] && clock="🕠";; 4) clock="🕓"; [ $minutes -ge 30 ] && clock="🕟";;
06) clock="🕕"; [ $minutes -ge 30 ] && clock="🕡";; 5) clock="🕔"; [ $minutes -ge 30 ] && clock="🕠";;
07) clock="🕖"; [ $minutes -ge 30 ] && clock="🕢";; 6) clock="🕕"; [ $minutes -ge 30 ] && clock="🕡";;
08) clock="🕗"; [ $minutes -ge 30 ] && clock="🕣";; 7) clock="🕖"; [ $minutes -ge 30 ] && clock="🕢";;
09) clock="🕘"; [ $minutes -ge 30 ] && clock="🕤";; 8) clock="🕗"; [ $minutes -ge 30 ] && clock="🕣";;
9) clock="🕘"; [ $minutes -ge 30 ] && clock="🕤";;
10) clock="🕙"; [ $minutes -ge 30 ] && clock="🕥";; 10) clock="🕙"; [ $minutes -ge 30 ] && clock="🕥";;
11) clock="🕚"; [ $minutes -ge 30 ] && clock="🕦";; 11) clock="🕚"; [ $minutes -ge 30 ] && clock="🕦";;
12) clock="🕛"; [ $minutes -ge 30 ] && clock="🕧";;
*) clock="⌛";; *) clock="⌛";;
esac esac
echo $clock echo $clock
......
# emoji plugin
Support for conveniently working with Unicode emoji in Zsh.
## Features
This plugin provides support for working with Unicode emoji characters in `zsh` using human-readable identifiers. It provides global variables which map emoji names to the actual characters, country names to their flags, and some named groupings of emoji. It also provides associated functions for displaying them.
#### Variables
Variable | Description
----------------- | --------------------------------
$emoji | Maps emoji names to characters
$emoji_flags | Maps country names to flag characters (using region indicators)
$emoji_groups | Named groups of emoji. Keys are group names; values are whitespace-separated lists of character names
You may define new emoji groups at run time by modifying `$emoji_groups`. The special group name `all` is reserved for use by the plugin. You should not modify `$emoji` or `$emoji_flags`.
#### Functions
Function | Description
---------------- | -------------------------------
random_emoji | Prints a random emoji character
display_emoji | Displays emoji, along with their names
## Usage and Examples
To output a specific emoji, use:
```
$> echo $emoji[<name>]
```
E.g.:
```
$> echo $emoji[mouse_face]
```
To output a random emoji, use:
```
$> random_emoji
```
To output a random emoji from a particular group, use:
```
$> random_emoji <group>
```
E.g.:
```
$> random_emoji fruits
$> random_emoji animals
$> random_emoji vehicles
$> random_emoji faces
```
The defined group names can be found with `echo ${(k)emoji_groups}`.
To list all available emoji with their names, use:
```
$> display_emoji
$> display_emoji fruits
$> display_emoji animals
$> display_emoji vehicles
$> display_emoji faces
```
To use emoji in a prompt:
```
PROMPT="$emoji[penguin] > ""
PROMPT='$(random_emoji fruits) > '
surfer=$emoji[surfer]
PROMPT="$surfer > "
```
## Technical Details
The emoji names and codes are sourced from Unicode Technical Report \#51, which provides information on emoji support in Unicode. It can be found at http://www.unicode.org/reports/tr51/index.html.
The group definitions are added by this OMZ plugin. They are not based on external definitions. (As far as I can tell. -apjanke)
The values in the `$emoji*` maps are the emoji characters themselves, not escape sequences or other forms that require interpretation. They can be used in any context and do not require escape sequence support from commands like `echo` or `print`.
The emoji in the main `$emoji` map are standalone character sequences which can all be output on their own, without worrying about combining characters. The values may actually be multi-code-point sequences, instead of a single code point, and may include combining characters in those sequences. But they're arranged so their effects do not extend beyond that sequence.
The exception to this is the skin tone variation selectors. These are included in the main `$emoji` map because they can be displayed on their own, as well as used as combining characters. (If they follow a character that is not one of the emoji characters they combine with, they are displayed as color swatches.)
## Experimental Features
This defines some additional variables and functions, but these are experimental and subject to change at any time. You shouldn't rely on them being available. They're mostly for the use of emoji plugin developers to help decide what to include in future revisions.
Variables:
Variable | Description
----------------- | --------------------------------
$emoji2 | Auxiliary and combining characters
$emoji_skintone | Skin tone modifiers (from Unicode 8.0)
#### Skin Tone Variation Selection
This includes experimental support for the skin tone Variation Selectors introduced with Unicode 8.0, which let you select different skin tones for emoji involving humans.
NOTE: This really is experimental. The skin tone selectors are a relatively new feature and may not be supported by all systems. And the support in this plugin is a work in progress. It may not work in all places. In fact, I haven't gotten it to work anywhere yet. -apjanke
The "variation selectors" are combining characters which change the appearance of the preceding character. A variation selector character can be output immediately following a human emoji to change its skin tone color. You can also output a variation selector on its own to display a color swatch of that skin tone.
The `$emoji_skintone` associative array maps skin tone IDs to the variation selector characters. To use one, output it immediately following a smiley or other human emoji.
```
echo "$emoji[smiling_face_with_open_mouth]$emoji_skintone[4]"
```
Note that `$emoji_skintone` is an associative array, and its keys are the *names* of "Fitzpatrick Skin Type" groups, not linear indexes into a normal array. The names are `1_2`, `3`, `4`, `5`, and `6`. (Types 1 and 2 are combined into a single color.) See the [Diversity section in Unicode TR 51](http://www.unicode.org/reports/tr51/index.html#Diversity) for details.
## TODO
These are things that could be enhanced in future revisions of the plugin.
* Incorporate CLDR data for ordering and groupings
* Short :bracket: style names (from gemoji)
* Incorporate `gemoji` data
* Country codes for flags
* ZWJ combining function?
#### Gemoji support
The [gemoji project](https://github.com/github/gemoji) seems to be the de facto main source for short names and other emoji-related metadata that isn't included in the official Unicode reports. (I'm saying this just from looking at the google results for "emoji short names" and related searches. -apjanke)
If this plugin is updated to provide short names, CLDR sorting data, and similar stuff, it should probably be changed to use the Gemoji project, and the `update_emoji.pl` script be rewritten in Ruby so it can use the Gemoji library directly instead of parsing its data files.
This does *not* mean that it should use Gemoji at run time. None of the `zsh` plugin stuff should call Gemoji or Ruby code. Rather, the "build time" `update_emoji.pl` script should be rewritten to use Gemoji to generate a pure-native-`zsh` character definition file which would be checked in to the repo and can be called by OMZ users without having Gemoji installed.
#### ZWJ combining function
One of the newer features of Unicode emoji is the ability to use the "Zero-Width Joiner" character to compose multiple emoji characters in to a single "emoji ligature" glyph. For example, this is [how Apple supports "family" emoji with various genders and skin tones](http://www.unicode.org/reports/tr51/index.html#ZWJ_Sequences).
These are a pain to write out (and probably worse to read), and it might be convenient to have a couple functions for concisely composing them, if wider support for them appears.
This diff is collapsed.
This diff is collapsed.
# emoji plugin
#
# Makes emoji support available within ZSH
#
# See the README for documentation.
_omz_emoji_plugin_dir="${0:h}"
() {
local LC_ALL=en_US.UTF-8
typeset -gAH emoji_groups
typeset -gAH emoji_con
typeset -gAH emoji2
typeset -gAH emoji_skintone
source "$_omz_emoji_plugin_dir/emoji-char-definitions.zsh"
unset _omz_emoji_plugin_dir
# These additional emoji are not in the definition file, but are useful in conjunction with it
# This is a combinin character that can be placed after any other character to surround
# it in a "keycap" symbol.
# The digits 0-9 are already in the emoji table as keycap_digit_<N>, keycap_ten, etc.
# It's unclear whether this should be in the $emoji array, because those characters are all ones
# which can be displayed on their own.
#emoji[combining_enclosing_keycap]="\U20E3"
emoji[regional_indicator_symbol_letter_d_regional_indicator_symbol_letter_e]=$'\xF0\x9F\x87\xA9\xF0\x9F\x87\xAA'
emoji[regional_indicator_symbol_letter_g_regional_indicator_symbol_letter_b]=$'\xF0\x9F\x87\xAC\xF0\x9F\x87\xA7'
emoji[regional_indicator_symbol_letter_c_regional_indicator_symbol_letter_n]=$'\xF0\x9F\x87\xA8\xF0\x9F\x87\xB3'
emoji[regional_indicator_symbol_letter_j_regional_indicator_symbol_letter_p]=$'\xF0\x9F\x87\xAF\xF0\x9F\x87\xB5'
emoji[regional_indicator_symbol_letter_k_regional_indicator_symbol_letter_r]=$'\xF0\x9F\x87\xB0\xF0\x9F\x87\xB7'
emoji[regional_indicator_symbol_letter_f_regional_indicator_symbol_letter_r]=$'\xF0\x9F\x87\xAB\xF0\x9F\x87\xB7'
emoji[regional_indicator_symbol_letter_e_regional_indicator_symbol_letter_s]=$'\xF0\x9F\x87\xAA\xF0\x9F\x87\xB8'
emoji[regional_indicator_symbol_letter_i_regional_indicator_symbol_letter_t]=$'\xF0\x9F\x87\xAE\xF0\x9F\x87\xB9'
emoji[regional_indicator_symbol_letter_u_regional_indicator_symbol_letter_s]=$'\xF0\x9F\x87\xBA\xF0\x9F\x87\xB8'
emoji[regional_indicator_symbol_letter_r_regional_indicator_symbol_letter_u]=$'\xF0\x9F\x87\xB7\xF0\x9F\x87\xBA'
# Nonstandard alias names
emoji[vulcan_salute]=$'\U1F596'
# Emoji combining and auxiliary characters
# "Variation Selectors" for controlling text vs emoji style presentation
# These apply to the immediately preceding character
emoji2[text_style]=$'\UFE0E'
emoji2[emoji_style]=$'\UFE0F'
# Joiner that indicates a single combined-form glyph (ligature) should be used
emoji2[zero_width_joiner]=$'\U200D'
# Skin tone modifiers
emoji2[emoji_modifier_fitzpatrick_type_1_2]=$'\U1F3FB'
emoji2[emoji_modifier_fitzpatrick_type_3]=$'\U1F3FC'
emoji2[emoji_modifier_fitzpatrick_type_4]=$'\U1F3FD'
emoji2[emoji_modifier_fitzpatrick_type_5]=$'\U1F3FE'
emoji2[emoji_modifier_fitzpatrick_type_6]=$'\U1F3FF'
# Various other combining characters. (Incomplete list; I selected ones that sound useful)
emoji2[combining_enclosing_circle]=$'\U20DD'
emoji2[combining_enclosing_square]=$'\U20DE'
emoji2[combining_enclosing_diamond]=$'\U20DF'
emoji2[combining_enclosing_circle_backslash]=$'\U20E0'
emoji2[combining_enclosing_screen]=$'\U20E2'
emoji2[combining_enclosing_keycap]=$'\U20E3'
emoji2[combining_enclosing_upward_pointing_triangle]=$'\U20E4'
# Easier access to skin tone modifiers
emoji_skintone[1_2]=$'\U1F3FB'
emoji_skintone[3]=$'\U1F3FC'
emoji_skintone[4]=$'\U1F3FD'
emoji_skintone[5]=$'\U1F3FE'
emoji_skintone[6]=$'\U1F3FF'
# Emoji groups
# These are stored in a single associative array, $emoji_groups, to avoid cluttering up the global
# namespace, and to allow adding additional group definitions at run time.
# The keys are the group names, and the values are whitespace-separated lists of emoji character names.
#
# These extra local arrays are used to allow more convenient formatting of the source code.
emoji_groups[fruits]="
tomato
aubergine
grapes
melon
watermelon
tangerine
banana
pineapple
red_apple
green_apple
peach
cherries
strawberry
lemon
pear
"
emoji_groups[vehicles]="
airplane
rocket
railway_car
high_speed_train
high_speed_train_with_bullet_nose
bus
ambulance
fire_engine
police_car
taxi
automobile
recreational_vehicle
delivery_truck
ship
speedboat
bicycle
helicopter
steam_locomotive
train
light_rail
tram
oncoming_bus
trolleybus
minibus
oncoming_police_car
oncoming_taxi
oncoming_automobile
articulated_lorry
tractor
monorail
mountain_railway
suspension_railway
mountain_cableway
aerial_tramway
rowboat
bicyclist
mountain_bicyclist
sailboat
"
emoji_groups[animals]="
snail
snake
horse
sheep
monkey
chicken
boar
elephant
octopus
spiral_shell
bug
ant
honeybee
lady_beetle
fish
tropical_fish
blowfish
turtle
hatching_chick
baby_chick
front_facing_baby_chick
bird
penguin
koala
poodle
bactrian_camel
dolphin
mouse_face
cow_face
tiger_face
rabbit_face
cat_face
dragon_face
spouting_whale
horse_face
monkey_face
dog_face
pig_face
frog_face
hamster_face
wolf_face
bear_face
panda_face
rat
mouse
ox
water_buffalo
cow
tiger
leopard
rabbit
cat
dragon
crocodile
whale
ram
goat
rooster
dog
pig
dromedary_camel
"
emoji_groups[faces]="
grinning_face_with_smiling_eyes
face_with_tears_of_joy
smiling_face_with_open_mouth
smiling_face_with_open_mouth_and_smiling_eyes
smiling_face_with_open_mouth_and_cold_sweat
smiling_face_with_open_mouth_and_tightly_closed_eyes
winking_face
smiling_face_with_smiling_eyes
face_savouring_delicious_food
relieved_face
smiling_face_with_heart_shaped_eyes
smirking_face
unamused_face
face_with_cold_sweat
pensive_face
confounded_face
face_throwing_a_kiss
kissing_face_with_closed_eyes
face_with_stuck_out_tongue_and_winking_eye
face_with_stuck_out_tongue_and_tightly_closed_eyes
disappointed_face
angry_face
pouting_face
crying_face
persevering_face
face_with_look_of_triumph
disappointed_but_relieved_face
fearful_face
weary_face
sleepy_face
tired_face
loudly_crying_face
face_with_open_mouth_and_cold_sweat
face_screaming_in_fear
astonished_face
flushed_face
dizzy_face
face_with_medical_mask
"
}
# Prints a random emoji character
#
# random_emoji [group]
#
function random_emoji() {
local group=$1
local names
if [[ -z "$group" || "$group" == "all" ]]; then
names=(${(k)emoji})
else
names=(${=emoji_groups[$group_name]})
fi
local list_size=$#names
local random_index=$(( ( RANDOM % $list_size ) + 1 ))
local name=${names[$random_index]}
echo ${emoji[$name]}
}
# Displays a listing of emoji with their names
#
# display_emoji [group]
#
function display_emoji() {
local group=$1
local names
if [[ -z "$group" || "$group" == "all" ]]; then
names=(${(k)emoji})
else
names=(${=emoji_groups[$group]})
fi
# The extra spaces in output here are a hack for readability, since some
# terminals treat these emoji chars as single-width.
for i in $names; do
printf '%s ' "$emoji[$i]"
done
print
for i in $names; do
echo "${emoji[$i]} = $i"
done
}
#!/usr/bin/perl -w
#
# update_emoji.pl
#
# This script generates the emoji.plugin.zsh emoji definitions from the Unicode
# character data for the emoji characters.
#
# The data file can be found at http://unicode.org/Public/emoji/latest/emoji-data.txt
# as referenced in Unicode TR51 (http://www.unicode.org/reports/tr51/index.html).
#
# This is known to work with the data file from version 1.0. It may not work with later
# versions if the format changes. In particular, this reads line comments to get the
# emoji character name and unicode version.
#
# Country names have punctuation and other non-letter characters removed from their name,
# to avoid possible complications with having to escape the strings when using them as
# array subscripts. The definition file seems to use some combining characters like accents
# that get stripped during this process.
use strict;
use warnings;
use 5.010;
use autodie;
use Path::Class;
use File::Copy;
# Parse definitions out of the data file and convert
sub process_emoji_data_file {
my ( $infile, $outfilename ) = @_;
my $file = file($infile);
my $outfile = file($outfilename);
my $outfilebase = $outfile->basename();
my $tempfilename = "$outfilename.tmp";
my $tempfile = file($tempfilename);
my $outfh = $tempfile->openw();
$outfh->print("
# $outfilebase - Emoji character definitions for oh-my-zsh emoji plugin
#
# This file is auto-generated by update_emoji.pl. Do not edit it manually.
#
# This contains the definition for:
# \$emoji - which maps character names to Unicode characters
# \$emoji_flags - maps country names to Unicode flag characters using region indicators
# Main emoji
typeset -gAH emoji
# National flags
typeset -gAH emoji_flags
# Combining modifiers
typeset -gAH emoji_mod
");
my $fh = $file->openr();
my $line_num = 0;
while ( my $line = $fh->getline() ) {
$line_num++;
$_ = $line;
# Skip all-comment lines (from the header) and blank lines
# (But don't strip comments on normal lines; we need to parse those for
# the emoji names.)
next if /^\s*#/ or /^\s*$/;
if (/^(\S.*?\S)\s*;\s*(\w+)\s*;\s*(\w+)\s*;\s*(\w+)\s*;\s*(\w.*?)\s*#\s*V(\S+)\s\(.*?\)\s*(\w.*\S)\s*$/) {
my ($code, $style, $level, $modifier_status, $sources, $version, $keycap_name)
= ($1, $2, $3, $4, $5, $6, $7);
#print "code=$code style=$style level=$level modifier_status=$modifier_status sources=$sources version=$version name=$keycap_name\n";
my @code_points = split /\s+/, $code;
my @sources = split /\s+/, $sources;
my $flag_country = "";
if ( $keycap_name =~ /^flag for (\S.*?)\s*$/) {
$flag_country = $1;
}
my $zsh_code = join '', map { "\\U$_" } @code_points;
# Convert keycap names to valid associative array names that do not require any
# quoting. Works fine for most stuff, but is clumsy for flags.
my $omz_name = lc($keycap_name);
$omz_name =~ s/[^A-Za-z0-9]/_/g;
my $zsh_flag_country = $flag_country;
$zsh_flag_country =~ s/[^\p{Letter}]/_/g;
if ($flag_country) {
$outfh->print("emoji_flags[$zsh_flag_country]=\$'$zsh_code'\n");
} else {
$outfh->print("emoji[$omz_name]=\$'$zsh_code'\n");
}
# Modifiers are included in both the main set and their separate map,
# because they have a standalone representation as a color swatch.
if ( $modifier_status == "modifier" ) {
$outfh->print("emoji_mod[$omz_name]=\$'$zsh_code'\n");
}
} else {
die "Failed parsing line $line_num: '$_'";
}
}
$fh->close();
$outfh->print("\n");
$outfh->close();
move($tempfilename, $outfilename)
or die "Failed moving temp file to $outfilename: $!";
}
my $datafile = "emoji-data.txt";
my $zsh_def_file = "emoji-char-definitions.zsh";
process_emoji_data_file($datafile, $zsh_def_file);
print "Updated definition file $zsh_def_file\n";
...@@ -3,6 +3,6 @@ ...@@ -3,6 +3,6 @@
_arguments \ _arguments \
'(-r --remove)'{-r,--remove}'[Remove archive.]' \ '(-r --remove)'{-r,--remove}'[Remove archive.]' \
"*::archive file:_files -g '(#i)*.(tar|tgz|tbz|tbz2|txz|tlz|gz|bz2|xz|lzma|Z|zip|rar|7z|deb)(-.)'" && return 0 "*::archive file:_files -g '(#i)*.(tar|tgz|tbz|tbz2|txz|tlz|gz|bz2|xz|lzma|Z|zip|ipsw|rar|7z|deb)(-.)'" && return 0
...@@ -23,7 +23,7 @@ function extract() { ...@@ -23,7 +23,7 @@ function extract() {
remove_archive=1 remove_archive=1
if [[ "$1" == "-r" ]] || [[ "$1" == "--remove" ]]; then if [[ "$1" == "-r" ]] || [[ "$1" == "--remove" ]]; then
remove_archive=0 remove_archive=0
shift shift
fi fi
...@@ -38,7 +38,7 @@ function extract() { ...@@ -38,7 +38,7 @@ function extract() {
file_name="$( basename "$1" )" file_name="$( basename "$1" )"
extract_dir="$( echo "$file_name" | sed "s/\.${1##*.}//g" )" extract_dir="$( echo "$file_name" | sed "s/\.${1##*.}//g" )"
case "$1" in case "$1" in
(*.tar.gz|*.tgz) tar xvzf "$1" ;; (*.tar.gz|*.tgz) [ -z $commands[pigz] ] && tar zxvf "$1" || pigz -dc "$1" | tar xv ;;
(*.tar.bz2|*.tbz|*.tbz2) tar xvjf "$1" ;; (*.tar.bz2|*.tbz|*.tbz2) tar xvjf "$1" ;;
(*.tar.xz|*.txz) tar --xz --help &> /dev/null \ (*.tar.xz|*.txz) tar --xz --help &> /dev/null \
&& tar --xz -xvf "$1" \ && tar --xz -xvf "$1" \
...@@ -47,12 +47,12 @@ function extract() { ...@@ -47,12 +47,12 @@ function extract() {
&& tar --lzma -xvf "$1" \ && tar --lzma -xvf "$1" \
|| lzcat "$1" | tar xvf - ;; || lzcat "$1" | tar xvf - ;;
(*.tar) tar xvf "$1" ;; (*.tar) tar xvf "$1" ;;
(*.gz) gunzip "$1" ;; (*.gz) [ -z $commands[pigz] ] && gunzip "$1" || pigz -d "$1" ;;
(*.bz2) bunzip2 "$1" ;; (*.bz2) bunzip2 "$1" ;;
(*.xz) unxz "$1" ;; (*.xz) unxz "$1" ;;
(*.lzma) unlzma "$1" ;; (*.lzma) unlzma "$1" ;;
(*.Z) uncompress "$1" ;; (*.Z) uncompress "$1" ;;
(*.zip|*.war|*.jar) unzip "$1" -d $extract_dir ;; (*.zip|*.war|*.jar|*.sublime-package|*.ipsw) unzip "$1" -d $extract_dir ;;
(*.rar) unrar x -ad "$1" ;; (*.rar) unrar x -ad "$1" ;;
(*.7z) 7za x "$1" ;; (*.7z) 7za x "$1" ;;
(*.deb) (*.deb)
...@@ -64,10 +64,10 @@ function extract() { ...@@ -64,10 +64,10 @@ function extract() {
cd ..; rm *.tar.gz debian-binary cd ..; rm *.tar.gz debian-binary
cd .. cd ..
;; ;;
(*) (*)
echo "extract: '$1' cannot be extracted" 1>&2 echo "extract: '$1' cannot be extracted" 1>&2
success=1 success=1
;; ;;
esac esac
(( success = $success > 0 ? $success : $? )) (( success = $success > 0 ? $success : $? ))
......
if [ $commands[fasd] ]; then # check if fasd is installed if [ $commands[fasd] ]; then # check if fasd is installed
fasd_cache="$HOME/.fasd-init-cache" fasd_cache="${ZSH_CACHE_DIR}/fasd-init-cache"
if [ "$(command -v fasd)" -nt "$fasd_cache" -o ! -s "$fasd_cache" ]; then if [ "$(command -v fasd)" -nt "$fasd_cache" -o ! -s "$fasd_cache" ]; then
fasd --init auto >| "$fasd_cache" fasd --init auto >| "$fasd_cache"
fi fi
source "$fasd_cache" source "$fasd_cache"
unset fasd_cache unset fasd_cache
alias v='f -e vim' alias v='f -e vim'
alias o='a -e open' alias o='a -e open_command'
fi fi
# start fbterm automatically in /dev/tty* # start fbterm automatically in /dev/tty*
if [[ $(tty|grep -o '/dev/tty') = /dev/tty ]] ; then if (( ${+commands[fbterm]} )); then
fbterm if [[ "$TTY" = /dev/tty* ]] ; then
exit fbterm && exit
fi
fi fi
## forklift
Plugin for ForkLift, an FTP application for OS X.
### Requirements
* [ForkLift](http://forkliftapp.com/forklift/)
### Usage
* If `fl` is called without arguments then the current folder is opened in ForkLift. Is equivalent to `fl .`
* If `fl` is called with a directory as the argument, then that directory is opened in ForkLift
\ No newline at end of file
# Open folder in ForkLift.app of ForkLift2.app from console # Open folder in ForkLift.app or ForkLift2.app from console
# Author: Adam Strzelecki nanoant.com, modified by Bodo Tasche bitboxer.de # Author: Adam Strzelecki nanoant.com, modified by Bodo Tasche bitboxer.de
# Updated to support ForkLift2 by Johan Kaving # Updated to support ForkLift2 by Johan Kaving
# #
......
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