Unverified Commit 8c95c523 authored by Kozlov Alexander's avatar Kozlov Alexander Committed by GitHub
Browse files

Merge branch 'master' into master

parents dd30cf10 3d8f2bda
if [[ -z $commands[thefuck] ]]; then
echo 'thefuck is not installed, you should "pip install thefuck" first'
return -1
echo 'thefuck is not installed, you should "pip install thefuck" or "brew install thefuck" first.'
echo 'See https://github.com/nvbn/thefuck#installation'
return 1
fi
# Register alias
......
# Themes Plugin
This plugin allows you to change ZSH theme on the go.
To use it, add `themes` to the plugins array in your zshrc file:
```
plugins=(... themes)
```
## Usage
`theme <theme_name>` - Changes the ZSH theme to specified theme.
`theme ` - Changes the ZSH theme to some random theme.
`lstheme ` - Lists installed ZSH themes.
......@@ -8,9 +8,9 @@ function theme
source "$RANDOM_THEME"
echo "[oh-my-zsh] Random theme '$RANDOM_THEME' loaded..."
else
if [ -f "$ZSH_CUSTOM/$1.zsh-theme" ]
if [ -f "$ZSH_CUSTOM/themes/$1.zsh-theme" ]
then
source "$ZSH_CUSTOM/$1.zsh-theme"
source "$ZSH_CUSTOM/themes/$1.zsh-theme"
else
source "$ZSH/themes/$1.zsh-theme"
fi
......@@ -19,6 +19,8 @@ function theme
function lstheme
{
cd $ZSH/themes
ls *zsh-theme | sed 's,\.zsh-theme$,,'
# Resources:
# http://zsh.sourceforge.net/Doc/Release/Expansion.html#Modifiers
# http://zsh.sourceforge.net/Doc/Release/Expansion.html#Glob-Qualifiers
print -l {$ZSH,$ZSH_CUSTOM}/themes/*.zsh-theme(N:t:r)
}
# tmux
This plugin provides aliases for [tmux](http://tmux.github.io/), the terminal multiplexer.
To use it add `tmux` to the plugins array in your zshrc file.
```zsh
plugins=(... tmux)
```
The plugin also supports the following -
- determines if tmux is installed or not, if not, prompts user to install tmux
- determines if the terminal supports the 256 colors or not, sets the appropriate configuration variable
- sets the correct local config file to use
## Aliases
| Alias | Command | Description |
| ------ | -----------------------|---------------------------------------------------------- |
| `ta` | tmux attach -t | Attach new tmux session to already running named session |
| `tad` | tmux attach -d -t | Detach named tmux session |
| `ts` | tmux new-session -s | Create a new named tmux session |
| `tl` | tmux list-sessions | Displays a list of running tmux sessions |
| `tksv` | tmux kill-server | Terminate all running tmux sessions |
| `tkss` | tmux kill-session -t | Terminate named running tmux session |
| `tmux` | `_zsh_tmux_plugin_run` | Start a new tmux session |
## Configuration Variables
| Variable | Description |
|-------------------------------------|-------------------------------------------------------------------------------|
| `ZSH_TMUX_AUTOSTART` | Automatically starts tmux (default: `false`) |
| `ZSH_TMUX_AUTOSTART_ONCE` | Autostart only if tmux hasn't been started previously (default: `true`) |
| `ZSH_TMUX_AUTOCONNECT` | Automatically connect to a previous session if it exits (default: `true`) |
| `ZSH_TMUX_AUTOQUIT` | Automatically closes terminal once tmux exits (default: `ZSH_TMUX_AUTOSTART`) |
| `ZSH_TMUX_FIXTERM` | Sets `$TERM` to 256-color term or not based on current terminal support |
| `ZSH_TMUX_ITERM2` | Sets the `-CC` option for iTerm2 tmux integration (default: `false`) |
| `ZSH_TMUX_FIXTERM_WITHOUT_256COLOR` | `$TERM` to use for non 256-color terminals (default: `screen`) |
| `ZSH_TMUX_FIXTERM_WITH_256COLOR` | `$TERM` to use for 256-color terminals (default: `screen-256color` |
#
# Aliases
#
if ! (( $+commands[tmux] )); then
print "zsh tmux plugin: tmux not found. Please install tmux before using this plugin." >&2
return 1
fi
# ALIASES
alias ta='tmux attach -t'
alias tad='tmux attach -d -t'
......@@ -9,90 +12,78 @@ alias tl='tmux list-sessions'
alias tksv='tmux kill-server'
alias tkss='tmux kill-session -t'
# Only run if tmux is actually installed
if which tmux &> /dev/null
then
# Configuration variables
#
# Automatically start tmux
[[ -n "$ZSH_TMUX_AUTOSTART" ]] || ZSH_TMUX_AUTOSTART=false
# Only autostart once. If set to false, tmux will attempt to
# autostart every time your zsh configs are reloaded.
[[ -n "$ZSH_TMUX_AUTOSTART_ONCE" ]] || ZSH_TMUX_AUTOSTART_ONCE=true
# Automatically connect to a previous session if it exists
[[ -n "$ZSH_TMUX_AUTOCONNECT" ]] || ZSH_TMUX_AUTOCONNECT=true
# Automatically close the terminal when tmux exits
[[ -n "$ZSH_TMUX_AUTOQUIT" ]] || ZSH_TMUX_AUTOQUIT=$ZSH_TMUX_AUTOSTART
# Set term to screen or screen-256color based on current terminal support
[[ -n "$ZSH_TMUX_FIXTERM" ]] || ZSH_TMUX_FIXTERM=true
# Set '-CC' option for iTerm2 tmux integration
[[ -n "$ZSH_TMUX_ITERM2" ]] || ZSH_TMUX_ITERM2=false
# The TERM to use for non-256 color terminals.
# Tmux states this should be screen, but you may need to change it on
# systems without the proper terminfo
[[ -n "$ZSH_TMUX_FIXTERM_WITHOUT_256COLOR" ]] || ZSH_TMUX_FIXTERM_WITHOUT_256COLOR="screen"
# The TERM to use for 256 color terminals.
# Tmux states this should be screen-256color, but you may need to change it on
# systems without the proper terminfo
[[ -n "$ZSH_TMUX_FIXTERM_WITH_256COLOR" ]] || ZSH_TMUX_FIXTERM_WITH_256COLOR="screen-256color"
# Get the absolute path to the current directory
local zsh_tmux_plugin_path="$(cd "$(dirname "$0")" && pwd)"
# CONFIGURATION VARIABLES
# Automatically start tmux
: ${ZSH_TMUX_AUTOSTART:=false}
# Only autostart once. If set to false, tmux will attempt to
# autostart every time your zsh configs are reloaded.
: ${ZSH_TMUX_AUTOSTART_ONCE:=true}
# Automatically connect to a previous session if it exists
: ${ZSH_TMUX_AUTOCONNECT:=true}
# Automatically close the terminal when tmux exits
: ${ZSH_TMUX_AUTOQUIT:=$ZSH_TMUX_AUTOSTART}
# Set term to screen or screen-256color based on current terminal support
: ${ZSH_TMUX_FIXTERM:=true}
# Set '-CC' option for iTerm2 tmux integration
: ${ZSH_TMUX_ITERM2:=false}
# The TERM to use for non-256 color terminals.
# Tmux states this should be screen, but you may need to change it on
# systems without the proper terminfo
: ${ZSH_TMUX_FIXTERM_WITHOUT_256COLOR:=screen}
# The TERM to use for 256 color terminals.
# Tmux states this should be screen-256color, but you may need to change it on
# systems without the proper terminfo
: ${ZSH_TMUX_FIXTERM_WITH_256COLOR:=screen-256color}
# Determine if the terminal supports 256 colors
if [[ `tput colors` == "256" ]]
then
# Determine if the terminal supports 256 colors
if [[ $(tput colors) == 256 ]]; then
export ZSH_TMUX_TERM=$ZSH_TMUX_FIXTERM_WITH_256COLOR
else
else
export ZSH_TMUX_TERM=$ZSH_TMUX_FIXTERM_WITHOUT_256COLOR
fi
fi
# Set the correct local config file to use.
if [[ "$ZSH_TMUX_ITERM2" == "false" ]] && [[ -f $HOME/.tmux.conf || -h $HOME/.tmux.conf ]]
then
#use this when they have a ~/.tmux.conf
export _ZSH_TMUX_FIXED_CONFIG="$zsh_tmux_plugin_path/tmux.extra.conf"
else
#use this when they don't have a ~/.tmux.conf
export _ZSH_TMUX_FIXED_CONFIG="$zsh_tmux_plugin_path/tmux.only.conf"
# Set the correct local config file to use.
if [[ "$ZSH_TMUX_ITERM2" == "false" && -e "$HOME/.tmux.conf" ]]; then
export _ZSH_TMUX_FIXED_CONFIG="${0:h:a}/tmux.extra.conf"
else
export _ZSH_TMUX_FIXED_CONFIG="${0:h:a}/tmux.only.conf"
fi
# Wrapper function for tmux.
function _zsh_tmux_plugin_run() {
if [[ -n "$@" ]]; then
command tmux "$@"
return $?
fi
# Wrapper function for tmux.
function _zsh_tmux_plugin_run()
{
# We have other arguments, just run them
if [[ -n "$@" ]]
then
\tmux $@
local -a tmux_cmd
tmux_cmd=(command tmux)
[[ "$ZSH_TMUX_ITERM2" == "true" ]] && tmux_cmd+=(-CC)
# Try to connect to an existing session.
elif [[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]]
then
\tmux `[[ "$ZSH_TMUX_ITERM2" == "true" ]] && echo '-CC '` attach || \tmux `[[ "$ZSH_TMUX_ITERM2" == "true" ]] && echo '-CC '` `[[ "$ZSH_TMUX_FIXTERM" == "true" ]] && echo '-f '$_ZSH_TMUX_FIXED_CONFIG` new-session
[[ "$ZSH_TMUX_AUTOQUIT" == "true" ]] && exit
# Just run tmux, fixing the TERM variable if requested.
else
\tmux `[[ "$ZSH_TMUX_ITERM2" == "true" ]] && echo '-CC '` `[[ "$ZSH_TMUX_FIXTERM" == "true" ]] && echo '-f '$_ZSH_TMUX_FIXED_CONFIG`
[[ "$ZSH_TMUX_AUTOQUIT" == "true" ]] && exit
[[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]] && $tmux_cmd attach
# If failed, just run tmux, fixing the TERM variable if requested.
if [[ $? -ne 0 ]]; then
[[ "$ZSH_TMUX_FIXTERM" == "true" ]] && tmux_cmd+=(-f "$_ZSH_TMUX_FIXED_CONFIG")
$tmux_cmd new-session
fi
}
# Use the completions for tmux for our function
compdef _tmux _zsh_tmux_plugin_run
if [[ "$ZSH_TMUX_AUTOQUIT" == "true" ]]; then
exit
fi
}
# Alias tmux to our wrapper function.
alias tmux=_zsh_tmux_plugin_run
# Use the completions for tmux for our function
compdef _tmux _zsh_tmux_plugin_run
# Alias tmux to our wrapper function.
alias tmux=_zsh_tmux_plugin_run
# Autostart if not already in tmux and enabled.
if [[ ! -n "$TMUX" && "$ZSH_TMUX_AUTOSTART" == "true" ]]
then
# Autostart if not already in tmux and enabled.
if [[ -z "$TMUX" && "$ZSH_TMUX_AUTOSTART" == "true" && -z "$INSIDE_EMACS" && -z "$EMACS" && -z "$VIM" ]]; then
# Actually don't autostart if we already did and multiple autostarts are disabled.
if [[ "$ZSH_TMUX_AUTOSTART_ONCE" == "false" || "$ZSH_TMUX_AUTOSTARTED" != "true" ]]
then
if [[ "$ZSH_TMUX_AUTOSTART_ONCE" == "false" || "$ZSH_TMUX_AUTOSTARTED" != "true" ]]; then
export ZSH_TMUX_AUTOSTARTED=true
_zsh_tmux_plugin_run
fi
fi
else
print "zsh tmux plugin: tmux not found. Please install tmux before using this plugin."
fi
# Tmuxinator plugin
This plugin provides completion for [tmuxinator](https://github.com/tmuxinator/tmuxinator),
as well as aliases for frequent tmuxinator commands.
To use it add `tmuxinator` to the plugins array in your zshrc file.
```zsh
plugins=(... tmuxinator)
```
## Aliases
| Alias | Command | Description |
| ------ | ---------------- | ------------------------ |
| `txs ` | tmuxinator start | Start Tmuxinator |
| `txo ` | tmuxinator open | Open project for editing |
| `txn ` | tmuxinator new | Create project |
| `txl ` | tmuxinator list | List projects |
#compdef tmuxinator mux
#autoload
_tmuxinator() {
local commands projects
commands=(${(f)"$(tmuxinator commands zsh)"})
projects=(${(f)"$(tmuxinator completions start)"})
local curcontext="$curcontext" state line ret=1
local -a _configs
_arguments -C \
'1: :->cmds' \
'2:: :->args' && ret=0
_configs=(${$(echo ~/.tmuxinator/*.yml):r:t})
case $state in
cmds)
_values "tmuxinator command" \
"new[create a new project file and open it in your editor]" \
"start[start a tmux session using project's tmuxinator config]" \
"open[create a new project file and open it in your editor]" \
"copy[copy source_project project file to a new project called new_project]" \
"delete[deletes the project called project_name]" \
"debug[output the shell commands generated by a projet]" \
"implode[deletes all existing projects!]" \
"list[list all existing projects]" \
"doctor[look for problems in your configuration]" \
"help[shows this help document]" \
"version[shows tmuxinator version number]" \
$_configs
ret=0
;;
args)
case $line[1] in
start|open|copy|delete|debug)
[[ -n "$_configs" ]] && _values 'configs' $_configs
ret=0
if (( CURRENT == 2 )); then
_describe -t commands "tmuxinator subcommands" commands
_describe -t projects "tmuxinator projects" projects
elif (( CURRENT == 3)); then
case $words[2] in
copy|debug|delete|open|start)
_arguments '*:projects:($projects)'
;;
esac
;;
esac
fi
return
}
return ret
compdef _tmuxinator tmuxinator mux
alias mux="tmuxinator"
# aliases
alias txs='tmuxinator start'
alias txo='tmuxinator open'
alias txn='tmuxinator new'
alias txl='tmuxinator list'
# `transfer` plugin
[`transfer.sh`](https://transfer.sh) is an easy to use file sharing service from the command line
## Usage
Add `transfer` to your plugins array in your zshrc file:
```zsh
plugins=(... transfer)
```
Then you can:
- transfer a file:
```zsh
transfer file.txt
```
- transfer a whole directory (it will be automatically compressed):
```zsh
transfer directory/
```
# transfer.sh Easy file sharing from the command line
# transfer Plugin
# Usage Example :
# > transfer file.txt
# > transfer directory/
# Author:
# Remco Verhoef <remco@dutchcoders.io>
# https://gist.github.com/nl5887/a511f172d3fb3cd0e42d
# Modified to use tar command instead of zip
#
curl --version 2>&1 > /dev/null
if [ $? -ne 0 ]; then
echo "Could not find curl."
return 1
fi
transfer() {
# check arguments
if [ $# -eq 0 ];
then
echo "No arguments specified. Usage:\necho transfer /tmp/test.md\ncat /tmp/test.md | transfer test.md"
return 1
fi
# get temporarily filename, output is written to this file show progress can be showed
tmpfile=$( mktemp -t transferXXX )
# upload stdin or file
file=$1
if tty -s;
then
basefile=$(basename "$file" | sed -e 's/[^a-zA-Z0-9._-]/-/g')
if [ ! -e $file ];
then
echo "File $file doesn't exists."
return 1
fi
if [ -d $file ];
then
echo $file
# tar directory and transfer
tarfile=$( mktemp -t transferXXX.tar.gz )
cd $(dirname $file) && tar -czf $tarfile $(basename $file)
curl --progress-bar --upload-file "$tarfile" "https://transfer.sh/$basefile.tar.gz" >> $tmpfile
rm -f $tarfile
else
# transfer file
curl --progress-bar --upload-file "$file" "https://transfer.sh/$basefile" >> $tmpfile
fi
else
# transfer pipe
curl --progress-bar --upload-file "-" "https://transfer.sh/$file" >> $tmpfile
fi
# cat output link
cat $tmpfile
# cleanup
rm -f $tmpfile
}
\ No newline at end of file
# Ubuntu plugin
This plugin adds completions and aliases for [Ubuntu](https://www.ubuntu.com/).
To use it, add `ubuntu` to the plugins array in your zshrc file:
```zsh
plugins=(... ubuntu)
```
## Aliases
Commands that use `$APT` will use apt if installed or defer to apt-get otherwise.
| Alias | Command | Description |
|---------|------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------|
| acs | `apt-cache search` | Search the apt-cache with the specified criteria |
| acp | `apt-cache policy` | Display the package source priorities |
| afs | `apt-file search --regexp` | Perform a regular expression apt-file search |
| afu | `sudo apt-file update` | Generates or updates the apt-file package database |
| ag | `sudo $APT` | Run apt-get with sudo |
| aga | `sudo $APT autoclean` | Clears out the local reposityory of retrieved package files that can no longer be downloaded |
| agb | `sudo $APT build-dep <source_pkg>` | Installs/Removes packages to satisfy the dependencies of a specified build pkg |
| agc | `sudo $APT clean` | Clears out the local repository of retrieved package files leaving everything from the lock files |
| agd | `sudo $APT dselect-upgrade` | Follows dselect choices for package installation |
| agi | `sudo $APT install <pkg>` | Install the specified package |
| agli | `apt list --installed` | List the installed packages |
| aglu | `sudo apt-get -u upgrade --assume-no` | Run an apt-get upgrade assuming no to all prompts |
| agp | `sudo $APT purge <pkg>` | Remove a package including any configuration files |
| agr | `sudo $APT remove <pkg>` | Remove a package |
| ags | `$APT source <pkg>` | Fetch the source for the specified package |
| agu | `sudo $APT update` | Update package list |
| agud | `sudo $APT update && sudo $APT dist-upgrade` | Update packages list and perform a distribution upgrade |
| agug | `sudo $APT upgrade` | Upgrade available packages |
| agar | `sudo $APT autoremove` | Remove automatically installed packages no longer needed |
| aguu | `sudo $APT update && sudo $APT upgrade` | Update packages list and upgrade available packages |
| allpkgs | `dpkg --get-selections \| grep -v deinstall` | Print all installed packages |
| kclean | `sudo aptitude remove -P ?and(~i~nlinux-(ima\|hea) ?not(~n$(uname -r)))` |Remove ALL kernel images and headers EXCEPT the one in use |
| mydeb | `time dpkg-buildpackage -rfakeroot -us -uc` | Create a basic .deb package |
| ppap | `sudo ppa-purge <ppa>` | Remove the specified PPA |
## Functions
| Function | Usage |Description |
|-------------------|---------------------------------------|--------------------------------------------------------------------------|
| aar | `aar ppa:xxxxxx/xxxxxx [packagename]` | apt-add-repository with automatic install/upgrade of the desired package |
| apt-history | `apt-history <action>` | Prints the Apt history of the specified action |
| apt-list-packages | `apt-list-packages` | List packages by size |
| kerndeb | `kerndeb` | Kernel-package building shortcut |
This plugin was created because the aliases in the debian plugin are inconsistent and hard to remember. Also this apt-priority detection that switched between apt-get and aptitude was dropped to keep it simpler. This plugin uses apt-get for everything but a few things that are only possible with aptitude I guess. Ubuntu does not have aptitude installed by default.
acs = Apt-Cache Search
acp = Apt-Cache Policy
ag = sudo Apt-Get
agi = sudo Apt-Get Install
agd = sudo Apt-Get Dselect-upgrade
By now you already can guess almost all aliases
There are two exeptions since ...
agu = sudo Apt-Get Update - we have ...
agug = sudo Apt-Get UpGrade - as the exceptional 4 letter alias for a single command.
afs = Apt-File Search --regexp - this has the regexp switch on without being represented in the alias, I guess this makes sense since the debian plugin has it, I never used that command.
Then there are the 2 other 4 letter aliases for combined commands, that are straight forward and easy to remember.
aguu = sudo Apt-Get Update && sudo apt-get Upgrade - better then adg or not?
agud = sudo Apt-Get Update && sudo apt-get full-upgrade
For a full list aliases and the functions just watch the plugins code https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/ubuntu/ubuntu.plugin.zsh, look at the comments if you want to switch from the debian plugin. Ubuntu, Mint and & co users will like the new aar function to install packages from ppas with a single command.
......@@ -5,18 +5,21 @@
# https://github.com/trinaldi
# Nicolas Jonas nextgenthemes.com
# https://github.com/loctauxphilippe
# https://github.com/HaraldNordgren
#
# Debian, Ubuntu and friends related zsh aliases and functions for zsh
(( $+commands[apt] )) && APT=apt || APT=apt-get
alias acs='apt-cache search'
compdef _acs acs='apt-cache search'
alias afs='apt-file search --regexp'
compdef _afs afs='apt-file search --regexp'
# These are apt-get only
alias ags='apt-get source' # asrc
compdef _ags ags='apt-get source'
# These are apt/apt-get only
alias ags="$APT source" # asrc
compdef _ags ags="$APT source"
alias acp='apt-cache policy' # app
compdef _acp acp='apt-cache policy'
......@@ -37,33 +40,33 @@ compdef _afu afu='sudo apt-file update'
alias ppap='sudo ppa-purge'
compdef _ppap ppap='sudo ppa-purge'
alias apg='sudo apt-get' # age - but without sudo
alias aga='sudo apt-get autoclean' # aac
alias agb='sudo apt-get build-dep' # abd
alias agc='sudo apt-get clean' # adc
alias agd='sudo apt-get dselect-upgrade' # ads
alias agi='sudo apt-get install' # ai
alias agp='sudo apt-get purge' # ap
alias agr='sudo apt-get remove' # ar
alias agu='sudo apt-get update' # ad
alias agud='sudo apt-get update && sudo apt-get full-upgrade' #adu
alias agug='sudo apt-get upgrade' # ag
alias aguu='sudo apt-get update && sudo apt-get upgrade' #adg
alias agar='sudo apt-get autoremove'
compdef _ag apg='sudo apt-get'
compdef _aga aga='sudo apt-get autoclean'
compdef _agb agb='sudo apt-get build-dep'
compdef _agc agc='sudo apt-get clean'
compdef _agd agd='sudo apt-get dselect-upgrade'
compdef _agi agi='sudo apt-get install'
compdef _agp agp='sudo apt-get purge'
compdef _agr agr='sudo apt-get remove'
compdef _agu agu='sudo apt-get update'
compdef _agud agud='sudo apt-get update && sudo apt-get full-upgrade'
compdef _agug agug='sudo apt-get upgrade'
compdef _aguu aguu='sudo apt-get update && sudo apt-get upgrade'
compdef _agar agar='sudo apt-get autoremove'
alias ag="sudo $APT" # age - but without sudo
alias aga="sudo $APT autoclean" # aac
alias agb="sudo $APT build-dep" # abd
alias agc="sudo $APT clean" # adc
alias agd="sudo $APT dselect-upgrade" # ads
alias agi="sudo $APT install" # ai
alias agp="sudo $APT purge" # ap
alias agr="sudo $APT remove" # ar
alias agu="sudo $APT update" # ad
alias agud="sudo $APT update && sudo $APT dist-upgrade" #adu
alias agug="sudo $APT upgrade" # ag
alias aguu="sudo $APT update && sudo $APT upgrade" #adg
alias agar="sudo $APT autoremove"
compdef _ag ag="sudo $APT"
compdef _aga aga="sudo $APT autoclean"
compdef _agb agb="sudo $APT build-dep"
compdef _agc agc="sudo $APT clean"
compdef _agd agd="sudo $APT dselect-upgrade"
compdef _agi agi="sudo $APT install"
compdef _agp agp="sudo $APT purge"
compdef _agr agr="sudo $APT remove"
compdef _agu agu="sudo $APT update"
compdef _agud agud="sudo $APT update && sudo $APT dist-upgrade"
compdef _agug agug="sudo $APT upgrade"
compdef _aguu aguu="sudo $APT update && sudo $APT upgrade"
compdef _agar agar="sudo $APT autoremove"
# Remove ALL kernel images and headers EXCEPT the one in use
alias kclean='sudo aptitude remove -P ?and(~i~nlinux-(ima|hea) \
......@@ -91,8 +94,8 @@ aar() {
PACKAGE=${1##*/}
fi
sudo apt-add-repository $1 && sudo apt-get update
sudo apt-get install $PACKAGE
sudo apt-add-repository $1 && sudo $APT update
sudo $APT install $PACKAGE
}
# Prints apt history
......@@ -102,7 +105,7 @@ aar() {
# apt-history remove
# apt-history rollback
# apt-history list
# Based On: http://linuxcommando.blogspot.com/2008/08/how-to-show-apt-log-history.html
# Based On: https://linuxcommando.blogspot.com/2008/08/how-to-show-apt-log-history.html
apt-history () {
case "$1" in
install)
......
#compdef ufw
#autoload
typeset -A opt_args
function _ufw_delete_rules {
if ufw status &> /dev/null ; then
ufw status numbered \
| perl -n -e'/\[ +(\d+)\] +([^ ].+)/ && print "\"$1\[$2\]\" "'
fi
}
function _ufw_app_profiles {
grep -rhoP "(?<=\[)[^\]]+" /etc/ufw/applications.d/ \
| awk '{ print "\""$0"\""}' \
| tr '\n' ' '
}
local -a _1st_arguments
_1st_arguments=(
'allow:add allow rule'
'app:Application profile commands'
'default:set default policy'
'delete:delete RULE'
'deny:add deny rule'
'disable:disables the firewall'
'enable:enables the firewall'
'insert:insert RULE at NUM'
'limit:add limit rule'
'logging:set logging to LEVEL'
'reject:add reject rule'
'reload:reloads firewall'
'reset:reset firewall'
'show:show firewall report'
'status:show firewall status'
'version:display version information'
)
local context state line curcontext="$curcontext"
_arguments -C \
'(--dry-run)--dry-run[dry run]' \
'1:: :->cmds' \
'2:: :->subcmds' \
'3:: :->subsubcmds' \
&& return 0
local rules
case "$state" in
(cmds)
_describe -t commands "ufw commands" _1st_arguments
return 0
;;
(subcmds)
case "$line[1]" in
(app)
_values 'app' \
'list[list application profiles]' \
'info[show information on PROFILE]' \
'update[update PROFILE]' \
'default[set default application policy]' \
&& ret=0
;;
(status)
_values 'status' \
'numbered[show firewall status as numbered list of RULES]' \
'verbose[show verbose firewall status]' \
&& ret=0
;;
(logging)
_values 'logging' \
'on' 'off' 'low' 'medium' 'high' 'full' \
&& ret=0
;;
(default)
_values 'default' \
'allow' 'deny' 'reject' \
&& ret=0
;;
(show)
_values 'show' \
'raw' 'builtins' 'before-rules' 'user-rules' 'after-rules' 'logging-rules' 'listening' 'added' \
&& ret=0
;;
(delete)
rules="$(_ufw_delete_rules)"
if [[ -n "$rules" ]] ; then
_values 'delete' \
${(Q)${(z)"$(_ufw_delete_rules)"}} \
&& ret=0
fi
;;
esac
;;
(subsubcmds)
case "$line[1]" in
(app)
case "$line[2]" in
(info|update)
_values 'profiles' \
${(Q)${(z)"$(_ufw_app_profiles)"}} \
&& ret=0
;;
esac
;;
(default)
_values 'default-direction' \
'incoming' 'outgoing' \
&& ret=0
;;
esac
esac
return
# URLTools plugin
This plugin provides two aliases to URL-encode and URL-decode strings.
To start using it, add the `urltools` plugin to your plugins array in `~/.zshrc`:
```zsh
plugins=(... urltools)
```
Original author: [Ian Chesal](https://github.com/ianchesal)
Original idea and aliases: [Ruslan Spivak](https://ruslanspivak.wordpress.com/2010/06/02/urlencode-and-urldecode-from-a-command-line/)
## Commands
| Command | Description |
| :---------- | :--------------------------- |
| `urlencode` | URL-encodes the given string |
| `urldecode` | URL-decodes the given string |
## Examples
```zsh
urlencode 'https://github.com/robbyrussell/oh-my-zsh/search?q=urltools&type=Code'
# returns https%3A%2F%2Fgithub.com%2Frobbyrussell%2Foh-my-zsh%2Fsearch%3Fq%3Durltools%26type%3DCode
urldecode 'https%3A%2F%2Fgithub.com%2Frobbyrussell%2Foh-my-zsh%2Fsearch%3Fq%3Durltools%26type%3DCode'
# returns https://github.com/robbyrussell/oh-my-zsh/search?q=urltools&type=Code
```
......@@ -2,7 +2,7 @@
# Adds handy command line aliases useful for dealing with URLs
#
# Taken from:
# http://ruslanspivak.com/2010/06/02/urlencode-and-urldecode-from-a-command-line/
# https://ruslanspivak.com/2010/06/02/urlencode-and-urldecode-from-a-command-line/
if [[ $(whence $URLTOOLS_METHOD) = "" ]]; then
URLTOOLS_METHOD=""
......
This plugin prompts the status of the Vagrant VMs. It supports single-host and
multi-host configurations as well.
Look inside the source for documentation about custom variables.
Alberto Re <alberto.re@gmail.com>
# vim:ft=zsh ts=2 sw=2 sts=2
#
# To display Vagrant infos on your prompt add the vagrant_prompt_info to the
# $PROMPT variable in your theme. Example:
#
# PROMPT='%{$fg[$NCOLOR]%}%B%n%b%{$reset_color%}:%{$fg[blue]%}%B%c/%b%{$reset_color%} $(vagrant_prompt_info)$(svn_prompt_info)$(git_prompt_info)%(!.#.$) '
#
# `vagrant_prompt_info` makes use of some custom variables. This is an example
# definition:
#
# ZSH_THEME_VAGRANT_PROMPT_PREFIX="%{$fg_bold[blue]%}["
# ZSH_THEME_VAGRANT_PROMPT_SUFFIX="%{$fg_bold[blue]%}]%{$reset_color%} "
# ZSH_THEME_VAGRANT_PROMPT_RUNNING="%{$fg_no_bold[green]%}●"
# ZSH_THEME_VAGRANT_PROMPT_POWEROFF="%{$fg_no_bold[red]%}●"
# ZSH_THEME_VAGRANT_PROMPT_SUSPENDED="%{$fg_no_bold[yellow]%}●"
# ZSH_THEME_VAGRANT_PROMPT_NOT_CREATED="%{$fg_no_bold[white]%}○"
function vagrant_prompt_info() {
test -d .vagrant && test -f Vagrantfile
if [[ "$?" == "0" ]]; then
statuses=$(vagrant status 2> /dev/null | grep -P "\w+\s+[\w\s]+\s\(\w+\)")
statuses=("${(f)statuses}")
printf '%s' $ZSH_THEME_VAGRANT_PROMPT_PREFIX
for vm_details in $statuses; do
vm_state=$(echo $vm_details | grep -o -E "saved|poweroff|not created|running")
if [[ "$vm_state" == "running" ]]; then
printf '%s' $ZSH_THEME_VAGRANT_PROMPT_RUNNING
elif [[ "$vm_state" == "saved" ]]; then
printf '%s' $ZSH_THEME_VAGRANT_PROMPT_SUSPENDED
elif [[ "$vm_state" == "not created" ]]; then
printf '%s' $ZSH_THEME_VAGRANT_PROMPT_NOT_CREATED
elif [[ "$vm_state" == "poweroff" ]]; then
printf '%s' $ZSH_THEME_VAGRANT_PROMPT_POWEROFF
fi
done
printf '%s' $ZSH_THEME_VAGRANT_PROMPT_SUFFIX
fi
}
# Vagrant plugin
This plugin adds autocompletion for [Vagrant](https://www.vagrantup.com/) commands, task names, box names and built-in handy documentation.
To use it, add `vagrant` to the plugins array in your zshrc file:
```zsh
plugins=(... vagrant)
```
......@@ -22,7 +22,7 @@ _1st_arguments=(
'push:Deploys code in this environment to a configured destination'
'rdp:Connects to machine via RDP'
'reload:Reload the vagrant environment'
'resume:Resumes a suspend vagrant environment'
'resume:Resumes a suspended vagrant environment'
'rsync:Syncs rsync synced folders to remote machine'
'rsync-auto:Syncs rsync synced folders automatically when files change'
'share:Shares your Vagrant environment with anyone in the world'
......@@ -81,7 +81,7 @@ __vagrant-box ()
case $state in
(command)
_describe -t commands "gem subcommand" _box_arguments
_describe -t commands "vagrant subcommand" _box_arguments
return
;;
......@@ -110,7 +110,7 @@ _arguments -C \
case $state in
(command)
_describe -t commands "gem subcommand" _1st_arguments
_describe -t commands "vagrant subcommand" _1st_arguments
return
;;
......
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