mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-02-13 03:01:32 +01:00
Merge form upstream
This commit is contained in:
commit
754bfcc356
121 changed files with 4237 additions and 353 deletions
|
|
@ -1,3 +1,5 @@
|
|||
!https://s3.amazonaws.com/ohmyzsh/oh-my-zsh-logo.png!
|
||||
|
||||
oh-my-zsh is an open source, community-driven framework for managing your ZSH configuration. It comes bundled with a ton of helpful functions, helpers, plugins, themes, and few things that make you shout...
|
||||
|
||||
bq. "OH MY ZSHELL!"
|
||||
|
|
@ -12,11 +14,11 @@ You can install this via the command line with either `curl` or `wget`.
|
|||
|
||||
h4. via `curl`
|
||||
|
||||
@curl -L https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh | sh@
|
||||
@curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh@
|
||||
|
||||
h4. via `wget`
|
||||
|
||||
@wget --no-check-certificate https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh@
|
||||
@wget --no-check-certificate https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O - | sh@
|
||||
|
||||
h3. The manual way
|
||||
|
||||
|
|
|
|||
|
|
@ -13,8 +13,18 @@ alias please='sudo'
|
|||
#alias g='grep -in'
|
||||
|
||||
# Show history
|
||||
alias history='fc -l 1'
|
||||
|
||||
if [ "$HIST_STAMPS" = "mm/dd/yyyy" ]
|
||||
then
|
||||
alias history='fc -fl 1'
|
||||
elif [ "$HIST_STAMPS" = "dd.mm.yyyy" ]
|
||||
then
|
||||
alias history='fc -El 1'
|
||||
elif [ "$HIST_STAMPS" = "yyyy-mm-dd" ]
|
||||
then
|
||||
alias history='fc -il 1'
|
||||
else
|
||||
alias history='fc -l 1'
|
||||
fi
|
||||
# List direcory contents
|
||||
alias lsa='ls -lah'
|
||||
alias l='ls -la'
|
||||
|
|
|
|||
10
lib/bzr.zsh
Normal file
10
lib/bzr.zsh
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
## Bazaar integration
|
||||
## Just works with the GIT integration just add $(bzr_prompt_info) to the PROMPT
|
||||
function bzr_prompt_info() {
|
||||
BZR_CB=`bzr nick 2> /dev/null | grep -v "ERROR" | cut -d ":" -f2 | awk -F / '{print "bzr::"$1}'`
|
||||
if [ -n "$BZR_CB" ]; then
|
||||
BZR_DIRTY=""
|
||||
[[ -n `bzr status` ]] && BZR_DIRTY=" %{$fg[red]%} * %{$fg[green]%}"
|
||||
echo "$ZSH_THEME_SCM_PROMPT_PREFIX$BZR_CB$BZR_DIRTY$ZSH_THEME_GIT_PROMPT_SUFFIX"
|
||||
fi
|
||||
}
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
autoload -U edit-command-line
|
||||
zle -N edit-command-line
|
||||
bindkey '\C-x\C-e' edit-command-line
|
||||
|
|
@ -15,3 +15,61 @@ function take() {
|
|||
cd $1
|
||||
}
|
||||
|
||||
#
|
||||
# Get the value of an alias.
|
||||
#
|
||||
# Arguments:
|
||||
# 1. alias - The alias to get its value from
|
||||
# STDOUT:
|
||||
# The value of alias $1 (if it has one).
|
||||
# Return value:
|
||||
# 0 if the alias was found,
|
||||
# 1 if it does not exist
|
||||
#
|
||||
function alias_value() {
|
||||
alias "$1" | sed "s/^$1='\(.*\)'$/\1/"
|
||||
test $(alias "$1")
|
||||
}
|
||||
|
||||
#
|
||||
# Try to get the value of an alias,
|
||||
# otherwise return the input.
|
||||
#
|
||||
# Arguments:
|
||||
# 1. alias - The alias to get its value from
|
||||
# STDOUT:
|
||||
# The value of alias $1, or $1 if there is no alias $1.
|
||||
# Return value:
|
||||
# Always 0
|
||||
#
|
||||
function try_alias_value() {
|
||||
alias_value "$1" || echo "$1"
|
||||
}
|
||||
|
||||
#
|
||||
# Set variable "$1" to default value "$2" if "$1" is not yet defined.
|
||||
#
|
||||
# Arguments:
|
||||
# 1. name - The variable to set
|
||||
# 2. val - The default value
|
||||
# Return value:
|
||||
# 0 if the variable exists, 3 if it was set
|
||||
#
|
||||
function default() {
|
||||
test `typeset +m "$1"` && return 0
|
||||
typeset -g "$1"="$2" && return 3
|
||||
}
|
||||
|
||||
#
|
||||
# Set enviroment variable "$1" to default value "$2" if "$1" is not yet defined.
|
||||
#
|
||||
# Arguments:
|
||||
# 1. name - The env variable to set
|
||||
# 2. val - The default value
|
||||
# Return value:
|
||||
# 0 if the env variable exists, 3 if it was set
|
||||
#
|
||||
function env_default() {
|
||||
env | grep -q "^$1=" && return 0
|
||||
export "$1=$2" && return 3
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
# get the name of the branch we are on
|
||||
function git_prompt_info() {
|
||||
ref=$(command git symbolic-ref HEAD 2> /dev/null) || \
|
||||
ref=$(command git rev-parse --short HEAD 2> /dev/null) || return
|
||||
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX"
|
||||
if [[ "$(git config --get oh-my-zsh.hide-status)" != "1" ]]; then
|
||||
ref=$(command git symbolic-ref HEAD 2> /dev/null) || \
|
||||
ref=$(command git rev-parse --short HEAD 2> /dev/null) || return
|
||||
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,11 @@ bindkey "^[[3~" delete-char
|
|||
bindkey "^[3;5~" delete-char
|
||||
bindkey "\e[3~" delete-char
|
||||
|
||||
# Edit the current command line in $EDITOR
|
||||
autoload -U edit-command-line
|
||||
zle -N edit-command-line
|
||||
bindkey '\C-x\C-e' edit-command-line
|
||||
|
||||
# consider emacs keybindings:
|
||||
|
||||
#bindkey -e ## emacs key bindings
|
||||
|
|
|
|||
9
lib/nvm.zsh
Normal file
9
lib/nvm.zsh
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# get the node.js version
|
||||
function nvm_prompt_info() {
|
||||
[ -f $HOME/.nvm/nvm.sh ] || return
|
||||
local nvm_prompt
|
||||
nvm_prompt=$(node -v 2>/dev/null)
|
||||
[[ "${nvm_prompt}x" == "x" ]] && return
|
||||
nvm_prompt=${nvm_prompt:1}
|
||||
echo "${ZSH_THEME_NVM_PROMPT_PREFIX}${nvm_prompt}${ZSH_THEME_NVM_PROMPT_SUFFIX}"
|
||||
}
|
||||
|
|
@ -26,3 +26,10 @@ function spectrum_ls() {
|
|||
done
|
||||
}
|
||||
|
||||
# Show all 256 colors where the background is set to specific color
|
||||
function spectrum_bls() {
|
||||
for code in {000..255}; do
|
||||
((cc = code + 1))
|
||||
print -P -- "$BG[$code]$code: Test %{$reset_color%}"
|
||||
done
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,10 @@ then
|
|||
# On NetBSD, test if "gls" (GNU ls) is installed (this one supports colors);
|
||||
# otherwise, leave ls as is, because NetBSD's ls doesn't support -G
|
||||
gls --color -d . &>/dev/null 2>&1 && alias ls='gls --color=tty'
|
||||
elif [[ "$(uname -s)" == "OpenBSD" ]]; then
|
||||
# On OpenBSD, test if "colorls" is installed (this one supports colors);
|
||||
# otherwise, leave ls as is, because OpenBSD's ls doesn't support -G
|
||||
colorls -G -d . &>/dev/null 2>&1 && alias ls='colorls -G'
|
||||
else
|
||||
ls --color -d . &>/dev/null 2>&1 && alias ls='ls --color=tty' || alias ls='ls -G'
|
||||
fi
|
||||
|
|
|
|||
29
oh-my-zsh.sh
29
oh-my-zsh.sh
|
|
@ -1,6 +1,5 @@
|
|||
# Check for updates on initial load...
|
||||
if [ "$DISABLE_AUTO_UPDATE" != "true" ]
|
||||
then
|
||||
if [ "$DISABLE_AUTO_UPDATE" != "true" ]; then
|
||||
/usr/bin/env ZSH=$ZSH DISABLE_UPDATE_PROMPT=$DISABLE_UPDATE_PROMPT zsh $ZSH/tools/check_for_upgrade.sh
|
||||
fi
|
||||
|
||||
|
|
@ -38,10 +37,20 @@ for plugin ($plugins); do
|
|||
fi
|
||||
done
|
||||
|
||||
# Figure out the SHORT hostname
|
||||
if [ -n "$commands[scutil]" ]; then
|
||||
# OS X
|
||||
SHORT_HOST=$(scutil --get ComputerName)
|
||||
else
|
||||
SHORT_HOST=${HOST/.*/}
|
||||
fi
|
||||
|
||||
# Save the location of the current completion dump file.
|
||||
ZSH_COMPDUMP="${ZDOTDIR:-${HOME}}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}"
|
||||
|
||||
# Load and run compinit
|
||||
autoload -U compinit
|
||||
compinit -i
|
||||
|
||||
compinit -i -d "${ZSH_COMPDUMP}"
|
||||
|
||||
# Load all of the plugins that were defined in ~/.zshrc
|
||||
for plugin ($plugins); do
|
||||
|
|
@ -59,8 +68,7 @@ done
|
|||
unset config_file
|
||||
|
||||
# Load the theme
|
||||
if [ "$ZSH_THEME" = "random" ]
|
||||
then
|
||||
if [ "$ZSH_THEME" = "random" ]; then
|
||||
themes=($ZSH/themes/*zsh-theme)
|
||||
N=${#themes[@]}
|
||||
((N=(RANDOM%N)+1))
|
||||
|
|
@ -68,13 +76,10 @@ then
|
|||
source "$RANDOM_THEME"
|
||||
echo "[oh-my-zsh] Random theme '$RANDOM_THEME' loaded..."
|
||||
else
|
||||
if [ ! "$ZSH_THEME" = "" ]
|
||||
then
|
||||
if [ -f "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme" ]
|
||||
then
|
||||
if [ ! "$ZSH_THEME" = "" ]; then
|
||||
if [ -f "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme" ]; then
|
||||
source "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme"
|
||||
elif [ -f "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme" ]
|
||||
then
|
||||
elif [ -f "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme" ]; then
|
||||
source "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme"
|
||||
else
|
||||
source "$ZSH/themes/$ZSH_THEME.zsh-theme"
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ if [ $commands[autojump] ]; then # check if autojump is installed
|
|||
. /etc/profile.d/autojump.zsh
|
||||
elif [ -f /etc/profile.d/autojump.sh ]; then # gentoo installation
|
||||
. /etc/profile.d/autojump.sh
|
||||
elif [ -f /usr/local/share/autojump/autojump.zsh ]; then # freebsd installation
|
||||
. /usr/local/share/autojump/autojump.zsh
|
||||
elif [ -f $HOME/.autojump/etc/profile.d/autojump.zsh ]; then # manual user-local installation
|
||||
. $HOME/.autojump/etc/profile.d/autojump.zsh
|
||||
elif [ -f /opt/local/etc/profile.d/autojump.zsh ]; then # mac os x with ports
|
||||
|
|
|
|||
32
plugins/autopep8/_autopep8
Normal file
32
plugins/autopep8/_autopep8
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#compdef autopep8
|
||||
#
|
||||
# this is zsh completion function file.
|
||||
# generated by genzshcomp(ver: 0.5.1)
|
||||
#
|
||||
|
||||
typeset -A opt_args
|
||||
local context state line
|
||||
|
||||
_arguments -s -S \
|
||||
"--help[show this help message and exit]:" \
|
||||
"-h[show this help message and exit]:" \
|
||||
"--version[show program's version number and exit]:" \
|
||||
"--verbose[print verbose messages; multiple -v result in more verbose messages]" \
|
||||
"-v[print verbose messages; multiple -v result in more verbose messages]" \
|
||||
"--diff[print the diff for the fixed source]" \
|
||||
"-d[print the diff for the fixed source]" \
|
||||
"--in-place[make changes to files in place]" \
|
||||
"-i[make changes to files in place]" \
|
||||
"--recursive[run recursively; must be used with --in-place or --diff]" \
|
||||
"-r[run recursively; must be used with --in-place or --diff]" \
|
||||
"--jobs[number of parallel jobs; match CPU count if value is less than 1]::n number of parallel jobs; match CPU count if value is:_files" \
|
||||
"-j[number of parallel jobs; match CPU count if value is less than 1]::n number of parallel jobs; match CPU count if value is:_files" \
|
||||
"--pep8-passes[maximum number of additional pep8 passes (default: 100)]::n:_files" \
|
||||
"-p[maximum number of additional pep8 passes (default: 100)]::n:_files" \
|
||||
"-a[-a result in more aggressive changes]::result:_files" \
|
||||
"--exclude[exclude files/directories that match these comma- separated globs]::globs:_files" \
|
||||
"--list-fixes[list codes for fixes; used by --ignore and --select]" \
|
||||
"--ignore[do not fix these errors/warnings (default E226,E24)]::errors:_files" \
|
||||
"--select[fix only these errors/warnings (e.g. E4,W)]::errors:_files" \
|
||||
"--max-line-length[set maximum allowed line length (default: 79)]::n:_files" \
|
||||
"*::args:_files"
|
||||
0
plugins/autopep8/autopep8.plugin.zsh
Normal file
0
plugins/autopep8/autopep8.plugin.zsh
Normal file
|
|
@ -79,4 +79,14 @@ elif [[ $(uname) == "Linux" ]] ; then
|
|||
echo "∞"
|
||||
fi
|
||||
}
|
||||
else
|
||||
# Empty functions so we don't cause errors in prompts
|
||||
function battery_pct_remaining() {
|
||||
}
|
||||
|
||||
function battery_time_remaining() {
|
||||
}
|
||||
|
||||
function battery_pct_prompt() {
|
||||
}
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -2,37 +2,80 @@ alias bi="bower install"
|
|||
alias bl="bower list"
|
||||
alias bs="bower search"
|
||||
|
||||
bower_package_list=''
|
||||
|
||||
_bower_installed_packages () {
|
||||
bower_package_list=$(bower ls --no-color 2>/dev/null| awk 'NR>3{print p}{p=$0}'| cut -d ' ' -f 2|sed 's/#.*//')
|
||||
}
|
||||
_bower ()
|
||||
{
|
||||
local curcontext="$curcontext" state line
|
||||
typeset -A opt_args
|
||||
local -a _1st_arguments _no_color _dopts _save_dev _force_lastest _production
|
||||
local expl
|
||||
typeset -A opt_args
|
||||
|
||||
_arguments -C \
|
||||
':command:->command' \
|
||||
'*::options:->options'
|
||||
_no_color=('--no-color[Do not print colors (available in all commands)]')
|
||||
|
||||
case $state in
|
||||
(command)
|
||||
_dopts=(
|
||||
'(--save)--save[Save installed packages into the project"s bower.json dependencies]'
|
||||
'(--force)--force[Force fetching remote resources even if a local copy exists on disk]'
|
||||
)
|
||||
|
||||
local -a subcommands
|
||||
subcommands=(${=$(bower help | grep help | sed -e 's/,//g')})
|
||||
_describe -t commands 'bower' subcommands
|
||||
;;
|
||||
_save_dev=('(--save-dev)--save-dev[Save installed packages into the project"s bower.json devDependencies]')
|
||||
|
||||
(options)
|
||||
case $line[1] in
|
||||
_force_lastest=('(--force-latest)--force-latest[Force latest version on conflict]')
|
||||
|
||||
_production=('(--production)--production[Do not install project devDependencies]')
|
||||
|
||||
_1st_arguments=(
|
||||
'cache-clean:Clean the Bower cache, or the specified package caches' \
|
||||
'help:Display help information about Bower' \
|
||||
'info:Version info and description of a particular package' \
|
||||
'init:Interactively create a bower.json file' \
|
||||
'install:Install a package locally' \
|
||||
'link:Symlink a package folder' \
|
||||
'lookup:Look up a package URL by name' \
|
||||
'register:Register a package' \
|
||||
'search:Search for a package by name' \
|
||||
'uninstall:Remove a package' \
|
||||
'update:Update a package' \
|
||||
{ls,list}:'[List all installed packages]'
|
||||
)
|
||||
_arguments \
|
||||
$_no_color \
|
||||
'*:: :->subcmds' && return 0
|
||||
|
||||
if (( CURRENT == 1 )); then
|
||||
_describe -t commands "bower subcommand" _1st_arguments
|
||||
return
|
||||
fi
|
||||
|
||||
case "$words[1]" in
|
||||
install)
|
||||
_arguments \
|
||||
$_dopts \
|
||||
$_save_dev \
|
||||
$_force_lastest \
|
||||
$_no_color \
|
||||
$_production
|
||||
;;
|
||||
update)
|
||||
_arguments \
|
||||
$_dopts \
|
||||
$_no_color \
|
||||
$_force_lastest
|
||||
_bower_installed_packages
|
||||
compadd "$@" $(echo $bower_package_list)
|
||||
;;
|
||||
uninstall)
|
||||
_arguments \
|
||||
$_no_color \
|
||||
$_dopts
|
||||
_bower_installed_packages
|
||||
compadd "$@" $(echo $bower_package_list)
|
||||
;;
|
||||
*)
|
||||
$_no_color \
|
||||
;;
|
||||
esac
|
||||
|
||||
(install)
|
||||
if [ -z "$bower_package_list" ];then
|
||||
bower_package_list=$(bower search | awk 'NR > 2' | cut -d '-' -f 2 | cut -d ' ' -f 2 | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g")
|
||||
fi
|
||||
compadd "$@" $(echo $bower_package_list)
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
compdef _bower bower
|
||||
|
|
|
|||
|
|
@ -26,8 +26,10 @@ _1st_arguments=(
|
|||
'list:list files in a formula or not-installed formulae'
|
||||
'log:git commit log for a formula'
|
||||
'missing:check all installed formuale for missing dependencies.'
|
||||
'options:display install options specific to formula.'
|
||||
'outdated:list formulas for which a newer version is available'
|
||||
'prune:remove dead links'
|
||||
'reinstall:reinstall a formula'
|
||||
'remove:remove a formula'
|
||||
'search:search for a formula (/regex/ or string)'
|
||||
'server:start a local web app that lets you browse formulae (requires Sinatra)'
|
||||
|
|
@ -75,7 +77,7 @@ case "$words[1]" in
|
|||
install|home|homepage|log|info|abv|uses|cat|deps|edit|options|versions)
|
||||
_brew_all_formulae
|
||||
_wanted formulae expl 'all formulae' compadd -a formulae ;;
|
||||
remove|rm|uninstall|unlink|cleanup|link|ln)
|
||||
reinstall|remove|rm|uninstall|unlink|cleanup|link|ln)
|
||||
_brew_installed_formulae
|
||||
_wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae ;;
|
||||
esac
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
alias be="bundle exec"
|
||||
alias bi="bundle install"
|
||||
alias bl="bundle list"
|
||||
alias bp="bundle package"
|
||||
alias bo="bundle open"
|
||||
|
|
@ -7,10 +6,34 @@ alias bu="bundle update"
|
|||
|
||||
# The following is based on https://github.com/gma/bundler-exec
|
||||
|
||||
bundled_commands=(annotate berks cap capify cucumber foodcritic foreman guard jekyll kitchen knife middleman nanoc rackup rainbows rake rspec ruby shotgun spec spin spork strainer tailor thin thor unicorn unicorn_rails puma)
|
||||
bundled_commands=(annotate berks cap capify cucumber foodcritic foreman guard jekyll kitchen knife middleman nanoc rackup rainbows rake rspec ruby shotgun spec spin spork strainer tailor taps thin thor unicorn unicorn_rails puma)
|
||||
|
||||
# Remove $UNBUNDLED_COMMANDS from the bundled_commands list
|
||||
for cmd in $UNBUNDLED_COMMANDS; do
|
||||
bundled_commands=(${bundled_commands#$cmd});
|
||||
done
|
||||
|
||||
## Functions
|
||||
|
||||
bi() {
|
||||
if _bundler-installed && _within-bundled-project; then
|
||||
local bundler_version=`bundle version | cut -d' ' -f3`
|
||||
if [[ $bundler_version > '1.4.0' || $bundler_version = '1.4.0' ]]; then
|
||||
if [[ "$(uname)" == 'Darwin' ]]
|
||||
then
|
||||
local cores_num="$(sysctl hw.ncpu | awk '{print $2}')"
|
||||
else
|
||||
local cores_num="$(nproc)"
|
||||
fi
|
||||
bundle install --jobs=$cores_num $@
|
||||
else
|
||||
bundle install $@
|
||||
fi
|
||||
else
|
||||
echo "Can't 'bundle install' outside a bundled project"
|
||||
fi
|
||||
}
|
||||
|
||||
_bundler-installed() {
|
||||
which bundle > /dev/null 2>&1
|
||||
}
|
||||
|
|
@ -42,3 +65,4 @@ for cmd in $bundled_commands; do
|
|||
compdef _$cmd bundled_$cmd=$cmd
|
||||
fi
|
||||
done
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
if [[ -f config/deploy.rb || -f Capfile ]]; then
|
||||
if [[ ! -f .cap_tasks~ || config/deploy.rb -nt .cap_tasks~ ]]; then
|
||||
echo "\nGenerating .cap_tasks~..." > /dev/stderr
|
||||
cap --tasks | grep '#' | cut -d " " -f 2 > .cap_tasks~
|
||||
cap -v --tasks | grep '#' | cut -d " " -f 2 > .cap_tasks~
|
||||
fi
|
||||
compadd `cat .cap_tasks~`
|
||||
fi
|
||||
|
|
|
|||
99
plugins/chruby/chruby.plugin.zsh
Normal file
99
plugins/chruby/chruby.plugin.zsh
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
#
|
||||
# INSTRUCTIONS
|
||||
#
|
||||
# With either a manual or brew installed chruby things should just work.
|
||||
#
|
||||
# If you'd prefer to specify an explicit path to load chruby from
|
||||
# you can set variables like so:
|
||||
#
|
||||
# zstyle :omz:plugins:chruby path /local/path/to/chruby.sh
|
||||
# zstyle :omz:plugins:chruby auto /local/path/to/auto.sh
|
||||
#
|
||||
# TODO
|
||||
# - autodetermine correct source path on non OS X systems
|
||||
# - completion if ruby-install exists
|
||||
|
||||
# rvm and rbenv plugins also provide this alias
|
||||
alias rubies='chruby'
|
||||
|
||||
local _chruby_path
|
||||
local _chruby_auto
|
||||
|
||||
_homebrew-installed() {
|
||||
whence brew &> /dev/null
|
||||
}
|
||||
|
||||
_chruby-from-homebrew-installed() {
|
||||
brew --prefix chruby &> /dev/null
|
||||
}
|
||||
|
||||
_ruby-build_installed() {
|
||||
whence ruby-build &> /dev/null
|
||||
}
|
||||
|
||||
_ruby-install-installed() {
|
||||
whence ruby-install &> /dev/null
|
||||
}
|
||||
|
||||
# Simple definition completer for ruby-build
|
||||
if _ruby-build_installed; then
|
||||
_ruby-build() { compadd $(ruby-build --definitions) }
|
||||
compdef _ruby-build ruby-build
|
||||
fi
|
||||
|
||||
_source_from_omz_settings() {
|
||||
zstyle -s :omz:plugins:chruby path _chruby_path
|
||||
zstyle -s :omz:plugins:chruby auto _chruby_auto
|
||||
|
||||
if _chruby_path && [[ -r _chruby_path ]]; then
|
||||
source ${_chruby_path}
|
||||
fi
|
||||
|
||||
if _chruby_auto && [[ -r _chruby_auto ]]; then
|
||||
source ${_chruby_auto}
|
||||
fi
|
||||
}
|
||||
|
||||
_chruby_dirs() {
|
||||
chrubydirs=($HOME/.rubies/ $PREFIX/opt/rubies)
|
||||
for dir in chrubydirs; do
|
||||
if [[ -d $dir ]]; then
|
||||
RUBIES+=$dir
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
if _homebrew-installed && _chruby-from-homebrew-installed ; then
|
||||
source $(brew --prefix chruby)/share/chruby/chruby.sh
|
||||
source $(brew --prefix chruby)/share/chruby/auto.sh
|
||||
_chruby_dirs
|
||||
elif [[ -r "/usr/local/share/chruby/chruby.sh" ]] ; then
|
||||
source /usr/local/share/chruby/chruby.sh
|
||||
source /usr/local/share/chruby/auto.sh
|
||||
_chruby_dirs
|
||||
else
|
||||
_source_from_omz_settings
|
||||
_chruby_dirs
|
||||
fi
|
||||
|
||||
function ensure_chruby() {
|
||||
$(whence chruby)
|
||||
}
|
||||
|
||||
function current_ruby() {
|
||||
local _ruby
|
||||
_ruby="$(chruby |grep \* |tr -d '* ')"
|
||||
if [[ $(chruby |grep -c \*) -eq 1 ]]; then
|
||||
echo ${_ruby}
|
||||
else
|
||||
echo "system"
|
||||
fi
|
||||
}
|
||||
|
||||
function chruby_prompt_info() {
|
||||
echo "$(current_ruby)"
|
||||
}
|
||||
|
||||
# complete on installed rubies
|
||||
_chruby() { compadd $(chruby | tr -d '* ') }
|
||||
compdef _chruby chruby
|
||||
|
|
@ -35,27 +35,37 @@
|
|||
# -------
|
||||
#
|
||||
# * Mario Fernandez (https://github.com/sirech)
|
||||
# * Dong Weiming (https://github.com/dongweiming)
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
local curcontext="$curcontext" state line ret=1
|
||||
local curcontext="$curcontext" state line ret=1 version opts first second third
|
||||
typeset -A opt_args
|
||||
version=(${(f)"$(_call_program version $words[1] --version)"})
|
||||
version=${${(z)${version[1]}}[3]}
|
||||
first=$(echo $version|cut -d '.' -f 1)
|
||||
second=$(echo $version|cut -d '.' -f 2)
|
||||
third=$(echo $version|cut -d '.' -f 3)
|
||||
if (( $first < 2 )) && (( $second < 7 )) && (( $third < 3 ));then
|
||||
opts+=('(-l --lint)'{-l,--lint}'[pipe the compiled JavaScript through JavaScript Lint]'
|
||||
'(-r --require)'{-r,--require}'[require a library before executing your script]:library')
|
||||
fi
|
||||
|
||||
|
||||
_arguments -C \
|
||||
'(- *)'{-h,--help}'[display this help message]' \
|
||||
'(- *)'{-v,--version}'[display the version number]' \
|
||||
$opts \
|
||||
'(-b --bare)'{-b,--bare}'[compile without a top-level function wrapper]' \
|
||||
'(-e --eval)'{-e,--eval}'[pass a string from the command line as input]:Inline Script' \
|
||||
'(-i --interactive)'{-i,--interactive}'[run an interactive CoffeeScript REPL]' \
|
||||
'(-j --join)'{-j,--join}'[concatenate the source CoffeeScript before compiling]:Destination JS file:_files -g "*.js"' \
|
||||
'(-l --lint)'{-l,--lint}'[pipe the compiled JavaScript through JavaScript Lint]' \
|
||||
'(--nodejs)--nodejs[pass options directly to the "node" binary]' \
|
||||
'(-c --compile)'{-c,--compile}'[compile to JavaScript and save as .js files]' \
|
||||
'(-o --output)'{-o,--output}'[set the output directory for compiled JavaScript]:Output Directory:_files -/' \
|
||||
'(-n -t -p)'{-n,--nodes}'[print out the parse tree that the parser produces]' \
|
||||
'(-n -t -p)'{-p,--print}'[print out the compiled JavaScript]' \
|
||||
'(-n -t -p)'{-t,--tokens}'[print out the tokens that the lexer/rewriter produce]' \
|
||||
'(-r --require)'{-r,--require}'[require a library before executing your script]:library' \
|
||||
'(-s --stdio)'{-s,--stdio}'[listen for and compile scripts over stdio]' \
|
||||
'(-w --watch)'{-w,--watch}'[watch scripts for changes and rerun commands]' \
|
||||
'*:script or directory:_files' && ret=0
|
||||
|
|
|
|||
94
plugins/common-aliases/common-aliases.plugin.zsh
Normal file
94
plugins/common-aliases/common-aliases.plugin.zsh
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
# Advanced Aliases.
|
||||
# Use with caution
|
||||
#
|
||||
|
||||
# ls, the common ones I use a lot shortened for rapid fire usage
|
||||
alias ls='ls --color' #I like color
|
||||
alias l='ls -lFh' #size,show type,human readable
|
||||
alias la='ls -lAFh' #long list,show almost all,show type,human readable
|
||||
alias lr='ls -tRFh' #sorted by date,recursive,show type,human readable
|
||||
alias lt='ls -ltFh' #long list,sorted by date,show type,human readable
|
||||
alias ll='ls -l' #long list
|
||||
alias ldot='ls -ld .*'
|
||||
alias lS='ls -1FSsh'
|
||||
alias lart='ls -1Fcart'
|
||||
alias lrt='ls -1Fcrt'
|
||||
|
||||
alias zshrc='vim ~/.zshrc' # Quick access to the ~/.zshrc file
|
||||
|
||||
alias grep='grep --color'
|
||||
alias sgrep='grep -R -n -H -C 5 --exclude-dir={.git,.svn,CVS} '
|
||||
|
||||
alias t='tail -f'
|
||||
|
||||
# because typing 'cd' is A LOT of work!!
|
||||
alias ..='cd ../'
|
||||
alias ...='cd ../../'
|
||||
alias ....='cd ../../../'
|
||||
alias .....='cd ../../../../'
|
||||
|
||||
# Command line head / tail shortcuts
|
||||
alias -g H='| head'
|
||||
alias -g T='| tail'
|
||||
alias -g G='| grep'
|
||||
alias -g L="| less"
|
||||
alias -g M="| most"
|
||||
alias -g LL="2>&1 | less"
|
||||
alias -g CA="2>&1 | cat -A"
|
||||
alias -g NE="2> /dev/null"
|
||||
alias -g NUL="> /dev/null 2>&1"
|
||||
alias -g P="2>&1| pygmentize -l pytb"
|
||||
|
||||
alias dud='du --max-depth=1 -h'
|
||||
alias duf='du -sh *'
|
||||
alias fd='find . -type d -name'
|
||||
alias ff='find . -type f -name'
|
||||
|
||||
alias h='history'
|
||||
alias hgrep="fc -El 0 | grep"
|
||||
alias help='man'
|
||||
alias j='jobs'
|
||||
alias p='ps -f'
|
||||
alias sortnr='sort -n -r'
|
||||
alias unexport='unset'
|
||||
|
||||
alias whereami=display_info
|
||||
|
||||
alias rm='rm -i'
|
||||
alias cp='cp -i'
|
||||
alias mv='mv -i'
|
||||
|
||||
# zsh is able to auto-do some kungfoo
|
||||
# depends on the SUFFIX :)
|
||||
if [ ${ZSH_VERSION//\./} -ge 420 ]; then
|
||||
# open browser on urls
|
||||
_browser_fts=(htm html de org net com at cx nl se dk dk php)
|
||||
for ft in $_browser_fts ; do alias -s $ft=$BROWSER ; done
|
||||
|
||||
_editor_fts=(cpp cxx cc c hh h inl asc txt TXT tex)
|
||||
for ft in $_editor_fts ; do alias -s $ft=$EDITOR ; done
|
||||
|
||||
_image_fts=(jpg jpeg png gif mng tiff tif xpm)
|
||||
for ft in $_image_fts ; do alias -s $ft=$XIVIEWER; done
|
||||
|
||||
_media_fts=(avi mpg mpeg ogm mp3 wav ogg ape rm mov mkv)
|
||||
for ft in $_media_fts ; do alias -s $ft=mplayer ; done
|
||||
|
||||
#read documents
|
||||
alias -s pdf=acroread
|
||||
alias -s ps=gv
|
||||
alias -s dvi=xdvi
|
||||
alias -s chm=xchm
|
||||
alias -s djvu=djview
|
||||
|
||||
#list whats inside packed file
|
||||
alias -s zip="unzip -l"
|
||||
alias -s rar="unrar l"
|
||||
alias -s tar="tar tf"
|
||||
alias -s tar.gz="echo "
|
||||
alias -s ace="unace l"
|
||||
fi
|
||||
|
||||
# Make zsh know about hosts already accessed by SSH
|
||||
zstyle -e ':completion:*:(ssh|scp|sftp|rsh|rsync):hosts' hosts 'reply=(${=${${(f)"$(cat {/etc/ssh_,~/.ssh/known_}hosts(|2)(N) /dev/null)"}%%[# ]*}//,/ })'
|
||||
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
# Authors:
|
||||
# https://github.com/AlexBio
|
||||
# https://github.com/dbb
|
||||
# https://github.com/Mappleconfusers
|
||||
#
|
||||
# Debian-related zsh aliases and functions for zsh
|
||||
|
||||
|
|
@ -56,7 +57,7 @@ if [[ $use_sudo -eq 1 ]]; then
|
|||
alias ar='sudo $apt_pref remove'
|
||||
|
||||
# apt-get only
|
||||
alias ads='sudo $apt_pref dselect-upgrade'
|
||||
alias ads='sudo apt-get dselect-upgrade'
|
||||
|
||||
# Install all .deb files in the current directory.
|
||||
# Warning: you will need to put the glob in single quotes if you use:
|
||||
|
|
@ -109,6 +110,38 @@ else
|
|||
?not(~n`uname -r`))'\'' root'
|
||||
fi
|
||||
|
||||
# Completion ################################################################
|
||||
|
||||
#
|
||||
# Registers a compdef for $1 that calls $apt_pref with the commands $2
|
||||
# To do that it creates a new completion function called _apt_pref_$2
|
||||
#
|
||||
apt_pref_compdef() {
|
||||
local f fb
|
||||
f="_apt_pref_${2}"
|
||||
|
||||
eval "function ${f}() {
|
||||
shift words;
|
||||
service=\"\$apt_pref\";
|
||||
words=(\"\$apt_pref\" '$2' \$words);
|
||||
((CURRENT++))
|
||||
test \"\${apt_pref}\" = 'aptitude' && _aptitude || _apt
|
||||
}"
|
||||
|
||||
compdef "$f" "$1"
|
||||
}
|
||||
|
||||
apt_pref_compdef aac "autoclean"
|
||||
apt_pref_compdef abd "build-dep"
|
||||
apt_pref_compdef ac "clean"
|
||||
apt_pref_compdef ad "update"
|
||||
apt_pref_compdef afu "update"
|
||||
apt_pref_compdef ag "upgrade"
|
||||
apt_pref_compdef ai "install"
|
||||
apt_pref_compdef ail "install"
|
||||
apt_pref_compdef ap "purge"
|
||||
apt_pref_compdef ar "remove"
|
||||
apt_pref_compdef ads "dselect-upgrade"
|
||||
|
||||
# Misc. #####################################################################
|
||||
# print all installed packages
|
||||
|
|
|
|||
19
plugins/docker/README.md
Normal file
19
plugins/docker/README.md
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
## Docker autocomplete plugin
|
||||
|
||||
- Adds autocomplete options for all docker commands.
|
||||
- Will also show containerIDs and Image names where applicable
|
||||
|
||||
####Shows help for all commands
|
||||

|
||||
|
||||
|
||||
####Shows your downloaded images where applicable
|
||||

|
||||
|
||||
|
||||
####Shows your running containers where applicable
|
||||

|
||||
|
||||
|
||||
|
||||
Maintainer : Ahmed Azaan ([@aeonazaan](https://twitter.com/aeonazaan))
|
||||
290
plugins/docker/_docker
Normal file
290
plugins/docker/_docker
Normal file
|
|
@ -0,0 +1,290 @@
|
|||
#compdef docker
|
||||
|
||||
# Docker autocompletion for oh-my-zsh
|
||||
# Requires: Docker installed
|
||||
# Author : Azaan (@aeonazaan)
|
||||
|
||||
|
||||
# ----- Helper functions
|
||||
# Output a selectable list of all running docker containers
|
||||
__docker_containers() {
|
||||
declare -a cont_cmd
|
||||
cont_cmd=($(docker ps | awk 'NR>1{print $1":[CON("$1")"$2"("$3")]"}'))
|
||||
_describe 'containers' cont_cmd
|
||||
}
|
||||
|
||||
# output a selectable list of all docker images
|
||||
__docker_images() {
|
||||
declare -a img_cmd
|
||||
img_cmd=($(docker images | awk 'NR>1{print $1}'))
|
||||
_describe 'images' img_cmd
|
||||
}
|
||||
|
||||
# ----- Commands
|
||||
# Seperate function for each command, makes extension easier later
|
||||
# ---------------------------
|
||||
__attach() {
|
||||
__docker_containers
|
||||
}
|
||||
|
||||
__build() {
|
||||
_arguments \
|
||||
'-q=false[Suppress verbose build output]' \
|
||||
'-t="[fuck to be applied to the resulting image in case of success]' \
|
||||
'*:files:_files'
|
||||
}
|
||||
|
||||
__commit() {
|
||||
_arguments \
|
||||
'-author="[Author]' \
|
||||
'-m="[Commit message]' \
|
||||
'-run="[Config automatically applied when the image is run.\n]'
|
||||
__docker_containers
|
||||
}
|
||||
|
||||
__diff() {
|
||||
__docker_containers
|
||||
}
|
||||
|
||||
__export() {
|
||||
__docker_containers
|
||||
}
|
||||
|
||||
|
||||
__history() {
|
||||
__docker_images
|
||||
}
|
||||
|
||||
__images() {
|
||||
_arguments \
|
||||
'-a[show all images]' \
|
||||
'-notrunc[dont truncate output]' \
|
||||
'-q[only show numeric IDs]' \
|
||||
'-viz[output graph in graphviz format]'
|
||||
__docker_images
|
||||
}
|
||||
|
||||
__import() {
|
||||
_arguments '*:files:_files'
|
||||
}
|
||||
|
||||
__info() {
|
||||
# no arguments
|
||||
}
|
||||
|
||||
__insert() {
|
||||
__docker_images
|
||||
_arguments '*:files:_files'
|
||||
}
|
||||
|
||||
__inspect() {
|
||||
__docker_images
|
||||
__docker_containers
|
||||
}
|
||||
|
||||
__kill() {
|
||||
__docker_containers
|
||||
}
|
||||
|
||||
__login() {
|
||||
_arguments \
|
||||
'-e="[email]' \
|
||||
'-p="[password]' \
|
||||
'-u="[username]' \
|
||||
}
|
||||
|
||||
__logs() {
|
||||
__docker_containers
|
||||
}
|
||||
|
||||
__port() {
|
||||
__docker_containers
|
||||
}
|
||||
|
||||
__top() {
|
||||
__docker_containers
|
||||
}
|
||||
|
||||
__ps() {
|
||||
_arguments \
|
||||
'-a[Show all containers. Only running containers are shown by default.]' \
|
||||
'-beforeId="[Show only container created before Id, include non-running ones.]' \
|
||||
'-l[Show only the latest created container, include non-running ones.]' \
|
||||
'-n=[Show n last created containers, include non-running ones.]' \
|
||||
'-notrurrrrnc[Dont truncate output]' \
|
||||
'-q[Only display numeric IDs]' \
|
||||
'-s[Display sizes]' \
|
||||
'-sinceId="[Show only containers created since Id, include non-running ones.]'
|
||||
}
|
||||
|
||||
__pull() {
|
||||
_arguments '-t="[Download tagged image in repository]'
|
||||
}
|
||||
|
||||
__push() {
|
||||
|
||||
}
|
||||
|
||||
__restart() {
|
||||
_arguments '-t=[number of seconds to try to stop before killing]'
|
||||
__docker_containers
|
||||
}
|
||||
|
||||
__rm() {
|
||||
_arguments '-v[Remove the volumes associated to the container]'
|
||||
__docker_containers
|
||||
}
|
||||
|
||||
__rmi() {
|
||||
__docker_images
|
||||
}
|
||||
|
||||
__run() {
|
||||
_arguments \
|
||||
'-a=[Attach to stdin, stdout or stderr.]' \
|
||||
'-c=[CPU shares (relative weight)]' \
|
||||
'-d[Detached mode: leave the container running in the background]' \
|
||||
'-dns=[Set custom dns servers]' \
|
||||
'-e=[Set environment variables]' \
|
||||
'-entrypoint="[Overwrite the default entrypoint of the image]' \
|
||||
'-h="[Container host name]' \
|
||||
'-i[Keep stdin open even if not attached]' \
|
||||
'-m=[Memory limit (in bytes)]' \
|
||||
'-p=[Expose a containers port to the host (use docker port to see the actual mapping)]' \
|
||||
'-t[Allocate a pseudo-tty]' \
|
||||
'-u="[Username or UID]' \
|
||||
'-v=[Bind mount a volume (e.g. from the host: -v /host:/container, from docker: -v /container)]' \
|
||||
'-volumes-from="[Mount volumes from the specified container]'
|
||||
__docker_images
|
||||
}
|
||||
|
||||
__search() {
|
||||
_arguments '-notrunc[Dont truncate output]'
|
||||
}
|
||||
|
||||
__start() {
|
||||
__docker_containers
|
||||
}
|
||||
|
||||
__stop() {
|
||||
_arguments '-t=[number of seconds to try to stop before killing]'
|
||||
__docker_containers
|
||||
}
|
||||
|
||||
__tag() {
|
||||
_arguments '-f[Force]'
|
||||
__docker_images
|
||||
}
|
||||
|
||||
__version() {
|
||||
|
||||
}
|
||||
|
||||
__wait() {
|
||||
__docker_containers
|
||||
}
|
||||
|
||||
# end commands ---------
|
||||
# ----------------------
|
||||
|
||||
local -a _1st_arguments
|
||||
_1st_arguments=(
|
||||
"attach":"Attach to a running container"
|
||||
"build":"Build a container from a Dockerfile"
|
||||
"commit":"Create a new image from a container's changes"
|
||||
"diff":"Inspect changes on a container's filesystem"
|
||||
"export":"Stream the contents of a container as a tar archive"
|
||||
"history":"Show the history of an image"
|
||||
"images":"List images"
|
||||
"import":"Create a new filesystem image from the contents of a tarball"
|
||||
"info":"Display system-wide information"
|
||||
"insert":"Insert a file in an image"
|
||||
"inspect":"Return low-level information on a container"
|
||||
"kill":"Kill a running container"
|
||||
"login":"Register or Login to the docker registry server"
|
||||
"logs":"Fetch the logs of a container"
|
||||
"port":"Lookup the public-facing port which is NAT-ed to PRIVATE_PORT"
|
||||
"top":"Lookup the running processes of a container"
|
||||
"ps":"List containers"
|
||||
"pull":"Pull an image or a repository from the docker registry server"
|
||||
"push":"Push an image or a repository to the docker registry server"
|
||||
"restart":"Restart a running container"
|
||||
"rm":"Remove one or more containers"
|
||||
"rmi":"Remove one or more images"
|
||||
"run":"Run a command in a new container"
|
||||
"search":"Search for an image in the docker index"
|
||||
"start":"Start a stopped container"
|
||||
"stop":"Stop a running container"
|
||||
"tag":"Tag an image into a repository"
|
||||
"version":"Show the docker version information"
|
||||
"wait":"Block until a container stops, then print its exit code"
|
||||
)
|
||||
|
||||
_arguments '*:: :->command'
|
||||
|
||||
if (( CURRENT == 1 )); then
|
||||
_describe -t commands "docker command" _1st_arguments
|
||||
return
|
||||
fi
|
||||
|
||||
local -a _command_args
|
||||
case "$words[1]" in
|
||||
attach)
|
||||
__docker_containers ;;
|
||||
build)
|
||||
__build ;;
|
||||
commit)
|
||||
__commit ;;
|
||||
diff)
|
||||
__diff ;;
|
||||
export)
|
||||
__export ;;
|
||||
history)
|
||||
__history ;;
|
||||
images)
|
||||
__images ;;
|
||||
import)
|
||||
__import ;;
|
||||
info)
|
||||
__info ;;
|
||||
insert)
|
||||
__insert ;;
|
||||
inspect)
|
||||
__inspect ;;
|
||||
kill)
|
||||
__kill ;;
|
||||
login)
|
||||
__login ;;
|
||||
logs)
|
||||
__logs ;;
|
||||
port)
|
||||
__port ;;
|
||||
top)
|
||||
__top ;;
|
||||
ps)
|
||||
__ps ;;
|
||||
pull)
|
||||
__pull ;;
|
||||
push)
|
||||
__push ;;
|
||||
restart)
|
||||
__restart ;;
|
||||
rm)
|
||||
__rm ;;
|
||||
rmi)
|
||||
__rmi ;;
|
||||
run)
|
||||
__run ;;
|
||||
search)
|
||||
__search ;;
|
||||
start)
|
||||
__start ;;
|
||||
stop)
|
||||
__stop ;;
|
||||
tag)
|
||||
__tag ;;
|
||||
version)
|
||||
__version ;;
|
||||
wait)
|
||||
__wait ;;
|
||||
esac
|
||||
|
|
@ -52,7 +52,7 @@ function extract() {
|
|||
(*.xz) unxz "$1" ;;
|
||||
(*.lzma) unlzma "$1" ;;
|
||||
(*.Z) uncompress "$1" ;;
|
||||
(*.zip) unzip "$1" -d $extract_dir ;;
|
||||
(*.zip|*.war|*.jar) unzip "$1" -d $extract_dir ;;
|
||||
(*.rar) unrar x -ad "$1" ;;
|
||||
(*.7z) 7za x "$1" ;;
|
||||
(*.deb)
|
||||
|
|
|
|||
138
plugins/fastfile/fastfile.plugin.zsh
Normal file
138
plugins/fastfile/fastfile.plugin.zsh
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
################################################################################
|
||||
# FILE: fastfile.plugin.zsh
|
||||
# DESCRIPTION: oh-my-zsh plugin file.
|
||||
# AUTHOR: Michael Varner (musikmichael@web.de)
|
||||
# VERSION: 1.0.0
|
||||
#
|
||||
# This plugin adds the ability to on the fly generate and access file shortcuts.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
###########################
|
||||
# Settings
|
||||
|
||||
# These can be overwritten any time.
|
||||
# If they are not set yet, they will be
|
||||
# overwritten with their default values
|
||||
|
||||
default fastfile_dir "${HOME}/.fastfile/"
|
||||
default fastfile_var_prefix "§"
|
||||
|
||||
###########################
|
||||
# Impl
|
||||
|
||||
#
|
||||
# Generate a shortcut
|
||||
#
|
||||
# Arguments:
|
||||
# 1. name - The name of the shortcut (default: name of the file)
|
||||
# 2. file - The file or directory to make the shortcut for
|
||||
# STDOUT:
|
||||
# => fastfle_print
|
||||
#
|
||||
function fastfile() {
|
||||
test "$2" || 2="."
|
||||
file=$(readlink -f "$2")
|
||||
|
||||
test "$1" || 1="$(basename "$file")"
|
||||
name=$(echo "$1" | tr " " "_")
|
||||
|
||||
|
||||
mkdir -p "${fastfile_dir}"
|
||||
echo "$file" > "$(fastfile_resolv "$name")"
|
||||
|
||||
fastfile_sync
|
||||
fastfile_print "$name"
|
||||
}
|
||||
|
||||
#
|
||||
# Resolve the location of a shortcut file (the database file, where the value is written!)
|
||||
#
|
||||
# Arguments:
|
||||
# 1. name - The name of the shortcut
|
||||
# STDOUT:
|
||||
# The path
|
||||
#
|
||||
function fastfile_resolv() {
|
||||
echo "${fastfile_dir}${1}"
|
||||
}
|
||||
|
||||
#
|
||||
# Get the real path of a shortcut
|
||||
#
|
||||
# Arguments:
|
||||
# 1. name - The name of the shortcut
|
||||
# STDOUT:
|
||||
# The path
|
||||
#
|
||||
function fastfile_get() {
|
||||
cat "$(fastfile_resolv "$1")"
|
||||
}
|
||||
|
||||
#
|
||||
# Print a shortcut
|
||||
#
|
||||
# Arguments:
|
||||
# 1. name - The name of the shortcut
|
||||
# STDOUT:
|
||||
# Name and value of the shortcut
|
||||
#
|
||||
function fastfile_print() {
|
||||
echo "${fastfile_var_prefix}${1} -> $(fastfile_get "$1")"
|
||||
}
|
||||
|
||||
#
|
||||
# List all shortcuts
|
||||
#
|
||||
# STDOUT:
|
||||
# (=> fastfle_print) for each shortcut
|
||||
#
|
||||
function fastfile_ls() {
|
||||
for f in "${fastfile_dir}"/*; do
|
||||
file=`basename "$f"` # To enable simpler handeling of spaces in file names
|
||||
varkey=`echo "$file" | tr " " "_"`
|
||||
|
||||
# Special format for colums
|
||||
echo "${fastfile_var_prefix}${varkey}|->|$(fastfile_get "$file")"
|
||||
done | column -t -s "|"
|
||||
}
|
||||
|
||||
#
|
||||
# Remove a shortcut
|
||||
#
|
||||
# Arguments:
|
||||
# 1. name - The name of the shortcut (default: name of the file)
|
||||
# 2. file - The file or directory to make the shortcut for
|
||||
# STDOUT:
|
||||
# => fastfle_print
|
||||
#
|
||||
function fastfile_rm() {
|
||||
fastfile_print "$1"
|
||||
rm "$(fastfile_resolv "$1")"
|
||||
}
|
||||
|
||||
#
|
||||
# Generate the aliases for the shortcuts
|
||||
#
|
||||
function fastfile_sync() {
|
||||
for f in "${fastfile_dir}"/*; do
|
||||
file=`basename "$f"` # To enable simpler handeling of spaces in file names
|
||||
varkey=`echo "$file" | tr " " "_"`
|
||||
|
||||
alias -g "${fastfile_var_prefix}${varkey}"="'$(fastfile_get "$file")'"
|
||||
done
|
||||
}
|
||||
|
||||
##################################
|
||||
# Shortcuts
|
||||
|
||||
alias ff=fastfile
|
||||
alias ffp=fastfile_print
|
||||
alias ffrm=fastfile_rm
|
||||
alias ffls=fastfile_ls
|
||||
alias ffsync=fastfile_sync
|
||||
|
||||
##################################
|
||||
# Init
|
||||
|
||||
fastfile_sync
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
# Open folder in ForkLift.app from console
|
||||
# Open folder in ForkLift.app of ForkLift2.app from console
|
||||
# Author: Adam Strzelecki nanoant.com, modified by Bodo Tasche bitboxer.de
|
||||
# Updated to support ForkLift2 by Johan Kaving
|
||||
#
|
||||
# Usage:
|
||||
# fl [<folder>]
|
||||
|
|
@ -22,9 +23,33 @@ function fl {
|
|||
fi
|
||||
fi
|
||||
osascript 2>&1 1>/dev/null <<END
|
||||
tell application "ForkLift"
|
||||
activate
|
||||
end tell
|
||||
|
||||
try
|
||||
tell application "Finder"
|
||||
set appName to name of application file id "com.binarynights.ForkLift2"
|
||||
end tell
|
||||
on error err_msg number err_num
|
||||
tell application "Finder"
|
||||
set appName to name of application file id "com.binarynights.ForkLift"
|
||||
end tell
|
||||
end try
|
||||
|
||||
if application appName is running
|
||||
tell application appName
|
||||
activate
|
||||
end tell
|
||||
else
|
||||
tell application appName
|
||||
activate
|
||||
end tell
|
||||
repeat until application appName is running
|
||||
delay 1
|
||||
end repeat
|
||||
tell application appName
|
||||
activate
|
||||
end tell
|
||||
end if
|
||||
|
||||
tell application "System Events"
|
||||
tell application process "ForkLift"
|
||||
try
|
||||
|
|
@ -36,7 +61,7 @@ function fl {
|
|||
keystroke "g" using {command down, shift down}
|
||||
tell sheet 1 of topWindow
|
||||
set value of text field 1 to "$PWD"
|
||||
keystroke return
|
||||
keystroke return
|
||||
end tell
|
||||
end tell
|
||||
end tell
|
||||
|
|
|
|||
|
|
@ -4,13 +4,15 @@
|
|||
# gem zsh completion, based on homebrew completion
|
||||
|
||||
_gem_installed() {
|
||||
installed_gems=(`gem list --local --no-versions`)
|
||||
installed_gems=(${(f)"$(gem list --local --no-versions)"})
|
||||
}
|
||||
|
||||
local -a _1st_arguments
|
||||
|
||||
_1st_arguments=(
|
||||
'build:Build a gem from a gemspec'
|
||||
'cert:Manage RubyGems certificates and signing settings'
|
||||
'check:Check installed gems'
|
||||
'check:Check a gem repository for added or missing files'
|
||||
'cleanup:Clean up old versions of installed gems in the local repository'
|
||||
'contents:Display the contents of the installed gems'
|
||||
'dependency:Show the dependencies of an installed gem'
|
||||
|
|
@ -21,7 +23,7 @@ _1st_arguments=(
|
|||
'install:Install a gem into the local repository'
|
||||
'list:Display gems whose name starts with STRING'
|
||||
'lock:Generate a lockdown list of gems'
|
||||
'mirror:Mirror a gem repository'
|
||||
'mirror:Mirror all gem files (requires rubygems-mirror)'
|
||||
'outdated:Display all gems that need updates'
|
||||
'owner:Manage gem owners on RubyGems.org.'
|
||||
'pristine:Restores installed gems to pristine condition from files located in the gem cache'
|
||||
|
|
@ -35,8 +37,9 @@ _1st_arguments=(
|
|||
'stale:List gems along with access times'
|
||||
'uninstall:Uninstall gems from the local repository'
|
||||
'unpack:Unpack an installed gem to the current directory'
|
||||
'update:Update the named gems (or all installed gems) in the local repository'
|
||||
'update:Update installed gems to the latest version'
|
||||
'which:Find the location of a library file you can require'
|
||||
'yank:Remove a specific gem version release from RubyGems.org'
|
||||
)
|
||||
|
||||
local expl
|
||||
|
|
|
|||
|
|
@ -41,6 +41,9 @@ _git-flow ()
|
|||
'hotfix:Manage your hotfix branches.'
|
||||
'support:Manage your support branches.'
|
||||
'version:Shows version information.'
|
||||
'finish:Finish the branch you are currently on.'
|
||||
'delete:Delete the branch you are currently on.'
|
||||
'publish:Publish the branch you are currently on.'
|
||||
)
|
||||
_describe -t commands 'git flow' subcommands
|
||||
;;
|
||||
|
|
@ -95,7 +98,7 @@ __git-flow-release ()
|
|||
'list:List all your release branches. (Alias to `git flow release`)'
|
||||
'publish:Publish release branch to remote.'
|
||||
'track:Checkout remote release branch.'
|
||||
'delet:Delete a release branch.'
|
||||
'delete:Delete a release branch.'
|
||||
)
|
||||
_describe -t commands 'git flow release' subcommands
|
||||
_arguments \
|
||||
|
|
|
|||
|
|
@ -20,6 +20,12 @@
|
|||
# c. Or, use this file as a oh-my-zsh plugin.
|
||||
#
|
||||
|
||||
#Alias
|
||||
alias gf='git flow'
|
||||
alias gcd='git checkout develop'
|
||||
alias gch='git checkout hotfix'
|
||||
alias gcr='git checkout release'
|
||||
|
||||
_git-flow ()
|
||||
{
|
||||
local curcontext="$curcontext" state line
|
||||
|
|
|
|||
60
plugins/git-prompt/git-prompt.plugin.zsh
Normal file
60
plugins/git-prompt/git-prompt.plugin.zsh
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
# ZSH Git Prompt Plugin from:
|
||||
# http://github.com/olivierverdier/zsh-git-prompt
|
||||
#
|
||||
export __GIT_PROMPT_DIR=$ZSH/plugins/git-prompt
|
||||
# Initialize colors.
|
||||
autoload -U colors
|
||||
colors
|
||||
|
||||
# Allow for functions in the prompt.
|
||||
setopt PROMPT_SUBST
|
||||
|
||||
## Enable auto-execution of functions.
|
||||
typeset -ga preexec_functions
|
||||
typeset -ga precmd_functions
|
||||
typeset -ga chpwd_functions
|
||||
|
||||
# Append git functions needed for prompt.
|
||||
preexec_functions+='preexec_update_git_vars'
|
||||
precmd_functions+='precmd_update_git_vars'
|
||||
chpwd_functions+='chpwd_update_git_vars'
|
||||
|
||||
## Function definitions
|
||||
function preexec_update_git_vars() {
|
||||
case "$2" in
|
||||
git*)
|
||||
__EXECUTED_GIT_COMMAND=1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
function precmd_update_git_vars() {
|
||||
if [ -n "$__EXECUTED_GIT_COMMAND" ]; then
|
||||
update_current_git_vars
|
||||
unset __EXECUTED_GIT_COMMAND
|
||||
fi
|
||||
}
|
||||
|
||||
function chpwd_update_git_vars() {
|
||||
update_current_git_vars
|
||||
}
|
||||
|
||||
function update_current_git_vars() {
|
||||
unset __CURRENT_GIT_STATUS
|
||||
|
||||
local gitstatus="$__GIT_PROMPT_DIR/gitstatus.py"
|
||||
_GIT_STATUS=`python ${gitstatus}`
|
||||
__CURRENT_GIT_STATUS=("${(f)_GIT_STATUS}")
|
||||
}
|
||||
|
||||
function prompt_git_info() {
|
||||
if [ -n "$__CURRENT_GIT_STATUS" ]; then
|
||||
echo "(%{${fg[red]}%}$__CURRENT_GIT_STATUS[1]%{${fg[default]}%}$__CURRENT_GIT_STATUS[2]%{${fg[magenta]}%}$__CURRENT_GIT_STATUS[3]%{${fg[default]}%})"
|
||||
fi
|
||||
}
|
||||
|
||||
# Set the prompt.
|
||||
#PROMPT='%B%m%~%b$(prompt_git_info) %# '
|
||||
# for a right prompt:
|
||||
#RPROMPT='%b$(prompt_git_info)'
|
||||
RPROMPT='$(prompt_git_info)'
|
||||
68
plugins/git-prompt/gitstatus.py
Normal file
68
plugins/git-prompt/gitstatus.py
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: UTF-8 -*-
|
||||
|
||||
# change those symbols to whatever you prefer
|
||||
symbols = {'ahead of': '↑', 'behind': '↓', 'staged':'♦', 'changed':'‣', 'untracked':'…', 'clean':'⚡', 'unmerged':'≠', 'sha1':':'}
|
||||
|
||||
from subprocess import Popen, PIPE
|
||||
|
||||
output,error = Popen(['git','status'], stdout=PIPE, stderr=PIPE).communicate()
|
||||
|
||||
if error:
|
||||
import sys
|
||||
sys.exit(0)
|
||||
lines = output.splitlines()
|
||||
|
||||
import re
|
||||
behead_re = re.compile(r"^# Your branch is (ahead of|behind) '(.*)' by (\d+) commit")
|
||||
diverge_re = re.compile(r"^# and have (\d+) and (\d+) different")
|
||||
|
||||
status = ''
|
||||
staged = re.compile(r'^# Changes to be committed:$', re.MULTILINE)
|
||||
changed = re.compile(r'^# Changed but not updated:$', re.MULTILINE)
|
||||
untracked = re.compile(r'^# Untracked files:$', re.MULTILINE)
|
||||
unmerged = re.compile(r'^# Unmerged paths:$', re.MULTILINE)
|
||||
|
||||
def execute(*command):
|
||||
out, err = Popen(stdout=PIPE, stderr=PIPE, *command).communicate()
|
||||
if not err:
|
||||
nb = len(out.splitlines())
|
||||
else:
|
||||
nb = '?'
|
||||
return nb
|
||||
|
||||
if staged.search(output):
|
||||
nb = execute(['git','diff','--staged','--name-only','--diff-filter=ACDMRT'])
|
||||
status += '%s%s' % (symbols['staged'], nb)
|
||||
if unmerged.search(output):
|
||||
nb = execute(['git','diff', '--staged','--name-only', '--diff-filter=U'])
|
||||
status += '%s%s' % (symbols['unmerged'], nb)
|
||||
if changed.search(output):
|
||||
nb = execute(['git','diff','--name-only', '--diff-filter=ACDMRT'])
|
||||
status += '%s%s' % (symbols['changed'], nb)
|
||||
if untracked.search(output):
|
||||
## nb = len(Popen(['git','ls-files','--others','--exclude-standard'],stdout=PIPE).communicate()[0].splitlines())
|
||||
## status += "%s" % (symbols['untracked']*(nb//3 + 1), )
|
||||
status += symbols['untracked']
|
||||
if status == '':
|
||||
status = symbols['clean']
|
||||
|
||||
remote = ''
|
||||
|
||||
bline = lines[0]
|
||||
if bline.find('Not currently on any branch') != -1:
|
||||
branch = symbols['sha1']+ Popen(['git','rev-parse','--short','HEAD'], stdout=PIPE).communicate()[0][:-1]
|
||||
else:
|
||||
branch = bline.split(' ')[3]
|
||||
bstatusline = lines[1]
|
||||
match = behead_re.match(bstatusline)
|
||||
if match:
|
||||
remote = symbols[match.groups()[0]]
|
||||
remote += match.groups()[2]
|
||||
elif lines[2:]:
|
||||
div_match = diverge_re.match(lines[2])
|
||||
if div_match:
|
||||
remote = "{behind}{1}{ahead of}{0}".format(*div_match.groups(), **symbols)
|
||||
|
||||
print '\n'.join([branch,remote,status])
|
||||
|
||||
|
|
@ -60,3 +60,24 @@ _git-branch ()
|
|||
"($l $c $m -d)-D[delete a branch]" \
|
||||
$dependent_deletion_args
|
||||
}
|
||||
|
||||
(( $+functions[__git_ignore_line] )) ||
|
||||
__git_ignore_line () {
|
||||
declare -a ignored
|
||||
ignored=()
|
||||
((CURRENT > 1)) &&
|
||||
ignored+=(${line[1,CURRENT-1]//(#m)[\[\]()\\*?#<>~\^]/\\$MATCH})
|
||||
((CURRENT < $#line)) &&
|
||||
ignored+=(${line[CURRENT+1,-1]//(#m)[\[\]()\\*?#<>~\^]/\\$MATCH})
|
||||
$* -F ignored
|
||||
}
|
||||
|
||||
(( $+functions[__git_ignore_line_inside_arguments] )) ||
|
||||
__git_ignore_line_inside_arguments () {
|
||||
declare -a compadd_opts
|
||||
|
||||
zparseopts -D -E -a compadd_opts V: J: 1 2 n f X: M: P: S: r: R: q F:
|
||||
|
||||
__git_ignore_line $* $compadd_opts
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ alias gst='git status'
|
|||
compdef _git gst=git-status
|
||||
alias gd='git diff'
|
||||
compdef _git gd=git-diff
|
||||
alias gdc='git diff --cached'
|
||||
compdef _git gdc=git-diff
|
||||
alias gl='git pull'
|
||||
compdef _git gl=git-pull
|
||||
alias gup='git pull --rebase'
|
||||
|
|
@ -22,6 +24,8 @@ alias gca='git commit -v -a'
|
|||
compdef _git gc=git-commit
|
||||
alias gca!='git commit -v -a --amend'
|
||||
compdef _git gca!=git-commit
|
||||
alias gcmsg='git commit -m'
|
||||
compdef _git gcmsg=git-commit
|
||||
alias gco='git checkout'
|
||||
compdef _git gco=git-checkout
|
||||
alias gcm='git checkout master'
|
||||
|
|
@ -52,9 +56,9 @@ compdef gcount=git
|
|||
alias gcl='git config --list'
|
||||
alias gcp='git cherry-pick'
|
||||
compdef _git gcp=git-cherry-pick
|
||||
alias glg='git log --stat --max-count=5'
|
||||
alias glg='git log --stat --max-count=10'
|
||||
compdef _git glg=git-log
|
||||
alias glgg='git log --graph --max-count=5'
|
||||
alias glgg='git log --graph --max-count=10'
|
||||
compdef _git glgg=git-log
|
||||
alias glgga='git log --graph --decorate --all'
|
||||
compdef _git glgga=git-log
|
||||
|
|
@ -70,7 +74,10 @@ alias grh='git reset HEAD'
|
|||
alias grhh='git reset HEAD --hard'
|
||||
alias gclean='git reset --hard && git clean -dfx'
|
||||
alias gwc='git whatchanged -p --abbrev-commit --pretty=medium'
|
||||
alias gf='git ls-files | grep'
|
||||
|
||||
#remove the gf alias
|
||||
#alias gf='git ls-files | grep'
|
||||
|
||||
alias gpoat='git push origin --all && git push origin --tags'
|
||||
alias gmt='git mergetool --no-prompt'
|
||||
compdef _git gm=git-mergetool
|
||||
|
|
@ -78,7 +85,11 @@ compdef _git gm=git-mergetool
|
|||
alias gg='git gui citool'
|
||||
alias gga='git gui citool --amend'
|
||||
alias gk='gitk --all --branches'
|
||||
alias gss='git stash show --text'
|
||||
|
||||
alias gsts='git stash show --text'
|
||||
alias gsta='git stash'
|
||||
alias gstp='git stash pop'
|
||||
alias gstd='git stash drop'
|
||||
|
||||
# Will cd into the top of the current repository
|
||||
# or submodule.
|
||||
|
|
@ -124,3 +135,26 @@ function _git_log_prettily(){
|
|||
}
|
||||
alias glp="_git_log_prettily"
|
||||
compdef _git glp=git-log
|
||||
|
||||
# Work In Progress (wip)
|
||||
# These features allow to pause a branch development and switch to another one (wip)
|
||||
# When you want to go back to work, just unwip it
|
||||
#
|
||||
# This function return a warning if the current branch is a wip
|
||||
function work_in_progress() {
|
||||
if $(git log -n 1 2>/dev/null | grep -q -c wip); then
|
||||
echo "WIP!!"
|
||||
fi
|
||||
}
|
||||
# these alias commit and uncomit wip branches
|
||||
alias gwip='git add -A; git ls-files --deleted -z | xargs -0 git rm; git commit -m "wip"'
|
||||
alias gunwip='git log -n 1 | grep -q -c wip && git reset HEAD~1'
|
||||
|
||||
# these alias ignore changes to file
|
||||
alias gignore='git update-index --assume-unchanged'
|
||||
alias gunignore='git update-index --no-assume-unchanged'
|
||||
# list temporarily ignored files
|
||||
alias gignored='git ls-files -v | grep "^[[:lower:]]"'
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
12
plugins/gitignore/gitignore.plugin.zsh
Normal file
12
plugins/gitignore/gitignore.plugin.zsh
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
function gi() { curl http://gitignore.io/api/$@ ;}
|
||||
|
||||
_gitignireio_get_command_list() {
|
||||
curl -s http://gitignore.io/api/list | tr "," "\n"
|
||||
}
|
||||
|
||||
_gitignireio () {
|
||||
compset -P '*,'
|
||||
compadd -S '' `_gitignireio_get_command_list`
|
||||
}
|
||||
|
||||
compdef _gitignireio gi
|
||||
|
|
@ -19,6 +19,9 @@ if ! gpg-connect-agent --quiet /bye > /dev/null 2> /dev/null; then
|
|||
# source settings of old agent, if applicable
|
||||
if [ -f "${GPG_ENV}" ]; then
|
||||
. ${GPG_ENV} > /dev/null
|
||||
export GPG_AGENT_INFO
|
||||
export SSH_AUTH_SOCK
|
||||
export SSH_AGENT_PID
|
||||
fi
|
||||
|
||||
# check again if another agent is running using the newly sourced settings
|
||||
|
|
|
|||
|
|
@ -23,8 +23,10 @@ _1st_arguments=(
|
|||
"auth\:login":"log in with your heroku credentials"
|
||||
"auth\:logout":"clear local authentication credentials"
|
||||
"config":"display the config vars for an app"
|
||||
"config\:add":"add one or more config vars"
|
||||
"config\:remove":"remove a config var"
|
||||
"config\:pull":"pull heroku config vars down to the local environment"
|
||||
"config\:push":"push local config vars to heroku"
|
||||
"config\:set":"set one or more config vars"
|
||||
"config\:unset":"unset one or more config vars"
|
||||
"db\:push":"push local data up to your app"
|
||||
"db\:pull":"pull heroku data down into your local database"
|
||||
"domains":"list custom domains for an app"
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ open_jira_issue () {
|
|||
|
||||
if [ -z "$1" ]; then
|
||||
echo "Opening new issue"
|
||||
`open $jira_url/secure/CreateIssue!default.jspa`
|
||||
$open_cmd "$jira_url/secure/CreateIssue!default.jspa"
|
||||
else
|
||||
echo "Opening issue #$1"
|
||||
if [[ "x$JIRA_RAPID_BOARD" = "xtrue" ]]; then
|
||||
|
|
|
|||
58
plugins/jump/jump.plugin.zsh
Normal file
58
plugins/jump/jump.plugin.zsh
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
# Easily jump around the file system by manually adding marks
|
||||
# marks are stored as symbolic links in the directory $MARKPATH (default $HOME/.marks)
|
||||
#
|
||||
# jump FOO: jump to a mark named FOO
|
||||
# mark FOO: create a mark named FOO
|
||||
# unmark FOO: delete a mark
|
||||
# marks: lists all marks
|
||||
#
|
||||
export MARKPATH=$HOME/.marks
|
||||
|
||||
jump() {
|
||||
cd -P "$MARKPATH/$1" 2>/dev/null || echo "No such mark: $1"
|
||||
}
|
||||
|
||||
mark() {
|
||||
if (( $# == 0 )); then
|
||||
MARK=$(basename "$(pwd)")
|
||||
else
|
||||
MARK="$1"
|
||||
fi
|
||||
if read -q \?"Mark $(pwd) as ${MARK}? (y/n) "; then
|
||||
mkdir -p "$MARKPATH"; ln -s "$(pwd)" "$MARKPATH/$MARK"
|
||||
fi
|
||||
}
|
||||
|
||||
unmark() {
|
||||
rm -i "$MARKPATH/$1"
|
||||
}
|
||||
|
||||
autoload colors
|
||||
marks() {
|
||||
for link in $MARKPATH/*(@); do
|
||||
local markname="$fg[cyan]${link:t}$reset_color"
|
||||
local markpath="$fg[blue]$(readlink $link)$reset_color"
|
||||
printf "%s\t" $markname
|
||||
printf "-> %s \t\n" $markpath
|
||||
done
|
||||
}
|
||||
|
||||
_completemarks() {
|
||||
if [[ $(ls "${MARKPATH}" | wc -l) -gt 1 ]]; then
|
||||
reply=($(ls $MARKPATH/**/*(-) | grep : | sed -E 's/(.*)\/([_\da-zA-Z\-]*):$/\2/g'))
|
||||
else
|
||||
if readlink -e "${MARKPATH}"/* &>/dev/null; then
|
||||
reply=($(ls "${MARKPATH}"))
|
||||
fi
|
||||
fi
|
||||
}
|
||||
compctl -K _completemarks jump
|
||||
compctl -K _completemarks unmark
|
||||
|
||||
_mark_expansion() {
|
||||
setopt extendedglob
|
||||
autoload -U modify-current-argument
|
||||
modify-current-argument '$(readlink "$MARKPATH/$ARG")'
|
||||
}
|
||||
zle -N _mark_expansion
|
||||
bindkey "^g" _mark_expansion
|
||||
18
plugins/knife_ssh/knife_ssh.plugin.zsh
Normal file
18
plugins/knife_ssh/knife_ssh.plugin.zsh
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
function knife_ssh() {
|
||||
grep -q $1 ~/.knife_comp~ 2> /dev/null || rm -f ~/.knife_comp~;
|
||||
ssh $(knife node show $1 | awk '/IP:/{print $2}')
|
||||
}
|
||||
|
||||
_knife_ssh() {
|
||||
if hash knife 2>/dev/null; then
|
||||
if [[ ! -f ~/.knife_comp~ ]]; then
|
||||
echo "\nGenerating ~/.knife_comp~..." >/dev/stderr
|
||||
knife node list > ~/.knife_comp~
|
||||
fi
|
||||
compadd $(<~/.knife_comp~)
|
||||
else
|
||||
echo "Could not find knife" > /dev/stderr;
|
||||
fi
|
||||
}
|
||||
|
||||
compdef _knife_ssh knife_ssh
|
||||
|
|
@ -13,6 +13,7 @@ alias hglr='hg pull --rebase'
|
|||
alias hgo='hg outgoing'
|
||||
alias hgp='hg push'
|
||||
alias hgs='hg status'
|
||||
alias hgsl='log --limit 20 --template "{node|short} | {date|isodatesec} | {author|user}: {desc|strip|firstline}\n" '
|
||||
# this is the 'git commit --amend' equivalent
|
||||
alias hgca='hg qimport -r tip ; hg qrefresh -e ; hg qfinish tip'
|
||||
|
||||
|
|
|
|||
63
plugins/mix/_mix
Normal file
63
plugins/mix/_mix
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
#compdef mix
|
||||
#autoload
|
||||
|
||||
# Elixir mix zsh completion
|
||||
|
||||
local -a _1st_arguments
|
||||
_1st_arguments=(
|
||||
'archive:Archive this project into a .ez file'
|
||||
'clean:Clean generated application files'
|
||||
'compile:Compile source files'
|
||||
'deps:List dependencies and their status'
|
||||
"deps.clean:Remove dependencies' files"
|
||||
'deps.compile:Compile dependencies'
|
||||
'deps.get:Get all out of date dependencies'
|
||||
'deps.unlock:Unlock the given dependencies'
|
||||
'deps.update:Update dependencies'
|
||||
'do:Executes the commands separated by comma'
|
||||
'escriptize:Generates an escript for the project'
|
||||
'help:Print help information for tasks'
|
||||
'local:List local tasks'
|
||||
'local.install:Install a task or an archive locally'
|
||||
'local.rebar:Install rebar locally'
|
||||
'local.uninstall:Uninstall local tasks or archives'
|
||||
'new:Creates a new Elixir project'
|
||||
'run:Run the given file or expression'
|
||||
"test:Run a project's tests"
|
||||
'--help:Describe available tasks'
|
||||
'--version:Prints the Elixir version information'
|
||||
)
|
||||
|
||||
__task_list ()
|
||||
{
|
||||
local expl
|
||||
declare -a tasks
|
||||
|
||||
tasks=(archive clean compile deps deps.clean deps.compile deps.get deps.unlock deps.update do escriptize help local local.install local.rebar local.uninstall new run test)
|
||||
|
||||
_wanted tasks expl 'help' compadd $tasks
|
||||
}
|
||||
|
||||
local expl
|
||||
|
||||
local curcontext="$curcontext" state line
|
||||
typeset -A opt_args
|
||||
|
||||
_arguments -C \
|
||||
':command:->command' \
|
||||
'*::options:->options'
|
||||
|
||||
case $state in
|
||||
(command)
|
||||
_describe -t commands "mix subcommand" _1st_arguments
|
||||
return
|
||||
;;
|
||||
|
||||
(options)
|
||||
case $line[1] in
|
||||
(help)
|
||||
_arguments ':feature:__task_list'
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
||||
2
plugins/mosh/mosh.plugin.zsh
Normal file
2
plugins/mosh/mosh.plugin.zsh
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
# Allow SSH tab completion for mosh hostnames
|
||||
compdef mosh=ssh
|
||||
|
|
@ -24,16 +24,18 @@ export RESET_FORMATTING=`tput sgr0`
|
|||
# Wrapper function for Maven's mvn command.
|
||||
mvn-color()
|
||||
{
|
||||
# Filter mvn output using sed
|
||||
mvn $@ | sed -e "s/\(\[INFO\]\ \-.*\)/${TEXT_BLUE}${BOLD}\1/g" \
|
||||
-e "s/\(\[INFO\]\ \[.*\)/${RESET_FORMATTING}${BOLD}\1${RESET_FORMATTING}/g" \
|
||||
(
|
||||
# Filter mvn output using sed. Before filtering set the locale to C, so invalid characters won't break some sed implementations
|
||||
unset LANG
|
||||
LC_CTYPE=C mvn $@ | sed -e "s/\(\[INFO\]\)\(.*\)/${TEXT_BLUE}${BOLD}\1${RESET_FORMATTING}\2/g" \
|
||||
-e "s/\(\[INFO\]\ BUILD SUCCESSFUL\)/${BOLD}${TEXT_GREEN}\1${RESET_FORMATTING}/g" \
|
||||
-e "s/\(\[WARNING\].*\)/${BOLD}${TEXT_YELLOW}\1${RESET_FORMATTING}/g" \
|
||||
-e "s/\(\[ERROR\].*\)/${BOLD}${TEXT_RED}\1${RESET_FORMATTING}/g" \
|
||||
-e "s/\(\[WARNING\]\)\(.*\)/${BOLD}${TEXT_YELLOW}\1${RESET_FORMATTING}\2/g" \
|
||||
-e "s/\(\[ERROR\]\)\(.*\)/${BOLD}${TEXT_RED}\1${RESET_FORMATTING}\2/g" \
|
||||
-e "s/Tests run: \([^,]*\), Failures: \([^,]*\), Errors: \([^,]*\), Skipped: \([^,]*\)/${BOLD}${TEXT_GREEN}Tests run: \1${RESET_FORMATTING}, Failures: ${BOLD}${TEXT_RED}\2${RESET_FORMATTING}, Errors: ${BOLD}${TEXT_RED}\3${RESET_FORMATTING}, Skipped: ${BOLD}${TEXT_YELLOW}\4${RESET_FORMATTING}/g"
|
||||
|
||||
# Make sure formatting is reset
|
||||
echo -ne ${RESET_FORMATTING}
|
||||
)
|
||||
}
|
||||
|
||||
# Override the mvn command with the colorized one.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,13 @@
|
|||
# Open the node api for your current version to the optional section.
|
||||
# TODO: Make the section part easier to use.
|
||||
function node-docs {
|
||||
open "http://nodejs.org/docs/$(node --version)/api/all.html#all_$1"
|
||||
# get the open command
|
||||
local open_cmd
|
||||
if [[ $(uname -s) == 'Darwin' ]]; then
|
||||
open_cmd='open'
|
||||
else
|
||||
open_cmd='xdg-open'
|
||||
fi
|
||||
|
||||
$open_cmd "http://nodejs.org/docs/$(node --version)/api/all.html#all_$1"
|
||||
}
|
||||
|
|
|
|||
26
plugins/nvm/_nvm
Normal file
26
plugins/nvm/_nvm
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#compdef nvm
|
||||
#autoload
|
||||
|
||||
[[ -s ~/.nvm/nvm.sh ]] || return 0
|
||||
|
||||
local -a _1st_arguments
|
||||
_1st_arguments=(
|
||||
'help:show help'
|
||||
'install:download and install a version'
|
||||
'uninstall:uninstall a version'
|
||||
'use:modify PATH to use version'
|
||||
'run:run version with given arguments'
|
||||
'ls:list installed versions or versions matching a given description'
|
||||
'ls-remote:list remote versions available for install'
|
||||
'deactivate:undo effects of NVM on current shell'
|
||||
'alias:show or set aliases'
|
||||
'unalias:deletes an alias'
|
||||
'copy-packages:install global NPM packages to current version'
|
||||
)
|
||||
|
||||
_arguments -C '*:: :->subcmds' && return 0
|
||||
|
||||
if (( CURRENT == 1 )); then
|
||||
_describe -t commands "nvm subcommand" _1st_arguments
|
||||
return
|
||||
fi
|
||||
3
plugins/nvm/nvm.plugin.zsh
Normal file
3
plugins/nvm/nvm.plugin.zsh
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# The addition 'nvm install' attempts in ~/.profile
|
||||
|
||||
[[ -s ~/.nvm/nvm.sh ]] && . ~/.nvm/nvm.sh
|
||||
|
|
@ -157,3 +157,37 @@ function trash() {
|
|||
function vncviewer() {
|
||||
open vnc://$@
|
||||
}
|
||||
|
||||
# iTunes control function
|
||||
function itunes() {
|
||||
local opt=$1
|
||||
shift
|
||||
case "$opt" in
|
||||
launch|play|pause|stop|rewind|resume|quit)
|
||||
;;
|
||||
mute)
|
||||
opt="set mute to true"
|
||||
;;
|
||||
unmute)
|
||||
opt="set mute to false"
|
||||
;;
|
||||
next|previous)
|
||||
opt="$opt track"
|
||||
;;
|
||||
""|-h|--help)
|
||||
echo "Usage: itunes <option>"
|
||||
echo "option:"
|
||||
echo "\tlaunch|play|pause|stop|rewind|resume|quit"
|
||||
echo "\tmute|unmute\tcontrol volume set"
|
||||
echo "\tnext|previous\tplay next or previous track"
|
||||
echo "\thelp\tshow this message and exit"
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
print "Unkonwn option: $opt"
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
osascript -e "tell application \"iTunes\" to $opt"
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ _pass_cmd_show () {
|
|||
_pass_complete_entries_helper () {
|
||||
local IFS=$'\n'
|
||||
local prefix="${PASSWORD_STORE_DIR:-$HOME/.password-store}"
|
||||
_values -C 'passwords' $(find "$prefix" \( -name .git -o -name .gpg-id \) -prune -o $@ -print | sed -e "s#${prefix}.##" -e 's#\.gpg##' | sort)
|
||||
_values -C 'passwords' $(find -L "$prefix" \( -name .git -o -name .gpg-id \) -prune -o $@ -print | sed -e "s#${prefix}.##" -e 's#\.gpg##' | sort)
|
||||
}
|
||||
|
||||
_pass_complete_entries_with_subdirs () {
|
||||
|
|
|
|||
34
plugins/pep8/_pep8
Normal file
34
plugins/pep8/_pep8
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#compdef pep8
|
||||
#
|
||||
# this is zsh completion function file.
|
||||
# generated by genzshcomp(ver: 0.5.1)
|
||||
#
|
||||
|
||||
typeset -A opt_args
|
||||
local context state line
|
||||
|
||||
_arguments -s -S \
|
||||
"--help[show this help message and exit]:" \
|
||||
"-h[show this help message and exit]:" \
|
||||
"--version[show program's version number and exit]:" \
|
||||
"--verbose[print status messages, or debug with -vv]" \
|
||||
"-v[print status messages, or debug with -vv]" \
|
||||
"--quiet[report only file names, or nothing with -qq]" \
|
||||
"-q[report only file names, or nothing with -qq]" \
|
||||
"--repeat[(obsolete) show all occurrences of the same error]" \
|
||||
"-r[(obsolete) show all occurrences of the same error]" \
|
||||
"--first[show first occurrence of each error]" \
|
||||
"--exclude[exclude files or directories which match these comma separated patterns (default: .svn,CVS,.bzr,.hg,.git,__pycache__)]::patterns:_files" \
|
||||
"--filename[when parsing directories, only check filenames matching these comma separated patterns (default: *.py)]::patterns:_files" \
|
||||
"--select[select errors and warnings (e.g. E,W6)]::errors:_files" \
|
||||
"--ignore[skip errors and warnings (e.g. E4,W)]::errors:_files" \
|
||||
"--show-source[show source code for each error]" \
|
||||
"--show-pep8[show text of PEP 8 for each error (implies --first)]" \
|
||||
"--statistics[count errors and warnings]" \
|
||||
"--count[print total number of errors and warnings to standard error and set exit code to 1 if total is not null]" \
|
||||
"--max-line-length[set maximum allowed line length (default: 79)]::n:_files" \
|
||||
"--format[set the error format \[default|pylint|<custom>\]]::format:_files" \
|
||||
"--diff[report only lines changed according to the unified diff received on STDIN]" \
|
||||
"--benchmark[measure processing speed are read from the \[pep8\] section of the tox.ini fg file located in any parent folder of the path(s) llowed options are: exclude, filename, select, ngth, count, format, quiet, show-pep8, show-source, .]" \
|
||||
"--config[user config file location (default: /home/gsemet/.config/pep8)]::path:_files" \
|
||||
"*::args:_files"
|
||||
|
|
@ -6,8 +6,8 @@
|
|||
_pip_all() {
|
||||
# we cache the list of packages (originally from the macports plugin)
|
||||
if (( ! $+piplist )); then
|
||||
echo -n " (caching package index...)"
|
||||
piplist=($(pip search * | cut -d ' ' -f 1 | tr '[A-Z]' '[a-z]'))
|
||||
zsh-pip-cache-packages
|
||||
piplist=($(cat $ZSH_PIP_CACHE_FILE))
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
@ -62,8 +62,13 @@ case "$words[1]" in
|
|||
'(--no-install)--no-install[only download packages]' \
|
||||
'(--no-download)--no-download[only install downloaded packages]' \
|
||||
'(--install-option)--install-option[extra arguments to be supplied to the setup.py]' \
|
||||
'(--single-version-externally-managed)--single-version-externally-managed[do not download/install dependencies. requires --record or --root]'\
|
||||
'(--root)--root[treat this path as a fake chroot, installing into it. implies --single-version-externally-managed]'\
|
||||
'(--record)--record[file to record all installed files to.]'\
|
||||
'(-r --requirement)'{-r,--requirement}'[requirements file]: :_files'\
|
||||
'(-e --editable)'{-e,--editable}'[path of or url to source to link to instead of installing.]: :_files -/'\
|
||||
'1: :->packages' && return 0
|
||||
|
||||
|
||||
if [[ "$state" == packages ]]; then
|
||||
_pip_all
|
||||
_wanted piplist expl 'packages' compadd -a piplist
|
||||
|
|
|
|||
78
plugins/pip/pip.plugin.zsh
Normal file
78
plugins/pip/pip.plugin.zsh
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
# Usage:
|
||||
# Just add pip to your installed plugins.
|
||||
|
||||
# If you would like to change the cheeseshops used for autocomplete set
|
||||
# ZSH_PIP_INDEXES in your zshrc. If one of your indexes are bogus you won't get
|
||||
# any kind of error message, pip will just not autocomplete from them. Double
|
||||
# check!
|
||||
#
|
||||
# If you would like to clear your cache, go ahead and do a
|
||||
# "zsh-pip-clear-cache".
|
||||
|
||||
ZSH_PIP_CACHE_FILE=~/.pip/zsh-cache
|
||||
ZSH_PIP_INDEXES=(https://pypi.python.org/simple/)
|
||||
|
||||
zsh-pip-clear-cache() {
|
||||
rm $ZSH_PIP_CACHE_FILE
|
||||
unset piplist
|
||||
}
|
||||
|
||||
zsh-pip-clean-packages() {
|
||||
sed -n '/<a href/ s/.*>\([^<]\{1,\}\).*/\1/p'
|
||||
}
|
||||
|
||||
zsh-pip-cache-packages() {
|
||||
if [[ ! -d ${ZSH_PIP_CACHE_FILE:h} ]]; then
|
||||
mkdir -p ${ZSH_PIP_CACHE_FILE:h}
|
||||
fi
|
||||
|
||||
if [[ ! -f $ZSH_PIP_CACHE_FILE ]]; then
|
||||
echo -n "(...caching package index...)"
|
||||
tmp_cache=/tmp/zsh_tmp_cache
|
||||
for index in $ZSH_PIP_INDEXES ; do
|
||||
# well... I've already got two problems
|
||||
curl $index 2>/dev/null | \
|
||||
zsh-pip-clean-packages \
|
||||
>> $tmp_cache
|
||||
done
|
||||
sort $tmp_cache | uniq | tr '\n' ' ' > $ZSH_PIP_CACHE_FILE
|
||||
rm $tmp_cache
|
||||
fi
|
||||
}
|
||||
|
||||
# A test function that validates the regex against known forms of the simple
|
||||
# index. If you modify the regex to make it work for you, you should add a test
|
||||
# case in here and make sure that your changes don't break things for someone
|
||||
# else.
|
||||
zsh-pip-test-clean-packages() {
|
||||
local expected
|
||||
local actual
|
||||
expected="0x10c-asm
|
||||
1009558_nester"
|
||||
|
||||
actual=$(echo -n "<html><head><title>Simple Index</title><meta name=\"api-version\" value=\"2\" /></head><body>
|
||||
<a href='0x10c-asm'>0x10c-asm</a><br/>
|
||||
<a href='1009558_nester'>1009558_nester</a><br/>
|
||||
</body></html>" | zsh-pip-clean-packages)
|
||||
|
||||
if [[ $actual != $expected ]] ; then
|
||||
echo -e "python's simple index is broken:\n$actual\n !=\n$expected"
|
||||
else
|
||||
echo "python's simple index is fine"
|
||||
fi
|
||||
|
||||
actual=$(echo -n '<html>
|
||||
<head>
|
||||
<title>Simple Package Index</title>
|
||||
</head>
|
||||
<body>
|
||||
<a href="0x10c-asm">0x10c-asm</a><br/>
|
||||
<a href="1009558_nester">1009558_nester</a><br/>
|
||||
</body></html>' | zsh-pip-clean-packages)
|
||||
|
||||
if [[ $actual != $expected ]] ; then
|
||||
echo -e "the djangopypi2 index is broken:\n$actual\n !=\n$expected"
|
||||
else
|
||||
echo "the djangopypi2 index is fine"
|
||||
fi
|
||||
}
|
||||
389
plugins/pod/_pod
Normal file
389
plugins/pod/_pod
Normal file
|
|
@ -0,0 +1,389 @@
|
|||
#compdef pod
|
||||
#autoload
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# FILE: _pod
|
||||
# DESCRIPTION: Cocoapods (0.27.1) autocomplete plugin for Oh-My-Zsh
|
||||
# http://cocoapods.org
|
||||
# AUTHOR: Alexandre Joly (alexandre.joly@mekanics.ch)
|
||||
# GITHUB: https://github.com/mekanics
|
||||
# TWITTER: @jolyAlexandre
|
||||
# VERSION: 0.0.3
|
||||
# LICENSE: MIT
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
local -a _1st_arguments
|
||||
_1st_arguments=(
|
||||
'help:Show help for the given command'
|
||||
'init:Generate a Podfile for the current directory'
|
||||
'install:Install project dependencies'
|
||||
'ipc:Inter-process communication'
|
||||
'list:List pods'
|
||||
'outdated:Show outdated project dependencies'
|
||||
'podfile-info:Shows information on installed Pods'
|
||||
'push:Push new specifications to a spec-repo'
|
||||
'repo:Manage spec-repositories'
|
||||
'search:Searches for pods'
|
||||
'setup:Setup the CocoaPods environment'
|
||||
'spec:Manage pod specs'
|
||||
'update:Update outdated project dependencies'
|
||||
)
|
||||
|
||||
local -a _repo_arguments
|
||||
_repo_arguments=(
|
||||
'add:Add a spec repo'
|
||||
'lint:Validates all specs in a repo'
|
||||
'remove:Remove a spec repo.'
|
||||
'update:Update a spec repo'
|
||||
)
|
||||
|
||||
local -a _spec_arguments
|
||||
_spec_arguments=(
|
||||
'cat:Prints a spec file'
|
||||
'create:Create spec file stub'
|
||||
'edit:Edit a spec file'
|
||||
'lint:Validates a spec file'
|
||||
'which:Prints the path of the given spec'
|
||||
)
|
||||
|
||||
local -a _ipc_arguments
|
||||
_ipc_arguments=(
|
||||
'list:Lists the specifications know to CocoaPods'
|
||||
'podfile:Converts a Podfile to YAML'
|
||||
'repl:The repl listens to commands on standard input'
|
||||
'spec:Converts a podspec to YAML'
|
||||
'update-search-index:Updates the search index'
|
||||
)
|
||||
|
||||
local -a _list_arguments
|
||||
_list_arguments=(
|
||||
'new:Lists pods introduced in the master spec-repo since the last check'
|
||||
)
|
||||
|
||||
local -a _inherited_options
|
||||
_inherited_options=(
|
||||
'(--silent)--silent[Show nothing]' \
|
||||
'(--version)--version[Show the version of CocoaPods]' \
|
||||
'(--no-color)--no-color[Show output without color]' \
|
||||
'(--verbose)--verbose[Show more debugging information]' \
|
||||
'(--help)--help[Show help banner of specified command]'
|
||||
)
|
||||
|
||||
local -a _install_options
|
||||
_install_options=(
|
||||
'(--no-clean)--no-clean[Leave SCM dirs like `.git` and `.svn` intact after downloading]' \
|
||||
'(--no-integrate)--no-integrate[Skip integration of the Pods libraries in the Xcode project(s)]' \
|
||||
'(--no-repo-update)--no-repo-update[Skip running `pod repo update` before install]'
|
||||
)
|
||||
|
||||
local -a _update_options
|
||||
_update_options=(
|
||||
'(--no-clean)--no-clean[Leave SCM dirs like `.git` and `.svn intact after downloading]' \
|
||||
'(--no-integrate)--no-integrate[Skip integration of the Pods libraries in the Xcode project(s)]' \
|
||||
'(--no-repo-update)--no-repo-update[Skip running `pod repo update before install]'
|
||||
)
|
||||
|
||||
local -a _outdated_options
|
||||
_outdated_options=(
|
||||
'(--no-repo-update)--no-repo-update[Skip running `pod repo update` before install]'
|
||||
)
|
||||
|
||||
local -a _search_options
|
||||
_search_options=(
|
||||
'(--full)--full[Search by name, summary, and description]' \
|
||||
'(--stats)--stats[Show additional stats (like GitHub watchers and forks)]' \
|
||||
'(--ios)--ios[Restricts the search to Pods supported on iOS]' \
|
||||
'(--osx)--osx[Restricts the search to Pods supported on OS X]'
|
||||
)
|
||||
|
||||
local -a _list_options
|
||||
_list_options=(
|
||||
'(--update)--update[Run `pod repo update` before listing]'
|
||||
)
|
||||
|
||||
local -a _podfile_info_options
|
||||
_podfile_info_options=(
|
||||
'(--all)--all[Show information about all Pods with dependencies that are used in a project]' \
|
||||
'(--md)--md[Output information in Markdown format]' \
|
||||
'*:script or directory:_files'
|
||||
)
|
||||
|
||||
local -a _push_options
|
||||
_push_options=(
|
||||
'(--allow-warnings)--allow-warnings[Allows pushing even if there are warnings]' \
|
||||
'(--local-only)--local-only[Does not perform the step of pushing REPO to its remote]' \
|
||||
'*:script or directory:_files'
|
||||
)
|
||||
|
||||
local -a _repo_lint_options
|
||||
_repo_lint_options=(
|
||||
'(--only-errors)--only-errors[Lint presents only the errors]'
|
||||
)
|
||||
|
||||
local -a _setup_options
|
||||
_setup_options=(
|
||||
'(--push)--push[Use this option to enable push access once granted]'
|
||||
)
|
||||
|
||||
local -a _spec_lint_options
|
||||
_spec_lint_options=(
|
||||
'(--quick)--quick[Lint skips checks that would require to download and build the spec]' \
|
||||
'(--only-errors)--only-errors[Lint validates even if warnings are present]' \
|
||||
'(--no-clean)--no-clean[Lint leaves the build directory intact for inspection]' \
|
||||
'*:script or directory:_files'
|
||||
)
|
||||
|
||||
local -a _spec_cat_options
|
||||
_spec_cat_options=(
|
||||
'(--show-all)--show-all[Pick from all versions of the given podspec]'
|
||||
)
|
||||
|
||||
local -a _spec_which_options
|
||||
_spec_which_options=(
|
||||
'(--show-all)--show-all[Print all versions of the given podspec]'
|
||||
)
|
||||
|
||||
local -a _spec_edit_options
|
||||
_spec_edit_options=(
|
||||
'(--show-all)--show-all[Pick which spec to edit from all available versions of the given podspec]'
|
||||
)
|
||||
|
||||
|
||||
__first_command_list ()
|
||||
{
|
||||
local expl
|
||||
declare -a tasks
|
||||
|
||||
tasks=(install ipc list outdated podfile-info push repo search setup spec update)
|
||||
|
||||
_wanted tasks expl 'help' compadd $tasks
|
||||
}
|
||||
|
||||
__repo_list() {
|
||||
_wanted application expl 'repo' compadd $(command ls -1 ~/.cocoapods/repos 2>/dev/null | sed -e 's/ /\\ /g')
|
||||
}
|
||||
|
||||
__pod-repo() {
|
||||
local curcontext="$curcontext" state line
|
||||
typeset -A opt_args
|
||||
|
||||
_arguments -C \
|
||||
':command:->command' \
|
||||
'*::options:->options'
|
||||
|
||||
case $state in
|
||||
(command)
|
||||
_describe -t commands "pod repo" _repo_arguments
|
||||
return
|
||||
;;
|
||||
|
||||
(options)
|
||||
case $line[1] in
|
||||
(lint)
|
||||
_arguments \
|
||||
$_inherited_options \
|
||||
$_repo_lint_options \
|
||||
':feature:__repo_list'
|
||||
;;
|
||||
|
||||
(update)
|
||||
_arguments \
|
||||
$_inherited_options \
|
||||
':feature:__repo_list'
|
||||
;;
|
||||
|
||||
(add)
|
||||
_arguments \
|
||||
$_inherited_options
|
||||
|
||||
(remove)
|
||||
_arguments \
|
||||
$_inherited_options \
|
||||
':feature:__repo_list'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__pod-spec() {
|
||||
local curcontext="$curcontext" state line
|
||||
typeset -A opt_args
|
||||
|
||||
_arguments -C \
|
||||
':command:->command' \
|
||||
'*::options:->options'
|
||||
|
||||
case $state in
|
||||
(command)
|
||||
_describe -t commands "pod spec" _spec_arguments
|
||||
return
|
||||
;;
|
||||
|
||||
(options)
|
||||
case $line[1] in
|
||||
(create)
|
||||
_arguments \
|
||||
$_inherited_options
|
||||
;;
|
||||
|
||||
(lint)
|
||||
_arguments \
|
||||
$_inherited_options \
|
||||
$_spec_lint_options
|
||||
;;
|
||||
|
||||
(cat)
|
||||
_arguments \
|
||||
$_inherited_options \
|
||||
$_spec_cat_options
|
||||
;;
|
||||
|
||||
(which)
|
||||
_arguments \
|
||||
$_inherited_options \
|
||||
$_spec_which_options
|
||||
;;
|
||||
|
||||
(edit)
|
||||
_arguments \
|
||||
$_inherited_options \
|
||||
$_spec_edit_options
|
||||
;;
|
||||
esac
|
||||
return
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__pod-ipc() {
|
||||
local curcontext="$curcontext" state line
|
||||
typeset -A opt_args
|
||||
|
||||
_arguments -C \
|
||||
':command:->command' \
|
||||
'*::options:->options'
|
||||
|
||||
case $state in
|
||||
(command)
|
||||
_describe -t commands "pod ipc" _ipc_arguments
|
||||
return
|
||||
;;
|
||||
|
||||
(options)
|
||||
_arguments -C \
|
||||
$_inherited_options
|
||||
return
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__pod-list() {
|
||||
local curcontext="$curcontext" state line
|
||||
typeset -A opt_args
|
||||
|
||||
_arguments -C \
|
||||
$_inherited_options \
|
||||
$_list_options \
|
||||
':command:->command' \
|
||||
'*::options:->options'
|
||||
|
||||
case $state in
|
||||
(command)
|
||||
_describe -t commands "pod list" _list_arguments
|
||||
return
|
||||
;;
|
||||
|
||||
(options)
|
||||
_arguments -C \
|
||||
$_inherited_options \
|
||||
$_list_options
|
||||
return
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
local curcontext="$curcontext" state line
|
||||
typeset -A opt_args
|
||||
|
||||
_arguments -C \
|
||||
$_inherited_options \
|
||||
':command:->command' \
|
||||
'*::options:->options'
|
||||
|
||||
case $state in
|
||||
(command)
|
||||
_describe -t commands "pod" _1st_arguments
|
||||
return
|
||||
;;
|
||||
|
||||
(options)
|
||||
case $line[1] in
|
||||
(help)
|
||||
_arguments \
|
||||
$_inherited_options \
|
||||
':help:__first_command_list'
|
||||
;;
|
||||
|
||||
(push)
|
||||
_arguments \
|
||||
$_inherited_options \
|
||||
$_push_options \
|
||||
':repo:__repo_list'
|
||||
;;
|
||||
|
||||
(repo)
|
||||
__pod-repo
|
||||
;;
|
||||
|
||||
(spec)
|
||||
__pod-spec
|
||||
;;
|
||||
|
||||
(ipc)
|
||||
__pod-ipc
|
||||
;;
|
||||
|
||||
(list)
|
||||
__pod-list
|
||||
;;
|
||||
|
||||
(install)
|
||||
_arguments \
|
||||
$_inherited_options \
|
||||
$_install_options
|
||||
;;
|
||||
|
||||
(update)
|
||||
_arguments \
|
||||
$_inherited_options \
|
||||
$_update_options
|
||||
;;
|
||||
|
||||
(outdated)
|
||||
_arguments \
|
||||
$_inherited_options \
|
||||
$_outdated_options
|
||||
;;
|
||||
|
||||
(search)
|
||||
_arguments \
|
||||
$_inherited_options \
|
||||
$_search_options
|
||||
;;
|
||||
|
||||
(podfile-info)
|
||||
_arguments \
|
||||
$_inherited_options \
|
||||
$_podfile_info_options
|
||||
;;
|
||||
|
||||
(setup)
|
||||
_arguments \
|
||||
$_inherited_options \
|
||||
$_setup_options
|
||||
;;
|
||||
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#compdef powify
|
||||
|
||||
_powify_all_servers() {
|
||||
all_servers=(`ls $HOME/.pow/`)
|
||||
all_servers=(`ls $HOME/.pow/ 2>/dev/null`)
|
||||
}
|
||||
|
||||
local -a all_servers
|
||||
|
|
@ -30,7 +30,7 @@ fi
|
|||
|
||||
case "$words[1]" in
|
||||
server)
|
||||
_values \
|
||||
_values , \
|
||||
'install[install pow server]' \
|
||||
'reinstall[reinstall pow server]' \
|
||||
'update[update pow server]' \
|
||||
|
|
@ -45,7 +45,7 @@ case "$words[1]" in
|
|||
'config[print the current server configuration]' \
|
||||
'logs[tails the pow server logs]' ;;
|
||||
utils)
|
||||
_values \
|
||||
_values , \
|
||||
'install[install powify.dev server management tool]' \
|
||||
'reinstall[reinstall powify.dev server management tool]' \
|
||||
'uninstall[uninstall powify.dev server management tool]' ;;
|
||||
|
|
|
|||
31
plugins/pyenv/pyenv.plugin.zsh
Normal file
31
plugins/pyenv/pyenv.plugin.zsh
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
_homebrew-installed() {
|
||||
type brew &> /dev/null
|
||||
}
|
||||
|
||||
_pyenv-from-homebrew-installed() {
|
||||
brew --prefix pyenv &> /dev/null
|
||||
}
|
||||
|
||||
FOUND_PYENV=0
|
||||
pyenvdirs=("$HOME/.pyenv" "/usr/local/pyenv" "/opt/pyenv")
|
||||
if _homebrew-installed && _pyenv-from-homebrew-installed ; then
|
||||
pyenvdirs=($(brew --prefix pyenv) "${pyenvdirs[@]}")
|
||||
fi
|
||||
|
||||
for pyenvdir in "${pyenvdirs[@]}" ; do
|
||||
if [ -d $pyenvdir/bin -a $FOUND_PYENV -eq 0 ] ; then
|
||||
FOUND_PYENV=1
|
||||
export PYENV_ROOT=$pyenvdir
|
||||
export PATH=${pyenvdir}/bin:$PATH
|
||||
eval "$(pyenv init --no-rehash - zsh)"
|
||||
|
||||
function pyenv_prompt_info() {
|
||||
echo "$(pyenv version-name)"
|
||||
}
|
||||
fi
|
||||
done
|
||||
unset pyenvdir
|
||||
|
||||
if [ $FOUND_PYENV -eq 0 ] ; then
|
||||
function pyenv_prompt_info() { echo "system: $(python -V 2>&1 | cut -f 2 -d ' ')" }
|
||||
fi
|
||||
31
plugins/pylint/_pylint
Normal file
31
plugins/pylint/_pylint
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#compdef pylint
|
||||
#
|
||||
# this is zsh completion function file.
|
||||
# generated by genzshcomp(ver: 0.5.1)
|
||||
#
|
||||
|
||||
typeset -A opt_args
|
||||
local context state line
|
||||
|
||||
_arguments -s -S \
|
||||
"--help[show this help message and exit]:" \
|
||||
"-h[show this help message and exit]:" \
|
||||
"--version[show program's version number and exit]:" \
|
||||
"--long-help[more verbose help.]" \
|
||||
"--rcfile[Specify a configuration file.]::<file>:_files" \
|
||||
"--errors-only[In error mode, checkers without error messages are disabled and for others, only the ERROR messages are displayed, and no reports are done by default]" \
|
||||
"-E[In error mode, checkers without error messages are disabled and for others, only the ERROR messages are displayed, and no reports are done by default]" \
|
||||
"--ignore[Add files or directories to the blacklist. They should be base names, not paths. \[current: CVS\]]::<file>[,<file>...]:_files" \
|
||||
"--help-msg[Display a help message for the given message id and exit. The value may be a comma separated list of message ids.]::<msg-id>:_files" \
|
||||
"--generate-rcfile[Generate a sample configuration file according to the current configuration. You can put other options before this one to get them in the generated configuration.]" \
|
||||
"--enable[Enable the message, report, category or checker with the given id(s). You can either give multiple identifier separated by comma (,) or put this option multiple time.]::<msg ids>:_files" \
|
||||
"-e[Enable the message, report, category or checker with the given id(s). You can either give multiple identifier separated by comma (,) or put this option multiple time.]::<msg ids>:_files" \
|
||||
"--disable[Disable the message, report, category or checker with the given id(s). You can either give multiple identifier separated by comma (,) or put this option multiple time (only on the command line, not in the configuration file where it should appear only once).]::<msg ids>:_files" \
|
||||
"-d[Disable the message, report, category or checker with the given id(s). You can either give multiple identifier separated by comma (,) or put this option multiple time (only on the command line, not in the configuration file where it should appear only once).]::<msg ids>:_files" \
|
||||
"--output-format[Set the output format. Available formats are text, parseable, colorized, msvs (visual studio) and html \[current: text\]]::<format>:_files" \
|
||||
"-f[Set the output format. Available formats are text, parseable, colorized, msvs (visual studio) and html \[current: text\]]::<format>:_files" \
|
||||
"--include-ids[Include message's id in output \[current: no\]]::<y_or_n>:_files" \
|
||||
"-i[Include message's id in output \[current: no\]]::<y_or_n>:_files" \
|
||||
"--reports[Tells whether to display a full report or only the messages \[current: yes\]]::<y_or_n>:_files" \
|
||||
"-r[Tells whether to display a full report or only the messages \[current: yes\]]::<y_or_n>:_files" \
|
||||
"*::args:_files"
|
||||
3
plugins/pylint/pylint.plugin.zsh
Normal file
3
plugins/pylint/pylint.plugin.zsh
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# Aliases
|
||||
alias pylint-quick='pylint --reports=n --include-ids=y'
|
||||
compdef _pylint-quick pylint-quick='pylint --reports=n --include-ids=y'
|
||||
54
plugins/python/_python
Normal file
54
plugins/python/_python
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
#compdef python
|
||||
|
||||
# Python 2.6
|
||||
# Python 3.0
|
||||
|
||||
local curcontext="$curcontext" state line expl
|
||||
typeset -A opt_args
|
||||
|
||||
local -a args
|
||||
|
||||
if _pick_variant python3=Python\ 3 python2 --version; then
|
||||
args=(
|
||||
'(-bb)-b[issue warnings about str(bytes_instance), str(bytearray_instance) and comparing bytes/bytearray with str]'
|
||||
'(-b)-bb[issue errors about str(bytes_instance), str(bytearray_instance) and comparing bytes/bytearray with str]'
|
||||
)
|
||||
else
|
||||
args=(
|
||||
'-Q+[division options]:division option:(old warn warnall new)'
|
||||
'(-tt)-t[issue warnings about inconsistent tab usage]'
|
||||
'(-t)-tt[issue errors about inconsistent tab usage]'
|
||||
'-3[warn about Python 3.x incompatibilities]'
|
||||
)
|
||||
fi
|
||||
|
||||
_arguments -C -s -S "$args[@]" \
|
||||
"-B[don't write .py\[co\] files on import]" \
|
||||
'(1 -)-c+[program passed in as string (terminates option list)]:python command:' \
|
||||
'-d[debug output from parser]' \
|
||||
'-E[ignore PYTHON* environment variables (such as PYTHONPATH)]' \
|
||||
'(1 * -)-h[display help information]' \
|
||||
'-i[inspect interactively after running script]' \
|
||||
'(1 * -)-m[run library module as a script (terminates option list)]:module:->modules' \
|
||||
'-O[optimize generated bytecode slightly]' \
|
||||
'-OO[remove doc-strings in addition to the -O optimizations]' \
|
||||
"-s[don't add user site directory to sys.path]" \
|
||||
"-S[don't imply 'import site' on initialization]" \
|
||||
'-u[unbuffered binary stdout and stderr]' \
|
||||
'-v[verbose (trace import statements)]' \
|
||||
'(1 * -)'{-V,--version}'[display version information]' \
|
||||
'-W+[warning control]:warning filter (action\:message\:category\:module\:lineno):(default always ignore module once error)' \
|
||||
'-x[skip first line of source, allowing use of non-Unix forms of #!cmd]' \
|
||||
'(-)1:script file:_files -g "*.py(|c|o)(-.)"' \
|
||||
'*::script argument: _normal' && return
|
||||
|
||||
if [[ "$state" = modules ]]; then
|
||||
local -a modules
|
||||
modules=(
|
||||
${${=${(f)"$(_call_program modules $words[1] -c \
|
||||
'from\ pydoc\ import\ help\;\ help\(\"modules\"\)')"}[2,-3]}:#\(package\)}
|
||||
)
|
||||
_wanted modules expl module compadd -a modules && return
|
||||
fi
|
||||
|
||||
return 1
|
||||
|
|
@ -6,7 +6,9 @@ alias pyfind='find . -name "*.py"'
|
|||
function pyclean() {
|
||||
ZSH_PYCLEAN_PLACES=${*:-'.'}
|
||||
find ${ZSH_PYCLEAN_PLACES} -type f -name "*.py[co]" -delete
|
||||
find ${ZSH_PYCLEAN_PLACES} -type d -name "__pycache__" -delete
|
||||
}
|
||||
|
||||
# Grep among .py files
|
||||
alias pygrep='grep --include="*.py"'
|
||||
|
||||
|
|
|
|||
63
plugins/rails/_rails
Normal file
63
plugins/rails/_rails
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
#compdef rails
|
||||
#autoload
|
||||
|
||||
local -a _1st_arguments
|
||||
_1st_arguments=(
|
||||
'generate:Generate new code (short-cut alias: "g")'
|
||||
'console:Start the Rails console (short-cut alias: "c")'
|
||||
'server:Start the Rails server (short-cut alias: "s")'
|
||||
'dbconsole:Start a console for the database specified in config/database.yml (short-cut alias: "db")'
|
||||
'new:Create a new Rails application. "rails new my_app" creates a new application called MyApp in "./my_app"'
|
||||
'application:Generate the Rails application code'
|
||||
'destroy:Undo code generated with "generate"'
|
||||
|
||||
'benchmarker:See how fast a piece of code runs'
|
||||
'profiler:Get profile information from a piece of code'
|
||||
'plugin:Install a plugin'
|
||||
|
||||
'plugin new:Generates skeleton for developing a Rails plugin'
|
||||
'runner:Run a piece of code in the application environment (short-cut alias: "r")'
|
||||
)
|
||||
|
||||
_rails_generate_arguments() {
|
||||
generate_arguments=(
|
||||
assets
|
||||
controller
|
||||
decorator
|
||||
generator
|
||||
helper
|
||||
integration_test
|
||||
mailer
|
||||
migration
|
||||
model
|
||||
observer
|
||||
performance_test
|
||||
plugin
|
||||
resource
|
||||
scaffold
|
||||
scaffold_controller
|
||||
session_migration
|
||||
stylesheets
|
||||
task
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
_arguments \
|
||||
'(--version)--version[show version]' \
|
||||
'(--help)--help[show help]' \
|
||||
'*:: :->subcmds' && return 0
|
||||
|
||||
if (( CURRENT == 1 )); then
|
||||
_describe -t commands "rails subcommand" _1st_arguments
|
||||
return
|
||||
fi
|
||||
|
||||
case "$words[1]" in
|
||||
g|generate)
|
||||
_rails_generate_arguments
|
||||
_wanted generate_arguments expl 'all generate' compadd -a generate_arguments ;;
|
||||
d|destroy)
|
||||
_rails_generate_arguments
|
||||
_wanted generate_arguments expl 'all generate' compadd -a generate_arguments ;;
|
||||
esac
|
||||
|
|
@ -1,20 +1,70 @@
|
|||
function _rails_command () {
|
||||
if [ -e "script/server" ]; then
|
||||
ruby script/$@
|
||||
elif [ -e "script/rails" ]; then
|
||||
ruby script/rails $@
|
||||
elif [ -e "bin/rails" ]; then
|
||||
bin/rails $@
|
||||
else
|
||||
rails $@
|
||||
fi
|
||||
}
|
||||
|
||||
function _rake_command () {
|
||||
if [ -e "bin/rake" ]; then
|
||||
bin/rake $@
|
||||
else
|
||||
rake $@
|
||||
fi
|
||||
}
|
||||
|
||||
alias rails='_rails_command'
|
||||
compdef _rails_command=rails
|
||||
|
||||
alias rake='_rake_command'
|
||||
compdef _rake_command=rake
|
||||
|
||||
alias devlog='tail -f log/development.log'
|
||||
alias prodlog='tail -f log/production.log'
|
||||
alias testlog='tail -f log/test.log'
|
||||
|
||||
alias -g RED='RAILS_ENV=development'
|
||||
alias -g REP='RAILS_ENV=production'
|
||||
alias -g RET='RAILS_ENV=test'
|
||||
|
||||
# Rails aliases
|
||||
alias rc='rails console'
|
||||
alias rd='rails destroy'
|
||||
alias rdb='rails dbconsole'
|
||||
alias rg='rails generate'
|
||||
alias rgm='rails generate migration'
|
||||
alias rp='rails plugin'
|
||||
alias ru='rails runner'
|
||||
alias rs='rails server'
|
||||
alias rsd='rails server --debugger'
|
||||
|
||||
# Rake aliases
|
||||
alias rdm='rake db:migrate'
|
||||
alias rdr='rake db:rollback'
|
||||
alias rdc='rake db:create'
|
||||
alias rds='rake db:seed'
|
||||
alias rdd='rake db:drop'
|
||||
alias rdtc='rake db:test:clone'
|
||||
alias rdtp='rake db:test:prepare'
|
||||
|
||||
alias rlc='rake log:clear'
|
||||
alias rn='rake notes'
|
||||
alias rr='rake routes'
|
||||
|
||||
# legacy stuff
|
||||
alias ss='thin --stats "/thin/stats" start'
|
||||
alias sg='ruby script/generate'
|
||||
alias sd='ruby script/destroy'
|
||||
alias sp='ruby script/plugin'
|
||||
alias sr='ruby script/runner'
|
||||
alias ssp='ruby script/spec'
|
||||
alias rdbm='rake db:migrate'
|
||||
alias rdbtp='rake db:test:prepare'
|
||||
alias migrate='rake db:migrate && rake db:test:prepare'
|
||||
alias sc='ruby script/console'
|
||||
alias sd='ruby script/server --debugger'
|
||||
alias devlog='tail -f log/development.log'
|
||||
alias testlog='tail -f log/test.log'
|
||||
alias prodlog='tail -f log/production.log'
|
||||
alias -g RET='RAILS_ENV=test'
|
||||
alias -g REP='RAILS_ENV=production'
|
||||
alias -g RED='RAILS_ENV=development'
|
||||
|
||||
function remote_console() {
|
||||
/usr/bin/env ssh $1 "( cd $2 && ruby script/console production )"
|
||||
|
|
|
|||
|
|
@ -1,28 +1,4 @@
|
|||
# Rails 3 aliases, backwards-compatible with Rails 2.
|
||||
|
||||
function _rails_command () {
|
||||
if [ -e "script/server" ]; then
|
||||
ruby script/$@
|
||||
else
|
||||
ruby script/rails $@
|
||||
fi
|
||||
}
|
||||
|
||||
alias rc='_rails_command console'
|
||||
alias rd='_rails_command destroy'
|
||||
alias rdb='_rails_command dbconsole'
|
||||
alias rdbm='rake db:migrate db:test:clone'
|
||||
alias rg='_rails_command generate'
|
||||
alias rgm='_rails_command generate migration'
|
||||
alias rp='_rails_command plugin'
|
||||
alias ru='_rails_command runner'
|
||||
alias rs='_rails_command server'
|
||||
alias rsd='_rails_command server --debugger'
|
||||
alias devlog='tail -f log/development.log'
|
||||
alias testlog='tail -f log/test.log'
|
||||
alias prodlog='tail -f log/production.log'
|
||||
alias rdm='rake db:migrate'
|
||||
alias rdr='rake db:rollback'
|
||||
alias -g RET='RAILS_ENV=test'
|
||||
alias -g REP='RAILS_ENV=production'
|
||||
alias -g RED='RAILS_ENV=development'
|
||||
echo "It looks like you have been using the 'rails3' plugin,"
|
||||
echo "which has been deprecated in favor of a newly consolidated 'rails' plugin."
|
||||
echo "You will want to modify your ~/.zshrc configuration to begin using it."
|
||||
echo "Learn more at https://github.com/robbyrussell/oh-my-zsh/pull/2240"
|
||||
|
|
|
|||
|
|
@ -1,32 +1,4 @@
|
|||
# Rails 4 aliases
|
||||
|
||||
function _rails_command () {
|
||||
if [ -e "script/server" ]; then
|
||||
ruby script/$@
|
||||
elif [ -e "script/rails" ]; then
|
||||
ruby script/rails $@
|
||||
else
|
||||
ruby bin/rails $@
|
||||
fi
|
||||
}
|
||||
|
||||
alias rc='_rails_command console'
|
||||
alias rd='_rails_command destroy'
|
||||
alias rdb='_rails_command dbconsole'
|
||||
alias rdbm='rake db:migrate db:test:clone'
|
||||
alias rg='_rails_command generate'
|
||||
alias rgm='_rails_command generate migration'
|
||||
alias rp='_rails_command plugin'
|
||||
alias ru='_rails_command runner'
|
||||
alias rs='_rails_command server'
|
||||
alias rsd='_rails_command server --debugger'
|
||||
alias devlog='tail -f log/development.log'
|
||||
alias testlog='tail -f log/test.log'
|
||||
alias prodlog='tail -f log/production.log'
|
||||
alias rdm='rake db:migrate'
|
||||
alias rdc='rake db:create'
|
||||
alias rdr='rake db:rollback'
|
||||
alias rds='rake db:seed'
|
||||
alias rlc='rake log:clear'
|
||||
alias rn='rake notes'
|
||||
alias rr='rake routes'
|
||||
echo "It looks like you have been using the 'rails4' plugin,"
|
||||
echo "which has been deprecated in favor of a newly consolidated 'rails' plugin."
|
||||
echo "You will want to modify your ~/.zshrc configuration to begin using it."
|
||||
echo "Learn more at https://github.com/robbyrussell/oh-my-zsh/pull/2240"
|
||||
|
|
|
|||
|
|
@ -5,13 +5,24 @@
|
|||
# Don't remove this header, thank you
|
||||
# Usage: quote
|
||||
|
||||
WHO_COLOR="\e[0;33m"
|
||||
TEXT_COLOR="\e[0;35m"
|
||||
COLON_COLOR="\e[0;35m"
|
||||
END_COLOR="\e[m"
|
||||
|
||||
if [[ -x `which curl` ]]; then
|
||||
function quote()
|
||||
{
|
||||
Q=$(curl -s --connect-timeout 2 "http://www.quotationspage.com/random.php3" | grep -m 1 "dt ")
|
||||
Q=$(curl -s --connect-timeout 2 "http://www.quotationspage.com/random.php3" | iconv -c -f ISO-8859-1 -t UTF-8 | grep -m 1 "dt ")
|
||||
TXT=$(echo "$Q" | sed -e 's/<\/dt>.*//g' -e 's/.*html//g' -e 's/^[^a-zA-Z]*//' -e 's/<\/a..*$//g')
|
||||
W=$(echo "$Q" | sed -e 's/.*\/quotes\///g' -e 's/<.*//g' -e 's/.*">//g')
|
||||
echo "\e[0;33m${W}\e[0;30m: \e[0;35m“${TXT}”\e[m"
|
||||
if [ "$W" -a "$TXT" ]; then
|
||||
echo "${WHO_COLOR}${W}${COLON_COLOR}: ${TEXT_COLOR}“${TXT}”${END_COLOR}"
|
||||
else
|
||||
quote
|
||||
fi
|
||||
}
|
||||
#quote
|
||||
else
|
||||
echo "rand-quote plugin needs curl to work" >&2
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -1,2 +1,12 @@
|
|||
# Aliases
|
||||
alias r='repo'
|
||||
compdef _repo r=repo
|
||||
|
||||
alias rra='repo rebase --auto-stash'
|
||||
compdef _repo rra='repo rebase --auto-stash'
|
||||
|
||||
alias rs='repo sync'
|
||||
compdef _repo rs='repo sync'
|
||||
|
||||
alias rsrra='repo sync ; repo rebase --auto-stash'
|
||||
compdef _repo rsrra='repo sync ; repo rebase --auto-stash'
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@ fpath=($rvm_path/scripts/zsh/Completion $fpath)
|
|||
alias rubies='rvm list rubies'
|
||||
alias gemsets='rvm gemset list'
|
||||
|
||||
local ruby18='ruby-1.8.7-p371'
|
||||
local ruby19='ruby-1.9.3-p392'
|
||||
local ruby20='ruby-2.0.0-p0'
|
||||
local ruby18='ruby-1.8.7'
|
||||
local ruby19='ruby-1.9.3'
|
||||
local ruby20='ruby-2.0.0'
|
||||
|
||||
function rb18 {
|
||||
if [ -z "$1" ]; then
|
||||
|
|
@ -31,7 +31,7 @@ compdef _rb19 rb19
|
|||
|
||||
function rb20 {
|
||||
if [ -z "$1" ]; then
|
||||
rvm use "$ruby"
|
||||
rvm use "$ruby20"
|
||||
else
|
||||
rvm use "$ruby20@$1"
|
||||
fi
|
||||
|
|
@ -42,7 +42,6 @@ compdef _rb20 rb20
|
|||
|
||||
function rvm-update {
|
||||
rvm get head
|
||||
rvm reload # TODO: Reload rvm completion?
|
||||
}
|
||||
|
||||
# TODO: Make this usable w/o rvm.
|
||||
|
|
|
|||
28
plugins/sfffe/sfffe.plugin.zsh
Normal file
28
plugins/sfffe/sfffe.plugin.zsh
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
# ------------------------------------------------------------------------------
|
||||
# FILE: sfffe.plugin.zsh
|
||||
# DESCRIPTION: search file for FE
|
||||
# AUTHOR: yleo77 (ylep77@gmail.com)
|
||||
# VERSION: 0.1
|
||||
# REQUIRE: ack
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
if [ ! -x $(which ack) ]; then
|
||||
echo \'ack\' is not installed!
|
||||
exit -1
|
||||
fi
|
||||
|
||||
ajs() {
|
||||
ack "$@" --type js
|
||||
}
|
||||
|
||||
acss() {
|
||||
ack "$@" --type css
|
||||
}
|
||||
|
||||
fjs() {
|
||||
find ./ -name "$@*" -type f | grep '\.js'
|
||||
}
|
||||
|
||||
fcss() {
|
||||
find ./ -name "$@*" -type f | grep '\.css'
|
||||
}
|
||||
133
plugins/singlechar/singlechar.plugin.zsh
Normal file
133
plugins/singlechar/singlechar.plugin.zsh
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
################################################################################
|
||||
# FILE: singlechar.plugin.zsh
|
||||
# DESCRIPTION: oh-my-zsh plugin file.
|
||||
# AUTHOR: Michael Varner (musikmichael@web.de)
|
||||
# VERSION: 1.0.0
|
||||
#
|
||||
# This plugin adds single char shortcuts (and combinations) for some commands.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
###########################
|
||||
# Settings
|
||||
|
||||
# These can be overwritten any time.
|
||||
# If they are not set yet, they will be
|
||||
# overwritten with their default values
|
||||
|
||||
default GREP grep
|
||||
default ROOT sudo
|
||||
default WGET wget
|
||||
default CURL curl
|
||||
|
||||
env_default PAGER less
|
||||
|
||||
###########################
|
||||
# Alias
|
||||
|
||||
# CAT, GREP, CURL, WGET
|
||||
|
||||
alias y='"$GREP" -Ri'
|
||||
alias n='"$GREP" -Rvi'
|
||||
|
||||
alias f.='find . | "$GREP"'
|
||||
alias f:='find'
|
||||
|
||||
alias f='"$GREP" -Rli'
|
||||
alias fn='"$GREP" -Rlvi'
|
||||
|
||||
alias w='echo >'
|
||||
alias a='echo >>'
|
||||
|
||||
alias c='cat'
|
||||
alias p='"$PAGER"'
|
||||
|
||||
alias m='man'
|
||||
|
||||
alias d='"$WGET"'
|
||||
alias u='"$CURL"'
|
||||
|
||||
# enhanced writing
|
||||
|
||||
alias w:='cat >'
|
||||
alias a:='cat >>'
|
||||
|
||||
# XARGS
|
||||
|
||||
alias x='xargs'
|
||||
|
||||
alias xy='xargs "$GREP" -Ri'
|
||||
alias xn='xargs "$GREP" -Riv'
|
||||
|
||||
alias xf.='xargs find | "$GREP"'
|
||||
alias xf:='xargs find'
|
||||
|
||||
alias xf='xargs "$GREP" -Rli'
|
||||
alias xfn='xargs "$GREP" -Rlvi'
|
||||
|
||||
alias xw='xargs echo >'
|
||||
alias xa='xargs echo >>'
|
||||
|
||||
alias xc='xargs cat'
|
||||
alias xp='xargs "$PAGER"'
|
||||
|
||||
alias xm='xargs man'
|
||||
|
||||
alias xd='xargs "$WGET"'
|
||||
alias xu='xargs "$CURL"'
|
||||
|
||||
alias xw:='xargs cat >'
|
||||
alias xa:='xargs >>'
|
||||
|
||||
# SUDO
|
||||
|
||||
alias s='"$ROOT"'
|
||||
|
||||
alias sy='"$ROOT" "$GREP" -Ri'
|
||||
alias sn='"$ROOT" "$GREP" -Riv'
|
||||
|
||||
alias sf.='"$ROOT" find . | "$GREP"'
|
||||
alias sf:='"$ROOT" find'
|
||||
|
||||
alias sf='"$ROOT" "$GREP" -Rli'
|
||||
alias sfn='"$ROOT" "$GREP" -Rlvi'
|
||||
|
||||
alias sw='"$ROOT" echo >'
|
||||
alias sa='"$ROOT" echo >>'
|
||||
|
||||
alias sc='"$ROOT" cat'
|
||||
alias sp='"$ROOT" "$PAGER"'
|
||||
|
||||
alias sm='"$ROOT" man'
|
||||
|
||||
alias sd='"$ROOT" "$WGET"'
|
||||
|
||||
alias sw:='"$ROOT" cat >'
|
||||
alias sa:='"$ROOT" cat >>'
|
||||
|
||||
# SUDO-XARGS
|
||||
|
||||
alias sx='"$ROOT" xargs'
|
||||
|
||||
alias sxy='"$ROOT" xargs "$GREP" -Ri'
|
||||
alias sxn='"$ROOT" xargs "$GREP" -Riv'
|
||||
|
||||
alias sxf.='"$ROOT" xargs find | "$GREP"'
|
||||
alias sxf:='"$ROOT" xargs find'
|
||||
|
||||
alias sxf='"$ROOT" xargs "$GREP" -li'
|
||||
alias sxfn='"$ROOT" xargs "$GREP" -lvi'
|
||||
|
||||
alias sxw='"$ROOT" xargs echo >'
|
||||
alias sxa='"$ROOT" xargs echo >>'
|
||||
|
||||
alias sxc='"$ROOT" xargs cat'
|
||||
alias sxp='"$ROOT" xargs "$PAGER"'
|
||||
|
||||
alias sxm='"$ROOT" xargs man'
|
||||
|
||||
alias sxd='"$ROOT" xargs "$WGET"'
|
||||
alias sxu='"$ROOT" xargs "$CURL"'
|
||||
|
||||
alias sxw:='"$ROOT" xargs cat >'
|
||||
alias sxa:='"$ROOT" xargs cat >>'
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
# To load multiple identities use the identities style, For
|
||||
# example:
|
||||
#
|
||||
# zstyle :omz:plugins:ssh-agent id_rsa id_rsa2 id_github
|
||||
# zstyle :omz:plugins:ssh-agent identities id_rsa id_rsa2 id_github
|
||||
#
|
||||
# To set the maximum lifetime of the identities, use the
|
||||
# lifetime style. The lifetime may be specified in seconds
|
||||
|
|
@ -57,7 +57,7 @@ if [[ ${_plugin__forwarding} == "yes" && -n "$SSH_AUTH_SOCK" ]]; then
|
|||
elif [ -f "${_plugin__ssh_env}" ]; then
|
||||
# Source SSH settings, if applicable
|
||||
. ${_plugin__ssh_env} > /dev/null
|
||||
ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {
|
||||
ps x | grep ${SSH_AGENT_PID} | grep ssh-agent > /dev/null || {
|
||||
_plugin__start_agent;
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -2,29 +2,32 @@
|
|||
|
||||
local _sublime_darwin_paths > /dev/null 2>&1
|
||||
_sublime_darwin_paths=(
|
||||
"/usr/local/bin/subl"
|
||||
"$HOME/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl"
|
||||
"$HOME/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl"
|
||||
"/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl"
|
||||
"/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl"
|
||||
"/usr/local/bin/subl"
|
||||
"$HOME/Applications/Sublime Text 3.app/Contents/SharedSupport/bin/subl"
|
||||
"$HOME/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl"
|
||||
"$HOME/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl"
|
||||
"/Applications/Sublime Text 3.app/Contents/SharedSupport/bin/subl"
|
||||
"/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl"
|
||||
"/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl"
|
||||
)
|
||||
|
||||
if [[ $('uname') == 'Linux' ]]; then
|
||||
if [ -f '/usr/bin/sublime_text' ]; then
|
||||
st_run() { nohup /usr/bin/sublime_text $@ > /dev/null & }
|
||||
else
|
||||
st_run() { nohup /usr/bin/sublime-text $@ > /dev/null & }
|
||||
fi
|
||||
alias st=st_run
|
||||
if [ -f '/usr/bin/sublime_text' ]; then
|
||||
st_run() { nohup /usr/bin/sublime_text $@ > /dev/null & }
|
||||
else
|
||||
st_run() { nohup /usr/bin/sublime-text $@ > /dev/null & }
|
||||
fi
|
||||
alias st=st_run
|
||||
|
||||
elif [[ $('uname') == 'Darwin' ]]; then
|
||||
|
||||
for _sublime_path in $_sublime_darwin_paths; do
|
||||
if [[ -a $_sublime_path ]]; then
|
||||
alias st="'$_sublime_path'"
|
||||
break
|
||||
fi
|
||||
done
|
||||
for _sublime_path in $_sublime_darwin_paths; do
|
||||
if [[ -a $_sublime_path ]]; then
|
||||
alias subl="'$_sublime_path'"
|
||||
alias st=subl
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
alias stt='st .'
|
||||
|
|
|
|||
22
plugins/sudo/sudo.zsh
Normal file
22
plugins/sudo/sudo.zsh
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
# ------------------------------------------------------------------------------
|
||||
# Description
|
||||
# -----------
|
||||
#
|
||||
# sudo will be inserted before the command
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
# Authors
|
||||
# -------
|
||||
#
|
||||
# * Dongweiming <ciici123@gmail.com>
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
sudo-command-line() {
|
||||
[[ -z $BUFFER ]] && zle up-history
|
||||
[[ $BUFFER != sudo\ * ]] && BUFFER="sudo $BUFFER"
|
||||
zle end-of-line
|
||||
}
|
||||
zle -N sudo-command-line
|
||||
# Defined shortcut keys: [Esc] [Esc]
|
||||
bindkey "\e\e" sudo-command-line
|
||||
|
|
@ -7,6 +7,7 @@ _arguments \
|
|||
{--configuration,-c}"[configuration file]:FILENAME:_files" \
|
||||
{--nodaemon,-n}"[run in the foreground (same as 'nodaemon true' in config file)]" \
|
||||
{--help,-h}"[print this usage message and exit]:" \
|
||||
{--version,-v}"[print supervisord version number and exit]:" \
|
||||
{--user,-u}"[run supervisord as this user]:USER:_users" \
|
||||
{--umask,-m}"[use this umask for daemon subprocess (default is 022)]" \
|
||||
{--directory,-d}"[directory to chdir to when daemonized]" \
|
||||
|
|
|
|||
|
|
@ -1,7 +1,61 @@
|
|||
alias zi='sudo zypper install'
|
||||
alias zrf='sudo zypper refresh'
|
||||
alias zs='zypper search'
|
||||
alias zup='sudo zypper dist-upgrade'
|
||||
alias zrm='sudo zypper remove'
|
||||
alias zp='sudo zypper patch'
|
||||
alias zps='sudo zypper ps'
|
||||
#Alias for Zypper according to the offical Zypper's alias
|
||||
|
||||
#Main commands
|
||||
alias z='sudo zypper' #call zypper
|
||||
alias zh='sudo zypper -h' #print help
|
||||
alias zhse='sudo zypper -h se' #print help for the search command
|
||||
alias zlicenses='sudo zypper licenses' #prints a report about licenses and EULAs of installed packages
|
||||
alias zps='sudo zypper ps' #list process using deleted files
|
||||
alias zshell='sudo zypper shell' #open a zypper shell session
|
||||
alias zsource-download='sudo zypper source-download' #download source rpms for all installed packages
|
||||
alias ztos='sudo zypper tos' #shows the ID string of the target operating system
|
||||
alias zvcmp='sudo zypper vcmp' #tell whether version1 is older or newer than version2
|
||||
|
||||
#Packages commands
|
||||
alias zin='sudo zypper in' #install packages
|
||||
alias zinr='sudo zypper inr' #install newly added packages recommended by already installed ones
|
||||
alias zrm='sudo zypper rm' #remove packages
|
||||
alias zsi='sudo zypper si' #install source of a package
|
||||
alias zve='sudo zypper ve' #verify dependencies of installed packages
|
||||
|
||||
#Updates commands
|
||||
alias zdup='sudo zypper dup' #upgrade packages
|
||||
alias zlp='sudo zypper lp' #list necessary patchs
|
||||
alias zlu='sudo zypper lu' #list updates
|
||||
alias zpchk='sudo zypper pchk' #check for patches
|
||||
alias zup='sudo zypper up' #update packages
|
||||
alias zpatch='sudo zypper patch' #install patches
|
||||
|
||||
#Request commands
|
||||
alias zif='sudo zypper if' #display info about packages
|
||||
alias zpa='sudo zypper pa' #list packages
|
||||
alias zpatch-info='sudo zypper patch-info' #display info about patches
|
||||
alias zpattern-info='sudo zypper patch-info' #display info about patterns
|
||||
alias zproduct-info='sudo zypper patch-info' #display info about products
|
||||
alias zpch='sudo zypper pch' #list all patches
|
||||
alias zpd='sudo zypper pd' #list products
|
||||
alias zpt='sudo zypper pt' #list patterns
|
||||
alias zse='sudo zypper se' #search for packages
|
||||
alias zwp='sudo zypper wp' #list all packages providing the specified capability
|
||||
|
||||
#Repositories commands
|
||||
alias zar='sudo zypper ar' #add a repository
|
||||
alias zcl='sudo zypper clean' #clean cache
|
||||
alias zlr='sudo zypper lr' #list repositories
|
||||
alias zmr='sudo zypper mr' #modify repositories
|
||||
alias znr='sudo zypper nr' #rename repositories (for the alias only)
|
||||
alias zref='sudo zypper ref' #refresh repositories
|
||||
alias zrr='sudo zypper rr' #remove repositories
|
||||
|
||||
#Services commands
|
||||
alias zas='sudo zypper as' #adds a service specified by URI to the system
|
||||
alias zms='sudo zypper ms' #modify properties of specified services
|
||||
alias zrefs='sudo zypper refs' #refreshing a service mean executing the service's special task
|
||||
alias zrs='sudo zypper rs' #remove specified repository index service from the sytem
|
||||
alias zls='sudo zypper ls' #list services defined on the system
|
||||
|
||||
#Package Locks Management commands
|
||||
alias zal='sudo zypper al' #add a package lock
|
||||
alias zcl='sudo zypper cl' #Remove unused locks
|
||||
alias zll='sudo zypper ll' #list currently active package locks
|
||||
alias zrl='sudo zypper rl' #remove specified package lock
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
# symfony basic command completion
|
||||
|
||||
_symfony_get_command_list () {
|
||||
./symfony | sed "1,/Available tasks/d" | awk 'BEGIN { cat=null; } /^[A-Za-z]+$/ { cat = $1; } /^ :[a-z]+/ { print cat $1; }'
|
||||
php symfony | sed "1,/Available tasks/d" | awk 'BEGIN { cat=null; } /^[A-Za-z]+$/ { cat = $1; } /^ :[a-z]+/ { print cat $1; }'
|
||||
}
|
||||
|
||||
_symfony () {
|
||||
|
|
|
|||
159
plugins/systemadmin/systemadmin.zsh
Normal file
159
plugins/systemadmin/systemadmin.zsh
Normal file
|
|
@ -0,0 +1,159 @@
|
|||
# ------------------------------------------------------------------------------
|
||||
# Description
|
||||
# -----------
|
||||
#
|
||||
# This is one for the system administrator, operation and maintenance.
|
||||
# Some of which come from http://justinlilly.com/dotfiles/zsh.html
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
# Authors
|
||||
# -------
|
||||
#
|
||||
# * Dongweiming <ciici123@gmail.com>
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
function retval() {
|
||||
if [[ -z $1 ]];then
|
||||
echo '.'
|
||||
else
|
||||
echo $1
|
||||
fi
|
||||
}
|
||||
|
||||
function retlog() {
|
||||
if [[ -z $1 ]];then
|
||||
echo '/var/log/nginx/access.log'
|
||||
else
|
||||
echo $1
|
||||
fi
|
||||
}
|
||||
|
||||
alias ping='ping -c 5'
|
||||
alias clr='clear;echo "Currently logged in on $(tty), as $(whoami) in directory $(pwd)."'
|
||||
alias path='echo -e ${PATH//:/\\n}'
|
||||
alias mkdir='mkdir -pv'
|
||||
# get top process eating memory
|
||||
alias psmem='ps -e -orss=,args= | sort -b -k1,1n'
|
||||
alias psmem10='ps -e -orss=,args= | sort -b -k1,1n| head -10'
|
||||
# get top process eating cpu if not work try excute : export LC_ALL='C'
|
||||
alias pscpu='ps -e -o pcpu,cpu,nice,state,cputime,args|sort -k1 -nr'
|
||||
alias pscpu10='ps -e -o pcpu,cpu,nice,state,cputime,args|sort -k1 -nr | head -10'
|
||||
# top10 of the history
|
||||
alias hist10='print -l ${(o)history%% *} | uniq -c | sort -nr | head -n 10'
|
||||
|
||||
# directory LS
|
||||
dls () {
|
||||
ls -l | grep "^d" | awk '{ print $9 }' | tr -d "/"
|
||||
}
|
||||
psgrep() {
|
||||
ps aux | grep "$(retval $1)" | grep -v grep
|
||||
}
|
||||
# Kills any process that matches a regexp passed to it
|
||||
killit() {
|
||||
ps aux | grep -v "grep" | grep "$@" | awk '{print $2}' | xargs sudo kill
|
||||
}
|
||||
|
||||
# list contents of directories in a tree-like format
|
||||
if [ -z "\${which tree}" ]; then
|
||||
tree () {
|
||||
find $@ -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'
|
||||
}
|
||||
fi
|
||||
|
||||
# Sort connection state
|
||||
sortcons() {
|
||||
netstat -nat |awk '{print $6}'|sort|uniq -c|sort -rn
|
||||
}
|
||||
|
||||
# View all 80 Port Connections
|
||||
con80() {
|
||||
netstat -nat|grep -i ":80"|wc -l
|
||||
}
|
||||
|
||||
# On the connected IP sorted by the number of connections
|
||||
sortconip() {
|
||||
netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n
|
||||
}
|
||||
|
||||
# top20 of Find the number of requests on 80 port
|
||||
req20() {
|
||||
netstat -anlp|grep 80|grep tcp|awk '{print $5}'|awk -F: '{print $1}'|sort|uniq -c|sort -nr|head -n20
|
||||
}
|
||||
|
||||
# top20 of Using tcpdump port 80 access to view
|
||||
http20() {
|
||||
sudo tcpdump -i eth0 -tnn dst port 80 -c 1000 | awk -F"." '{print $1"."$2"."$3"."$4}' | sort | uniq -c | sort -nr |head -20
|
||||
}
|
||||
|
||||
# top20 of Find time_wait connection
|
||||
timewait20() {
|
||||
netstat -n|grep TIME_WAIT|awk '{print $5}'|sort|uniq -c|sort -rn|head -n20
|
||||
}
|
||||
|
||||
# top20 of Find SYN connection
|
||||
syn20() {
|
||||
netstat -an | grep SYN | awk '{print $5}' | awk -F: '{print $1}' | sort | uniq -c | sort -nr|head -n20
|
||||
}
|
||||
|
||||
# Printing process according to the port number
|
||||
port_pro() {
|
||||
netstat -ntlp | grep "$(retval $1)" | awk '{print $7}' | cut -d/ -f1
|
||||
}
|
||||
|
||||
# top10 of gain access to the ip address
|
||||
accessip10() {
|
||||
awk '{counts[$(11)]+=1}; END {for(url in counts) print counts[url], url}' "$(retlog)"
|
||||
}
|
||||
|
||||
# top20 of Most Visited file or page
|
||||
visitpage20() {
|
||||
awk '{print $11}' "$(retlog)"|sort|uniq -c|sort -nr|head -20
|
||||
}
|
||||
|
||||
# top100 of Page lists the most time-consuming (more than 60 seconds) as well as the corresponding page number of occurrences
|
||||
consume100() {
|
||||
awk '($NF > 60 && $7~/\.php/){print $7}' "$(retlog)" |sort -n|uniq -c|sort -nr|head -100
|
||||
# if django website or other webiste make by no suffix language
|
||||
# awk '{print $7}' "$(retlog)" |sort -n|uniq -c|sort -nr|head -100
|
||||
}
|
||||
|
||||
# Website traffic statistics (G)
|
||||
webtraffic() {
|
||||
awk "{sum+=$10} END {print sum/1024/1024/1024}" "$(retlog)"
|
||||
}
|
||||
|
||||
# Statistical connections 404
|
||||
c404() {
|
||||
awk '($9 ~/404/)' "$(retlog)" | awk '{print $9,$7}' | sort
|
||||
}
|
||||
|
||||
# Statistical http status.
|
||||
httpstatus() {
|
||||
awk '{counts[$(9)]+=1}; END {for(code in counts) print code, counts[code]}' "$(retlog)"
|
||||
}
|
||||
|
||||
# Delete 0 byte file
|
||||
d0() {
|
||||
find "$(retval $1)" -type f -size 0 -exec rm -rf {} \;
|
||||
}
|
||||
|
||||
# gather external ip address
|
||||
geteip() {
|
||||
curl http://ifconfig.me
|
||||
}
|
||||
|
||||
# determine local IP address
|
||||
getip() {
|
||||
ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'
|
||||
}
|
||||
|
||||
# Clear zombie processes
|
||||
clrz() {
|
||||
ps -eal | awk '{ if ($2 == "Z") {print $4}}' | kill -9
|
||||
}
|
||||
|
||||
# Second concurrent
|
||||
conssec() {
|
||||
awk '{if($9~/200|30|404/)COUNT[$4]++}END{for( a in COUNT) print a,COUNT[a]}' "$(retlog)"|sort -k 2 -nr|head -n10
|
||||
}
|
||||
|
|
@ -32,7 +32,7 @@ if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then
|
|||
# Register the function so it is called whenever the working
|
||||
# directory changes.
|
||||
autoload add-zsh-hook
|
||||
add-zsh-hook chpwd update_terminal_cwd
|
||||
add-zsh-hook precmd update_terminal_cwd
|
||||
|
||||
# Tell the terminal about the initial directory.
|
||||
update_terminal_cwd
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
function theme
|
||||
{
|
||||
if [ "$1" = "random" ]; then
|
||||
if [ -z "$1" ] || [ "$1" = "random" ]; then
|
||||
themes=($ZSH/themes/*zsh-theme)
|
||||
N=${#themes[@]}
|
||||
((N=(RANDOM%N)+1))
|
||||
|
|
|
|||
|
|
@ -1,3 +1,11 @@
|
|||
#
|
||||
# Aliases
|
||||
#
|
||||
|
||||
alias ta='tmux attach -t'
|
||||
alias ts='tmux new-session -s'
|
||||
alias tl='tmux list-sessions'
|
||||
|
||||
# Only run if tmux is actually installed
|
||||
if which tmux &> /dev/null
|
||||
then
|
||||
|
|
@ -15,7 +23,7 @@ if which tmux &> /dev/null
|
|||
# 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
|
||||
[[ -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
|
||||
|
|
@ -38,7 +46,7 @@ if which tmux &> /dev/null
|
|||
fi
|
||||
|
||||
# Set the correct local config file to use.
|
||||
if [[ "$ZSH_TMUX_ITERM2" == "false" ]] && (( [[ -f $HOME/.tmux.conf ]] || -h $HOME/.tmux.conf ]] ))
|
||||
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"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#compdef tmuxinator
|
||||
#compdef tmuxinator mux
|
||||
#autoload
|
||||
|
||||
local curcontext="$curcontext" state line ret=1
|
||||
|
|
@ -25,7 +25,7 @@ case $state in
|
|||
args)
|
||||
case $line[1] in
|
||||
start|open|copy|delete)
|
||||
_configs=(`tmuxinator list | sed -n 's/^[ \t]\+//p'`)
|
||||
_configs=(`find ~/.tmuxinator/ -name \*.yml | cut -d/ -f5 | sed s:.yml::g`)
|
||||
_values 'configs' $_configs
|
||||
ret=0
|
||||
;;
|
||||
|
|
@ -33,4 +33,4 @@ case $state in
|
|||
;;
|
||||
esac
|
||||
|
||||
return ret
|
||||
return ret
|
||||
|
|
|
|||
|
|
@ -14,6 +14,9 @@ if [[ $(whence node) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHOD
|
|||
elif [[ $(whence python) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHOD" = "xpython" ) ]]; then
|
||||
alias urlencode='python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1])"'
|
||||
alias urldecode='python -c "import sys, urllib as ul; print ul.unquote_plus(sys.argv[1])"'
|
||||
elif [[ $(whence xxd) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHOD" = "xshell" ) ]]; then
|
||||
function urlencode() {echo $@ | tr -d "\n" | xxd -plain | sed "s/\(..\)/%\1/g"}
|
||||
function urldecode() {printf $(echo -n $@ | sed 's/\\/\\\\/g;s/\(%\)\([0-9a-fA-F][0-9a-fA-F]\)/\\x\2/g')"\n"}
|
||||
elif [[ $(whence ruby) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHOD" = "xruby" ) ]]; then
|
||||
alias urlencode='ruby -r cgi -e "puts CGI.escape(ARGV[0])"'
|
||||
alias urldecode='ruby -r cgi -e "puts CGI.unescape(ARGV[0])"'
|
||||
|
|
@ -33,4 +36,4 @@ elif [[ $(whence perl) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHO
|
|||
fi
|
||||
fi
|
||||
|
||||
unset URLTOOLS_METHOD
|
||||
unset URLTOOLS_METHOD
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ if (( $+commands[$virtualenvwrapper] )); then
|
|||
# Check for virtualenv name override
|
||||
if [[ -f "$PROJECT_ROOT/.venv" ]]; then
|
||||
ENV_NAME=`cat "$PROJECT_ROOT/.venv"`
|
||||
elif [[ -f "$PROJECT_ROOT/.venv/bin/activate" ]];then
|
||||
ENV_NAME="$PROJECT_ROOT/.venv"
|
||||
elif [[ "$PROJECT_ROOT" != "." ]]; then
|
||||
ENV_NAME=`basename "$PROJECT_ROOT"`
|
||||
else
|
||||
|
|
@ -27,6 +29,8 @@ if (( $+commands[$virtualenvwrapper] )); then
|
|||
if [[ "$VIRTUAL_ENV" != "$WORKON_HOME/$ENV_NAME" ]]; then
|
||||
if [[ -e "$WORKON_HOME/$ENV_NAME/bin/activate" ]]; then
|
||||
workon "$ENV_NAME" && export CD_VIRTUAL_ENV="$ENV_NAME"
|
||||
elif [[ -e "$ENV_NAME/bin/activate" ]]; then
|
||||
source $ENV_NAME/bin/activate && export CD_VIRTUAL_ENV="$ENV_NAME"
|
||||
fi
|
||||
fi
|
||||
elif [ $CD_VIRTUAL_ENV ]; then
|
||||
|
|
|
|||
38
plugins/wd/README.md
Normal file
38
plugins/wd/README.md
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
## wd
|
||||
|
||||
**Maintainer:** [mfaerevaag](https://github.com/mfaerevaag)
|
||||
|
||||
`wd` (warp directory) lets you jump to custom directories in zsh, without using cd. Why? Because cd seems ineffecient when the folder is frequently visited or has a long path. [Source](https://github.com/mfaerevaag/wd)
|
||||
|
||||
### Usage
|
||||
|
||||
* Add warp point to current working directory:
|
||||
|
||||
wd add test
|
||||
|
||||
If a warp point with the same name exists, use `add!` to overwrite it.
|
||||
|
||||
* From an other directory, warp to test with:
|
||||
|
||||
wd test
|
||||
|
||||
* You can warp back to previous directory, and so on, with the puncticulation syntax:
|
||||
|
||||
wd ..
|
||||
wd ...
|
||||
|
||||
This is a wrapper for the zsh `dirs` function.
|
||||
|
||||
* Remove warp point test point:
|
||||
|
||||
wd rm test
|
||||
|
||||
* List warp points to current directory (stored in `~/.warprc`):
|
||||
|
||||
wd show
|
||||
|
||||
* List all warp points (stored in `~/.warprc`):
|
||||
|
||||
wd ls
|
||||
|
||||
* Print usage with no opts or the `help` argument.
|
||||
48
plugins/wd/_wd.sh
Normal file
48
plugins/wd/_wd.sh
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
#compdef wd.sh
|
||||
|
||||
zstyle ":completion:*:descriptions" format "%B%d%b"
|
||||
|
||||
CONFIG=$HOME/.warprc
|
||||
|
||||
local -a main_commands
|
||||
main_commands=(
|
||||
add:'Adds the current working directory to your warp points'
|
||||
#add'\!':'Overwrites existing warp point' # TODO: Fix
|
||||
rm:'Removes the given warp point'
|
||||
ls:'Outputs all stored warp points'
|
||||
show:'Outputs warp points to current directory'
|
||||
)
|
||||
|
||||
local -a points
|
||||
while read line
|
||||
do
|
||||
points+=$(awk "{ gsub(/\/Users\/$USER|\/home\/$USER/,\"~\"); print }" <<< $line)
|
||||
done < $CONFIG
|
||||
|
||||
_wd()
|
||||
{
|
||||
# init variables
|
||||
local curcontext="$curcontext" state line
|
||||
typeset -A opt_args
|
||||
|
||||
# init state
|
||||
_arguments \
|
||||
'1: :->command' \
|
||||
'2: :->argument'
|
||||
|
||||
case $state in
|
||||
command)
|
||||
compadd "$@" add rm ls show
|
||||
_describe -t warp-points 'Warp points:' points && ret=0
|
||||
;;
|
||||
argument)
|
||||
case $words[2] in
|
||||
rm|add!)
|
||||
_describe -t warp-points 'warp points' points && ret=0
|
||||
;;
|
||||
*)
|
||||
esac
|
||||
esac
|
||||
}
|
||||
|
||||
_wd "$@"
|
||||
9
plugins/wd/wd.plugin.zsh
Executable file
9
plugins/wd/wd.plugin.zsh
Executable file
|
|
@ -0,0 +1,9 @@
|
|||
#!/bin/zsh
|
||||
|
||||
# WARP
|
||||
# ====
|
||||
# oh-my-zsh plugin
|
||||
#
|
||||
# @github.com/mfaerevaag/wd
|
||||
|
||||
alias wd='. $ZSH/plugins/wd/wd.sh'
|
||||
216
plugins/wd/wd.sh
Executable file
216
plugins/wd/wd.sh
Executable file
|
|
@ -0,0 +1,216 @@
|
|||
#!/bin/zsh
|
||||
|
||||
# WARP
|
||||
# ====
|
||||
# Jump to custom directories in terminal
|
||||
# because `cd` takes too long...
|
||||
#
|
||||
# @github.com/mfaerevaag/wd
|
||||
|
||||
|
||||
## variables
|
||||
CONFIG=$HOME/.warprc
|
||||
|
||||
## colors
|
||||
BLUE="\033[96m"
|
||||
GREEN="\033[92m"
|
||||
YELLOW="\033[93m"
|
||||
RED="\033[91m"
|
||||
NOC="\033[m"
|
||||
|
||||
|
||||
# check if config file exists
|
||||
if [[ ! -a $CONFIG ]]
|
||||
then
|
||||
# if not: create config file
|
||||
touch $CONFIG
|
||||
fi
|
||||
|
||||
## load warp points
|
||||
typeset -A points
|
||||
while read line
|
||||
do
|
||||
arr=(${(s,:,)line})
|
||||
key=${arr[1]}
|
||||
val=${arr[2]}
|
||||
|
||||
points[$key]=$val
|
||||
done < $CONFIG
|
||||
|
||||
|
||||
## functions
|
||||
# prepended wd_ to not conflict with your environment (no sub shell)
|
||||
|
||||
wd_warp()
|
||||
{
|
||||
if [[ $1 =~ "^\.+$" ]]
|
||||
then
|
||||
if [[ $#1 < 2 ]]
|
||||
then
|
||||
wd_print_msg $YELLOW "Warping to current directory?"
|
||||
else
|
||||
(( n = $#1 - 1 ))
|
||||
wd_print_msg $BLUE "Warping..."
|
||||
cd -$n > /dev/null
|
||||
fi
|
||||
elif [[ ${points[$1]} != "" ]]
|
||||
then
|
||||
wd_print_msg $BLUE "Warping..."
|
||||
cd ${points[$1]}
|
||||
else
|
||||
wd_print_msg $RED "Unkown warp point '$1'"
|
||||
fi
|
||||
}
|
||||
|
||||
wd_add()
|
||||
{
|
||||
if [[ $1 =~ "^\.+$" ]]
|
||||
then
|
||||
wd_print_msg $RED "Illeagal warp point (see README)."
|
||||
elif [[ ${points[$1]} == "" ]] || $2
|
||||
then
|
||||
wd_remove $1 > /dev/null
|
||||
print "$1:$PWD" >> $CONFIG
|
||||
wd_print_msg $GREEN "Warp point added"
|
||||
else
|
||||
wd_print_msg $YELLOW "Warp point '$1' alredy exists. Use 'add!' to overwrite."
|
||||
fi
|
||||
}
|
||||
|
||||
wd_remove()
|
||||
{
|
||||
if [[ ${points[$1]} != "" ]]
|
||||
then
|
||||
if wd_tmp=`sed "/^$1:/d" $CONFIG`
|
||||
then
|
||||
echo $wd_tmp > $CONFIG
|
||||
wd_print_msg $GREEN "Warp point removed"
|
||||
else
|
||||
wd_print_msg $RED "Warp point unsuccessfully removed. Sorry!"
|
||||
fi
|
||||
else
|
||||
wd_print_msg $RED "Warp point was not found"
|
||||
fi
|
||||
}
|
||||
|
||||
wd_show()
|
||||
{
|
||||
wd_print_msg $BLUE "Warp points to current directory:"
|
||||
wd_list_all | grep $PWD$
|
||||
}
|
||||
|
||||
wd_list_all()
|
||||
{
|
||||
wd_print_msg $BLUE "All warp points:"
|
||||
while read line
|
||||
do
|
||||
if [[ $line != "" ]]
|
||||
then
|
||||
arr=(${(s,:,)line})
|
||||
key=${arr[1]}
|
||||
val=${arr[2]}
|
||||
|
||||
print "\t" $key "\t -> \t" $val
|
||||
fi
|
||||
done < $CONFIG
|
||||
}
|
||||
|
||||
wd_print_msg()
|
||||
{
|
||||
if [[ $1 == "" || $2 == "" ]]
|
||||
then
|
||||
print " $RED*$NOC Could not print message. Sorry!"
|
||||
else
|
||||
print " $1*$NOC $2"
|
||||
fi
|
||||
}
|
||||
|
||||
wd_print_usage()
|
||||
{
|
||||
print "Usage: wd [add|-a|--add] [rm|-r|--remove] [ls|-l|--list] <point>"
|
||||
print "\nCommands:"
|
||||
print "\t add \t Adds the current working directory to your warp points"
|
||||
print "\t add! \t Overwrites existing warp point"
|
||||
print "\t remove Removes the given warp point"
|
||||
print "\t show \t Outputs warp points to current directory"
|
||||
print "\t list \t Outputs all stored warp points"
|
||||
print "\t help \t Show this extremely helpful text"
|
||||
}
|
||||
|
||||
|
||||
## run
|
||||
|
||||
# get opts
|
||||
args=`getopt -o a:r:lhs -l add:,remove:,list,help,show -- $*`
|
||||
|
||||
# check if no arguments were given
|
||||
if [[ $? -ne 0 || $#* -eq 0 ]]
|
||||
then
|
||||
wd_print_usage
|
||||
|
||||
# check if config file is writeable
|
||||
elif [[ ! -w $CONFIG ]]
|
||||
then
|
||||
wd_print_msg $RED "\'$CONFIG\' is not writeable."
|
||||
# do nothing => exit
|
||||
# can't run `exit`, as this would exit the executing shell
|
||||
# i.e. your terminal
|
||||
|
||||
else
|
||||
#set -- $args # WTF
|
||||
|
||||
for i
|
||||
do
|
||||
case "$i"
|
||||
in
|
||||
-a|--add|add)
|
||||
wd_add $2 false
|
||||
shift
|
||||
shift
|
||||
break
|
||||
;;
|
||||
-a!|--add!|add!)
|
||||
wd_add $2 true
|
||||
shift
|
||||
shift
|
||||
break
|
||||
;;
|
||||
-r|--remove|rm)
|
||||
wd_remove $2
|
||||
shift
|
||||
shift
|
||||
break
|
||||
;;
|
||||
-l|--list|ls)
|
||||
wd_list_all
|
||||
shift
|
||||
break
|
||||
;;
|
||||
-h|--help|help)
|
||||
wd_print_usage
|
||||
shift
|
||||
break
|
||||
;;
|
||||
-s|--show|show)
|
||||
wd_show
|
||||
shift
|
||||
break
|
||||
;;
|
||||
*)
|
||||
wd_warp $i
|
||||
shift
|
||||
break
|
||||
;;
|
||||
--)
|
||||
shift; break;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
## garbage collection
|
||||
# if not, next time warp will pick up variables from this run
|
||||
# remember, there's no sub shell
|
||||
points=""
|
||||
args=""
|
||||
unhash -d val &> /dev/null # fixes issue #1
|
||||
|
|
@ -11,7 +11,7 @@ function web_search() {
|
|||
fi
|
||||
|
||||
# check whether the search engine is supported
|
||||
if [[ ! $1 =~ '(google|bing|yahoo)' ]];
|
||||
if [[ ! $1 =~ '(google|bing|yahoo|duckduckgo)' ]];
|
||||
then
|
||||
echo "Search engine $1 not supported."
|
||||
return 1
|
||||
|
|
@ -24,8 +24,12 @@ function web_search() {
|
|||
$open_cmd "$url"
|
||||
return
|
||||
fi
|
||||
|
||||
url="${url}/search?q="
|
||||
if [[ $1 == 'duckduckgo' ]]; then
|
||||
#slightly different search syntax for DDG
|
||||
url="${url}/?q="
|
||||
else
|
||||
url="${url}/search?q="
|
||||
fi
|
||||
shift # shift out $1
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
|
|
@ -34,10 +38,19 @@ function web_search() {
|
|||
done
|
||||
|
||||
url="${url%?}" # remove the last '+'
|
||||
|
||||
|
||||
$open_cmd "$url"
|
||||
}
|
||||
|
||||
|
||||
alias bing='web_search bing'
|
||||
alias google='web_search google'
|
||||
alias yahoo='web_search yahoo'
|
||||
alias ddg='web_search duckduckgo'
|
||||
#add your own !bang searches here
|
||||
alias wiki='web_search duckduckgo \!w'
|
||||
alias news='web_search duckduckgo \!n'
|
||||
alias youtube='web_search duckduckgo \!yt'
|
||||
alias map='web_search duckduckgo \!m'
|
||||
alias image='web_search duckduckgo \!i'
|
||||
alias ducky='web_search duckduckgo \!'
|
||||
|
|
|
|||
18
plugins/xcode/xcode.plugin.zsh
Normal file
18
plugins/xcode/xcode.plugin.zsh
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#xc function courtesy of http://gist.github.com/subdigital/5420709
|
||||
function xc {
|
||||
xcode_proj=`find . -name "*.xc*" -d 1 | sort -r | head -1`
|
||||
if [[ `echo -n $xcode_proj | wc -m` == 0 ]]
|
||||
then
|
||||
echo "No xcworkspace/xcodeproj file found in the current directory."
|
||||
else
|
||||
echo "Found $xcode_proj"
|
||||
open "$xcode_proj"
|
||||
fi
|
||||
}
|
||||
|
||||
function xcsel {
|
||||
sudo xcode-select --switch "$*"
|
||||
}
|
||||
|
||||
alias xcb='xcodebuild'
|
||||
alias xcp='xcode-select --print-path'
|
||||
4
plugins/z/Makefile
Normal file
4
plugins/z/Makefile
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
readme:
|
||||
@groff -man -Tascii z.1 | col -bx
|
||||
|
||||
.PHONY: readme
|
||||
135
plugins/z/README
Normal file
135
plugins/z/README
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
Z(1) User Commands Z(1)
|
||||
|
||||
|
||||
|
||||
NAME
|
||||
z - jump around
|
||||
|
||||
SYNOPSIS
|
||||
z [-chlrt] [regex1 regex2 ... regexn]
|
||||
|
||||
AVAILABILITY
|
||||
bash, zsh
|
||||
|
||||
DESCRIPTION
|
||||
Tracks your most used directories, based on 'frecency'.
|
||||
|
||||
After a short learning phase, z will take you to the most 'frecent'
|
||||
directory that matches ALL of the regexes given on the command line.
|
||||
|
||||
OPTIONS
|
||||
-c restrict matches to subdirectories of the current directory.
|
||||
|
||||
-h show a brief help message
|
||||
|
||||
-l list only
|
||||
|
||||
-r match by rank only
|
||||
|
||||
-t match by recent access only
|
||||
|
||||
EXAMPLES
|
||||
z foo cd to most frecent dir matching foo
|
||||
|
||||
z foo bar cd to most frecent dir matching foo and bar
|
||||
|
||||
z -r foo cd to highest ranked dir matching foo
|
||||
|
||||
z -t foo cd to most recently accessed dir matching foo
|
||||
|
||||
z -l foo list all dirs matching foo (by frecency)
|
||||
|
||||
NOTES
|
||||
Installation:
|
||||
Put something like this in your $HOME/.bashrc or $HOME/.zshrc:
|
||||
|
||||
. /path/to/z.sh
|
||||
|
||||
cd around for a while to build up the db.
|
||||
|
||||
PROFIT!!
|
||||
|
||||
Optionally:
|
||||
Set $_Z_CMD to change the command name (default z).
|
||||
Set $_Z_DATA to change the datafile (default $HOME/.z).
|
||||
Set $_Z_NO_RESOLVE_SYMLINKS to prevent symlink resolution.
|
||||
Set $_Z_NO_PROMPT_COMMAND to handle PROMPT_COMMAND/precmd your-
|
||||
self.
|
||||
Set $_Z_EXCLUDE_DIRS to an array of directories to exclude.
|
||||
(These settings should go in .bashrc/.zshrc before the lines
|
||||
added above.)
|
||||
Install the provided man page z.1 somewhere like
|
||||
/usr/local/man/man1.
|
||||
|
||||
Aging:
|
||||
The rank of directories maintained by z undergoes aging based on a sim-
|
||||
ple formula. The rank of each entry is incremented every time it is
|
||||
accessed. When the sum of ranks is greater than 6000, all ranks are
|
||||
multiplied by 0.99. Entries with a rank lower than 1 are forgotten.
|
||||
|
||||
Frecency:
|
||||
Frecency is a portmantaeu of 'recent' and 'frequency'. It is a weighted
|
||||
rank that depends on how often and how recently something occured. As
|
||||
far as I know, Mozilla came up with the term.
|
||||
|
||||
To z, a directory that has low ranking but has been accessed recently
|
||||
will quickly have higher rank than a directory accessed frequently a
|
||||
long time ago.
|
||||
|
||||
Frecency is determined at runtime.
|
||||
|
||||
Common:
|
||||
When multiple directories match all queries, and they all have a common
|
||||
prefix, z will cd to the shortest matching directory, without regard to
|
||||
priority. This has been in effect, if undocumented, for quite some
|
||||
time, but should probably be configurable or reconsidered.
|
||||
|
||||
Tab Completion:
|
||||
z supports tab completion. After any number of arguments, press TAB to
|
||||
complete on directories that match each argument. Due to limitations of
|
||||
the completion implementations, only the last argument will be com-
|
||||
pleted in the shell.
|
||||
|
||||
Internally, z decides you've requested a completion if the last argu-
|
||||
ment passed is an absolute path to an existing directory. This may
|
||||
cause unexpected behavior if the last argument to z begins with /.
|
||||
|
||||
ENVIRONMENT
|
||||
A function _z() is defined.
|
||||
|
||||
The contents of the variable $_Z_CMD is aliased to _z 2>&1. If not set,
|
||||
$_Z_CMD defaults to z.
|
||||
|
||||
The environment variable $_Z_DATA can be used to control the datafile
|
||||
location. If it is not defined, the location defaults to $HOME/.z.
|
||||
|
||||
The environment variable $_Z_NO_RESOLVE_SYMLINKS can be set to prevent
|
||||
resolving of symlinks. If it is not set, symbolic links will be
|
||||
resolved when added to the datafile.
|
||||
|
||||
In bash, z prepends a command to the PROMPT_COMMAND environment vari-
|
||||
able to maintain its database. In zsh, z appends a function _z_precmd
|
||||
to the precmd_functions array.
|
||||
|
||||
The environment variable $_Z_NO_PROMPT_COMMAND can be set if you want
|
||||
to handle PROMPT_COMMAND or precmd yourself.
|
||||
|
||||
The environment variable $_Z_EXCLUDE_DIRS can be set to an array of
|
||||
directories to exclude from tracking. $HOME is always excluded. Direc-
|
||||
tories must be full paths without trailing slashes.
|
||||
|
||||
FILES
|
||||
Data is stored in $HOME/.z. This can be overridden by setting the
|
||||
$_Z_DATA environment variable. When initialized, z will raise an error
|
||||
if this path is a directory, and not function correctly.
|
||||
|
||||
A man page (z.1) is provided.
|
||||
|
||||
SEE ALSO
|
||||
regex(7), pushd, popd, autojump, cdargs
|
||||
|
||||
Please file bugs at https://github.com/rupa/z/
|
||||
|
||||
|
||||
|
||||
z January 2013 Z(1)
|
||||
155
plugins/z/z.1
Normal file
155
plugins/z/z.1
Normal file
|
|
@ -0,0 +1,155 @@
|
|||
.TH "Z" "1" "January 2013" "z" "User Commands"
|
||||
.SH
|
||||
NAME
|
||||
z \- jump around
|
||||
.SH
|
||||
SYNOPSIS
|
||||
z [\-chlrt] [regex1 regex2 ... regexn]
|
||||
.SH
|
||||
AVAILABILITY
|
||||
bash, zsh
|
||||
.SH
|
||||
DESCRIPTION
|
||||
Tracks your most used directories, based on 'frecency'.
|
||||
.P
|
||||
After a short learning phase, \fBz\fR will take you to the most 'frecent'
|
||||
directory that matches ALL of the regexes given on the command line.
|
||||
.SH
|
||||
OPTIONS
|
||||
.TP
|
||||
\fB\-c\fR
|
||||
restrict matches to subdirectories of the current directory.
|
||||
.TP
|
||||
\fB\-h\fR
|
||||
show a brief help message
|
||||
.TP
|
||||
\fB\-l\fR
|
||||
list only
|
||||
.TP
|
||||
\fB\-r\fR
|
||||
match by rank only
|
||||
.TP
|
||||
\fB\-t\fR
|
||||
match by recent access only
|
||||
.SH EXAMPLES
|
||||
.TP 14
|
||||
\fBz foo\fR
|
||||
cd to most frecent dir matching foo
|
||||
.TP 14
|
||||
\fBz foo bar\fR
|
||||
cd to most frecent dir matching foo and bar
|
||||
.TP 14
|
||||
\fBz -r foo\fR
|
||||
cd to highest ranked dir matching foo
|
||||
.TP 14
|
||||
\fBz -t foo\fR
|
||||
cd to most recently accessed dir matching foo
|
||||
.TP 14
|
||||
\fBz -l foo\fR
|
||||
list all dirs matching foo (by frecency)
|
||||
.SH
|
||||
NOTES
|
||||
.SS
|
||||
Installation:
|
||||
.P
|
||||
Put something like this in your \fB$HOME/.bashrc\fR or \fB$HOME/.zshrc\fR:
|
||||
.RS
|
||||
.P
|
||||
\fB. /path/to/z.sh\fR
|
||||
.RE
|
||||
.P
|
||||
\fBcd\fR around for a while to build up the db.
|
||||
.P
|
||||
PROFIT!!
|
||||
.P
|
||||
Optionally:
|
||||
.RS
|
||||
Set \fB$_Z_CMD\fR to change the command name (default \fBz\fR).
|
||||
.RE
|
||||
.RS
|
||||
Set \fB$_Z_DATA\fR to change the datafile (default \fB$HOME/.z\fR).
|
||||
.RE
|
||||
.RS
|
||||
Set \fB$_Z_NO_RESOLVE_SYMLINKS\fR to prevent symlink resolution.
|
||||
.RE
|
||||
.RS
|
||||
Set \fB$_Z_NO_PROMPT_COMMAND\fR to handle \fBPROMPT_COMMAND/precmd\fR yourself.
|
||||
.RE
|
||||
.RS
|
||||
Set \fB$_Z_EXCLUDE_DIRS\fR to an array of directories to exclude.
|
||||
.RE
|
||||
.RS
|
||||
(These settings should go in .bashrc/.zshrc before the lines added above.)
|
||||
.RE
|
||||
.RS
|
||||
Install the provided man page \fBz.1\fR somewhere like \fB/usr/local/man/man1\fR.
|
||||
.RE
|
||||
.SS
|
||||
Aging:
|
||||
The rank of directories maintained by \fBz\fR undergoes aging based on a simple
|
||||
formula. The rank of each entry is incremented every time it is accessed. When
|
||||
the sum of ranks is greater than 6000, all ranks are multiplied by 0.99. Entries
|
||||
with a rank lower than 1 are forgotten.
|
||||
.SS
|
||||
Frecency:
|
||||
Frecency is a portmantaeu of 'recent' and 'frequency'. It is a weighted rank
|
||||
that depends on how often and how recently something occured. As far as I
|
||||
know, Mozilla came up with the term.
|
||||
.P
|
||||
To \fBz\fR, a directory that has low ranking but has been accessed recently
|
||||
will quickly have higher rank than a directory accessed frequently a long time
|
||||
ago.
|
||||
.P
|
||||
Frecency is determined at runtime.
|
||||
.SS
|
||||
Common:
|
||||
When multiple directories match all queries, and they all have a common prefix,
|
||||
\fBz\fR will cd to the shortest matching directory, without regard to priority.
|
||||
This has been in effect, if undocumented, for quite some time, but should
|
||||
probably be configurable or reconsidered.
|
||||
.SS
|
||||
Tab Completion:
|
||||
\fBz\fR supports tab completion. After any number of arguments, press TAB to
|
||||
complete on directories that match each argument. Due to limitations of the
|
||||
completion implementations, only the last argument will be completed in the
|
||||
shell.
|
||||
.P
|
||||
Internally, \fBz\fR decides you've requested a completion if the last argument
|
||||
passed is an absolute path to an existing directory. This may cause unexpected
|
||||
behavior if the last argument to \fBz\fR begins with \fB/\fR.
|
||||
.SH
|
||||
ENVIRONMENT
|
||||
A function \fB_z()\fR is defined.
|
||||
.P
|
||||
The contents of the variable \fB$_Z_CMD\fR is aliased to \fB_z 2>&1\fR. If not
|
||||
set, \fB$_Z_CMD\fR defaults to \fBz\fR.
|
||||
.P
|
||||
The environment variable \fB$_Z_DATA\fR can be used to control the datafile
|
||||
location. If it is not defined, the location defaults to \fB$HOME/.z\fR.
|
||||
.P
|
||||
The environment variable \fB$_Z_NO_RESOLVE_SYMLINKS\fR can be set to prevent
|
||||
resolving of symlinks. If it is not set, symbolic links will be resolved when
|
||||
added to the datafile.
|
||||
.P
|
||||
In bash, \fBz\fR prepends a command to the \fBPROMPT_COMMAND\fR environment
|
||||
variable to maintain its database. In zsh, \fBz\fR appends a function
|
||||
\fB_z_precmd\fR to the \fBprecmd_functions\fR array.
|
||||
.P
|
||||
The environment variable \fB$_Z_NO_PROMPT_COMMAND\fR can be set if you want to
|
||||
handle \fBPROMPT_COMMAND\fR or \fBprecmd\fR yourself.
|
||||
.P
|
||||
The environment variable \fB$_Z_EXCLUDE_DIRS\fR can be set to an array of
|
||||
directories to exclude from tracking. \fB$HOME\fR is always excluded.
|
||||
Directories must be full paths without trailing slashes.
|
||||
.SH
|
||||
FILES
|
||||
Data is stored in \fB$HOME/.z\fR. This can be overridden by setting the
|
||||
\fB$_Z_DATA\fR environment variable. When initialized, \fBz\fR will raise an
|
||||
error if this path is a directory, and not function correctly.
|
||||
.P
|
||||
A man page (\fBz.1\fR) is provided.
|
||||
.SH
|
||||
SEE ALSO
|
||||
regex(7), pushd, popd, autojump, cdargs
|
||||
.P
|
||||
Please file bugs at https://github.com/rupa/z/
|
||||
6
plugins/z/z.plugin.zsh
Normal file
6
plugins/z/z.plugin.zsh
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
_load_z() {
|
||||
source $1/z.sh
|
||||
}
|
||||
|
||||
[[ -f $ZSH_CUSTOM/plugins/z/z.plugin.zsh ]] && _load_z $ZSH_CUSTOM/plugins/z
|
||||
[[ -f $ZSH/plugins/z/z.plugin.zsh ]] && _load_z $ZSH/plugins/z
|
||||
228
plugins/z/z.sh
Normal file
228
plugins/z/z.sh
Normal file
|
|
@ -0,0 +1,228 @@
|
|||
# Copyright (c) 2009 rupa deadwyler under the WTFPL license
|
||||
|
||||
# maintains a jump-list of the directories you actually use
|
||||
#
|
||||
# INSTALL:
|
||||
# * put something like this in your .bashrc/.zshrc:
|
||||
# . /path/to/z.sh
|
||||
# * cd around for a while to build up the db
|
||||
# * PROFIT!!
|
||||
# * optionally:
|
||||
# set $_Z_CMD in .bashrc/.zshrc to change the command (default z).
|
||||
# set $_Z_DATA in .bashrc/.zshrc to change the datafile (default ~/.z).
|
||||
# set $_Z_NO_RESOLVE_SYMLINKS to prevent symlink resolution.
|
||||
# set $_Z_NO_PROMPT_COMMAND if you're handling PROMPT_COMMAND yourself.
|
||||
# set $_Z_EXCLUDE_DIRS to an array of directories to exclude.
|
||||
#
|
||||
# USE:
|
||||
# * z foo # cd to most frecent dir matching foo
|
||||
# * z foo bar # cd to most frecent dir matching foo and bar
|
||||
# * z -r foo # cd to highest ranked dir matching foo
|
||||
# * z -t foo # cd to most recently accessed dir matching foo
|
||||
# * z -l foo # list matches instead of cd
|
||||
# * z -c foo # restrict matches to subdirs of $PWD
|
||||
|
||||
case $- in
|
||||
*i*) ;;
|
||||
*) echo 'ERROR: z.sh is meant to be sourced, not directly executed.'
|
||||
esac
|
||||
|
||||
[ -d "${_Z_DATA:-$HOME/.z}" ] && {
|
||||
echo "ERROR: z.sh's datafile (${_Z_DATA:-$HOME/.z}) is a directory."
|
||||
}
|
||||
|
||||
_z() {
|
||||
|
||||
local datafile="${_Z_DATA:-$HOME/.z}"
|
||||
|
||||
# bail out if we don't own ~/.z (we're another user but our ENV is still set)
|
||||
[ -f "$datafile" -a ! -O "$datafile" ] && return
|
||||
|
||||
# add entries
|
||||
if [ "$1" = "--add" ]; then
|
||||
shift
|
||||
|
||||
# $HOME isn't worth matching
|
||||
[ "$*" = "$HOME" ] && return
|
||||
|
||||
# don't track excluded dirs
|
||||
local exclude
|
||||
for exclude in "${_Z_EXCLUDE_DIRS[@]}"; do
|
||||
[ "$*" = "$exclude" ] && return
|
||||
done
|
||||
|
||||
# maintain the file
|
||||
local tempfile
|
||||
tempfile="$(mktemp "$datafile.XXXXXX")" || return
|
||||
while read line; do
|
||||
[ -d "${line%%\|*}" ] && echo $line
|
||||
done < "$datafile" | awk -v path="$*" -v now="$(date +%s)" -F"|" '
|
||||
BEGIN {
|
||||
rank[path] = 1
|
||||
time[path] = now
|
||||
}
|
||||
$2 >= 1 {
|
||||
if( $1 == path ) {
|
||||
rank[$1] = $2 + 1
|
||||
time[$1] = now
|
||||
} else {
|
||||
rank[$1] = $2
|
||||
time[$1] = $3
|
||||
}
|
||||
count += $2
|
||||
}
|
||||
END {
|
||||
if( count > 6000 ) {
|
||||
for( i in rank ) print i "|" 0.99*rank[i] "|" time[i] # aging
|
||||
} else for( i in rank ) print i "|" rank[i] "|" time[i]
|
||||
}
|
||||
' 2>/dev/null >| "$tempfile"
|
||||
if [ $? -ne 0 -a -f "$datafile" ]; then
|
||||
env rm -f "$tempfile"
|
||||
else
|
||||
env mv -f "$tempfile" "$datafile"
|
||||
fi
|
||||
|
||||
# tab completion
|
||||
elif [ "$1" = "--complete" ]; then
|
||||
while read line; do
|
||||
[ -d "${line%%\|*}" ] && echo $line
|
||||
done < "$datafile" | awk -v q="$2" -F"|" '
|
||||
BEGIN {
|
||||
if( q == tolower(q) ) nocase = 1
|
||||
split(substr(q,3),fnd," ")
|
||||
}
|
||||
{
|
||||
if( nocase ) {
|
||||
for( i in fnd ) tolower($1) !~ tolower(fnd[i]) && $1 = ""
|
||||
} else {
|
||||
for( i in fnd ) $1 !~ fnd[i] && $1 = ""
|
||||
}
|
||||
if( $1 ) print $1
|
||||
}
|
||||
' 2>/dev/null
|
||||
|
||||
else
|
||||
# list/go
|
||||
while [ "$1" ]; do case "$1" in
|
||||
--) while [ "$1" ]; do shift; local fnd="$fnd $1";done;;
|
||||
-*) local opt=${1:1}; while [ "$opt" ]; do case ${opt:0:1} in
|
||||
c) local fnd="^$PWD $fnd";;
|
||||
h) echo "${_Z_CMD:-z} [-chlrt] args" >&2; return;;
|
||||
l) local list=1;;
|
||||
r) local typ="rank";;
|
||||
t) local typ="recent";;
|
||||
esac; opt=${opt:1}; done;;
|
||||
*) local fnd="$fnd $1";;
|
||||
esac; local last=$1; shift; done
|
||||
[ "$fnd" -a "$fnd" != "^$PWD " ] || local list=1
|
||||
|
||||
# if we hit enter on a completion just go there
|
||||
case "$last" in
|
||||
# completions will always start with /
|
||||
/*) [ -z "$list" -a -d "$last" ] && cd "$last" && return;;
|
||||
esac
|
||||
|
||||
# no file yet
|
||||
[ -f "$datafile" ] || return
|
||||
|
||||
local cd
|
||||
cd="$(while read line; do
|
||||
[ -d "${line%%\|*}" ] && echo $line
|
||||
done < "$datafile" | awk -v t="$(date +%s)" -v list="$list" -v typ="$typ" -v q="$fnd" -F"|" '
|
||||
function frecent(rank, time) {
|
||||
dx = t-time
|
||||
if( dx < 3600 ) return rank*4
|
||||
if( dx < 86400 ) return rank*2
|
||||
if( dx < 604800 ) return rank/2
|
||||
return rank/4
|
||||
}
|
||||
function output(files, toopen, override) {
|
||||
if( list ) {
|
||||
cmd = "sort -n >&2"
|
||||
for( i in files ) if( files[i] ) printf "%-10s %s\n", files[i], i | cmd
|
||||
if( override ) printf "%-10s %s\n", "common:", override > "/dev/stderr"
|
||||
} else {
|
||||
if( override ) toopen = override
|
||||
print toopen
|
||||
}
|
||||
}
|
||||
function common(matches) {
|
||||
# shortest match
|
||||
for( i in matches ) {
|
||||
if( matches[i] && (!short || length(i) < length(short)) ) short = i
|
||||
}
|
||||
if( short == "/" ) return
|
||||
# shortest match must be common to each match. escape special characters in
|
||||
# a copy when testing, so we can return the original.
|
||||
clean_short = short
|
||||
gsub(/[\(\)\[\]\|]/, "\\\\&", clean_short)
|
||||
for( i in matches ) if( matches[i] && i !~ clean_short ) return
|
||||
return short
|
||||
}
|
||||
BEGIN { split(q, a, " "); oldf = noldf = -9999999999 }
|
||||
{
|
||||
if( typ == "rank" ) {
|
||||
f = $2
|
||||
} else if( typ == "recent" ) {
|
||||
f = $3-t
|
||||
} else f = frecent($2, $3)
|
||||
wcase[$1] = nocase[$1] = f
|
||||
for( i in a ) {
|
||||
if( $1 !~ a[i] ) delete wcase[$1]
|
||||
if( tolower($1) !~ tolower(a[i]) ) delete nocase[$1]
|
||||
}
|
||||
if( wcase[$1] && wcase[$1] > oldf ) {
|
||||
cx = $1
|
||||
oldf = wcase[$1]
|
||||
} else if( nocase[$1] && nocase[$1] > noldf ) {
|
||||
ncx = $1
|
||||
noldf = nocase[$1]
|
||||
}
|
||||
}
|
||||
END {
|
||||
if( cx ) {
|
||||
output(wcase, cx, common(wcase))
|
||||
} else if( ncx ) output(nocase, ncx, common(nocase))
|
||||
}
|
||||
')"
|
||||
[ $? -gt 0 ] && return
|
||||
[ "$cd" ] && cd "$cd"
|
||||
fi
|
||||
}
|
||||
|
||||
alias ${_Z_CMD:-z}='_z 2>&1'
|
||||
|
||||
[ "$_Z_NO_RESOLVE_SYMLINKS" ] || _Z_RESOLVE_SYMLINKS="-P"
|
||||
|
||||
if compctl &> /dev/null; then
|
||||
[ "$_Z_NO_PROMPT_COMMAND" ] || {
|
||||
# zsh populate directory list, avoid clobbering any other precmds
|
||||
if [ "$_Z_NO_RESOLVE_SYMLINKS" ]; then
|
||||
_z_precmd() {
|
||||
_z --add "${PWD:a}"
|
||||
}
|
||||
else
|
||||
_z_precmd() {
|
||||
_z --add "${PWD:A}"
|
||||
}
|
||||
fi
|
||||
precmd_functions+=(_z_precmd)
|
||||
}
|
||||
# zsh tab completion
|
||||
_z_zsh_tab_completion() {
|
||||
local compl
|
||||
read -l compl
|
||||
reply=(${(f)"$(_z --complete "$compl")"})
|
||||
}
|
||||
compctl -U -K _z_zsh_tab_completion _z
|
||||
elif complete &> /dev/null; then
|
||||
# bash tab completion
|
||||
complete -o filenames -C '_z --complete "$COMP_LINE"' ${_Z_CMD:-z}
|
||||
[ "$_Z_NO_PROMPT_COMMAND" ] || {
|
||||
# bash populate directory list. avoid clobbering other PROMPT_COMMANDs.
|
||||
echo $PROMPT_COMMAND | grep -q "_z --add" || {
|
||||
PROMPT_COMMAND='_z --add "$(pwd '$_Z_RESOLVE_SYMLINKS' 2>/dev/null)" 2>/dev/null;'"$PROMPT_COMMAND"
|
||||
}
|
||||
}
|
||||
fi
|
||||
|
|
@ -41,3 +41,13 @@
|
|||
|
||||
* `zsw` aliases `rm .zeus.sock`
|
||||
* `zweep` aliases `rm .zeus.sock`
|
||||
|
||||
`zdbr` aliases `zeus rake db:reset db:test:prepare`
|
||||
`zdbreset` aliases `zeus rake db:reset db:test:prepare`
|
||||
|
||||
`zdbm` aliases `zeus rake db:migrate db:test:prepare`
|
||||
`zdbmigrate` aliases `zeus rake db:migrate db:test:prepare`
|
||||
|
||||
`zdbc` aliases `zeus rake db:create`
|
||||
|
||||
`zdbcm` aliases `zeus rake db:create db:migrate db:test:prepare`
|
||||
|
|
|
|||
|
|
@ -53,3 +53,17 @@ alias zall='zeus test test/unit/*; zeus test test/functional/; zeus cucumber'
|
|||
# Clean up crashed zeus instances.
|
||||
alias zsw='rm .zeus.sock'
|
||||
alias zweep='rm .zeus.sock'
|
||||
|
||||
# Reset database
|
||||
alias zdbr='zeus rake db:reset db:test:prepare'
|
||||
alias zdbreset='zeus rake db:reset db:test:prepare'
|
||||
|
||||
# Migrate and prepare database
|
||||
alias zdbm='zeus rake db:migrate db:test:prepare'
|
||||
alias zdbmigrate='zeus rake db:migrate db:test:prepare'
|
||||
|
||||
# Create database
|
||||
alias zdbc='zeus rake db:create'
|
||||
|
||||
# Create, migrate and prepare database
|
||||
alias zdbcm='zeus rake db:create db:migrate db:test:prepare'
|
||||
|
|
@ -14,7 +14,7 @@ ZSH_THEME="robbyrussell"
|
|||
# Set to this to use case-sensitive completion
|
||||
# CASE_SENSITIVE="true"
|
||||
|
||||
# Comment this out to disable bi-weekly auto-update checks
|
||||
# Uncomment this to disable bi-weekly auto-update checks
|
||||
# DISABLE_AUTO_UPDATE="true"
|
||||
|
||||
# Uncomment to change how often before auto-updates occur? (in days)
|
||||
|
|
@ -37,6 +37,11 @@ ZSH_THEME="robbyrussell"
|
|||
# much faster.
|
||||
# DISABLE_UNTRACKED_FILES_DIRTY="true"
|
||||
|
||||
# Uncomment following line if you want to shown in the command execution time stamp
|
||||
# in the history command output. The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|
|
||||
# yyyy-mm-dd
|
||||
# HIST_STAMPS="mm/dd/yyyy"
|
||||
|
||||
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
|
||||
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
|
||||
# Example format: plugins=(rails git textmate ruby lighthouse)
|
||||
|
|
@ -44,4 +49,21 @@ plugins=(git)
|
|||
|
||||
source $ZSH/oh-my-zsh.sh
|
||||
|
||||
# Customize to your needs...
|
||||
# User configuration
|
||||
|
||||
export PATH=$HOME/bin:/usr/local/bin:$PATH
|
||||
# export MANPATH="/usr/local/man:$MANPATH"
|
||||
|
||||
# # Preferred editor for local and remote sessions
|
||||
# if [[ -n $SSH_CONNECTION ]]; then
|
||||
# export EDITOR='vim'
|
||||
# else
|
||||
# export EDITOR='mvim'
|
||||
# fi
|
||||
|
||||
# Compilation flags
|
||||
# export ARCHFLAGS="-arch x86_64"
|
||||
|
||||
# ssh
|
||||
# export SSH_KEY_PATH="~/.ssh/dsa_id"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,26 +1,121 @@
|
|||
#!/usr/bin/env zsh
|
||||
local USER_HOST='%{$terminfo[bold]$fg[yellow]%}%n@%m%{$reset_color%}'
|
||||
local RETURN_CODE="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
|
||||
local GIT_BRANCH='%{$terminfo[bold]$fg[red]%}$(git_prompt_info)%{$reset_color%}'
|
||||
local CURRENT_DIR='%{$terminfo[bold]$fg[green]%} %~%{$reset_color%}'
|
||||
local RUBY_RVM='%{$fg[gray]%}‹$(rvm-prompt i v g)›%{$reset_color%}'
|
||||
local COMMAND_TIP='%{$terminfo[bold]$fg[blue]%}$(wget -qO - http://www.commandlinefu.com/commands/random/plaintext | sed 1d | sed '/^$/d' | sed 's/^/║/g')%{$reset_color%}'
|
||||
######### PROMPT #########
|
||||
PROMPT="%{$terminfo[bold]$fg[blue]%}╔═ %{$reset_color%}${USER_HOST} ${CURRENT_DIR} ${RUBY_RVM} ${GIT_BRANCH}
|
||||
${COMMAND_TIP}
|
||||
%{$terminfo[bold]$fg[blue]%}╚═ %{$reset_color%}%B%{$terminfo[bold]$fg[white]%}$%b%{$reset_color%} "
|
||||
RPS1='${RETURN_CODE}'
|
||||
RPROMPT='%{$fg[green]%}[%*]%{$reset_color%}'
|
||||
######### PROMPT #########
|
||||
########## GIT ###########
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX="‹"
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$GIT_PROMPT_INFO%}›"
|
||||
ZSH_THEME_GIT_PROMPT_DIRTY=" %{$GIT_DIRTY_COLOR%}✘"
|
||||
ZSH_THEME_GIT_PROMPT_CLEAN=" %{$GIT_CLEAN_COLOR%}✔"
|
||||
ZSH_THEME_GIT_PROMPT_ADDED="%{$FG[082]%}✚%{$reset_color%}"
|
||||
ZSH_THEME_GIT_PROMPT_MODIFIED="%{$FG[166]%}✹%{$reset_color%}"
|
||||
ZSH_THEME_GIT_PROMPT_DELETED="%{$FG[160]%}✖%{$reset_color%}"
|
||||
ZSH_THEME_GIT_PROMPT_RENAMED="%{$FG[220]%}➜%{$reset_color%}"
|
||||
ZSH_THEME_GIT_PROMPT_UNMERGED="%{$FG[082]%}═%{$reset_color%}"
|
||||
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$FG[190]%}✭%{$reset_color%}"
|
||||
########## GIT ###########
|
||||
# #
|
||||
# # #README
|
||||
# #
|
||||
# # This theme provides two customizable header functionalities :
|
||||
# # a) displaying a pseudo-random message from a database of quotations
|
||||
# # (https://en.wikipedia.org/wiki/Fortune_%28Unix%29)
|
||||
# # b) displaying randomly command line tips from The command line fu
|
||||
# # (http://www.commandlinefu.com) community: in order to make use of this functionality
|
||||
# # you will need Internet connection.
|
||||
# # This theme provides as well information for the current user's context, like;
|
||||
# # branch and status for the current version control system (git and svn currently
|
||||
# # supported) and time, presented to the user in a non invasive volatile way.
|
||||
# #
|
||||
# # #REQUIREMENTS
|
||||
# # This theme requires wget::
|
||||
# # -Homebrew-osx- brew install wget
|
||||
# # -Debian/Ubuntu- apt-get install wget
|
||||
# # and fortune ::
|
||||
# # -Homebrew-osx- brew install fortune
|
||||
# # -Debian/Ubuntu- apt-get install fortune
|
||||
# #
|
||||
# # optionally:
|
||||
# # -Oh-myzsh vcs plug-ins git and svn.
|
||||
# # -Solarized theme (https://github.com/altercation/solarized/)
|
||||
# # -OS X: iTerm 2 (http://www.iterm2.com/)
|
||||
# # -font Source code pro (https://github.com/adobe/source-code-pro)
|
||||
# #
|
||||
# # Author: Adolfo Benedetti
|
||||
# # email: adolfo.benedetti@gmail.com
|
||||
# # License: Public Domain
|
||||
# # This theme's look and feel is based on the Aaron Toponce's zsh theme , more info:
|
||||
# # http://pthree.org/2008/11/23/727/
|
||||
# # enjoy!
|
||||
########## COLOR ###########
|
||||
for COLOR in CYAN WHITE YELLOW MAGENTA BLACK BLUE RED DEFAULT GREEN GREY; do
|
||||
eval PR_$COLOR='%{$fg[${(L)COLOR}]%}'
|
||||
eval PR_BRIGHT_$COLOR='%{$fg_bold[${(L)COLOR}]%}'
|
||||
done
|
||||
PR_RESET="%{$reset_color%}"
|
||||
RED_START="${PR_RESET}${PR_GREY}<${PR_RESET}${PR_RED}<${PR_BRIGHT_RED}<${PR_RESET} "
|
||||
RED_END="${PR_RESET}${PR_BRIGHT_RED}>${PR_RESET}${PR_RED}>${PR_GREY}>${PR_RESET} "
|
||||
GREEN_END="${PR_RESET}${PR_BRIGHT_GREEN}>${PR_RESET}${PR_GREEN}>${PR_GREY}>${PR_RESET} "
|
||||
GREEN_BASE_START="${PR_RESET}${PR_GREY}>${PR_RESET}${PR_GREEN}>${PR_BRIGHT_GREEN}>${PR_RESET}"
|
||||
GREEN_START_P1="${PR_RESET}${GREEN_BASE_START}${PR_RESET} "
|
||||
DIVISION="${PR_RESET}${PR_RED} < ${PR_RESET}"
|
||||
VCS_DIRTY_COLOR="${PR_RESET}${PR_YELLOW}"
|
||||
Vcs_CLEAN_COLOR="${PR_RESET}${PR_GREEN}"
|
||||
VCS_SUFIX_COLOR="${PR_RESET}${PR_RED}› ${PR_RESET}"
|
||||
# ########## COLOR ###########
|
||||
# ########## SVN ###########
|
||||
ZSH_THEME_SVN_PROMPT_PREFIX="${PR_RESET}${PR_RED}‹svn:"
|
||||
ZSH_THEME_SVN_PROMPT_SUFFIX=""
|
||||
ZSH_THEME_SVN_PROMPT_DIRTY="${VCS_DIRTY_COLOR} ✘${VCS_SUFIX_COLOR}"
|
||||
ZSH_THEME_SVN_PROMPT_CLEAN="${VCS_CLEAN_COLOR} ✔${VCS_SUFIX_COLOR}"
|
||||
# ########## SVN ###########
|
||||
# ########## GIT ###########
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX="${PR_RESET}${PR_RED}‹git:"
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX=""
|
||||
ZSH_THEME_GIT_PROMPT_DIRTY="${VCS_DIRTY_COLOR} ✘${VCS_SUFIX_COLOR}"
|
||||
ZSH_THEME_GIT_PROMPT_CLEAN="${VCS_CLEAN_COLOR} ✔${VCS_SUFIX_COLOR}"
|
||||
ZSH_THEME_GIT_PROMPT_ADDED="${PR_RESET}${PR_YELLOW} ✚${PR_RESET}"
|
||||
ZSH_THEME_GIT_PROMPT_MODIFIED="${PR_RESET}${PR_YELLOW} ✹${PR_RESET}"
|
||||
ZSH_THEME_GIT_PROMPT_DELETED="${PR_RESET}${PR_YELLOW} ✖${PR_RESET}"
|
||||
ZSH_THEME_GIT_PROMPT_RENAMED="${PR_RESET}${PR_YELLOW} ➜${PR_RESET}"
|
||||
ZSH_THEME_GIT_PROMPT_UNMERGED="${PR_RESET}${PR_YELLOW} ═${PR_RESET}"
|
||||
ZSH_THEME_GIT_PROMPT_UNTRACKED="${PR_RESET}${PR_YELLOW} ✭${PR_RESET}"
|
||||
# ########## GIT ###########
|
||||
function precmd {
|
||||
#gets the fortune
|
||||
ps1_fortune () {
|
||||
#Choose from all databases, regardless of whether they are considered "offensive"
|
||||
fortune -a
|
||||
}
|
||||
#obtains the tip
|
||||
ps1_command_tip () {
|
||||
wget -qO - http://www.commandlinefu.com/commands/random/plaintext | sed 1d | sed '/^$/d'
|
||||
}
|
||||
prompt_header () {
|
||||
if [[ "true" == "$ENABLE_COMMAND_TIP" ]]; then
|
||||
ps1_command_tip
|
||||
else
|
||||
ps1_fortune
|
||||
fi
|
||||
}
|
||||
PROMPT_HEAD="${RED_START}${PR_YELLOW}$(prompt_header)${PR_RESET}"
|
||||
# set a simple variable to show when in screen
|
||||
if [[ -n "${WINDOW}" ]]; then
|
||||
SCREEN=""
|
||||
fi
|
||||
}
|
||||
|
||||
# Context: user@directory or just directory
|
||||
prompt_context () {
|
||||
local user=`whoami`
|
||||
if [[ "$user" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
|
||||
echo -n "${PR_RESET}${PR_RED}$user@%m${PR_RESET}${PR_BRIGHT_YELLOW}%~%<<${PR_RESET}"
|
||||
else
|
||||
echo -n "${PR_RESET}${PR_BRIGHT_YELLOW}%~%<<${PR_RESET}"
|
||||
fi
|
||||
}
|
||||
|
||||
set_prompt () {
|
||||
# required for the prompt
|
||||
setopt prompt_subst
|
||||
autoload colors zsh/terminfo
|
||||
if [[ "$terminfo[colors]" -gt 8 ]]; then
|
||||
colors
|
||||
fi
|
||||
|
||||
# ######### PROMPT #########
|
||||
PROMPT='${PROMPT_HEAD}
|
||||
${RED_START}$(prompt_context)
|
||||
${GREEN_START_P1}'
|
||||
RPROMPT='${PR_RESET}$(git_prompt_info)$(svn_prompt_info)${PR_YELLOW}%D{%R.%S %a %b %d %Y} ${GREEN_END}${PR_RESET}'
|
||||
# Matching continuation prompt
|
||||
PROMPT2='${GREEN_BASE_START}${PR_RESET} %_ ${GREEN_BASE_START}${PR_RESET} '
|
||||
# ######### PROMPT #########
|
||||
}
|
||||
|
||||
set_prompt
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ eval my_gray='$FG[237]'
|
|||
eval my_orange='$FG[214]'
|
||||
|
||||
# right prompt
|
||||
RPROMPT='$my_gray%n@%m%{$reset_color%}%'
|
||||
PROMPT='$(virtualenv_prompt_info)$my_gray%n@%m%{$reset_color%}%'
|
||||
|
||||
# git settings
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX="$FG[075](branch:"
|
||||
|
|
|
|||
|
|
@ -90,43 +90,43 @@ prompt_git() {
|
|||
zstyle ':vcs_info:*' formats ' %u%c'
|
||||
zstyle ':vcs_info:*' actionformats '%u%c'
|
||||
vcs_info
|
||||
echo -n "${ref/refs\/heads\// }${vcs_info_msg_0_}"
|
||||
echo -n "${ref/refs\/heads\//± }${vcs_info_msg_0_}"
|
||||
fi
|
||||
}
|
||||
|
||||
prompt_hg() {
|
||||
local rev status
|
||||
if $(hg id >/dev/null 2>&1); then
|
||||
if $(hg prompt >/dev/null 2>&1); then
|
||||
if [[ $(hg prompt "{status|unknown}") = "?" ]]; then
|
||||
# if files are not added
|
||||
prompt_segment red white
|
||||
st='±'
|
||||
elif [[ -n $(hg prompt "{status|modified}") ]]; then
|
||||
# if any modification
|
||||
prompt_segment yellow black
|
||||
st='±'
|
||||
else
|
||||
# if working copy is clean
|
||||
prompt_segment green black
|
||||
fi
|
||||
echo -n $(hg prompt " {rev}@{branch}") $st
|
||||
else
|
||||
st=""
|
||||
rev=$(hg id -n 2>/dev/null | sed 's/[^-0-9]//g')
|
||||
branch=$(hg id -b 2>/dev/null)
|
||||
if `hg st | grep -Eq "^\?"`; then
|
||||
prompt_segment red black
|
||||
st='±'
|
||||
elif `hg st | grep -Eq "^(M|A)"`; then
|
||||
prompt_segment yellow black
|
||||
st='±'
|
||||
else
|
||||
prompt_segment green black
|
||||
fi
|
||||
echo -n " $rev@$branch" $st
|
||||
fi
|
||||
fi
|
||||
local rev status
|
||||
if $(hg id >/dev/null 2>&1); then
|
||||
if $(hg prompt >/dev/null 2>&1); then
|
||||
if [[ $(hg prompt "{status|unknown}") = "?" ]]; then
|
||||
# if files are not added
|
||||
prompt_segment red white
|
||||
st='±'
|
||||
elif [[ -n $(hg prompt "{status|modified}") ]]; then
|
||||
# if any modification
|
||||
prompt_segment yellow black
|
||||
st='±'
|
||||
else
|
||||
# if working copy is clean
|
||||
prompt_segment green black
|
||||
fi
|
||||
echo -n $(hg prompt "☿ {rev}@{branch}") $st
|
||||
else
|
||||
st=""
|
||||
rev=$(hg id -n 2>/dev/null | sed 's/[^-0-9]//g')
|
||||
branch=$(hg id -b 2>/dev/null)
|
||||
if `hg st | grep -Eq "^\?"`; then
|
||||
prompt_segment red black
|
||||
st='±'
|
||||
elif `hg st | grep -Eq "^(M|A)"`; then
|
||||
prompt_segment yellow black
|
||||
st='±'
|
||||
else
|
||||
prompt_segment green black
|
||||
fi
|
||||
echo -n "☿ $rev@$branch" $st
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Dir: current working directory
|
||||
|
|
@ -137,7 +137,7 @@ prompt_dir() {
|
|||
# Virtualenv: current working virtualenv
|
||||
prompt_virtualenv() {
|
||||
local virtualenv_path="$VIRTUAL_ENV"
|
||||
if [[ -n $virtualenv_path ]]; then
|
||||
if [[ -n $virtualenv_path && -n $VIRTUAL_ENV_DISABLE_PROMPT ]]; then
|
||||
prompt_segment blue black "(`basename $virtualenv_path`)"
|
||||
fi
|
||||
}
|
||||
|
|
|
|||
21
themes/amuse.zsh-theme
Normal file
21
themes/amuse.zsh-theme
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
# vim:ft=zsh ts=2 sw=2 sts=2
|
||||
|
||||
rvm_current() {
|
||||
rvm current 2>/dev/null
|
||||
}
|
||||
|
||||
rbenv_version() {
|
||||
rbenv version 2>/dev/null | awk '{print $1}'
|
||||
}
|
||||
|
||||
PROMPT='
|
||||
%{$fg_bold[green]%}${PWD/#$HOME/~}%{$reset_color%}$(git_prompt_info) ⌚ %{$fg_bold[red]%}%*%{$reset_color%}
|
||||
$ '
|
||||
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX=" on %{$fg[magenta]%}⭠ "
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
|
||||
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}!"
|
||||
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[green]%}?"
|
||||
ZSH_THEME_GIT_PROMPT_CLEAN=""
|
||||
|
||||
RPROMPT='%{$fg_bold[red]%}$(rbenv_version)%{$reset_color%}'
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue