1
0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2026-01-23 01:17:24 +08:00

Compare commits

..

No commits in common. "72707d92b1f127a2c16f0447e4d8233ed7b3c10e" and "9ce7de9f16ba894423bc5105c7e959894ca2e751" have entirely different histories.

8 changed files with 22 additions and 97 deletions

View File

@ -2,9 +2,7 @@ __GREP_CACHE_FILE="$ZSH_CACHE_DIR"/grep-alias
# See if there's a cache file modified in the last day
__GREP_ALIAS_CACHES=("$__GREP_CACHE_FILE"(Nm-1))
if [[ -n "$__GREP_ALIAS_CACHES" ]]; then
source "$__GREP_CACHE_FILE"
else
if [[ -z "$__GREP_ALIAS_CACHES" ]]; then
grep-flags-available() {
command grep "$@" "" &>/dev/null <<< ""
}
@ -14,28 +12,26 @@ else
# Check for --exclude-dir, otherwise check for --exclude. If --exclude
# isn't available, --color won't be either (they were released at the same
# time (v2.5): https://git.savannah.gnu.org/cgit/grep.git/tree/NEWS?id=1236f007
# time (v2.5): http://git.savannah.gnu.org/cgit/grep.git/tree/NEWS?id=1236f007
if grep-flags-available --color=auto --exclude-dir=.cvs; then
GREP_OPTIONS="--color=auto --exclude-dir=$EXC_FOLDERS"
elif grep-flags-available --color=auto --exclude=.cvs; then
GREP_OPTIONS="--color=auto --exclude=$EXC_FOLDERS"
fi
if [[ -n "$GREP_OPTIONS" ]]; then
# export grep, egrep and fgrep settings
alias grep="grep $GREP_OPTIONS"
alias egrep="egrep $GREP_OPTIONS"
alias fgrep="fgrep $GREP_OPTIONS"
# write to cache file if cache directory is writable
if [[ -w "$ZSH_CACHE_DIR" ]]; then
alias -L grep egrep fgrep >| "$__GREP_CACHE_FILE"
{
if [[ -n "$GREP_OPTIONS" ]]; then
# export grep, egrep and fgrep settings
echo "alias grep='grep $GREP_OPTIONS'"
echo "alias egrep='egrep $GREP_OPTIONS'"
echo "alias fgrep='fgrep $GREP_OPTIONS'"
fi
fi
} > "$__GREP_CACHE_FILE"
# Clean up
unset GREP_OPTIONS EXC_FOLDERS
unfunction grep-flags-available
fi
source "$__GREP_CACHE_FILE"
unset __GREP_CACHE_FILE __GREP_ALIAS_CACHES

View File

@ -26,8 +26,10 @@ fi
# OSX command-not-found support
# https://github.com/Homebrew/homebrew-command-not-found
if [[ -s '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-command-not-found/handler.sh' ]]; then
source '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-command-not-found/handler.sh'
if type brew &> /dev/null; then
if brew command command-not-found-init > /dev/null 2>&1; then
eval "$(brew command-not-found-init)";
fi
fi
# NixOS command-not-found support

View File

@ -1,13 +1,6 @@
# Autocompletion for Minikube.
#
if (( $+commands[minikube] )); then
__MINICUBE_COMPLETION_FILE="${ZSH_CACHE_DIR}/minicube_completion"
if [[ ! -f $__MINICUBE_COMPLETION_FILE ]]; then
minikube completion zsh >! $__MINICUBE_COMPLETION_FILE
fi
[[ -f $__MINICUBE_COMPLETION_FILE ]] && source $__MINICUBE_COMPLETION_FILE
unset __MINICUBE_COMPLETION_FILE
if [ $commands[minikube] ]; then
source <(minikube completion zsh)
fi

View File

@ -89,7 +89,6 @@ case "$words[1]" in
if [[ "$state" == packages ]]; then
_pip_all
_wanted piplist expl 'packages' compadd -a piplist
_files -g "*.(tar.gz|whl)"
fi ;;
uninstall)
_pip_installed

View File

@ -11,8 +11,7 @@ plugins=(... python)
| Command | Description |
|------------------|---------------------------------------------------------------------------------|
| `ipython` | Runs the appropriate `ipython` version according to the activated virtualenv |
| `pyfind` | Finds .py files recursively in the current directory |
| `pyclean [dirs]` | Deletes byte-code and cache files from a list of directories or the current one |
| `pygrep <text>` | Looks for `text` in .py files |
| `pyuserpaths` | Add --user site-packages to PYTHONPATH, for all installed python versions. |
| `ipython` | Runs the appropriate `ipython` version according to the activated virtualenv |

View File

