diff options
-rw-r--r-- | README.markdown | 2 | ||||
-rw-r--r-- | lib/clipboard.zsh | 86 | ||||
-rw-r--r-- | lib/diagnostics.zsh | 30 | ||||
-rw-r--r-- | plugins/autoenv/autoenv.plugin.zsh | 28 | ||||
-rw-r--r-- | plugins/coffee/coffee.plugin.zsh | 10 | ||||
-rw-r--r-- | plugins/colored-man-pages/colored-man-pages.plugin.zsh (renamed from plugins/colored-man/colored-man.plugin.zsh) | 0 | ||||
-rw-r--r-- | plugins/copydir/copydir.plugin.zsh | 6 | ||||
-rw-r--r-- | plugins/copyfile/copyfile.plugin.zsh | 8 | ||||
-rw-r--r-- | plugins/encode64/encode64.plugin.zsh | 4 | ||||
-rw-r--r-- | plugins/git/git.plugin.zsh | 2 | ||||
-rw-r--r-- | plugins/gradle/gradle.plugin.zsh | 12 | ||||
-rw-r--r-- | plugins/pyenv/pyenv.plugin.zsh | 3 | ||||
-rw-r--r-- | plugins/rails/rails.plugin.zsh | 1 | ||||
-rw-r--r-- | plugins/systemd/systemd.plugin.zsh | 4 | ||||
-rw-r--r-- | tools/uninstall.sh | 7 |
15 files changed, 174 insertions, 29 deletions
diff --git a/README.markdown b/README.markdown index a29df81ab..779ce77c3 100644 --- a/README.markdown +++ b/README.markdown @@ -5,7 +5,7 @@ Oh My Zsh is an open source, community-driven framework for managing your [zsh]( __Oh My Zsh is a way of life!__ Once installed, your terminal prompt will become the talk of the town _or your money back!_ Each time you interact with your command prompt, you'll be able take advantage of the hundreds of bundled plugins and pretty themes. Strangers will come up to you in cafés and ask you, _"that is amazing. are you some sort of genius?"_ Finally, you'll begin to get the sort of attention that you always felt that you deserved. ...or maybe you'll just use the time that you saved to start flossing more often. -To learn more, visit http://ohmyz.sh and/or follow [ohmyzsh](https://twitter.com/ohmyzsh) on Twitter. +To learn more, visit [ohmyz.sh](http://ohmyz.sh) and/or follow [ohmyzsh](https://twitter.com/ohmyzsh) on Twitter. ## Getting Started diff --git a/lib/clipboard.zsh b/lib/clipboard.zsh new file mode 100644 index 000000000..b663800a4 --- /dev/null +++ b/lib/clipboard.zsh @@ -0,0 +1,86 @@ +# System clipboard integration +# +# This file has support for doing system clipboard copy and paste operations +# from the command line in a generic cross-platform fashion. +# +# On OS X and Windows, the main system clipboard or "pasteboard" is used. On other +# Unix-like OSes, this considers the X Windows CLIPBOARD selection to be the +# "system clipboard", and the X Windows `xclip` command must be installed. + +# clipcopy - Copy data to clipboard +# +# Usage: +# +# <command> | clipcopy - copies stdin to clipboard +# +# clipcopy <file> - copies a file's contents to clipboard +# +function clipcopy() { + emulate -L zsh + local file=$1 + if [[ $OSTYPE == darwin* ]]; then + if [[ -z $file ]]; then + pbcopy + else + cat $file | pbcopy + fi + elif [[ $OSTYPE == cygwin* ]]; then + if [[ -z $file ]]; then + cat > /dev/clipboard + else + cat $file > /dev/clipboard + fi + else + if which xclip &>/dev/null; then + if [[ -z $file ]]; then + xclip -in -selection clipboard + else + xclip -in -selection clipboard $file + fi + elif which xsel &>/dev/null; then + if [[ -z $file ]]; then + xsel --clipboard --input + else + cat "$file" | xsel --clipboard --input + fi + else + print "clipcopy: Platform $OSTYPE not supported or xclip/xsel not installed" >&2 + return 1 + fi + fi +} + +# clippaste - "Paste" data from clipboard to stdout +# +# Usage: +# +# clippaste - writes clipboard's contents to stdout +# +# clippaste | <command> - pastes contents and pipes it to another process +# +# clippaste > <file> - paste contents to a file +# +# Examples: +# +# # Pipe to another process +# clippaste | grep foo +# +# # Paste to a file +# clippaste > file.txt +function clippaste() { + emulate -L zsh + if [[ $OSTYPE == darwin* ]]; then + pbpaste + elif [[ $OSTYPE == cygwin* ]]; then + cat /dev/clipboard + else + if which xclip &>/dev/null; then + xclip -out -selection clipboard + elif which xsel &>/dev/null; then + xsel --clipboard --output + else + print "clipcopy: Platform $OSTYPE not supported or xclip/xsel not installed" >&2 + return 1 + fi + fi +} diff --git a/lib/diagnostics.zsh b/lib/diagnostics.zsh index afc33829b..9c9905e4d 100644 --- a/lib/diagnostics.zsh +++ b/lib/diagnostics.zsh @@ -52,6 +52,9 @@ # * Consider whether to move default output file location to TMPDIR. More robust # but less user friendly. # + +autoload -Uz is-at-least + function omz_diagnostic_dump() { emulate -L zsh @@ -247,7 +250,7 @@ function _omz_diag_dump_one_big_text() { function _omz_diag_dump_check_core_commands() { builtin echo "Core command check:" - local redefined name builtins externals + local redefined name builtins externals reserved_words redefined=() # All the zsh non-module builtin commands # These are taken from the zsh reference manual for 5.0.2 @@ -255,17 +258,32 @@ function _omz_diag_dump_check_core_commands() { # (For back-compatibility, if any of these are newish, they should be removed, # or at least made conditional on the version of the current running zsh.) # "history" is also excluded because OMZ is known to redefine that + reserved_words=( do done esac then elif else fi for case if while function + repeat time until select coproc nocorrect foreach end '!' '[[' '{' '}' + ) builtins=( alias autoload bg bindkey break builtin bye cd chdir command comparguments compcall compctl compdescribe compfiles compgroups compquote comptags - comptry compvalues continue declare dirs disable disown echo echotc echoti emulate - enable eval exec exit export false fc fg float functions getln getopts hash - integer jobs kill let limit local log logout noglob popd print printf - pushd pushln pwd r read readonly rehash return sched set setopt shift - source suspend test times trap true ttyctl type typeset ulimit umask unalias + comptry compvalues continue dirs disable disown echo echotc echoti emulate + enable eval exec exit false fc fg functions getln getopts hash + jobs kill let limit log logout noglob popd print printf + pushd pushln pwd r read rehash return sched set setopt shift + source suspend test times trap true ttyctl type ulimit umask unalias unfunction unhash unlimit unset unsetopt vared wait whence where which zcompile zle zmodload zparseopts zregexparse zstyle ) + if is-at-least 5.1; then + reserved_word+=( declare export integer float local readonly typeset ) + else + builtins+=( declare export integer float local readonly typeset ) + fi builtins_fatal=( builtin command local ) externals=( zsh ) + for name in $reserved_words; do + if [[ $(builtin whence -w $name) != "$name: reserved" ]]; then + builtin echo "reserved word '$name' has been redefined" + builtin which $name + redefined+=$name + fi + done for name in $builtins; do if [[ $(builtin whence -w $name) != "$name: builtin" ]]; then builtin echo "builtin '$name' has been redefined" diff --git a/plugins/autoenv/autoenv.plugin.zsh b/plugins/autoenv/autoenv.plugin.zsh index a8271849e..ea2e56dd6 100644 --- a/plugins/autoenv/autoenv.plugin.zsh +++ b/plugins/autoenv/autoenv.plugin.zsh @@ -1,12 +1,26 @@ # Activates autoenv or reports its failure -if ! source $HOME/.autoenv/activate.sh 2>/dev/null; then - echo '-------- AUTOENV ---------' - echo 'Could not find ~/.autoenv/activate.sh.' - echo 'Please check if autoenv is correctly installed.' - echo 'In the meantime the autoenv plugin is DISABLED.' - echo '--------------------------' - return 1 +() { +if ! type autoenv_init >/dev/null; then + for d (~/.autoenv /usr/local/opt/autoenv); do + if [[ -e $d/activate.sh ]]; then + autoenv_dir=$d + break + fi + done + if [[ -z $autoenv_dir ]]; then + cat <<END >&2 +-------- AUTOENV --------- +Could not locate autoenv installation. +Please check if autoenv is correctly installed. +In the meantime the autoenv plugin is DISABLED. +-------------------------- +END + return 1 + fi + source $autoenv_dir/activate.sh fi +} +[[ $? != 0 ]] && return $? # The use_env call below is a reusable command to activate/create a new Python # virtualenv, requiring only a single declarative line of code in your .env files. diff --git a/plugins/coffee/coffee.plugin.zsh b/plugins/coffee/coffee.plugin.zsh index 4e98e0228..77cb663f7 100644 --- a/plugins/coffee/coffee.plugin.zsh +++ b/plugins/coffee/coffee.plugin.zsh @@ -6,11 +6,11 @@ cf () { } # compile & copy to clipboard cfc () { - cf "$1" | pbcopy + cf "$1" | clipcopy } -# compile from pasteboard & print -alias cfp='coffeeMe "$(pbpaste)"' +# compile from clipboard & print +alias cfp='coffeeMe "$(clippaste)"' -# compile from pasteboard and copy to clipboard -alias cfpc='cfp | pbcopy' +# compile from clipboard and copy to clipboard +alias cfpc='cfp | clipcopy' diff --git a/plugins/colored-man/colored-man.plugin.zsh b/plugins/colored-man-pages/colored-man-pages.plugin.zsh index 5c613f49d..5c613f49d 100644 --- a/plugins/colored-man/colored-man.plugin.zsh +++ b/plugins/colored-man-pages/colored-man-pages.plugin.zsh diff --git a/plugins/copydir/copydir.plugin.zsh b/plugins/copydir/copydir.plugin.zsh index 37bb5e086..c45106240 100644 --- a/plugins/copydir/copydir.plugin.zsh +++ b/plugins/copydir/copydir.plugin.zsh @@ -1,3 +1,5 @@ +# Copies the pathname of the current directory to the system or X Windows clipboard function copydir { - pwd | tr -d "\r\n" | pbcopy -}
\ No newline at end of file + emulate -L zsh + print -n $PWD | clipcopy +} diff --git a/plugins/copyfile/copyfile.plugin.zsh b/plugins/copyfile/copyfile.plugin.zsh index 944a903c6..f4eca5acf 100644 --- a/plugins/copyfile/copyfile.plugin.zsh +++ b/plugins/copyfile/copyfile.plugin.zsh @@ -1,5 +1,7 @@ +# Copies the contents of a given file to the system or X Windows clipboard +# +# copyfile <file> function copyfile { - [[ "$#" != 1 ]] && return 1 - local file_to_copy=$1 - cat $file_to_copy | pbcopy + emulate -L zsh + clipcopy $1 } diff --git a/plugins/encode64/encode64.plugin.zsh b/plugins/encode64/encode64.plugin.zsh index 4dbd1b453..53de6478a 100644 --- a/plugins/encode64/encode64.plugin.zsh +++ b/plugins/encode64/encode64.plugin.zsh @@ -1,4 +1,4 @@ -encode64(){ echo -n $1 | base64 } -decode64(){ echo -n $1 | base64 --decode } +encode64(){ printf '%s' $1 | base64 } +decode64(){ printf '%s' $1 | base64 --decode } alias e64=encode64 alias d64=decode64 diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 4f2745038..d78b82df3 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -212,11 +212,13 @@ alias gsts='git stash show --text' alias gsu='git submodule update' alias gts='git tag -s' +alias gtv='git tag | sort -V' alias gunignore='git update-index --no-assume-unchanged' alias gunwip='git log -n 1 | grep -q -c "\-\-wip\-\-" && git reset HEAD~1' alias gup='git pull --rebase' alias gupv='git pull --rebase -v' +alias glum='git pull upstream master' alias gvt='git verify-tag' diff --git a/plugins/gradle/gradle.plugin.zsh b/plugins/gradle/gradle.plugin.zsh index 97941756d..661c29d5b 100644 --- a/plugins/gradle/gradle.plugin.zsh +++ b/plugins/gradle/gradle.plugin.zsh @@ -1,6 +1,6 @@ #!zsh ############################################################################## -# A descriptive listing of core Gradle commands +# A descriptive listing of core Gradle commands ############################################################################ function _gradle_core_commands() { local ret=1 state @@ -32,14 +32,22 @@ function _gradle_arguments() { '--stop[Stop the Gradle daemon]' \ '--daemon[Use the Gradle daemon]' \ '--no-daemon[Do not use the Gradle daemon]' \ - '--no-opt[Do not perform any task optimization]' \ + '--rerun-task [Specifies that any task optimization is ignored.]' \ '-i[Log at the info level]' \ '-m[Dry run]' \ '-P[Set a project property]' \ + '-p[Specifies the start directory]' \ '--profile[Profile the build time]' \ '-q[Log at the quiet level (only show errors)]' \ '-v[Print the Gradle version info]' \ '-x[Specify a task to be excluded]' \ + '-b[Specifies the build file.]' \ + '-c[Specifies the settings file.]' \ + '--continue[Continues task execution after a task failure.]' \ + '-g[Specifies the Gradle user home directory.]' \ + '-I[Specifies an initialization script.]' \ + '--refresh-dependencies[Refresh the state of dependencies.]' \ + '-u[Don''t search in parent directories for a settings.gradle file.]' \ '*::command:->command' \ && return 0 } diff --git a/plugins/pyenv/pyenv.plugin.zsh b/plugins/pyenv/pyenv.plugin.zsh index b3dc7aa17..b06507b62 100644 --- a/plugins/pyenv/pyenv.plugin.zsh +++ b/plugins/pyenv/pyenv.plugin.zsh @@ -17,7 +17,8 @@ for pyenvdir in "${pyenvdirs[@]}" ; do FOUND_PYENV=1 export PYENV_ROOT=$pyenvdir export PATH=${pyenvdir}/bin:$PATH - eval "$(pyenv init --no-rehash - zsh)" + eval "$(pyenv init - zsh)" + eval "$(pyenv virtualenv-init - zsh)" function pyenv_prompt_info() { echo "$(pyenv version-name)" diff --git a/plugins/rails/rails.plugin.zsh b/plugins/rails/rails.plugin.zsh index 1bbd1fb4b..a390c919c 100644 --- a/plugins/rails/rails.plugin.zsh +++ b/plugins/rails/rails.plugin.zsh @@ -42,6 +42,7 @@ alias rp='rails plugin' alias ru='rails runner' alias rs='rails server' alias rsd='rails server --debugger' +alias rsp='rails server --port' # Rake aliases alias rdm='rake db:migrate' diff --git a/plugins/systemd/systemd.plugin.zsh b/plugins/systemd/systemd.plugin.zsh index 07eb595a6..b19793557 100644 --- a/plugins/systemd/systemd.plugin.zsh +++ b/plugins/systemd/systemd.plugin.zsh @@ -10,3 +10,7 @@ sudo_commands=( 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 + +alias sc-enable-now="sc-enable --now" +alias sc-disable-now="sc-disable --now" +alias sc-mask-now="sc-mask --now" diff --git a/tools/uninstall.sh b/tools/uninstall.sh index 23bfac0eb..f9da00c9b 100644 --- a/tools/uninstall.sh +++ b/tools/uninstall.sh @@ -1,3 +1,10 @@ +read -r -p "Are you sure you want to remove Oh My Zsh? [y/N] " confirmation +if ! [[ $confirmation =~ ^[yY]$ ]] +then + echo "Uninstall cancelled" + exit +fi + echo "Removing ~/.oh-my-zsh" if [ -d ~/.oh-my-zsh ] then |