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
...@@ -7,8 +7,8 @@ droplr() { ...@@ -7,8 +7,8 @@ droplr() {
return 1 return 1
fi fi
if [[ "$1" =~ ^http[|s]:// ]]; then if [[ "$1" =~ ^https?:// ]]; then
osascript -e "tell app 'Droplr' to shorten '$1'" osascript -e 'tell app "Droplr" to shorten "'"$1"'"'
else else
open -ga /Applications/Droplr.app "$1" open -ga /Applications/Droplr.app "$1"
fi fi
......
# Drush
## Description
This plugin offers aliases and functions to make the work with drush easier and more productive.
To enable it, add the `drush` to your `plugins` array in `~/.zshrc`:
```
plugins=(... drush)
```
## Aliases
| Alias | Description | Command |
|-------|-----------------------------------------------------------------------|-----------------------------|
| dr | Display drush help | drush |
| drca | Clear all drupal caches. | drush cc all |
| drcb | Clear block cache. | drush cc block |
| drcg | Clear registry cache. | drush cc registry |
| drcj | Clear css-js cache. | drush cc css-js |
| drcm | Clear menu cache. | drush cc menu |
| drcml | Clear module-list cache. | drush cc module-list |
| drcr | Run all cron hooks in all active modules for specified site. | drush core-cron |
| drct | Clear theme-registry cache. | drush cc theme-registry |
| drcv | Clear views cache. (Make sure that the views module is enabled) | drush cc views |
| drdmp | Backup database in a new dump.sql file | drush drush sql-dump --ordered-dump --result-file=dump.sql|
| drf | Display features status | drush features |
| drfr | Revert a feature module on your site. | drush features-revert -y |
| drfu | Update a feature module on your site. | drush features-update -y |
| drfra | Revert all enabled feature module on your site. | drush features-revert-all |
| drif | Flush all derived images. | drush image-flush --all |
| drpm | Show a list of available modules. | drush pm-list --type=module |
| drst | Provides a birds-eye view of the current Drupal installation, if any. | drush core-status |
| drup | Apply any database updates required (as with running update.php). | drush updatedb |
| drups | List any pending database updates. | drush updatedb-status |
| drv | Show drush version. | drush version |
| drvd | Delete a variable. | drush variable-del |
| drvg | Get a list of some or all site variables and values. | drush variable-get |
| drvs | Set a variable. | drush variable-set |
## Functions
### dren
Download and enable one or more extensions (modules or themes).
Must be invoked with one or more parameters. e.g.:
`dren devel` or `dren devel module_filter views`
### drf
Edit drushrc, site alias, and Drupal settings.php files.
Can be invoked with one or without parameters. e.g.:
`drf 1`
### dris
Disable one or more extensions (modules or themes)
Must be invoked with one or more parameters. e.g.:
`dris devel` or `dris devel module_filter views`
### drpu
Uninstall one or more modules.
Must be invoked with one or more parameters. e.g.:
`drpu devel` or `drpu devel module_filter views`
### drnew
Creates a brand new drupal website.
Note: As soon as the installation is complete, drush will print a username and a random password into the terminal:
```
Installation complete. User name: admin User password: cf7t8yqNEm
```
## Additional features
### Autocomplete
The [completion script for drush](https://github.com/drush-ops/drush/blob/8.0.1/drush.complete.sh) comes enabled with this plugin.
So, it is possible to type a command:
```
drush sql
```
And as soon as the tab key is pressed, the script will display the available commands:
```
drush sql
sqlc sql-conf sql-create sql-dump sql-query sql-sanitize
sql-cli sql-connect sql-drop sqlq sqlsan sql-sync
```
# BASH completion script for Drush.
#
# Place this in your /etc/bash_completion.d/ directory or source it from your
# ~/.bash_completion or ~/.bash_profile files. Alternatively, source
# examples/example.bashrc instead, as it will automatically find and source
# this file.
#
# If you're using ZSH instead of BASH, add the following to your ~/.zshrc file
# and source it.
#
# autoload bashcompinit
# bashcompinit
# source /path/to/your/drush.complete.sh
# Ensure drush is available.
which drush > /dev/null || alias drush &> /dev/null || return
__drush_ps1() {
f="${TMPDIR:-/tmp/}/drush-env-${USER}/drush-drupal-site-$$"
if [ -f $f ]
then
__DRUPAL_SITE=$(cat "$f")
else
__DRUPAL_SITE="$DRUPAL_SITE"
fi
# Set DRUSH_PS1_SHOWCOLORHINTS to a non-empty value and define a
# __drush_ps1_colorize_alias() function for color hints in your Drush PS1
# prompt. See example.prompt.sh for an example implementation.
if [ -n "${__DRUPAL_SITE-}" ] && [ -n "${DRUSH_PS1_SHOWCOLORHINTS-}" ]; then
__drush_ps1_colorize_alias
fi
[[ -n "$__DRUPAL_SITE" ]] && printf "${1:- (%s)}" "$__DRUPAL_SITE"
}
# Completion function, uses the "drush complete" command to retrieve
# completions for a specific command line COMP_WORDS.
_drush_completion() {
# Set IFS to newline (locally), since we only use newline separators, and
# need to retain spaces (or not) after completions.
local IFS=$'\n'
# The '< /dev/null' is a work around for a bug in php libedit stdin handling.
# Note that libedit in place of libreadline in some distributions. See:
# https://bugs.launchpad.net/ubuntu/+source/php5/+bug/322214
COMPREPLY=( $(drush --early=includes/complete.inc "${COMP_WORDS[@]}" < /dev/null 2> /dev/null) )
}
# Register our completion function. We include common short aliases for Drush.
complete -o bashdefault -o default -o nospace -F _drush_completion d dr drush drush5 drush6 drush7 drush8 drush.php
# Drush support.
function dren() {
drush en $@ -y
}
function dris() {
drush pm-disable $@ -y
}
function drpu() {
drush pm-uninstall $@ -y
}
function drf() {
if [[ $1 == "" ]] then
drush core-config
else
drush core-config --choice=$1
fi
}
function drfi() {
if [[ $1 == "fields" ]]; then
drush field-info fields
elif [[ $1 == "types" ]]; then
drush field-info types
else
drush field-info
fi
}
function drnew() {
cd ~
echo "Website's name: "
read WEBSITE_NAME
HOST=http://$(hostname -i)/
if [[ $WEBSITE_NAME == "" ]] then
MINUTES=$(date +%M:%S)
WEBSITE_NAME="Drupal-$MINUTES"
echo "Your website will be named: $WEBSITE_NAME"
fi
drush dl drupal --drupal-project-rename=$WEBSITE_NAME
echo "Type your localhost directory: (Leave empty for /var/www/html/)"
read DIRECTORY
if [[ $DIRECTORY == "" ]] then
DIRECTORY="/var/www/html/"
fi
echo "Moving to $DIRECTORY$WEBSITE_NAME"
sudo mv $WEBSITE_NAME $DIRECTORY
cd $DIRECTORY$WEBSITE_NAME
echo "Database's user: "
read DATABASE_USR
echo "Database's password: "
read -s DATABASE_PWD
echo "Database's name for your project: "
read DATABASE
DB_URL="mysql://$DATABASE_USR:$DATABASE_PWD@localhost/$DATABASE"
drush site-install standard --db-url=$DB_URL --site-name=$WEBSITE_NAME
open_command $HOST$WEBSITE_NAME
echo "Done"
}
# Aliases, sorted alphabetically.
alias dr="drush"
alias drca="drush cc all" # Deprecated for Drush 8
alias drcb="drush cc block" # Deprecated for Drush 8
alias drcg="drush cc registry" # Deprecated for Drush 8
alias drcj="drush cc css-js"
alias drcm="drush cc menu"
alias drcml="drush cc module-list"
alias drcr="drush core-cron"
alias drct="drush cc theme-registry"
alias drcv="drush cc views"
alias drdmp="drush sql-dump --ordered-dump --result-file=dump.sql"
alias drf="drush features"
alias drfr="drush features-revert -y"
alias drfu="drush features-update -y"
alias drfra="drush features-revert-all"
alias drif="drush image-flush --all"
alias drpm="drush pm-list --type=module"
alias drst="drush core-status"
alias drup="drush updatedb"
alias drups="drush updatedb-status"
alias drv="drush version"
alias drvd="drush variable-del"
alias drvg="drush variable-get"
alias drvs="drush variable-set"
# Enable drush autocomplete support
autoload bashcompinit
bashcompinit
source $(dirname $0)/drush.complete.sh
# eecms plugin
This plugin adds auto-completion of console commands for [`eecms`](https://github.com/ExpressionEngine/ExpressionEngine).
To use it, add `eecms` to the plugins array of your `.zshrc` file:
```
plugins=(... eecms)
```
It also adds the alias `eecms` which finds the eecms file in the current project
and runs it with php.
# ExpressionEngine CMS basic command completion
_eecms_console () {
echo "php $(find . -maxdepth 3 -mindepth 1 -name 'eecms' -type f | head -n 1)"
}
_eecms_get_command_list () {
`_eecms_console` | sed "/Available commands/,/^/d" | sed "s/[[:space:]].*//g"
}
_eecms () {
compadd `_eecms_get_command_list`
}
compdef _eecms '`_eecms_console`'
compdef _eecms 'system/ee/eecms'
compdef _eecms eecms
#Alias
alias eecms='`_eecms_console`'
# Emacs plugin
This plugin utilizes the Emacs daemon capability, allowing the user to quickly open frames, whether they are opened in a terminal via a ssh connection, or X frames opened on the same host. The plugin also provides some aliases for such operations.
- You don't have the cost of starting Emacs all the time anymore
- Opening a file is as fast as Emacs does not have anything else to do.
- You can share opened buffered across opened frames.
- Configuration changes made at runtime are applied to all frames.
**NOTE:** requires Emacs 24 and newer.
To use it, add emacs to the plugins array in your zshrc file:
```zsh
plugins=(... emacs)
```
## Aliases
The plugin uses a custom launcher (which we'll call here `$EMACS_LAUNCHER`) that is just a wrapper around [`emacsclient`](https://www.emacswiki.org/emacs/EmacsClient).
| Alias | Command | Description |
|--------|----------------------------------------------------|----------------------------------------------------------------|
| emacs | `$EMACS_LAUNCHER --no-wait` | Opens a temporary emacsclient frame |
| e | `emacs` | Same as emacs alias |
| te | `$EMACS_LAUNCHER -nw` | Open terminal emacsclient |
| eeval | `$EMACS_LAUNCHER --eval` | Same as `M-x eval` but from outside Emacs |
| eframe | `emacsclient --alternate-editor "" --create-frame` | Create new X frame |
| efile | - | Print the path to the file open in the current buffer |
| ecd | - | Print the directory of the file open in the the current buffer |
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
# - Configuration changes made at runtime are applied to all frames. # - Configuration changes made at runtime are applied to all frames.
if "$ZSH/tools/require_tool.sh" emacs 24 2>/dev/null ; then if "$ZSH/tools/require_tool.sh" emacsclient 24 2>/dev/null ; then
export EMACS_PLUGIN_LAUNCHER="$ZSH/plugins/emacs/emacsclient.sh" export EMACS_PLUGIN_LAUNCHER="$ZSH/plugins/emacs/emacsclient.sh"
# set EDITOR if not already defined. # set EDITOR if not already defined.
......
# Ember CLI # Ember CLI
**Maintainers:** [BilalBudhani](http://www.github.com/BilalBudhani), [eubenesa](http://www.github.com/eubenesa) **Maintainers:** [BilalBudhani](https://github.com/BilalBudhani), [eubenesa](https://github.com/eubenesa), [scottkidder](https://github.com/scottkidder]
Ember CLI (http://www.ember-cli.com/) Ember CLI (https://www.ember-cli.com/)
### List of Aliases ### List of Aliases
...@@ -17,5 +17,6 @@ Alias | Ember-CLI command ...@@ -17,5 +17,6 @@ Alias | Ember-CLI command
**ein** | *ember init* **ein** | *ember init*
**ei** | *ember install* **ei** | *ember install*
**et** | *ember test* **et** | *ember test*
**ets** | *ember test --serve*
**eu** | *ember update* **eu** | *ember update*
**ev** | *ember version* **ev** | *ember version*
# Ember CLI # Ember CLI
# Visit http://www.ember-cli.com/ to view user guide # Visit https://www.ember-cli.com/ to view user guide
alias es='ember serve' alias es='ember serve'
alias ea='ember addon' alias ea='ember addon'
...@@ -10,6 +10,7 @@ alias eh='ember help' ...@@ -10,6 +10,7 @@ alias eh='ember help'
alias ein='ember init' alias ein='ember init'
alias ei='ember install' alias ei='ember install'
alias et='ember test' alias et='ember test'
alias ets='ember test --serve'
alias eu='ember update' alias eu='ember update'
# version # version
......
# emoji-clock
The plugin displays current time as an emoji symbol with half hour accuracy.
To use it, add `emoji-clock` to the plugins array of your zshrc file:
```
plugins=(... emoji-clock)
```
## Features
| Function | Description |
|-------------------|----------------------------------------------------------------------|
| `emoji-clock` | Displays current time in clock emoji symbol with half hour accuracy |
...@@ -71,7 +71,7 @@ PROMPT="$surfer > " ...@@ -71,7 +71,7 @@ PROMPT="$surfer > "
## Technical Details ## 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 emoji names and codes are sourced from Unicode Technical Report \#51, which provides information on emoji support in Unicode. It can be found at https://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 group definitions are added by this OMZ plugin. They are not based on external definitions. (As far as I can tell. -apjanke)
...@@ -108,7 +108,7 @@ The `$emoji_skintone` associative array maps skin tone IDs to the variation sele ...@@ -108,7 +108,7 @@ The `$emoji_skintone` associative array maps skin tone IDs to the variation sele
echo "$emoji[smiling_face_with_open_mouth]$emoji_skintone[4]" 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. 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](https://www.unicode.org/reports/tr51/index.html#Diversity) for details.
## TODO ## TODO
...@@ -130,6 +130,6 @@ This does *not* mean that it should use Gemoji at run time. None of the `zsh` pl ...@@ -130,6 +130,6 @@ This does *not* mean that it should use Gemoji at run time. None of the `zsh` pl
#### ZWJ combining function #### 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). 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](https://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. 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.
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
# none: not applicable # none: not applicable
# Field 4 — Emoji_Sources: # Field 4 — Emoji_Sources:
# one or more values from {z, a, j, w, x} # one or more values from {z, a, j, w, x}
# see the key in http://www.unicode.org/draft/reports/tr51/tr51.html#Major_Sources # see the key in https://www.unicode.org/draft/reports/tr51/tr51.html#Major_Sources
# NA: not applicable # NA: not applicable
# Comment — currently contains the version where the character was first encoded, # Comment — currently contains the version where the character was first encoded,
# followed by: # followed by:
...@@ -1200,7 +1200,7 @@ ...@@ -1200,7 +1200,7 @@
1F1F2 1F1ED ; emoji ; L2 ; none ; x # V6.0 (🇲🇭) flag for Marshall Islands 1F1F2 1F1ED ; emoji ; L2 ; none ; x # V6.0 (🇲🇭) flag for Marshall Islands
1F1F2 1F1F0 ; emoji ; L2 ; none ; x # V6.0 (🇲🇰) flag for Macedonia 1F1F2 1F1F0 ; emoji ; L2 ; none ; x # V6.0 (🇲🇰) flag for Macedonia
1F1F2 1F1F1 ; emoji ; L2 ; none ; x # V6.0 (🇲🇱) flag for Mali 1F1F2 1F1F1 ; emoji ; L2 ; none ; x # V6.0 (🇲🇱) flag for Mali
1F1F2 1F1F2 ; emoji ; L2 ; none ; x # V6.0 (🇲🇲) flag for Myanmar 1F1F2 1F1F2 ; emoji ; L2 ; none ; x # V6.0 (🇲🇲) flag for Myanmar
1F1F2 1F1F3 ; emoji ; L2 ; none ; x # V6.0 (🇲🇳) flag for Mongolia 1F1F2 1F1F3 ; emoji ; L2 ; none ; x # V6.0 (🇲🇳) flag for Mongolia
1F1F2 1F1F4 ; emoji ; L2 ; none ; x # V6.0 (🇲🇴) flag for Macau 1F1F2 1F1F4 ; emoji ; L2 ; none ; x # V6.0 (🇲🇴) flag for Macau
1F1F2 1F1F5 ; emoji ; L2 ; none ; x # V6.0 (🇲🇵) flag for Northern Mariana Islands 1F1F2 1F1F5 ; emoji ; L2 ; none ; x # V6.0 (🇲🇵) flag for Northern Mariana Islands
......
...@@ -5,15 +5,15 @@ ...@@ -5,15 +5,15 @@
# This script generates the emoji.plugin.zsh emoji definitions from the Unicode # This script generates the emoji.plugin.zsh emoji definitions from the Unicode
# character data for the emoji characters. # character data for the emoji characters.
# #
# The data file can be found at http://unicode.org/Public/emoji/latest/emoji-data.txt # The data file can be found at https://unicode.org/Public/emoji/latest/emoji-data.txt
# as referenced in Unicode TR51 (http://www.unicode.org/reports/tr51/index.html). # as referenced in Unicode TR51 (https://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 # 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 # versions if the format changes. In particular, this reads line comments to get the
# emoji character name and unicode version. # emoji character name and unicode version.
# #
# Country names have punctuation and other non-letter characters removed from their name, # 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 # 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 # array subscripts. The definition file seems to use some combining characters like accents
# that get stripped during this process. # that get stripped during this process.
...@@ -41,7 +41,7 @@ sub process_emoji_data_file { ...@@ -41,7 +41,7 @@ sub process_emoji_data_file {
# #
# This contains the definition for: # This contains the definition for:
# \$emoji - which maps character names to Unicode characters # \$emoji - which maps character names to Unicode characters
# \$emoji_flags - maps country names to Unicode flag characters using region indicators # \$emoji_flags - maps country names to Unicode flag characters using region indicators
# Main emoji # Main emoji
typeset -gAH emoji typeset -gAH emoji
...@@ -63,7 +63,7 @@ typeset -gAH emoji_mod ...@@ -63,7 +63,7 @@ typeset -gAH emoji_mod
next if /^\s*#/ or /^\s*$/; 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*$/) { 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) my ($code, $style, $level, $modifier_status, $sources, $version, $keycap_name)
= ($1, $2, $3, $4, $5, $6, $7); = ($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"; #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 @code_points = split /\s+/, $code;
...@@ -84,7 +84,7 @@ typeset -gAH emoji_mod ...@@ -84,7 +84,7 @@ typeset -gAH emoji_mod
if ($flag_country) { if ($flag_country) {
$outfh->print("emoji_flags[$zsh_flag_country]=\$'$zsh_code'\n"); $outfh->print("emoji_flags[$zsh_flag_country]=\$'$zsh_code'\n");
} else { } else {
$outfh->print("emoji[$omz_name]=\$'$zsh_code'\n"); $outfh->print("emoji[$omz_name]=\$'$zsh_code'\n");
} }
# Modifiers are included in both the main set and their separate map, # Modifiers are included in both the main set and their separate map,
# because they have a standalone representation as a color swatch. # because they have a standalone representation as a color swatch.
......
# emotty plugin
This plugin returns an emoji for the current $TTY number so it can be used
in a prompt.
To use it, add emotty to the plugins array in your zshrc file:
```
plugins=(... emotty)
```
**NOTE:** it requires the [emoji plugin](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/emoji).
## Usage
The function `emotty` displays an emoji from the current character set (default: `emoji`), based
on the number associated to the `$TTY`.
There are different sets of emoji characters available, to choose a different
set, set `$emotty_set` to the name of the set you would like to use, e.g.:
```
emotty_set=nature
```
### Character Sets
- emoji
- loral
- love
- nature
- stellar
- zodiac
Use the `display_emotty` function to list the emojis in the current character set, or
the character set passed as the first argument. For example:
```
$ display_emotty zodiac
<list of all the emojis in the zodiac character set>
```
...@@ -25,14 +25,21 @@ emotty_default_set=emoji ...@@ -25,14 +25,21 @@ emotty_default_set=emoji
function emotty() { function emotty() {
# Use emotty set defined by user, fallback to default # Use emotty set defined by user, fallback to default
local emotty=${_emotty_sets[${emotty_set:-$emotty_default_set}]} local emotty=${_emotty_sets[${emotty_set:-$emotty_default_set}]}
# Parse $TTY number, normalizing it to an emotty set index
(( tty = (${TTY##/dev/ttys} % ${#${=emotty}}) + 1 )) # Parse tty number via prompt expansion. %l equals:
# - N if tty = /dev/ttyN
# - pts/N if tty = /dev/pts/N
local tty = ${${(%):-%l}##pts/}
# Normalize it to an emotty set index
(( tty = (tty % ${#${=emotty}}) + 1 ))
local character_name=${${=emotty}[tty]} local character_name=${${=emotty}[tty]}
echo "${emoji[${character_name}]}${emoji2[emoji_style]}" echo "${emoji[${character_name}]}${emoji2[emoji_style]}"
} }
function display_emotty() { function display_emotty() {
local name=$1 local name=${1:-$emotty_set}
echo $name
for i in ${=_emotty_sets[$name]}; do for i in ${=_emotty_sets[$name]}; do
printf "${emoji[$i]}${emoji2[emoji_style]} " printf "${emoji[$i]}${emoji2[emoji_style]} "
done done
......
# encode64
Alias plugin for encoding or decoding using `base64` command
## Functions and Aliases
| Function | Alias | Description |
| ---------- | ----- | ------------------------------ |
| `encode64` | `e64` | Encodes given data to base64 |
| `decode64` | `d64` | Decodes given data from base64 |
## Enabling plugin
1. Edit your `.zshrc` file and add `encode64` to the list of plugins:
```sh
plugins=(
# ...other enabled plugins
encode64
)
```
2. Restart your terminal session or reload configuration by running:
```sh
source ~/.zshrc
```
## Usage and examples
### Encoding
- From parameter
```console
$ encode64 "oh-my-zsh"
b2gtbXktenNo
$ e64 "oh-my-zsh"
b2gtbXktenNo
```
- From piping
```console
$ echo "oh-my-zsh" | encode64
b2gtbXktenNo==
$ echo "oh-my-zsh" | e64
b2gtbXktenNo==
```
### Decoding
- From parameter
```console
$ decode64 b2gtbXktenNo
oh-my-zsh%
$ d64 b2gtbXktenNo
oh-my-zsh%
```
- From piping
```console
$ echo "b2gtbXktenNoCg==" | decode64
oh-my-zsh
$ echo "b2gtbXktenNoCg==" | decode64
oh-my-zsh
```
# extract plugin
This plugin defines a function called `extract` that extracts the archive file
you pass it, and it supports a wide variety of archive filetypes.
This way you don't have to know what specific command extracts a file, you just
do `extract <filename>` and the function takes care of the rest.
To use it, add `extract` to the plugins array in your zshrc file:
```zsh
plugins=(... extract)
```
## Supported file extensions
| Extension | Description |
|:------------------|:-------------------------------------|
| `7z` | 7zip file |
| `Z` | Z archive (LZW) |
| `apk` | Android app file |
| `aar` | Android library file |
| `bz2` | Bzip2 file |
| `deb` | Debian package |
| `gz` | Gzip file |
| `ipsw` | iOS firmware file |
| `jar` | Java Archive |
| `lzma` | LZMA archive |
| `rar` | WinRAR archive |
| `sublime-package` | Sublime Text package |
| `tar` | Tarball |
| `tar.bz2` | Tarball with bzip2 compression |
| `tar.gz` | Tarball with gzip compression |
| `tar.xz` | Tarball with lzma2 compression |
| `tar.zma` | Tarball with lzma compression |
| `tbz` | Tarball with bzip compression |
| `tbz2` | Tarball with bzip2 compression |
| `tgz` | Tarball with gzip compression |
| `tlz` | Tarball with lzma compression |
| `txz` | Tarball with lzma2 compression |
| `war` | Web Application archive (Java-based) |
| `xpi` | Mozilla XPI module file |
| `xz` | LZMA2 archive |
| `zip` | Zip archive |
See [list of archive formats](https://en.wikipedia.org/wiki/List_of_archive_formats) for
more information regarding archive formats.
...@@ -3,6 +3,5 @@ ...@@ -3,6 +3,5 @@
_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|ipsw|rar|7z|deb)(-.)'" && return 0 "*::archive file:_files -g '(#i)*.(7z|Z|apk|aar|bz2|deb|gz|ipsw|jar|lzma|rar|sublime-package|tar|tar.bz2|tar.gz|tar.xz|tar.zma|tbz|tbz2|tgz|tlz|txz|war|whl|xpi|xz|zip)(-.)'" \
&& return 0
# ------------------------------------------------------------------------------ alias x=extract
# FILE: extract.plugin.zsh
# DESCRIPTION: oh-my-zsh plugin file.
# AUTHOR: Sorin Ionescu (sorin.ionescu@gmail.com)
# VERSION: 1.0.1
# ------------------------------------------------------------------------------
extract() {
local remove_archive
local success
local extract_dir
function extract() { if (( $# == 0 )); then
local remove_archive cat <<-'EOF' >&2
local success Usage: extract [-option] [file ...]
local file_name
local extract_dir
if (( $# == 0 )); then Options:
echo "Usage: extract [-option] [file ...]" -r, --remove Remove archive after unpacking.
echo EOF
echo Options: fi
echo " -r, --remove Remove archive."
echo
echo "Report bugs to <sorin.ionescu@gmail.com>."
fi
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
while (( $# > 0 )); do while (( $# > 0 )); do
if [[ ! -f "$1" ]]; then if [[ ! -f "$1" ]]; then
echo "extract: '$1' is not a valid file" 1>&2 echo "extract: '$1' is not a valid file" >&2
shift shift
continue continue
fi fi
success=0 success=0
file_name="$( basename "$1" )" extract_dir="${1:t:r}"
extract_dir="$( echo "$file_name" | sed "s/\.${1##*.}//g" )" case "${1:l}" in
case "$1" in (*.tar.gz|*.tgz) (( $+commands[pigz] )) && { pigz -dc "$1" | tar xv } || tar zxvf "$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|*.txz) tar --xz --help &> /dev/null \ tar --xz --help &> /dev/null \
&& tar --xz -xvf "$1" \ && tar --xz -xvf "$1" \
|| xzcat "$1" | tar xvf - ;; || xzcat "$1" | tar xvf - ;;
(*.tar.zma|*.tlz) tar --lzma --help &> /dev/null \ (*.tar.zma|*.tlz)
&& tar --lzma -xvf "$1" \ tar --lzma --help &> /dev/null \
|| lzcat "$1" | tar xvf - ;; && tar --lzma -xvf "$1" \
(*.tar) tar xvf "$1" ;; || lzcat "$1" | tar xvf - ;;
(*.gz) [ -z $commands[pigz] ] && gunzip "$1" || pigz -d "$1" ;; (*.tar) tar xvf "$1" ;;
(*.bz2) bunzip2 "$1" ;; (*.gz) (( $+commands[pigz] )) && pigz -d "$1" || gunzip "$1" ;;
(*.xz) unxz "$1" ;; (*.bz2) bunzip2 "$1" ;;
(*.lzma) unlzma "$1" ;; (*.xz) unxz "$1" ;;
(*.Z) uncompress "$1" ;; (*.lzma) unlzma "$1" ;;
(*.zip|*.war|*.jar|*.sublime-package|*.ipsw|*.xpi|*.apk) unzip "$1" -d $extract_dir ;; (*.z) uncompress "$1" ;;
(*.rar) unrar x -ad "$1" ;; (*.zip|*.war|*.jar|*.sublime-package|*.ipsw|*.xpi|*.apk|*.aar|*.whl) unzip "$1" -d $extract_dir ;;
(*.7z) 7za x "$1" ;; (*.rar) unrar x -ad "$1" ;;
(*.deb) (*.7z) 7za x "$1" ;;
mkdir -p "$extract_dir/control" (*.deb)
mkdir -p "$extract_dir/data" mkdir -p "$extract_dir/control"
cd "$extract_dir"; ar vx "../${1}" > /dev/null mkdir -p "$extract_dir/data"
cd control; tar xzvf ../control.tar.gz cd "$extract_dir"; ar vx "../${1}" > /dev/null
cd ../data; tar xzvf ../data.tar.gz cd control; tar xzvf ../control.tar.gz
cd ..; rm *.tar.gz debian-binary cd ../data; extract ../data.tar.*
cd .. cd ..; rm *.tar.* debian-binary
;; cd ..
(*) ;;
echo "extract: '$1' cannot be extracted" 1>&2 (*)
success=1 echo "extract: '$1' cannot be extracted" >&2
;; success=1
esac ;;
esac
(( success = $success > 0 ? $success : $? )) (( success = $success > 0 ? $success : $? ))
(( $success == 0 )) && (( $remove_archive == 0 )) && rm "$1" (( $success == 0 )) && (( $remove_archive == 0 )) && rm "$1"
shift shift
done done
} }
alias x=extract
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