@ -11,35 +11,6 @@ function pyclean() {
find ${ZSH_PYCLEAN_PLACES} -depth -type d -name ".pytest_cache" -exec rm -r "{}" +
}
# Add the user installed site-packages paths to PYTHONPATH, only if the
# directory exists. Also preserve the current PYTHONPATH value.
# Feel free to autorun this when .zshrc loads.
function pyuserpaths() {
local targets=("python2" "python3") # bins
# Get existing interpreters.
local interps=()
for target in $targets; do
[ `command -v $target` ] && interps+=($target)
done
# Check for a non-standard install directory.
local user_base="${HOME}/.local"
[ $PYTHONUSERBASE ] && user_base=$PYTHONUSERBASE
# Add version specific paths, if:
# it exists in the filesystem;
# it isn't in PYTHONPATH already.
for interp in $interps; do
# Get minor release version.
local ver=`$interp -V 2>&1`
ver=`echo ${ver:7} | cut -d '.' -f 1,2` # The patch version is variable length, truncate it.
local site_pkgs="${user_base}/lib/python${ver}/site-packages"
[[ -d $site_pkgs && ! $PYTHONPATH =~ $site_pkgs ]] && export PYTHONPATH=${site_pkgs}:$PYTHONPATH
done
}
# Grep among .py files
alias pygrep='grep -r --include="*.py"'

View File

@ -20,8 +20,6 @@ here are the results of calling `shrink_path <option> /home/me/foo/bar/quux`:
-s|--short /h/m/f/b/q
-t|--tilde ~/f/ba/q
-f|--fish ~/f/b/quux
-3 /hom/me/foo/bar/quu
-e '$' -3 /ho$/me/foo/bar/qu$
```
@ -40,13 +38,10 @@ The following options are available:
```
-f, --fish fish simulation, equivalent to -l -s -t.
-l, --last Print the last directory's full name.
-s, --short Truncate directory names to the number of characters given by -. Without
-s, --short Truncate directory names to the first character. Without
-s, names are truncated without making them ambiguous.
-t, --tilde Substitute ~ for the home directory.
-T, --nameddirs Substitute named directories as well.
-# Truncate each directly to at least this many characters inclusive of the
ellipsis character(s) (defaulting to 1).
-e SYMBOL Postfix symbol(s) to indicate that a directory name had been truncated.
```
The long options can also be set via zstyle, like
@ -61,7 +56,6 @@ supported.
## License
Copyright (C) 2008 by Daniel Friesel <derf@xxxxxxxxxxxxxxxxxx>
Copyright (C) 2018-2020 by Pavel N. Krivitsky
License: WTFPL <http://www.wtfpl.net>

View File

@ -10,13 +10,10 @@
#
# -f, --fish fish simulation, equivalent to -l -s -t.
# -l, --last Print the last directory's full name.
# -s, --short Truncate directory names to the number of characters given by -#. Without
# -s, --short Truncate directory names to the first character. Without
# -s, names are truncated without making them ambiguous.
# -t, --tilde Substitute ~ for the home directory.
# -T, --nameddirs Substitute named directories as well.
# -# Truncate each directly to at least this many characters inclusive of the
# ellipsis character(s) (defaulting to 1).
# -e SYMBOL Postfix symbol(s) to indicate that a directory name had been truncated.
#
# The long options can also be set via zstyle, like
# zstyle :prompt:shrink_path fish yes
@ -40,8 +37,6 @@ shrink_path () {
typeset -i short=0
typeset -i tilde=0
typeset -i named=0
typeset -i length=1
typeset ellipsis=""
if zstyle -t ':prompt:shrink_path' fish; then
lastfull=1
@ -58,10 +53,6 @@ shrink_path () {
while [[ $1 == -* ]]; do
case $1 in
--)
shift
break
;;
-f|--fish)
lastfull=1
short=1
@ -71,13 +62,9 @@ shrink_path () {
print 'Usage: shrink_path [-f -l -s -t] [directory]'
print ' -f, --fish fish-simulation, like -l -s -t'
print ' -l, --last Print the last directory''s full name'
print ' -s, --short Truncate directory names to the number of characters given by -#. Without'
print ' -s, names are truncated without making them ambiguous.'
print ' -s, --short Truncate directory names to the first character'
print ' -t, --tilde Substitute ~ for the home directory'
print ' -T, --nameddirs Substitute named directories as well'
print ' -# Truncate each directly to at least this many characters inclusive of the'
print ' ellipsis character(s) (defaulting to 1).'
print ' -e SYMBOL Postfix symbol(s) to indicate that a directory name had been truncated.'
print 'The long options can also be set via zstyle, like'
print ' zstyle :prompt:shrink_path fish yes'
return 0
@ -89,18 +76,10 @@ shrink_path () {
tilde=1
named=1
;;
-[0-9]|-[0-9][0-9])
length=${1/-/}
;;
-e)
shift
ellipsis="$1"
;;
esac
shift
done
typeset -i elllen=${#ellipsis}
typeset -a tree expn
typeset result part dir=${1-$PWD}
typeset -i i
@ -130,20 +109,12 @@ shrink_path () {
expn=(a b)
part=''
i=0
until [[ $i -gt 99 || ( $i -ge $((length - ellen)) || $dir == $part ) && ( (( ${#expn} == 1 )) || $dir = $expn ) ]]; do
until [[ (( ${#expn} == 1 )) || $dir = $expn || $i -gt 99 ]] do
(( i++ ))
part+=$dir[$i]
expn=($(echo ${part}*(-/)))
(( short )) && [[ $i -ge $((length - ellen)) ]] && break
(( short )) && break
done
typeset -i dif=$(( ${#dir} - ${#part} - ellen ))
if [[ $dif -gt 0 ]]
then
part+="$ellipsis"
else
part="$dir"
fi
result+="/$part"
cd -q $dir
shift tree