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

Merge remote-tracking branch 'robbyrussell/master'

parents eafd5f32 192de6bc
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# This will look for a custom profile for the local machine and each domain or # This will look for a custom profile for the local machine and each domain or
# subdomain it belongs to. (e.g. com, example.com and foo.example.com) # subdomain it belongs to. (e.g. com, example.com and foo.example.com)
parts=(${(s:.:)$(hostname)}) parts=(${(s:.:)HOST})
for i in {${#parts}..1}; do for i in {${#parts}..1}; do
profile=${(j:.:)${parts[$i,${#parts}]}} profile=${(j:.:)${parts[$i,${#parts}]}}
file=$ZSH_CUSTOM/profiles/$profile file=$ZSH_CUSTOM/profiles/$profile
......
...@@ -6,7 +6,7 @@ function _rails_command () { ...@@ -6,7 +6,7 @@ function _rails_command () {
elif [ -e "script/server" ]; then elif [ -e "script/server" ]; then
ruby script/$@ ruby script/$@
else else
rails $@ command rails $@
fi fi
} }
...@@ -14,7 +14,7 @@ function _rake_command () { ...@@ -14,7 +14,7 @@ function _rake_command () {
if [ -e "bin/rake" ]; then if [ -e "bin/rake" ]; then
bin/rake $@ bin/rake $@
else else
rake $@ command rake $@
fi fi
} }
...@@ -45,10 +45,12 @@ alias rsd='rails server --debugger' ...@@ -45,10 +45,12 @@ alias rsd='rails server --debugger'
# Rake aliases # Rake aliases
alias rdm='rake db:migrate' alias rdm='rake db:migrate'
alias rdms='rake db:migrate:status'
alias rdr='rake db:rollback' alias rdr='rake db:rollback'
alias rdc='rake db:create' alias rdc='rake db:create'
alias rds='rake db:seed' alias rds='rake db:seed'
alias rdd='rake db:drop' alias rdd='rake db:drop'
alias rdrs='rake db:reset'
alias rdtc='rake db:test:clone' alias rdtc='rake db:test:clone'
alias rdtp='rake db:test:prepare' alias rdtp='rake db:test:prepare'
alias rdmtc='rake db:migrate db:test:clone' alias rdmtc='rake db:migrate db:test:clone'
...@@ -58,7 +60,7 @@ alias rn='rake notes' ...@@ -58,7 +60,7 @@ alias rn='rake notes'
alias rr='rake routes' alias rr='rake routes'
# legacy stuff # legacy stuff
alias ss='thin --stats "/thin/stats" start' alias sstat='thin --stats "/thin/stats" start'
alias sg='ruby script/generate' alias sg='ruby script/generate'
alias sd='ruby script/destroy' alias sd='ruby script/destroy'
alias sp='ruby script/plugin' alias sp='ruby script/plugin'
......
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"
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"
...@@ -10,7 +10,7 @@ _rake_refresh () { ...@@ -10,7 +10,7 @@ _rake_refresh () {
_rake_does_task_list_need_generating () { _rake_does_task_list_need_generating () {
if [ ! -f .rake_tasks ]; then return 0; if [ ! -f .rake_tasks ]; then return 0;
else else
if [[ $(uname -s) == 'Darwin' ]]; then if [[ "$OSTYPE" = darwin* ]]; then
accurate=$(stat -f%m .rake_tasks) accurate=$(stat -f%m .rake_tasks)
changed=$(stat -f%m Rakefile) changed=$(stat -f%m Rakefile)
else else
......
...@@ -7,7 +7,7 @@ _rbenv-from-homebrew-installed() { ...@@ -7,7 +7,7 @@ _rbenv-from-homebrew-installed() {
} }
FOUND_RBENV=0 FOUND_RBENV=0
rbenvdirs=("$HOME/.rbenv" "/usr/local/rbenv" "/opt/rbenv") rbenvdirs=("$HOME/.rbenv" "/usr/local/rbenv" "/opt/rbenv" "/usr/local/opt/rbenv")
if _homebrew-installed && _rbenv-from-homebrew-installed ; then if _homebrew-installed && _rbenv-from-homebrew-installed ; then
rbenvdirs=($(brew --prefix rbenv) "${rbenvdirs[@]}") rbenvdirs=($(brew --prefix rbenv) "${rbenvdirs[@]}")
fi fi
......
...@@ -10,3 +10,9 @@ compdef _repo rs='repo sync' ...@@ -10,3 +10,9 @@ compdef _repo rs='repo sync'
alias rsrra='repo sync ; repo rebase --auto-stash' alias rsrra='repo sync ; repo rebase --auto-stash'
compdef _repo rsrra='repo sync ; repo rebase --auto-stash' compdef _repo rsrra='repo sync ; repo rebase --auto-stash'
alias ru='repo upload'
compdef _repo ru='repo upload'
alias rst='repo status'
compdef _repo rst='repo status'
alias rsync-copy="rsync -av --progress -h" alias rsync-copy="rsync -avz --progress -h"
alias rsync-move="rsync -av --progress -h --remove-source-files" alias rsync-move="rsync -avz --progress -h --remove-source-files"
alias rsync-update="rsync -avu --progress -h" alias rsync-update="rsync -avzu --progress -h"
alias rsync-synchronize="rsync -avu --delete --progress -h" alias rsync-synchronize="rsync -avzu --delete --progress -h"
...@@ -6,6 +6,7 @@ alias gemsets='rvm gemset list' ...@@ -6,6 +6,7 @@ alias gemsets='rvm gemset list'
local ruby18='ruby-1.8.7' local ruby18='ruby-1.8.7'
local ruby19='ruby-1.9.3' local ruby19='ruby-1.9.3'
local ruby20='ruby-2.0.0' local ruby20='ruby-2.0.0'
local ruby21='ruby-2.1.2'
function rb18 { function rb18 {
if [ -z "$1" ]; then if [ -z "$1" ]; then
...@@ -40,6 +41,17 @@ function rb20 { ...@@ -40,6 +41,17 @@ function rb20 {
_rb20() {compadd `ls -1 $rvm_path/gems | grep "^$ruby20@" | sed -e "s/^$ruby20@//" | awk '{print $1}'`} _rb20() {compadd `ls -1 $rvm_path/gems | grep "^$ruby20@" | sed -e "s/^$ruby20@//" | awk '{print $1}'`}
compdef _rb20 rb20 compdef _rb20 rb20
function rb21 {
if [ -z "$1" ]; then
rvm use "$ruby21"
else
rvm use "$ruby21@$1"
fi
}
_rb21() {compadd `ls -1 $rvm_path/gems | grep "^$ruby21@" | sed -e "s/^$ruby21@//" | awk '{print $1}'`}
compdef _rb21 rb21
function rvm-update { function rvm-update {
rvm get head rvm get head
} }
......
...@@ -11,12 +11,9 @@ the index. A selection menu is displayed in case of several matches, with a ...@@ -11,12 +11,9 @@ the index. A selection menu is displayed in case of several matches, with a
preference given to recently visited paths. `scd` can create permanent preference given to recently visited paths. `scd` can create permanent
directory aliases, which appear as named directories in zsh session. directory aliases, which appear as named directories in zsh session.
## INSTALLATION ## INSTALLATION NOTES
For oh-my-zsh, add `scd` to the `plugins` array in the ~/.zshrc file as in the Besides oh-my-zsh, `scd` can be used with *bash*, *dash* or *tcsh*
[template file](../../templates/zshrc.zsh-template#L45).
Besides zsh, `scd` can be used with *bash*, *dash* or *tcsh*
shells and is also available as [Vim](http://www.vim.org/) plugin and shells and is also available as [Vim](http://www.vim.org/) plugin and
[IPython](http://ipython.org/) extension. For installation details, see [IPython](http://ipython.org/) extension. For installation details, see
https://github.com/pavoljuhas/smart-change-directory. https://github.com/pavoljuhas/smart-change-directory.
...@@ -34,7 +31,7 @@ scd [options] [pattern1 pattern2 ...] ...@@ -34,7 +31,7 @@ scd [options] [pattern1 pattern2 ...]
add specified directories to the directory index.</dd><dt> add specified directories to the directory index.</dd><dt>
--unindex</dt><dd> --unindex</dt><dd>
remove specified directories from the index.</dd><dt> remove current or specified directories from the index.</dd><dt>
-r, --recursive</dt><dd> -r, --recursive</dt><dd>
apply options <em>--add</em> or <em>--unindex</em> recursively.</dd><dt> apply options <em>--add</em> or <em>--unindex</em> recursively.</dd><dt>
...@@ -47,6 +44,10 @@ scd [options] [pattern1 pattern2 ...] ...@@ -47,6 +44,10 @@ scd [options] [pattern1 pattern2 ...]
remove ALIAS definition for the current or specified directory from remove ALIAS definition for the current or specified directory from
<em>~/.scdalias.zsh</em>.</dd><dt> <em>~/.scdalias.zsh</em>.</dd><dt>
-A, --all</dt><dd>
include all matching directories. Disregard matching by directory
alias and filtering of less likely paths.</dd><dt>
--list</dt><dd> --list</dt><dd>
show matching directories and exit.</dd><dt> show matching directories and exit.</dd><dt>
...@@ -70,7 +71,7 @@ scd doc ...@@ -70,7 +71,7 @@ scd doc
scd a b c scd a b c
# Change to a directory path that ends with "ts" # Change to a directory path that ends with "ts"
scd "ts(#e)" scd "ts$"
# Show selection menu and ranking of 20 most likely directories # Show selection menu and ranking of 20 most likely directories
scd -v scd -v
......
...@@ -11,20 +11,22 @@ fi ...@@ -11,20 +11,22 @@ fi
local DOC='scd -- smart change to a recently used directory local DOC='scd -- smart change to a recently used directory
usage: scd [options] [pattern1 pattern2 ...] usage: scd [options] [pattern1 pattern2 ...]
Go to a directory path that contains all fixed string patterns. Prefer Go to a directory path that contains all fixed string patterns. Prefer
recently visited directories and directories with patterns in their tail recent or frequently visited directories as found in the directory index.
component. Display a selection menu in case of multiple matches. Display a selection menu in case of multiple matches.
Options: Options:
-a, --add add specified directories to the directory index -a, --add add specified directories to the directory index.
--unindex remove specified directories from the index --unindex remove current or specified directories from the index.
-r, --recursive apply options --add or --unindex recursively -r, --recursive apply options --add or --unindex recursively.
--alias=ALIAS create alias for the current or specified directory and --alias=ALIAS create alias for the current or specified directory and
store it in ~/.scdalias.zsh store it in ~/.scdalias.zsh.
--unalias remove ALIAS definition for the current or specified --unalias remove ALIAS definition for the current or specified
directory from ~/.scdalias.zsh directory from ~/.scdalias.zsh.
--list show matching directories and exit -A, --all include all matching directories. Disregard matching by
-v, --verbose display directory rank in the selection menu directory alias and filtering of less likely paths.
-h, --help display this message and exit --list show matching directories and exit.
-v, --verbose display directory rank in the selection menu.
-h, --help display this message and exit.
' '
local SCD_HISTFILE=${SCD_HISTFILE:-${HOME}/.scdhistory} local SCD_HISTFILE=${SCD_HISTFILE:-${HOME}/.scdhistory}
...@@ -35,9 +37,9 @@ local SCD_THRESHOLD=${SCD_THRESHOLD:-0.005} ...@@ -35,9 +37,9 @@ local SCD_THRESHOLD=${SCD_THRESHOLD:-0.005}
local SCD_SCRIPT=${RUNNING_AS_COMMAND:+$SCD_SCRIPT} local SCD_SCRIPT=${RUNNING_AS_COMMAND:+$SCD_SCRIPT}
local SCD_ALIAS=~/.scdalias.zsh local SCD_ALIAS=~/.scdalias.zsh
local ICASE a d m p i tdir maxrank threshold local ICASE a d m p i maxrank threshold
local opt_help opt_add opt_unindex opt_recursive opt_verbose local opt_help opt_add opt_unindex opt_recursive opt_verbose
local opt_alias opt_unalias opt_list local opt_alias opt_unalias opt_all opt_list
local -A drank dalias local -A drank dalias
local dmatching local dmatching
local last_directory local last_directory
...@@ -56,7 +58,8 @@ zmodload -i zsh/zutil ...@@ -56,7 +58,8 @@ zmodload -i zsh/zutil
zmodload -i zsh/datetime zmodload -i zsh/datetime
zparseopts -D -- a=opt_add -add=opt_add -unindex=opt_unindex \ zparseopts -D -- a=opt_add -add=opt_add -unindex=opt_unindex \
r=opt_recursive -recursive=opt_recursive \ r=opt_recursive -recursive=opt_recursive \
-alias:=opt_alias -unalias=opt_unalias -list=opt_list \ -alias:=opt_alias -unalias=opt_unalias \
A=opt_all -all=opt_all -list=opt_list \
v=opt_verbose -verbose=opt_verbose h=opt_help -help=opt_help \ v=opt_verbose -verbose=opt_verbose h=opt_help -help=opt_help \
|| $EXIT $? || $EXIT $?
...@@ -68,6 +71,11 @@ fi ...@@ -68,6 +71,11 @@ fi
# load directory aliases if they exist # load directory aliases if they exist
[[ -r $SCD_ALIAS ]] && source $SCD_ALIAS [[ -r $SCD_ALIAS ]] && source $SCD_ALIAS
# Private internal functions are prefixed with _scd_Y19oug_.
# Clean them up when the scd function returns.
setopt localtraps
trap 'unfunction -m "_scd_Y19oug_*"' EXIT
# works faster than the (:a) modifier and is compatible with zsh 4.2.6 # works faster than the (:a) modifier and is compatible with zsh 4.2.6
_scd_Y19oug_abspath() { _scd_Y19oug_abspath() {
set -A $1 ${(ps:\0:)"$( set -A $1 ${(ps:\0:)"$(
...@@ -123,11 +131,52 @@ if [[ -n $opt_unalias ]]; then ...@@ -123,11 +131,52 @@ if [[ -n $opt_unalias ]]; then
$EXIT $? $EXIT $?
fi fi
# The "compress" function collapses repeated directories to
# one entry with a time stamp that gives equivalent-probability.
_scd_Y19oug_compress() {
awk -v epochseconds=$EPOCHSECONDS -v meanlife=$SCD_MEANLIFE '
BEGIN { FS = "[:;]"; }
length($0) < 4096 && $2 > 0 {
tau = 1.0 * ($2 - epochseconds) / meanlife;
if (tau < -6.9078) tau = -6.9078;
prob = exp(tau);
sub(/^[^;]*;/, "");
if (NF) {
dlist[last[$0]] = "";
dlist[NR] = $0;
last[$0] = NR;
ptot[$0] += prob;
}
}
END {
for (i = 1; i <= NR; ++i) {
d = dlist[i];
if (d) {
ts = log(ptot[d]) * meanlife + epochseconds;
printf(": %.0f:0;%s\n", ts, d);
}
}
}
' $*
}
# Rewrite directory index if it is at least 20% oversized # Rewrite directory index if it is at least 20% oversized
if [[ -s $SCD_HISTFILE ]] && \ if [[ -s $SCD_HISTFILE ]] && \
(( $(wc -l <$SCD_HISTFILE) > 1.2 * $SCD_HISTSIZE )); then (( $(wc -l <$SCD_HISTFILE) > 1.2 * $SCD_HISTSIZE )); then
m=( ${(f)"$(<$SCD_HISTFILE)"} ) # compress repeated entries
print -lr -- ${m[-$SCD_HISTSIZE,-1]} >| ${SCD_HISTFILE} m=( ${(f)"$(_scd_Y19oug_compress $SCD_HISTFILE)"} )
# purge non-existent directories
m=( ${(f)"$(
for a in $m; do
if [[ -d ${a#*;} ]]; then print -r -- $a; fi
done
)"}
)
# cut old entries if still oversized
if [[ $#m -gt $SCD_HISTSIZE ]]; then
m=( ${m[-$SCD_HISTSIZE,-1]} )
fi
print -lr -- $m >| ${SCD_HISTFILE}
fi fi
# Determine the last recorded directory # Determine the last recorded directory
...@@ -135,7 +184,6 @@ if [[ -s ${SCD_HISTFILE} ]]; then ...@@ -135,7 +184,6 @@ if [[ -s ${SCD_HISTFILE} ]]; then
last_directory=${"$(tail -1 ${SCD_HISTFILE})"#*;} last_directory=${"$(tail -1 ${SCD_HISTFILE})"#*;}
fi fi
# Internal functions are prefixed with "_scd_Y19oug_".
# The "record" function adds its arguments to the directory index. # The "record" function adds its arguments to the directory index.
_scd_Y19oug_record() { _scd_Y19oug_record() {
while [[ -n $last_directory && $1 == $last_directory ]]; do while [[ -n $last_directory && $1 == $last_directory ]]; do
...@@ -217,7 +265,7 @@ _scd_Y19oug_action() { ...@@ -217,7 +265,7 @@ _scd_Y19oug_action() {
# set global arrays dmatching and drank # set global arrays dmatching and drank
_scd_Y19oug_match() { _scd_Y19oug_match() {
## single argument that is an existing directory or directory alias ## single argument that is an existing directory or directory alias
if [[ $# == 1 ]] && \ if [[ -z $opt_all && $# == 1 ]] && \
[[ -d ${d::=$1} || -d ${d::=${nameddirs[$1]}} ]] && [[ -x $d ]]; [[ -d ${d::=$1} || -d ${d::=${nameddirs[$1]}} ]] && [[ -x $d ]];
then then
_scd_Y19oug_abspath dmatching $d _scd_Y19oug_abspath dmatching $d
...@@ -227,6 +275,8 @@ _scd_Y19oug_match() { ...@@ -227,6 +275,8 @@ _scd_Y19oug_match() {
# ignore case unless there is an argument with an uppercase letter # ignore case unless there is an argument with an uppercase letter
[[ "$*" == *[[:upper:]]* ]] || ICASE='(#i)' [[ "$*" == *[[:upper:]]* ]] || ICASE='(#i)'
# support "$" as an anchor for the directory name ending
argv=( ${argv/(#m)?[$](#e)/${MATCH[1]}(#e)} )
# calculate rank of all directories in the SCD_HISTFILE and keep it as drank # calculate rank of all directories in the SCD_HISTFILE and keep it as drank
# include a dummy entry for splitting of an empty string is buggy # include a dummy entry for splitting of an empty string is buggy
...@@ -237,10 +287,10 @@ _scd_Y19oug_match() { ...@@ -237,10 +287,10 @@ _scd_Y19oug_match() {
BEGIN { FS = "[:;]"; } BEGIN { FS = "[:;]"; }
length($0) < 4096 && $2 > 0 { length($0) < 4096 && $2 > 0 {
tau = 1.0 * ($2 - epochseconds) / meanlife; tau = 1.0 * ($2 - epochseconds) / meanlife;
if (tau < -4.61) tau = -4.61; if (tau < -6.9078) tau = -6.9078;
prec = exp(tau); prob = exp(tau);
sub(/^[^;]*;/, ""); sub(/^[^;]*;/, "");
if (NF) ptot[$0] += prec; if (NF) ptot[$0] += prob;
} }
END { for (di in ptot) { print di; print ptot[di]; } }' END { for (di in ptot) { print di; print ptot[di]; } }'
)"} )"}
...@@ -249,9 +299,12 @@ _scd_Y19oug_match() { ...@@ -249,9 +299,12 @@ _scd_Y19oug_match() {
# filter drank to the entries that match all arguments # filter drank to the entries that match all arguments
for a; do for a; do
p=${ICASE}"*${a}*" p=${ICASE}"*(${a})*"
drank=( ${(kv)drank[(I)${~p}]} ) drank=( ${(kv)drank[(I)${~p}]} )
done done
# require at least one argument matches the directory name
p=${ICASE}"*(${(j:|:)argv})[^/]#"
drank=( ${(kv)drank[(I)${~p}]} )
# build a list of matching directories reverse-sorted by their probabilities # build a list of matching directories reverse-sorted by their probabilities
dmatching=( ${(f)"$( dmatching=( ${(f)"$(
...@@ -261,26 +314,6 @@ _scd_Y19oug_match() { ...@@ -261,26 +314,6 @@ _scd_Y19oug_match() {
)"} )"}
) )
# if some directory paths match all patterns in order, discard all others
p=${ICASE}"*${(j:*:)argv}*"
m=( ${(M)dmatching:#${~p}} )
[[ -d ${m[1]} ]] && dmatching=( $m )
# if some directory names match last pattern, discard all others
p=${ICASE}"*${(j:*:)argv}[^/]#"
m=( ${(M)dmatching:#${~p}} )
[[ -d ${m[1]} ]] && dmatching=( $m )
# if some directory names match all patterns, discard all others
m=( $dmatching )
for a; do
p=${ICASE}"*/[^/]#${a}[^/]#"
m=( ${(M)m:#${~p}} )
done
[[ -d ${m[1]} ]] && dmatching=( $m )
# if some directory names match all patterns in order, discard all others
p=${ICASE}"/*${(j:[^/]#:)argv}[^/]#"
m=( ${(M)dmatching:#${~p}} )
[[ -d ${m[1]} ]] && dmatching=( $m )
# do not match $HOME or $PWD when run without arguments # do not match $HOME or $PWD when run without arguments
if [[ $# == 0 ]]; then if [[ $# == 0 ]]; then
dmatching=( ${dmatching:#(${HOME}|${PWD})} ) dmatching=( ${dmatching:#(${HOME}|${PWD})} )
...@@ -302,6 +335,9 @@ _scd_Y19oug_match() { ...@@ -302,6 +335,9 @@ _scd_Y19oug_match() {
# discard all directories below the rank threshold # discard all directories below the rank threshold
threshold=$(( maxrank * SCD_THRESHOLD )) threshold=$(( maxrank * SCD_THRESHOLD ))
if [[ -n ${opt_all} ]]; then
threshold=0
fi
dmatching=( ${^dmatching}(Ne:'(( ${drank[$REPLY]} >= threshold ))':) ) dmatching=( ${^dmatching}(Ne:'(( ${drank[$REPLY]} >= threshold ))':) )
} }
...@@ -339,6 +375,7 @@ fi ...@@ -339,6 +375,7 @@ fi
## here we have multiple matches - display selection menu ## here we have multiple matches - display selection menu
a=( {a-z} {A-Z} ) a=( {a-z} {A-Z} )
a=( ${a[1,${#dmatching}]} )
p=( ) p=( )
for i in {1..${#dmatching}}; do for i in {1..${#dmatching}}; do
[[ -n ${a[i]} ]] || break [[ -n ${a[i]} ]] || break
......
# #
# INSTRUCTIONS # INSTRUCTIONS
# #
# To enabled agent forwarding support add the following to # To enable agent forwarding support add the following to
# your .zshrc file: # your .zshrc file:
# #
# zstyle :omz:plugins:ssh-agent agent-forwarding on # zstyle :omz:plugins:ssh-agent agent-forwarding on
......
## sublime
Plugin for Sublime Text, a cross platform text and code editor, available for Linux, Mac OS X, and Windows.
### Requirements
* [Sublime Text](http://www.sublimetext.com/)
### Usage
* If `st` command is called without an argument, launch Sublime Text
* If `st` is passed a directory, `cd` to it and open it in Sublime Text
* If `st` is passed a file, open it in Sublime Text
* If `stt` command is called, it is equivalent to `st .`, opening the current folder in Sublime Text
* If `sst` command is called, it is like `sudo st`, opening the file or folder in Sublime Text. Useful for editing system protected files.
\ No newline at end of file
...@@ -5,18 +5,24 @@ if [[ $('uname') == 'Linux' ]]; then ...@@ -5,18 +5,24 @@ if [[ $('uname') == 'Linux' ]]; then
_sublime_linux_paths=( _sublime_linux_paths=(
"$HOME/bin/sublime_text" "$HOME/bin/sublime_text"
"/opt/sublime_text/sublime_text" "/opt/sublime_text/sublime_text"
"/opt/sublime_text_3/sublime_text"
"/usr/bin/sublime_text" "/usr/bin/sublime_text"
"/usr/local/bin/sublime_text" "/usr/local/bin/sublime_text"
"/usr/bin/subl"
"/opt/sublime_text_3/sublime_text"
"/usr/bin/subl3"
) )
for _sublime_path in $_sublime_linux_paths; do for _sublime_path in $_sublime_linux_paths; do
if [[ -a $_sublime_path ]]; then if [[ -a $_sublime_path ]]; then
st_run() { $_sublime_path $@ >/dev/null 2>&1 &| } st_run() { $_sublime_path $@ >/dev/null 2>&1 &| }
st_run_sudo() {sudo $_sublime_path $@ >/dev/null 2>&1}
alias sst=st_run_sudo
alias st=st_run alias st=st_run
break break
fi fi
done done
elif [[ $('uname') == 'Darwin' ]]; then elif [[ "$OSTYPE" = darwin* ]]; then
local _sublime_darwin_paths > /dev/null 2>&1 local _sublime_darwin_paths > /dev/null 2>&1
_sublime_darwin_paths=( _sublime_darwin_paths=(
"/usr/local/bin/subl" "/usr/local/bin/subl"
...@@ -30,7 +36,7 @@ elif [[ $('uname') == 'Darwin' ]]; then ...@@ -30,7 +36,7 @@ elif [[ $('uname') == 'Darwin' ]]; then
for _sublime_path in $_sublime_darwin_paths; do for _sublime_path in $_sublime_darwin_paths; do
if [[ -a $_sublime_path ]]; then if [[ -a $_sublime_path ]]; then
alias subl="'$_sublime_path'" subl () { "$_sublime_path" $* }
alias st=subl alias st=subl
break break
fi fi
......
...@@ -13,9 +13,8 @@ ...@@ -13,9 +13,8 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
sudo-command-line() { sudo-command-line() {
[[ -z $BUFFER ]] && zle up-history [[ -z $BUFFER ]] && zle up-history
[[ $BUFFER != sudo\ * ]] && BUFFER="sudo $BUFFER" [[ $BUFFER != sudo\ * ]] && LBUFFER="sudo $LBUFFER"
zle end-of-line
} }
zle -N sudo-command-line zle -N sudo-command-line
# Defined shortcut keys: [Esc] [Esc] # Defined shortcut keys: [Esc] [Esc]
......
...@@ -63,11 +63,11 @@ function svn_current_revision() { ...@@ -63,11 +63,11 @@ function svn_current_revision() {
function svn_status_info() { function svn_status_info() {
local svn_status_string="$ZSH_THEME_SVN_PROMPT_CLEAN" local svn_status_string="$ZSH_THEME_SVN_PROMPT_CLEAN"
local svn_status="$(svn status 2> /dev/null)"; local svn_status="$(svn status 2> /dev/null)";
if grep -E '^\s*A' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_ADDITIONS:-+}"; fi if command grep -E '^\s*A' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_ADDITIONS:-+}"; fi
if grep -E '^\s*D' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_DELETIONS:-}"; fi if command grep -E '^\s*D' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_DELETIONS:-}"; fi
if grep -E '^\s*M' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_MODIFICATIONS:-}"; fi if command grep -E '^\s*M' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_MODIFICATIONS:-}"; fi
if grep -E '^\s*[R~]' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_REPLACEMENTS:-}"; fi if command grep -E '^\s*[R~]' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_REPLACEMENTS:-}"; fi
if grep -E '^\s*\?' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_UNTRACKED:-?}"; fi if command grep -E '^\s*\?' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_UNTRACKED:-?}"; fi
if grep -E '^\s*[CI!L]' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_DIRTY:-'!'}"; fi if command grep -E '^\s*[CI!L]' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_DIRTY:-'!'}"; fi
echo $svn_status_string echo $svn_status_string
} }
...@@ -61,7 +61,7 @@ function svn_get_rev_nr() { ...@@ -61,7 +61,7 @@ function svn_get_rev_nr() {
function svn_dirty_choose() { function svn_dirty_choose() {
if in_svn; then if in_svn; then
root=`svn info 2> /dev/null | sed -n 's/^Working Copy Root Path: //p'` root=`svn info 2> /dev/null | sed -n 's/^Working Copy Root Path: //p'`
if $(svn status $root 2> /dev/null | grep -Eq '^\s*[ACDIM!?L]'); then if $(svn status $root 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'); then
# Grep exits with 0 when "One or more lines were selected", return "dirty". # Grep exits with 0 when "One or more lines were selected", return "dirty".
echo $1 echo $1
else else
...@@ -77,8 +77,8 @@ function svn_dirty() { ...@@ -77,8 +77,8 @@ function svn_dirty() {
function svn_dirty_choose_pwd () { function svn_dirty_choose_pwd () {
if in_svn; then if in_svn; then
root=`pwd` root=$PWD
if $(svn status $root 2> /dev/null | grep -Eq '^\s*[ACDIM!?L]'); then if $(svn status $root 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'); then
# Grep exits with 0 when "One or more lines were selected", return "dirty". # Grep exits with 0 when "One or more lines were selected", return "dirty".
echo $1 echo $1
else else
......
# Symfony2 basic command completion # Symfony2 basic command completion
_symfony_console () {
echo "php $(find . -maxdepth 2 -mindepth 1 -name 'console' -type f | head -n 1)"
}
_symfony2_get_command_list () { _symfony2_get_command_list () {
php app/console --no-ansi | sed "1,/Available commands/d" | awk '/^ [a-z]+/ { print $1 }' `_symfony_console` --no-ansi | sed "1,/Available commands/d" | awk '/^ ?[a-z]+/ { print $1 }'
} }
_symfony2 () { _symfony2 () {
if [ -f app/console ]; then compadd `_symfony2_get_command_list`
compadd `_symfony2_get_command_list`
fi
} }
compdef _symfony2 app/console compdef _symfony2 '`_symfony_console`'
compdef _symfony2 'app/console'
compdef _symfony2 'bin/console'
compdef _symfony2 sf compdef _symfony2 sf
#Alias #Alias
alias sf='php app/console' alias sf='`_symfony_console`'
alias sfcl='php app/console cache:clear' alias sfcl='sf cache:clear'
alias sfroute='php app/console router:debug' alias sfsr='sf server:run -vvv'
alias sfgb='php app/console generate:bundle' alias sfcw='sf cache:warmup'
alias sfroute='sf router:debug'
alias sfcontainer='sf container:debug'
alias sfgb='sf generate:bundle'
...@@ -30,7 +30,7 @@ function retlog() { ...@@ -30,7 +30,7 @@ function retlog() {
} }
alias ping='ping -c 5' alias ping='ping -c 5'
alias clr='clear;echo "Currently logged in on $(tty), as $(whoami) in directory $(pwd)."' alias clr='clear;echo "Currently logged in on $(tty), as $USER in directory $PWD."'
alias path='echo -e ${PATH//:/\\n}' alias path='echo -e ${PATH//:/\\n}'
alias mkdir='mkdir -pv' alias mkdir='mkdir -pv'
# get top process eating memory # get top process eating memory
......
user_commands=( user_commands=(
list-units is-active status show help list-unit-files list-units is-active status show help list-unit-files
is-enabled list-jobs show-environment) is-enabled list-jobs show-environment cat)
sudo_commands=( sudo_commands=(
start stop reload restart try-restart isolate kill start stop reload restart try-restart isolate kill
reset-failed enable disable reenable preset mask unmask reset-failed enable disable reenable preset mask unmask
link load cancel set-environment unset-environment) link load cancel set-environment unset-environment
edit)
for c in $user_commands; do; alias sc-$c="systemctl $c"; done for c in $user_commands; do; alias sc-$c="systemctl $c"; done
for c in $sudo_commands; do; alias sc-$c="sudo systemctl $c"; done for c in $sudo_commands; do; alias sc-$c="sudo systemctl $c"; done
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