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

Merge remote-tracking branch 'robbyrussell/master'

parents eafd5f32 192de6bc
......@@ -3,23 +3,59 @@ alias bl="bundle list"
alias bp="bundle package"
alias bo="bundle open"
alias bu="bundle update"
alias bi="bundle_install"
alias bcn="bundle clean"
# The following is based on https://github.com/gma/bundler-exec
bundled_commands=(annotate berks cap capify cucumber foodcritic foreman guard irb jekyll kitchen knife middleman nanoc puma rackup rainbows rake rspec ruby shotgun spec spin spork strainer tailor taps thin thor unicorn unicorn_rails)
bundled_commands=(
annotate
cap
capify
cucumber
foodcritic
guard
irb
jekyll
kitchen
knife
middleman
nanoc
pry
puma
rackup
rainbows
rake
rspec
shotgun
sidekiq
spec
spork
spring
strainer
tailor
taps
thin
thor
unicorn
unicorn_rails
)
# Remove $UNBUNDLED_COMMANDS from the bundled_commands list
for cmd in $UNBUNDLED_COMMANDS; do
bundled_commands=(${bundled_commands#$cmd});
done
# Add $BUNDLED_COMMANDS to the bundled_commands list
for cmd in $BUNDLED_COMMANDS; do
bundled_commands+=($cmd);
done
## Functions
bi() {
bundle_install() {
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' ]]
if [[ "$OSTYPE" = darwin* ]]
then
local cores_num="$(sysctl hw.ncpu | awk '{print $2}')"
else
......@@ -39,17 +75,25 @@ _bundler-installed() {
}
_within-bundled-project() {
local check_dir=$PWD
while [ $check_dir != "/" ]; do
local check_dir="$PWD"
while [ "$check_dir" != "/" ]; do
[ -f "$check_dir/Gemfile" ] && return
check_dir="$(dirname $check_dir)"
done
false
}
_binstubbed() {
[ -f "./bin/${1}" ]
}
_run-with-bundler() {
if _bundler-installed && _within-bundled-project; then
bundle exec $@
if _binstubbed $1; then
./bin/$@
else
bundle exec $@
fi
else
$@
fi
......@@ -62,7 +106,6 @@ for cmd in $bundled_commands; do
alias $cmd=bundled_$cmd
if which _$cmd > /dev/null 2>&1; then
compdef _$cmd bundled_$cmd=$cmd
compdef _$cmd bundled_$cmd=$cmd
fi
done
......@@ -17,13 +17,16 @@ function _cabal_commands() {
subcommand)
subcommands=(
"bench:Run the benchmark, if any (configure with UserHooks)"
"build:Make this package ready for installation"
"build:Compile all targets or specific target."
"check:Check the package for common mistakes"
"clean:Clean up after a build"
"copy:Copy teh files into the install locations"
"copy:Copy the files into the install locations"
"configure:Prepare to build the package"
"exec:Run a command with the cabal environment"
"fetch:Downloads packages for later installation"
"haddock:Generate HAddock HTML documentation"
"freeze:Freeze dependencies."
"get:Gets a package's source code"
"haddock:Generate Haddock HTML documentation"
"help:Help about commands"
"hscolour:Generate HsColour colourised code, in HTML format"
"info:Display detailed information about a particular package"
......@@ -31,7 +34,10 @@ function _cabal_commands() {
"install:Installs a list of packages"
"list:List packages matching a search string"
"register:Register this package with the compiler"
"repl:Open an interpreter session for the given target"
"report:Upload build reports to a remote server"
"run:Runs the compiled executable"
"sandbox:Create/modify/delete a sandbox"
"sdist:Generate a source distribution file (.tar.gz)"
"test:Run the test suite, if any (configure with UserHooks)"
"unpack:Unpacks packages for user inspection"
......@@ -45,3 +51,43 @@ function _cabal_commands() {
}
compdef _cabal_commands cabal
function _cab_commands() {
local ret=1 state
_arguments ':subcommand:->subcommand' && ret=0
case $state in
subcommand)
subcommands=(
"sync:Fetch the latest package index"
"install:Install packages"
"uninstall:Uninstall packages"
"installed:List installed packages"
"configure:Configure a cabal package"
"build:Build a cabal package"
"clean:Clean up a build directory"
"outdated:Display outdated packages"
"info:Display information of a package"
"sdist:Make tar.gz for source distribution"
"upload:Uploading tar.gz to HackageDB"
"get:Untar a package in the current directory"
"deps:Show dependencies of this package"
"revdeps:Show reverse dependencies of this package"
"check:Check consistency of packages"
"genpaths:Generate Paths_<pkg>.hs"
"search:Search available packages by package name"
"add:Add a source directory"
"test:Run tests"
"bench:Run benchmarks"
"doc:Generate manuals"
"ghci:Run GHCi (with a sandbox)"
"init:Initialize a sandbox"
"help:Display the help message of the command"
)
_describe -t subcommands 'cab subcommands' subcommands && ret=0
esac
return ret
}
command -v cab >/dev/null 2>&1 && { compdef _cab_commands cab }
......@@ -15,7 +15,7 @@ _cake_does_target_list_need_generating () {
fi
[ ! -f ${_cake_task_cache_file} ] && return 0;
[ ${_cake_task_cache_file} -nt Cakefile ] && return 0;
[ Cakefile -nt ${_cake_task_cache_file} ] && return 0;
return 1;
}
......
# CakePHP 3 basic command completion
_cakephp3_get_command_list () {
cakephp3commands=($(bin/cake completion commands));printf "%s\n" "${cakephp3commands[@]}"
}
_cakephp3 () {
if [ -f bin/cake ]; then
compadd `_cakephp3_get_command_list`
fi
}
compdef _cakephp3 bin/cake
compdef _cakephp3 cake
#Alias
alias c3='bin/cake'
alias c3cache='bin/cake orm_cache clear'
alias c3migrate='bin/cake migrations migrate'
if which cask &> /dev/null; then
source $(dirname $(which cask))/../etc/cask_completion.zsh
else
print "zsh cask plugin: cask not found"
fi
......@@ -24,7 +24,7 @@ _homebrew-installed() {
}
_chruby-from-homebrew-installed() {
brew --prefix chruby &> /dev/null
[ -r $(brew --prefix chruby)] &> /dev/null
}
_ruby-build_installed() {
......@@ -45,11 +45,11 @@ _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
if ${_chruby_path} && [[ -r ${_chruby_path} ]]; then
source ${_chruby_path}
fi
if _chruby_auto && [[ -r _chruby_auto ]]; then
if ${_chruby_auto} && [[ -r ${_chruby_auto} ]]; then
source ${_chruby_auto}
fi
}
......
fortunes/chucknorris.dat
License: GPL v2
Thanks to http://www.k-lug.org/~kessler/projects.html for the fortune file.
if [ ! -f $ZSH/plugins/chucknorris/fortunes/chucknorris.dat ]; then
strfile $ZSH/plugins/chucknorris/fortunes/chucknorris $ZSH/plugins/chucknorris/fortunes/chucknorris.dat
fi
alias chuck="fortune -a $ZSH/plugins/chucknorris/fortunes"
alias chuck_cow="chuck | cowthink"
This diff is collapsed.
## Coffeescript Plugin
This plugin provides aliases for quickly compiling and previewing your
cofeescript code.
When writing Coffeescript it's very common to want to preview the output of a
certain snippet of code, either because you want to test the output or because
you'd like to execute it in a browser console which doesn't accept Coffeescript.
Preview the compiled result of your coffeescript with `cf "code"` as per the
following:
```zsh
$ cf 'if a then be else c'
if (a) {
b;
} else {
c;
}
```
Also provides the following aliases:
* **cfc:** Copies the compiled JS to your clipboard. Very useful when you want
to run the code in a JS console.
* **cfp:** Compiles from your currently copied clipboard. Useful when you want
to compile large/multi-line snippets
* **cfpc:** Paste coffeescript from clipboard, compile to JS, then copy the
the result back to clipboard.
#!/bin/zsh
# compile a string of coffeescript and print to output
cf () {
coffee -peb $1
}
# compile & copy to clipboard
cfc () {
cf $1 | pbcopy
}
# compile from pasteboard & print
alias cfp='coffeeMe "$(pbpaste)"'
# compile from pasteboard and copy to clipboard
alias cfpc='cfp | pbcopy'
......@@ -19,4 +19,4 @@ bindkey -a 'N' vi-join
bindkey -a 'j' vi-forward-word-end
bindkey -a 'J' vi-forward-blank-word-end
lesskey $ZSH_CUSTOM/plugins/colemak/colemak-less
lesskey $ZSH/plugins/colemak/colemak-less
if [ "$OSTYPE[0,7]" = "solaris" ]
then
if [ ! -x ${HOME}/bin/nroff ]
then
mkdir -p ${HOME}/bin
cat > ${HOME}/bin/nroff <<EOF
#!/bin/sh
if [ -n "\$_NROFF_U" -a "\$1,\$2,\$3" = "-u0,-Tlp,-man" ]; then
shift
exec /usr/bin/nroff -u\${_NROFF_U} "\$@"
fi
#-- Some other invocation of nroff
exec /usr/bin/nroff "\$@"
EOF
chmod +x ${HOME}/bin/nroff
fi
fi
man() {
env \
LESS_TERMCAP_mb=$(printf "\e[1;31m") \
......@@ -7,5 +25,8 @@ man() {
LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
LESS_TERMCAP_ue=$(printf "\e[0m") \
LESS_TERMCAP_us=$(printf "\e[1;32m") \
PAGER=/usr/bin/less \
_NROFF_U=1 \
PATH=${HOME}/bin:${PATH} \
man "$@"
}
# Plugin for highligthing file content
# Plugin for highlighting file content
# Plugin highlights file content based on the filename extension.
# If no highlighting method supported for given extension then it tries
# guess it by looking for file content.
......@@ -6,9 +6,9 @@
alias colorize='colorize_via_pygmentize'
colorize_via_pygmentize() {
if [ ! -x $(which pygmentize) ]; then
echo package \'pygmentize\' is not installed!
exit -1
if [ ! -x "$(which pygmentize)" ]; then
echo "package \'pygmentize\' is not installed!"
return -1
fi
if [ $# -eq 0 ]; then
......@@ -25,4 +25,4 @@ colorize_via_pygmentize() {
pygmentize -g "$FNAME"
fi
done
}
\ No newline at end of file
}
......@@ -7,3 +7,19 @@
# Arch Linux command-not-found support, you must have package pkgfile installed
# https://wiki.archlinux.org/index.php/Pkgfile#.22Command_not_found.22_hook
[[ -e /usr/share/doc/pkgfile/command-not-found.zsh ]] && source /usr/share/doc/pkgfile/command-not-found.zsh
# Fedora command-not-found support
if [ -f /usr/libexec/pk-command-not-found ]; then
command_not_found_handler () {
runcnf=1
retval=127
[ ! -S /var/run/dbus/system_bus_socket ] && runcnf=0
[ ! -x /usr/libexec/packagekitd ] && runcnf=0
if [ $runcnf -eq 1 ]
then
/usr/libexec/pk-command-not-found $@
retval=$?
fi
return $retval
}
fi
......@@ -3,7 +3,6 @@
#
# 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
......@@ -14,19 +13,13 @@ alias lS='ls -1FSsh'
alias lart='ls -1Fcart'
alias lrt='ls -1Fcrt'
alias zshrc='vim ~/.zshrc' # Quick access to the ~/.zshrc file
alias zshrc='$EDITOR ~/.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'
......@@ -39,7 +32,7 @@ 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 dud='du -d 1 -h'
alias duf='du -sh *'
alias fd='find . -type d -name'
alias ff='find . -type f -name'
......@@ -47,7 +40,6 @@ 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'
......
......@@ -7,11 +7,11 @@
# Composer basic command completion
_composer_get_command_list () {
composer --no-ansi | sed "1,/Available commands/d" | awk '/^ [a-z]+/ { print $1 }'
$_comp_command1 --no-ansi | sed "1,/Available commands/d" | awk '/^[ \t]*[a-z]+/ { print $1 }'
}
_composer_get_required_list () {
composer show -s --no-ansi | sed '1,/requires/d' | awk 'NF > 0 && !/^requires \(dev\)/{ print $1 }'
$_comp_command1 show -s --no-ansi | sed '1,/requires/d' | awk 'NF > 0 && !/^requires \(dev\)/{ print $1 }'
}
_composer () {
......@@ -20,29 +20,33 @@ _composer () {
_arguments \
'1: :->command'\
'*: :->args'
if [ -f composer.json ]; then
case $state in
command)
compadd `_composer_get_command_list`
;;
*)
compadd `_composer_get_required_list`
;;
esac
else
compadd create-project init search selfupdate show
fi
case $state in
command)
compadd $(_composer_get_command_list)
;;
*)
compadd $(_composer_get_required_list)
;;
esac
}
compdef _composer composer
compdef _composer composer.phar
# Aliases
alias c='composer'
alias csu='composer self-update'
alias cu='composer update'
alias cr='composer require'
alias ci='composer install'
alias ccp='composer create-project'
alias cdu='composer dump-autoload'
alias cgu='composer global update'
alias cgr='composer global require'
# install composer in the current directory
alias cget='curl -s https://getcomposer.org/installer | php'
# Add Composer's global binaries to PATH
export PATH=$PATH:~/.composer/vendor/bin
......@@ -9,8 +9,10 @@
# You can just set apt_pref='apt-get' to override it.
if [[ -e $( which -p aptitude 2>&1 ) ]]; then
apt_pref='aptitude'
apt_upgr='safe-upgrade'
else
apt_pref='apt-get'
apt_upgr='upgrade'
fi
# Use sudo by default if it's installed
......@@ -45,10 +47,10 @@ if [[ $use_sudo -eq 1 ]]; then
alias abd='sudo $apt_pref build-dep'
alias ac='sudo $apt_pref clean'
alias ad='sudo $apt_pref update'
alias adg='sudo $apt_pref update && sudo $apt_pref upgrade'
alias adg='sudo $apt_pref update && sudo $apt_pref $apt_upgr'
alias adu='sudo $apt_pref update && sudo $apt_pref dist-upgrade'
alias afu='sudo apt-file update'
alias ag='sudo $apt_pref upgrade'
alias ag='sudo $apt_pref $apt_upgr'
alias ai='sudo $apt_pref install'
# Install all packages given on the command line while using only the first word of each line:
# acs ... | ail
......@@ -80,10 +82,10 @@ else
}
alias ac='su -ls \'$apt_pref clean\' root'
alias ad='su -lc \'$apt_pref update\' root'
alias adg='su -lc \'$apt_pref update && aptitude safe-upgrade\' root'
alias adg='su -lc \'$apt_pref update && aptitude $apt_upgr\' root'
alias adu='su -lc \'$apt_pref update && aptitude dist-upgrade\' root'
alias afu='su -lc "apt-file update"'
alias ag='su -lc \'$apt_pref safe-upgrade\' root'
alias ag='su -lc \'$apt_pref $apt_upgr\' root'
ai() {
cmd="su -lc 'aptitude -P install $@' root"
print "$cmd"
......@@ -136,7 +138,7 @@ 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 ag "$apt_upgr"
apt_pref_compdef ai "install"
apt_pref_compdef ail "install"
apt_pref_compdef ap "purge"
......
##
# dircycle plugin: enables cycling through the directory
# stack using Ctrl+Shift+Left/Right
# enables cycling through the directory stack using
# Ctrl+Shift+Left/Right
#
# left/right direction follows the order in which directories
# were visited, like left/right arrows do in a browser
eval "insert-cycledleft () { zle push-line; LBUFFER='pushd -q +1'; zle accept-line }"
# NO_PUSHD_MINUS syntax:
# pushd +N: start counting from left of `dirs' output
# pushd -N: start counting from right of `dirs' output
insert-cycledleft () {
emulate -L zsh
setopt nopushdminus
builtin pushd -q +1 &>/dev/null || true
zle reset-prompt
}
zle -N insert-cycledleft
bindkey "\e[1;6D" insert-cycledleft
eval "insert-cycledright () { zle push-line; LBUFFER='pushd -q -0'; zle accept-line }"
insert-cycledright () {
emulate -L zsh
setopt nopushdminus
builtin pushd -q -0 &>/dev/null || true
zle reset-prompt
}
zle -N insert-cycledright
bindkey "\e[1;6C" insert-cycledright
# add key bindings for iTerm2
if [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
bindkey "^[[1;6D" insert-cycledleft
bindkey "^[[1;6C" insert-cycledright
else
bindkey "\e[1;6D" insert-cycledleft
bindkey "\e[1;6C" insert-cycledright
fi
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment