mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-02-13 03:01:32 +01:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
a8d33bcaa7
18 changed files with 508 additions and 78 deletions
|
|
@ -11,6 +11,10 @@ then
|
||||||
# On NetBSD, test if "gls" (GNU ls) is installed (this one supports colors);
|
# 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
|
# 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'
|
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
|
else
|
||||||
ls --color -d . &>/dev/null 2>&1 && alias ls='ls --color=tty' || alias ls='ls -G'
|
ls --color -d . &>/dev/null 2>&1 && alias ls='ls --color=tty' || alias ls='ls -G'
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
15
oh-my-zsh.sh
15
oh-my-zsh.sh
|
|
@ -1,6 +1,5 @@
|
||||||
# Check for updates on initial load...
|
# Check for updates on initial load...
|
||||||
if [ "$DISABLE_AUTO_UPDATE" != "true" ]
|
if [ "$DISABLE_AUTO_UPDATE" != "true" ]; then
|
||||||
then
|
|
||||||
/usr/bin/env ZSH=$ZSH DISABLE_UPDATE_PROMPT=$DISABLE_UPDATE_PROMPT zsh $ZSH/tools/check_for_upgrade.sh
|
/usr/bin/env ZSH=$ZSH DISABLE_UPDATE_PROMPT=$DISABLE_UPDATE_PROMPT zsh $ZSH/tools/check_for_upgrade.sh
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -69,8 +68,7 @@ done
|
||||||
unset config_file
|
unset config_file
|
||||||
|
|
||||||
# Load the theme
|
# Load the theme
|
||||||
if [ "$ZSH_THEME" = "random" ]
|
if [ "$ZSH_THEME" = "random" ]; then
|
||||||
then
|
|
||||||
themes=($ZSH/themes/*zsh-theme)
|
themes=($ZSH/themes/*zsh-theme)
|
||||||
N=${#themes[@]}
|
N=${#themes[@]}
|
||||||
((N=(RANDOM%N)+1))
|
((N=(RANDOM%N)+1))
|
||||||
|
|
@ -78,13 +76,10 @@ then
|
||||||
source "$RANDOM_THEME"
|
source "$RANDOM_THEME"
|
||||||
echo "[oh-my-zsh] Random theme '$RANDOM_THEME' loaded..."
|
echo "[oh-my-zsh] Random theme '$RANDOM_THEME' loaded..."
|
||||||
else
|
else
|
||||||
if [ ! "$ZSH_THEME" = "" ]
|
if [ ! "$ZSH_THEME" = "" ]; then
|
||||||
then
|
if [ -f "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme" ]; then
|
||||||
if [ -f "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme" ]
|
|
||||||
then
|
|
||||||
source "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme"
|
source "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme"
|
||||||
elif [ -f "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme" ]
|
elif [ -f "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme" ]; then
|
||||||
then
|
|
||||||
source "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme"
|
source "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme"
|
||||||
else
|
else
|
||||||
source "$ZSH/themes/$ZSH_THEME.zsh-theme"
|
source "$ZSH/themes/$ZSH_THEME.zsh-theme"
|
||||||
|
|
|
||||||
|
|
@ -4,18 +4,6 @@ alias bp="bundle package"
|
||||||
alias bo="bundle open"
|
alias bo="bundle open"
|
||||||
alias bu="bundle update"
|
alias bu="bundle update"
|
||||||
|
|
||||||
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
|
|
||||||
eval "alias bi='bundle install --jobs=$cores_num'"
|
|
||||||
else
|
|
||||||
alias bi='bundle install'
|
|
||||||
fi
|
|
||||||
|
|
||||||
# The following is based on https://github.com/gma/bundler-exec
|
# The following is based on https://github.com/gma/bundler-exec
|
||||||
|
|
||||||
|
|
@ -44,14 +32,28 @@ _run-with-bundler() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
## Main program
|
if _bundler-installed; then
|
||||||
for cmd in $bundled_commands; do
|
bundler_version=`bundle version | cut -d' ' -f3`
|
||||||
eval "function unbundled_$cmd () { $cmd \$@ }"
|
if [[ $bundler_version > '1.4.0' || $bundler_version = '1.4.0' ]]; then
|
||||||
eval "function bundled_$cmd () { _run-with-bundler $cmd \$@}"
|
if [[ "$(uname)" == 'Darwin' ]]
|
||||||
alias $cmd=bundled_$cmd
|
then
|
||||||
|
local cores_num="$(sysctl hw.ncpu | awk '{print $2}')"
|
||||||
|
else
|
||||||
|
local cores_num="$(nproc)"
|
||||||
|
fi
|
||||||
|
eval "alias bi='bundle install --jobs=$cores_num'"
|
||||||
|
else
|
||||||
|
alias bi='bundle install'
|
||||||
|
fi
|
||||||
|
|
||||||
if which _$cmd > /dev/null 2>&1; then
|
## Main program
|
||||||
compdef _$cmd bundled_$cmd=$cmd
|
for cmd in $bundled_commands; do
|
||||||
fi
|
eval "function unbundled_$cmd () { $cmd \$@ }"
|
||||||
done
|
eval "function bundled_$cmd () { _run-with-bundler $cmd \$@}"
|
||||||
|
alias $cmd=bundled_$cmd
|
||||||
|
|
||||||
|
if which _$cmd > /dev/null 2>&1; then
|
||||||
|
compdef _$cmd bundled_$cmd=$cmd
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
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
|
||||||
|
|
@ -23,8 +23,10 @@ _1st_arguments=(
|
||||||
"auth\:login":"log in with your heroku credentials"
|
"auth\:login":"log in with your heroku credentials"
|
||||||
"auth\:logout":"clear local authentication credentials"
|
"auth\:logout":"clear local authentication credentials"
|
||||||
"config":"display the config vars for an app"
|
"config":"display the config vars for an app"
|
||||||
"config\:add":"add one or more config vars"
|
"config\:pull":"pull heroku config vars down to the local environment"
|
||||||
"config\:remove":"remove a config var"
|
"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\:push":"push local data up to your app"
|
||||||
"db\:pull":"pull heroku data down into your local database"
|
"db\:pull":"pull heroku data down into your local database"
|
||||||
"domains":"list custom domains for an app"
|
"domains":"list custom domains for an app"
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ open_jira_issue () {
|
||||||
|
|
||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
echo "Opening new issue"
|
echo "Opening new issue"
|
||||||
`open $jira_url/secure/CreateIssue!default.jspa`
|
$open_cmd "$jira_url/secure/CreateIssue!default.jspa"
|
||||||
else
|
else
|
||||||
echo "Opening issue #$1"
|
echo "Opening issue #$1"
|
||||||
if [[ "x$JIRA_RAPID_BOARD" = "xtrue" ]]; then
|
if [[ "x$JIRA_RAPID_BOARD" = "xtrue" ]]; then
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ _pass_cmd_show () {
|
||||||
_pass_complete_entries_helper () {
|
_pass_complete_entries_helper () {
|
||||||
local IFS=$'\n'
|
local IFS=$'\n'
|
||||||
local prefix="${PASSWORD_STORE_DIR:-$HOME/.password-store}"
|
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 () {
|
_pass_complete_entries_with_subdirs () {
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@
|
||||||
_pip_all() {
|
_pip_all() {
|
||||||
# we cache the list of packages (originally from the macports plugin)
|
# we cache the list of packages (originally from the macports plugin)
|
||||||
if (( ! $+piplist )); then
|
if (( ! $+piplist )); then
|
||||||
echo -n " (caching package index...)"
|
zsh-pip-cache-packages
|
||||||
piplist=($(pip search * | cut -d ' ' -f 1 | tr '[A-Z]' '[a-z]'))
|
piplist=($(cat $ZSH_PIP_CACHE_FILE))
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
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
|
||||||
|
}
|
||||||
|
|
@ -3,18 +3,19 @@
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# FILE: _pod
|
# FILE: _pod
|
||||||
# DESCRIPTION: Cocoapods autocomplete plugin for Oh-My-Zsh
|
# DESCRIPTION: Cocoapods (0.27.1) autocomplete plugin for Oh-My-Zsh
|
||||||
# http://cocoapods.org
|
# http://cocoapods.org
|
||||||
# AUTHOR: Alexandre Joly (alexandre.joly@mekanics.ch)
|
# AUTHOR: Alexandre Joly (alexandre.joly@mekanics.ch)
|
||||||
# GITHUB: https://github.com/mekanics
|
# GITHUB: https://github.com/mekanics
|
||||||
# TWITTER: @jolyAlexandre
|
# TWITTER: @jolyAlexandre
|
||||||
# VERSION: 0.0.1
|
# VERSION: 0.0.3
|
||||||
# LICENSE: MIT
|
# LICENSE: MIT
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
local -a _1st_arguments
|
local -a _1st_arguments
|
||||||
_1st_arguments=(
|
_1st_arguments=(
|
||||||
'help:Show help for the given command.'
|
'help:Show help for the given command'
|
||||||
|
'init:Generate a Podfile for the current directory'
|
||||||
'install:Install project dependencies'
|
'install:Install project dependencies'
|
||||||
'ipc:Inter-process communication'
|
'ipc:Inter-process communication'
|
||||||
'list:List pods'
|
'list:List pods'
|
||||||
|
|
@ -32,6 +33,7 @@ local -a _repo_arguments
|
||||||
_repo_arguments=(
|
_repo_arguments=(
|
||||||
'add:Add a spec repo'
|
'add:Add a spec repo'
|
||||||
'lint:Validates all specs in a repo'
|
'lint:Validates all specs in a repo'
|
||||||
|
'remove:Remove a spec repo.'
|
||||||
'update:Update a spec repo'
|
'update:Update a spec repo'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -158,7 +160,7 @@ __first_command_list ()
|
||||||
}
|
}
|
||||||
|
|
||||||
__repo_list() {
|
__repo_list() {
|
||||||
_wanted application expl 'repo' compadd $(command ls -1 ~/.cocoapods 2>/dev/null | sed -e 's/ /\\ /g')
|
_wanted application expl 'repo' compadd $(command ls -1 ~/.cocoapods/repos 2>/dev/null | sed -e 's/ /\\ /g')
|
||||||
}
|
}
|
||||||
|
|
||||||
__pod-repo() {
|
__pod-repo() {
|
||||||
|
|
@ -193,6 +195,12 @@ __pod-repo() {
|
||||||
(add)
|
(add)
|
||||||
_arguments \
|
_arguments \
|
||||||
$_inherited_options
|
$_inherited_options
|
||||||
|
|
||||||
|
(remove)
|
||||||
|
_arguments \
|
||||||
|
$_inherited_options \
|
||||||
|
':feature:__repo_list'
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
|
||||||
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
|
||||||
|
|
@ -6,6 +6,7 @@ alias pyfind='find . -name "*.py"'
|
||||||
function pyclean() {
|
function pyclean() {
|
||||||
ZSH_PYCLEAN_PLACES=${*:-'.'}
|
ZSH_PYCLEAN_PLACES=${*:-'.'}
|
||||||
find ${ZSH_PYCLEAN_PLACES} -type f -name "*.py[co]" -delete
|
find ${ZSH_PYCLEAN_PLACES} -type f -name "*.py[co]" -delete
|
||||||
|
find ${ZSH_PYCLEAN_PLACES} -type d -name "__pycache__" -delete
|
||||||
}
|
}
|
||||||
|
|
||||||
# Grep among .py files
|
# Grep among .py files
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ if [[ ${_plugin__forwarding} == "yes" && -n "$SSH_AUTH_SOCK" ]]; then
|
||||||
elif [ -f "${_plugin__ssh_env}" ]; then
|
elif [ -f "${_plugin__ssh_env}" ]; then
|
||||||
# Source SSH settings, if applicable
|
# Source SSH settings, if applicable
|
||||||
. ${_plugin__ssh_env} > /dev/null
|
. ${_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;
|
_plugin__start_agent;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then
|
||||||
# Register the function so it is called whenever the working
|
# Register the function so it is called whenever the working
|
||||||
# directory changes.
|
# directory changes.
|
||||||
autoload add-zsh-hook
|
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.
|
# Tell the terminal about the initial directory.
|
||||||
update_terminal_cwd
|
update_terminal_cwd
|
||||||
|
|
|
||||||
9
plugins/wd2/wd2/wd.plugin.zsh
Executable file
9
plugins/wd2/wd2/wd.plugin.zsh
Executable file
|
|
@ -0,0 +1,9 @@
|
||||||
|
#!/bin/zsh
|
||||||
|
|
||||||
|
# WARP
|
||||||
|
# ====
|
||||||
|
# oh-my-zsh plugin
|
||||||
|
#
|
||||||
|
# @github.com/mfaerevaag/wd
|
||||||
|
|
||||||
|
alias wd='. ~/.oh-my-zsh/plugins/wd/wd.sh'
|
||||||
201
plugins/wd2/wd2/wd.sh
Executable file
201
plugins/wd2/wd2/wd.sh
Executable file
|
|
@ -0,0 +1,201 @@
|
||||||
|
#!/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"
|
||||||
|
|
||||||
|
|
||||||
|
## 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 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 -- $*`
|
||||||
|
|
||||||
|
if [[ $? -ne 0 || $#* -eq 0 ]]
|
||||||
|
then
|
||||||
|
wd_print_usage
|
||||||
|
else
|
||||||
|
# can't exit, as this would exit the excecuting shell
|
||||||
|
# e.i. your terminal
|
||||||
|
|
||||||
|
#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
|
||||||
|
|
@ -95,38 +95,38 @@ prompt_git() {
|
||||||
}
|
}
|
||||||
|
|
||||||
prompt_hg() {
|
prompt_hg() {
|
||||||
local rev status
|
local rev status
|
||||||
if $(hg id >/dev/null 2>&1); then
|
if $(hg id >/dev/null 2>&1); then
|
||||||
if $(hg prompt >/dev/null 2>&1); then
|
if $(hg prompt >/dev/null 2>&1); then
|
||||||
if [[ $(hg prompt "{status|unknown}") = "?" ]]; then
|
if [[ $(hg prompt "{status|unknown}") = "?" ]]; then
|
||||||
# if files are not added
|
# if files are not added
|
||||||
prompt_segment red white
|
prompt_segment red white
|
||||||
st='±'
|
st='±'
|
||||||
elif [[ -n $(hg prompt "{status|modified}") ]]; then
|
elif [[ -n $(hg prompt "{status|modified}") ]]; then
|
||||||
# if any modification
|
# if any modification
|
||||||
prompt_segment yellow black
|
prompt_segment yellow black
|
||||||
st='±'
|
st='±'
|
||||||
else
|
else
|
||||||
# if working copy is clean
|
# if working copy is clean
|
||||||
prompt_segment green black
|
prompt_segment green black
|
||||||
fi
|
fi
|
||||||
echo -n $(hg prompt "☿ {rev}@{branch}") $st
|
echo -n $(hg prompt "☿ {rev}@{branch}") $st
|
||||||
else
|
else
|
||||||
st=""
|
st=""
|
||||||
rev=$(hg id -n 2>/dev/null | sed 's/[^-0-9]//g')
|
rev=$(hg id -n 2>/dev/null | sed 's/[^-0-9]//g')
|
||||||
branch=$(hg id -b 2>/dev/null)
|
branch=$(hg id -b 2>/dev/null)
|
||||||
if `hg st | grep -Eq "^\?"`; then
|
if `hg st | grep -Eq "^\?"`; then
|
||||||
prompt_segment red black
|
prompt_segment red black
|
||||||
st='±'
|
st='±'
|
||||||
elif `hg st | grep -Eq "^(M|A)"`; then
|
elif `hg st | grep -Eq "^(M|A)"`; then
|
||||||
prompt_segment yellow black
|
prompt_segment yellow black
|
||||||
st='±'
|
st='±'
|
||||||
else
|
else
|
||||||
prompt_segment green black
|
prompt_segment green black
|
||||||
fi
|
fi
|
||||||
echo -n " $rev@$branch" $st
|
echo -n "☿ $rev@$branch" $st
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Dir: current working directory
|
# Dir: current working directory
|
||||||
|
|
@ -137,7 +137,7 @@ prompt_dir() {
|
||||||
# Virtualenv: current working virtualenv
|
# Virtualenv: current working virtualenv
|
||||||
prompt_virtualenv() {
|
prompt_virtualenv() {
|
||||||
local virtualenv_path="$VIRTUAL_ENV"
|
local virtualenv_path="$VIRTUAL_ENV"
|
||||||
if [[ -n $virtualenv_path && -z $VIRTUAL_ENV_DISABLE_PROMPT ]]; then
|
if [[ -n $virtualenv_path && -n $VIRTUAL_ENV_DISABLE_PROMPT ]]; then
|
||||||
prompt_segment blue black "(`basename $virtualenv_path`)"
|
prompt_segment blue black "(`basename $virtualenv_path`)"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue