update zsh

This commit is contained in:
vincent 2020-06-11 16:47:03 +02:00
parent cc688e5871
commit 92e3a7a5ff
36 changed files with 2788 additions and 0 deletions

0
zsh/.oh-my-zsh/cache/.gitkeep vendored Normal file
View File

View File

@ -0,0 +1,41 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2019 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
alias sudo_u='sudo -u'
sudo(){}
BUFFER='sudo_u phy1729 ls foo'
expected_region_highlight=(
'1 6 alias' # sudo_u
'8 14 default' # phy1729
'16 17 command' # ls
'19 21 default' # foo
)

View File

@ -0,0 +1,42 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2018 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
alias sudo_b='sudo -b'
alias sudo_b_u='sudo_b -u'
sudo(){}
BUFFER='sudo_b_u phy1729 ls foo'
expected_region_highlight=(
'1 8 alias' # sudo_b_u
'10 16 default' # phy1729
'18 19 command' # ls
'21 23 default' # foo
)

View File

@ -0,0 +1,37 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2019 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
alias a=b b=foo
BUFFER='a '
expected_region_highlight=(
'1 1 unknown-token' # a
)

View File

@ -0,0 +1,37 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2019 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
alias a='() { ls "$@" ; foo }'
BUFFER='a '
expected_region_highlight=(
'1 1 unknown-token' # a
)

View File

@ -0,0 +1,45 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2019 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
BUFFER='echo "$(echo)$(echo)'
expected_region_highlight=(
'1 4 builtin' # echo
'6 20 default' # "$(echo)$(echo)
'6 6 double-quoted-argument-unclosed' # "
'7 13 command-substitution-quoted' # $(echo)
'7 8 command-substitution-delimiter-quoted' # $(
'9 12 builtin' # echo
'13 13 command-substitution-delimiter-quoted' # )
'14 20 command-substitution-quoted' # $(echo)
'14 15 command-substitution-delimiter-quoted' # $(
'16 19 builtin' # echo
'20 20 command-substitution-delimiter-quoted' # )
)

View File

@ -0,0 +1,39 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2019 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
# Newline after semicolon isn't unknown-token
BUFFER=$':;\n:'
expected_region_highlight=(
'1 1 builtin' # :
'2 2 commandseparator' # ;
'3 3 commandseparator "issue #616"' # \n
'4 4 builtin' # :
)

View File

@ -0,0 +1,40 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2019 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
BUFFER=$'for i in \\\n; do done'
expected_region_highlight=(
'1 3 reserved-word' # for
'5 5 default' # i
'7 8 default' # in
'12 12 commandseparator' # ;
'14 15 reserved-word' # do
'17 20 reserved-word' # done
)

View File

@ -0,0 +1,39 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2018 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
BUFFER=$': -$\'n\''
touch ./-n
expected_region_highlight=(
'1 1 builtin' # :
'3 7 single-hyphen-option' # -$'n'
'4 7 dollar-quoted-argument' # $'n'
)

View File

@ -0,0 +1,61 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2019 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
# Test the behaviour of a builtin that exists as a command as well.
# The spaces in $BUFFER are to align precommand-type*.zsh test files.
BUFFER=$'test ; builtin test ; builtin command test ; nice test '
# Our expectations assumes that a 'test' external command exists (in addition
# to the 'test' builtin). Let's verify that, using the EQUALS option (which
# is on by default). If there's no 'test' command, the expansion will fail,
# diagnose a message on stdout, and the harness will detect a failure.
#
# This seems to work on all platforms, insofar as no one ever reported a bug
# about their system not having a 'test' binary in PATH. That said, if someone
# ever does see this test fail for this reason, we should explicitly create
# a 'test' executable in cwd and 'rehash'.
: =test
expected_region_highlight=(
'1 4 builtin' # test
'7 7 commandseparator' # ;
'9 15 precommand' # builtin
'17 20 builtin' # test
'23 23 commandseparator' # ;
'25 31 precommand' # builtin
'33 39 precommand' # command
'41 44 command "issue #608"' # test
'47 47 commandseparator' # ;
'49 52 precommand' # nice
'54 57 command "issue #608"' # test
)

View File

@ -0,0 +1,55 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2019 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
# Test the behaviour of a builtin that does not exist as a command.
# The spaces in $BUFFER are to align precommand-type*.zsh test files.
BUFFER=$'zstyle; builtin zstyle; builtin command zstyle; nice zstyle'
# Verify that no $^path/zstyle(N) binary exists.
if (disable zstyle; type zstyle >/dev/null); then
echo >&2 "precommand-type2: error: 'zstyle' exists not only as a builtin"
fi
expected_region_highlight=(
'1 6 builtin' # zstyle
'7 7 commandseparator' # ;
'9 15 precommand' # builtin
'17 22 builtin' # zstyle
'23 23 commandseparator' # ;
'25 31 precommand' # builtin
'33 39 precommand' # command
'41 46 unknown-token "issue #608"' # zstyle
'47 47 commandseparator' # ;
'49 52 precommand' # nice
'54 59 unknown-token "issue #608"' # zstyle
)

View File

@ -0,0 +1,55 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2019 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
# Test an external command that does not exist as a builtin.
# The spaces in $BUFFER are to align precommand-type*.zsh test files.
BUFFER=$'ls ; builtin ls ; builtin command ls ; nice ls '
# Verify that the 'ls' command isn't shadowed.
if [[ $(type -w ls) != "ls: command" ]]; then
echo >&2 "precommand-type3: error: the 'ls' command is shadowed (or possibly missing altogether)"
fi
expected_region_highlight=(
'1 2 command' # ls
'7 7 commandseparator' # ;
'9 15 precommand' # builtin
'17 18 unknown-token "issue #608"' # ls
'23 23 commandseparator' # ;
'25 31 precommand' # builtin
'33 39 precommand' # command
'41 42 command' # ls
'47 47 commandseparator' # ;
'49 52 precommand' # nice
'54 55 command' # ls
)

195
zsh/.oh-my-zsh/lib/cli.zsh Normal file
View File

@ -0,0 +1,195 @@
#!/usr/bin/env zsh
function omz {
[[ $# -gt 0 ]] || {
_omz::help
return 1
}
local command="$1"
shift
# Subcommand functions start with _ so that they don't
# appear as completion entries when looking for `omz`
(( $+functions[_omz::$command] )) || {
_omz::help
return 1
}
_omz::$command "$@"
}
function _omz {
local -a cmds subcmds
cmds=(
'help:Usage information'
'pr:Commands for Oh My Zsh Pull Requests'
)
if (( CURRENT == 2 )); then
_describe 'command' cmds
elif (( CURRENT == 3 )); then
case "$words[2]" in
pr) subcmds=( 'test:Test a Pull Request' 'clean:Delete all Pull Request branches' )
_describe 'command' subcmds ;;
esac
fi
return 0
}
compdef _omz omz
function _omz::help {
cat <<EOF
Usage: omz <command> [options]
Available commands:
help Print this help message
pr <command> Commands for Oh My Zsh Pull Requests
EOF
}
function _omz::log {
# if promptsubst is set, a message with `` or $()
# will be run even if quoted due to `print -P`
setopt localoptions nopromptsubst
# $1 = info|warn|error|debug
# $@ = text
local logtype=$1
local logname=${${functrace[1]#_}%:*}
shift
# Don't print anything if debug is not active
if [[ $logtype = debug && -z $_OMZ_DEBUG ]]; then
return
fi
# Choose coloring based on log type
case "$logtype" in
prompt) print -Pn "%S%F{blue}$logname%f%s: $@" ;;
debug) print -P "%F{white}$logname%f: $@" ;;
info) print -P "%F{green}$logname%f: $@" ;;
warn) print -P "%S%F{yellow}$logname%f%s: $@" ;;
error) print -P "%S%F{red}$logname%f%s: $@" ;;
esac >&2
}
function _omz::pr {
(( $# > 0 && $+functions[_omz::pr::$1] )) || {
cat <<EOF
Usage: omz pr <command> [options]
Available commands:
clean Delete all PR branches (ohmyzsh/pull-*)
test <PR_number_or_URL> Fetch PR #NUMBER and rebase against master
EOF
return 1
}
local command="$1"
shift
_omz::pr::$command "$@"
}
function _omz::pr::clean {
(
set -e
builtin cd -q "$ZSH"
_omz::log info "removing all Oh My Zsh Pull Request branches..."
command git branch --list 'ohmyzsh/pull-*' | while read branch; do
command git branch -D "$branch"
done
)
}
function _omz::pr::test {
# Allow $1 to be a URL to the pull request
if [[ "$1" = https://* ]]; then
1="${1:t}"
fi
# Check the input
if ! [[ -n "$1" && "$1" =~ ^[[:digit:]]+$ ]]; then
echo >&2 "Usage: omz pr test <PR_NUMBER_or_URL>"
return 1
fi
# Save current git HEAD
local branch
branch=$(builtin cd -q "$ZSH"; git symbolic-ref --short HEAD) || {
_omz::log error "error when getting the current git branch. Aborting..."
return 1
}
# Fetch PR onto ohmyzsh/pull-<PR_NUMBER> branch and rebase against master
# If any of these operations fail, undo the changes made
(
set -e
builtin cd -q "$ZSH"
# Get the ohmyzsh git remote
command git remote -v | while read remote url _; do
case "$url" in
https://github.com/ohmyzsh/ohmyzsh(|.git)) found=1; break ;;
git@github.com:ohmyzsh/ohmyzsh(|.git)) found=1; break ;;
esac
done
(( $found )) || {
_omz::log error "could not found the ohmyzsh git remote. Aborting..."
return 1
}
# Fetch pull request head
_omz::log info "fetching PR #$1 to ohmyzsh/pull-$1..."
command git fetch -f "$remote" refs/pull/$1/head:ohmyzsh/pull-$1 || {
_omz::log error "error when trying to fetch PR #$1."
return 1
}
# Rebase pull request branch against the current master
_omz::log info "rebasing PR #$1..."
command git rebase master ohmyzsh/pull-$1 || {
command git rebase --abort &>/dev/null
_omz::log warn "could not rebase PR #$1 on top of master."
_omz::log warn "you might not see the latest stable changes."
_omz::log info "run \`zsh\` to test the changes."
return 1
}
_omz::log info "fetch of PR #${1} successful."
)
# If there was an error, abort running zsh to test the PR
[[ $? -eq 0 ]] || return 1
# Run zsh to test the changes
_omz::log info "running \`zsh\` to test the changes. Run \`exit\` to go back."
command zsh -l
# After testing, go back to the previous HEAD if the user wants
_omz::log prompt "do you want to go back to the previous branch? [Y/n] "
read -r -k 1
[[ "$REPLY" = [nN] ]] && return
(
set -e
builtin cd -q "$ZSH"
command git checkout "$branch" -- || {
_omz::log error "could not go back to the previous branch ('$branch')."
return 1
}
)
}

View File

View File

@ -0,0 +1,5 @@
## Bazel autocomplete plugin
A copy of the completion script from the
[bazelbuild/bazel](https://github.com/bazelbuild/bazel/master/scripts/zsh_completion/_bazel)
git repo.

View File

@ -0,0 +1,341 @@
#compdef bazel
# Copyright 2015 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Installation
# ------------
#
# 1. Add this script to a directory on your $fpath:
# fpath[1,0]=~/.zsh/completion/
# mkdir -p ~/.zsh/completion/
# cp scripts/zsh_completion/_bazel ~/.zsh/completion
#
# 2. Optionally, add the following to your .zshrc.
# zstyle ':completion:*' use-cache on
# zstyle ':completion:*' cache-path ~/.zsh/cache
#
# This way, the completion script does not have to parse Bazel's options
# repeatedly. The directory in cache-path must be created manually.
#
# 3. Restart the shell
#
# Options
# -------
# completion:init:bazel:* cache-lifetime
# Lifetime for the completion cache (if turned on, default: 1 week)
local curcontext="$curcontext" state line
: ${BAZEL_COMPLETION_PACKAGE_PATH:=%workspace%}
: ${BAZEL:=bazel}
_bazel_b() { ${BAZEL} --noblock_for_lock "$@" 2>/dev/null; }
# Default cache lifetime is 1 week
zstyle -s ":completion:${curcontext}:" cache-lifetime lifetime
if [[ -z "${lifetime}" ]]; then
lifetime=$((60*60*24*7))
fi
_bazel_cache_policy() {
local -a oldp
oldp=( "$1"(Nms+${lifetime}) )
(( $#oldp ))
}
_set_cache_policy() {
zstyle -s ":completion:*:$curcontext*" cache-policy update_policy
if [[ -z "$update_policy" ]]; then
zstyle ":completion:$curcontext*" cache-policy _bazel_cache_policy
fi
}
# Skips over all global arguments. After invocation, OFFSET contains the
# position of the bazel command in $words.
_adapt_subcommand_offset() {
OFFSET=2
for w in ${words[2,-1]}; do
if [[ $w == (#b)-* ]]; then
(( OFFSET++ ))
else
return
fi
done
}
# Retrieve the cache but also check that the value is not empty.
_bazel_safe_retrieve_cache() {
_retrieve_cache $1 && [[ ${(P)#2} -gt 0 ]]
}
# Puts the name of the variable that contains the options for the bazel
# subcommand handed in as the first argument into the global variable
# _bazel_cmd_options.
_bazel_get_options() {
local lcmd=$1
_bazel_cmd_options=_bazel_${lcmd}_options
_bazel_cmd_args=_bazel_${lcmd}_args
if [[ ${(P)#_bazel_cmd_options} != 0 ]]; then
return
fi
if _cache_invalid BAZEL_${lcmd}_options || _cache_invalid BAZEL_${lcmd}_args \
|| ! _bazel_safe_retrieve_cache BAZEL_${lcmd}_options ${_bazel_cmd_options} \
|| ! _retrieve_cache BAZEL_${lcmd}_args ${_bazel_cmd_args}; then
if ! eval "$(_bazel_b help completion)"; then
return
fi
local opts_var
if [[ $lcmd == "startup_options" ]]; then
opts_var="BAZEL_STARTUP_OPTIONS"
else
opts_var="BAZEL_COMMAND_${lcmd:u}_FLAGS"
fi
local -a raw_options
if ! eval "raw_options=(\${(@f)$opts_var})"; then
return
fi
local -a option_list
for opt in $raw_options; do
case $opt in
--*"={"*)
local lst="${${opt##*"={"}%"}"}"
local opt="${opt%%=*}="
option_list+=("${opt}:string:_values '' ${lst//,/ }") ;;
--*=path)
option_list+=("${opt%path}:path:_files") ;;
--*=label)
option_list+=("${opt%label}:target:_bazel_complete_target") ;;
--*=*)
option_list+=("${opt}:string:") ;;
*)
option_list+=("$opt") ;;
esac
done
local -a cmd_args
local cmd_type
if eval "cmd_type=\${BAZEL_COMMAND_${lcmd:u}_ARGUMENT}" && [[ -n $cmd_type ]]; then
case $cmd_type in
label|label-*)
cmd_args+=("*::${cmd_type}:_bazel_complete_target_${cmd_type//-/_}") ;;
info-key)
cmd_args+=('1::key:_bazel_info_key') ;;
path)
cmd_args+=('1::profile:_path_files') ;;
"command|{"*"}")
local lst=${${cmd_type#"command|{"}%"}"}
cmd_args+=("1::topic:_bazel_help_topic -- ${lst//,/ }") ;;
esac
fi
typeset -g "${_bazel_cmd_options}"="${(pj:|:)option_list[*]}"
_store_cache BAZEL_${lcmd}_options ${_bazel_cmd_options}
typeset -g "${_bazel_cmd_args}"="${(pj:|:)cmd_args[*]}"
_store_cache BAZEL_${lcmd}_args ${_bazel_cmd_args}
fi
}
_get_build_targets() {
local pkg=$1
local rule_re
typeset -a completions
case $target_type in
test)
rule_re=".*_test"
;;
build)
rule_re=".*"
;;
bin)
rule_re=".*_test|.*_binary"
;;
esac
completions=(${$(_bazel_b query "kind(\"${rule_re}\", ${pkg}:all)" 2>/dev/null)##*:})
if ( (( ${#completions} > 0 )) && [[ $target_type != run ]] ); then
completions+=(all)
fi
echo ${completions[*]}
}
# Returns all packages that match $PREFIX. PREFIX may start with //, in which
# case the workspace roots are searched. Otherwise, they are completed based on
# PWD.
_get_build_packages() {
local workspace pfx
typeset -a package_roots paths final_paths
workspace=$PWD
package_roots=(${(ps.:.)BAZEL_COMPLETION_PACKAGE_PATH})
package_roots=(${^package_roots//\%workspace\%/$workspace})
if [[ "${(e)PREFIX}" == //* ]]; then
pfx=${(e)PREFIX[2,-1]}
else
pfx=${(e)PREFIX}
fi
paths=(${^package_roots}/${pfx}*(/))
for p in ${paths[*]}; do
if [[ -f ${p}/BUILD || -f ${p}/BUILD.bazel ]]; then
final_paths+=(${p##*/}:)
fi
final_paths+=(${p##*/}/)
done
echo ${final_paths[*]}
}
_package_remove_slash() {
if [[ $KEYS == ':' && $LBUFFER == */ ]]; then
LBUFFER=${LBUFFER[1,-2]}
fi
}
# Completion function for BUILD targets, called by the completion system.
_bazel_complete_target() {
local expl
typeset -a packages targets
if [[ "${(e)PREFIX}" != *:* ]]; then
# There is no : in the prefix, completion can be either
# a package or a target, if the cwd is a package itself.
if [[ -f $PWD/BUILD || -f $PWD/BUILD.bazel ]]; then
targets=($(_get_build_targets ""))
_description build_target expl "BUILD target"
compadd "${expl[@]}" -a targets
fi
packages=($(_get_build_packages))
_description build_package expl "BUILD package"
# Chop of the leading path segments from the prefix for display.
compset -P '*/'
compadd -R _package_remove_slash -S '' "${expl[@]}" -a packages
else
targets=($(_get_build_targets "${${(e)PREFIX}%:*}"))
_description build_target expl "BUILD target"
# Ignore the current prefix for the upcoming completion, since we only list
# the names of the targets, not the full path.
compset -P '*:'
compadd "${expl[@]}" -a targets
fi
}
_bazel_complete_target_label() {
typeset -g target_type=build
_bazel_complete_target
}
_bazel_complete_target_label_test() {
typeset -g target_type=test
_bazel_complete_target
}
_bazel_complete_target_label_bin() {
typeset -g target_type=bin
_bazel_complete_target
}
### Actual completion commands
_bazel() {
_adapt_subcommand_offset
if (( CURRENT - OFFSET > 0 )); then
# Remember the subcommand name, stored globally so we can access it
# from any subsequent function
cmd=${words[OFFSET]//-/_}
# Set the context for the subcommand.
curcontext="${curcontext%:*:*}:bazel-$cmd:"
_set_cache_policy
# Narrow the range of words we are looking at to exclude cmd
# name and any leading options
(( CURRENT = CURRENT - OFFSET + 1 ))
shift $((OFFSET - 1)) words
# Run the completion for the subcommand
_bazel_get_options $cmd
_arguments : \
${(Pps:|:)_bazel_cmd_options} \
${(Pps:|:)_bazel_cmd_args}
else
_set_cache_policy
# Start special handling for global options,
# which can be retrieved by calling
# $ bazel help startup_options
_bazel_get_options startup_options
_arguments : \
${(Pps:|:)_bazel_cmd_options} \
"*:commands:_bazel_commands"
fi
return
}
_get_commands() {
# bazel_cmd_list is a global (g) array (a)
typeset -ga _bazel_cmd_list
# Use `bazel help` instead of `bazel help completion` to get command
# descriptions.
if _bazel_cmd_list=("${(@f)$(_bazel_b help | awk '
/Available commands/ { command=1; }
/ [-a-z]+[ \t]+.+/ { if (command) { printf "%s:", $1; for (i=2; i<=NF; i++) printf "%s ", $i; print "" } }
/^$/ { command=0; }')}"); then
_store_cache BAZEL_commands _bazel_cmd_list
fi
}
# Completion function for bazel subcommands, called by the completion system.
_bazel_commands() {
if [[ ${#_bazel_cmd_list} == 0 ]]; then
if _cache_invalid BAZEL_commands \
|| ! _bazel_safe_retrieve_cache BAZEL_commands _bazel_cmd_list; then
_get_commands
fi
fi
_describe -t bazel-commands 'Bazel command' _bazel_cmd_list
}
# Completion function for bazel help options, called by the completion system.
_bazel_help_topic() {
if [[ ${#_bazel_cmd_list} == 0 ]]; then
if _cache_invalid BAZEL_commands \
|| ! _bazel_safe_retrieve_cache BAZEL_commands _bazel_cmd_list; then
_get_commands
fi
fi
while [[ $# -gt 0 ]]; do
if [[ $1 == -- ]]; then
shift
break
fi
shift
done
_bazel_help_list=($@)
_bazel_help_list+=($_bazel_cmd_list)
_describe -t bazel-help 'Help topic' _bazel_help_list
}
# Completion function for bazel info keys, called by the completion system.
_bazel_info_key() {
if [[ ${#_bazel_info_keys_list} == 0 ]]; then
if _cache_invalid BAZEL_info_keys \
|| ! _bazel_safe_retrieve_cache BAZEL_info_keys _bazel_info_keys_list; then
typeset -ga _bazel_info_keys_list
# Use `bazel help` instead of `bazel help completion` to get info-key
# descriptions.
if _bazel_info_keys_list=("${(@f)$(_bazel_b help info-keys | awk '
{ printf "%s:", $1; for (i=2; i<=NF; i++) printf "%s ", $i; print "" }')}"); then
_store_cache BAZEL_info_keys _bazel_info_keys_list
fi
fi
fi
_describe -t bazel-info 'Key' _bazel_info_keys_list
}

View File

@ -0,0 +1,15 @@
# direnv plugin
This plugin creates the [Direnv](https://direnv.net/) hook.
To use it, add `direnv` to the plugins array in your zshrc file:
```zsh
plugins=(... direnv)
```
## Requirements
In order to make this work, you will need to have the direnv installed.
More info on the usage and install: https://github.com/direnv/direnv

View File

@ -0,0 +1,16 @@
# Don't continue if direnv is not found
command -v direnv &>/dev/null || return
_direnv_hook() {
trap -- '' SIGINT;
eval "$(direnv export zsh)";
trap - SIGINT;
}
typeset -ag precmd_functions;
if [[ -z ${precmd_functions[(r)_direnv_hook]} ]]; then
precmd_functions=( _direnv_hook ${precmd_functions[@]} )
fi
typeset -ag chpwd_functions;
if [[ -z ${chpwd_functions[(r)_direnv_hook]} ]]; then
chpwd_functions=( _direnv_hook ${chpwd_functions[@]} )
fi

View File

@ -0,0 +1,11 @@
# JFrog CLI
This plugin provides completion for [JFrog CLI](https://github.com/jfrog/jfrog-cli).
JFrog CLI provides a simple interface that automates access to [Artifactory](https://jfrog.com/artifactory), [Xray](https://jfrog.com/xray), [Bintray](https://jfrog.com/bintray) and [Mission Control](https://jfrog.com/mission-control) through their respective REST APIs.
To use it, add `jfrog` to the plugins array in your zshrc file:
```zsh
plugins=(... jfrog)
```

View File

@ -0,0 +1,10 @@
_jfrog() {
local -a opts
opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} --generate-bash-completion)}")
_describe 'values' opts
if [[ $compstate[nmatches] -eq 0 && $words[$CURRENT] != -* ]]; then
_files
fi
}
compdef _jfrog jfrog

View File

@ -0,0 +1,9 @@
# lxd
This plugin provides completion for [lxd](https://linuxcontainers.org/lxd/), as well as aliases
for frequent lxc commands.
To use it add `lxd` to the plugins array in your zshrc file.
```zsh
plugins=(... lxd)

View File

@ -0,0 +1,26 @@
_lxc_get_command_list () {
$_comp_command1 | sed "1,/Available Commands/d" | awk '/^[ \t]*[a-z]+/ { print $1 }'
}
_lxc_get_subcommand_list () {
$_comp_command1 ${words[2]} | sed "1,/Available Commands/d" | awk '/^[ \t]*[a-z]+/ { print $1 }'
}
_lxc () {
local curcontext="$curcontext" state line
typeset -A opt_args
_arguments \
'1: :->command'\
'*: :->args'
case $state in
command)
compadd $(_lxc_get_command_list)
;;
*)
compadd $(_lxc_get_subcommand_list)
;;
esac
}
compdef _lxc lxc

View File

@ -0,0 +1,9 @@
# rustup
This plugin adds completion for [`rustup`](https://rustup.rs/), the toolchain installer for the Rust programming language.
To use it, add `rustup` to the plugins array in your zshrc file:
```zsh
plugins=(... rustup)
```

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,52 @@
# Shell Proxy oh-my-zsh plugin
This a pure user-space program, shell-proxy setter, written Python3 and Bash.
100% only no side-effects, only effect **environment variables** and **aliases**
## Key feature
- Support Ubuntu, Archlinux, etc (Linux)
- Support macOS
- Support git via based-`$GIT_SSH`
- Support ssh, sftp, scp, slogin and ssh-copy-id via based-`alias`
- Built-in Auto-complete
## Usage
Method 1:
`$DEFAULT_PROXY` is the proxy URL you will set
Method 2:
Write a program to `$HOME/.config/proxy` in the file.
Example program:
```bash
#!/bin/bash
# The file path: $HOME/.config/proxy
if [[ "$OSTYPE" == "darwin"* ]]; then
echo "http://127.0.0.1:6152" # Surge Mac
else
echo "http://127.0.0.1:8123" # polipo
fi
```
Method 3:
The working path of **Method 2** can be changed via `$CONFIG_PROXY`
## Reference
- `$GIT_SSH`: <https://www.git-scm.com/docs/git#Documentation/git.txt-codeGITSSHcode>
- OpenSSH manual: <https://man.openbsd.org/ssh>
## Maintainer
- <https://github.com/septs>
## The oh-my-zsh plugin (shell-proxy)
Public Domain

View File

@ -0,0 +1,72 @@
#!/usr/bin/env python3
import os
import sys
from subprocess import check_output, list2cmdline
cwd = os.path.dirname(__file__)
ssh_agent = os.path.join(cwd, "ssh-agent.py")
user_proxy = os.environ.get("CONFIG_PROXY", os.path.expandvars("$HOME/.config/proxy"))
def get_http_proxy():
if "DEFAULT_PROXY" in os.environ:
return os.environ["DEFAULT_PROXY"]
if os.path.isfile(user_proxy):
return check_output(user_proxy).decode("utf-8").strip()
raise Exception("Not found, Proxy configuration")
def make_proxies(url: str):
proxies = {"%s_PROXY" % _: url for _ in ("HTTP", "HTTPS", "FTP", "RSYNC", "ALL")}
proxies.update({name.lower(): value for (name, value) in proxies.items()})
proxies["GIT_SSH"] = ssh_agent
return proxies
def merge(mapping: dict):
return ("%s=%s" % _ for _ in mapping.items())
class CommandSet:
proxies = make_proxies(get_http_proxy())
aliases = {
_: "env NAME=%s %s" % (_, ssh_agent)
for _ in ("ssh", "sftp", "scp", "slogin", "ssh-copy-id")
}
def enable(self):
cmdline("export", *merge(self.proxies))
cmdline("alias", *merge(self.aliases))
def disable(self):
cmdline("unset", *self.proxies.keys())
cmdline("unalias", *self.aliases.keys())
def status(self):
proxies = (
"%11s = %s" % (name, os.environ[name])
for name in self.proxies.keys()
if name in os.environ
)
for _ in proxies:
cmdline("echo", _)
def usage(self):
cmdline("echo", "usage: proxy {enable,disable,status}")
self.status()
def cmdline(*items):
print(list2cmdline(items))
def main():
command = CommandSet()
if len(sys.argv) == 1:
command.usage()
sys.exit(-1)
getattr(command, sys.argv[1], command.usage)()
if __name__ == "__main__":
main()

View File

@ -0,0 +1,16 @@
#!/usr/bin/bash
# shellcheck disable=SC1090
__PROXY__="${0:A:h}/proxy.py"
proxy() {
source <("$__PROXY__" "$1")
}
_proxy() {
local -r commands=('enable' 'disable' 'status')
compset -P '*,'
compadd -S '' "${commands[@]}"
}
compdef '_proxy' 'proxy'

View File

@ -0,0 +1,16 @@
#!/usr/bin/env python3
import os
import subprocess
import sys
ssh_proxy = os.path.join(os.path.dirname(__file__), "ssh-proxy.py")
argv = [
os.environ.get("NAME", "ssh"),
"-o",
"ProxyCommand={} %h %p".format(ssh_proxy),
"-o",
"Compression=yes",
]
subprocess.call(argv + sys.argv[1:], env=os.environ)

View File

@ -0,0 +1,18 @@
#!/usr/bin/env python3
import os
import subprocess
import sys
import urllib.parse
proxy = next(os.environ[_] for _ in ("HTTP_PROXY", "HTTPS_PROXY") if _ in os.environ)
argv = [
"nc",
"-X",
"connect",
"-x",
urllib.parse.urlparse(proxy).netloc, # proxy-host:proxy-port
sys.argv[1], # host
sys.argv[2], # port
]
subprocess.call(argv)

View File

@ -0,0 +1,33 @@
alias vgi="vagrant init"
alias vup="vagrant up"
alias vd="vagrant destroy"
alias vdf="vagrant destroy -f"
alias vssh="vagrant ssh"
alias vsshc="vagrant ssh-config"
alias vrdp="vagrant rdp"
alias vh="vagrant halt"
alias vssp="vagrant suspend"
alias vst="vagrant status"
alias vre="vagrant resume"
alias vgs="vagrant global-status"
alias vpr="vagrant provision"
alias vr="vagrant reload"
alias vrp="vagrant reload --provision"
alias vp="vagrant push"
alias vsh="vagrant share"
alias vba="vagrant box add"
alias vbr="vagrant box remove"
alias vbl="vagrant box list"
alias vbo="vagrant box outdated"
alias vbu="vagrant box update"
alias vpli="vagrant plugin install"
alias vpll="vagrant plugin list"
alias vplun="vagrant plugin uninstall"
alias vplu="vagrant plugin update"

View File

@ -0,0 +1,43 @@
# wakeonlan
This plugin provides a wrapper around the "wakeonlan" tool available from most
distributions' package repositories, or from [the following website](https://github.com/jpoliv/wakeonlan).
To use it, add `wakeonlan` to the plugins array in your zshrc file:
```zsh
plugins=(... wakeonlan)
```
## Usage
In order to use this wrapper, create the `~/.wakeonlan` directory, and place in
that directory one file for each device you would like to be able to wake. Give
the file a name that describes the device, such as its hostname. Each file
should contain a line with the mac address of the target device and the network
broadcast address.
For instance, there might be a file ~/.wakeonlan/leto with the following
contents:
```
00:11:22:33:44:55:66 192.168.0.255
```
To wake that device, use the following command:
```console
$ wake leto
```
The available device names will be autocompleted, so:
```console
$ wake <tab>
```
...will suggest "leto", along with any other configuration files that were
placed in the ~/.wakeonlan directory.
For more information regarding the configuration file format, check the
wakeonlan man page.

View File

@ -0,0 +1,23 @@
# z - jump around
This plugin defines the [z command](https://github.com/rupa/z) that tracks your most visited directories and allows you to access them with very few keystrokes.
### Example
Assume that you have previously visited directory `~/.oh-my-zsh/plugins`. From any folder in your command line, you can quickly access it by using a regex match to this folder:
```bash
/usr/bin$ z plug # Even 'z p' might suffice
~/.oh-my-zsh/plugins$
```
### Setup
To enable z, add `z` to your `plugins` array in your zshrc file:
```zsh
plugins=(... z)
```
### Further reading
For advanced usage and details of z, see [README](./README) (in man page format, copied from [rupa/z](https://github.com/rupa/z)).

View File

@ -0,0 +1,23 @@
# zsh-interactive-cd
This plugin adds a fish-like interactive tab completion for the `cd` command.
To use it, add `zsh-interactive-cd` to the plugins array of your zshrc file:
```zsh
plugins=(... zsh-interactive-cd)
```
![demo](https://user-images.githubusercontent.com/1441704/74360670-cb202900-4dc5-11ea-9734-f60caf726e85.gif)
## Usage
Press tab for completion as usual, it'll launch fzf automatically. Check fzfs [readme](https://github.com/junegunn/fzf#search-syntax) for more search syntax usage.
## Requirements
This plugin requires [fzf](https://github.com/junegunn/fzf). Install it by following
its [installation instructions](https://github.com/junegunn/fzf#installation).
## Author
[Henry Chang](https://github.com/changyuheng)

View File

@ -0,0 +1,148 @@
# Copyright (c) 2017 Henry Chang
__zic_fzf_prog() {
[ -n "$TMUX_PANE" ] && [ "${FZF_TMUX:-0}" != 0 ] && [ ${LINES:-40} -gt 15 ] \
&& echo "fzf-tmux -d${FZF_TMUX_HEIGHT:-40%}" || echo "fzf"
}
__zic_matched_subdir_list() {
local dir length seg starts_with_dir
if [[ "$1" == */ ]]; then
dir="$1"
if [[ "$dir" != / ]]; then
dir="${dir: : -1}"
fi
length=$(echo -n "$dir" | wc -c)
if [ "$dir" = "/" ]; then
length=0
fi
find -L "$dir" -mindepth 1 -maxdepth 1 -type d 2>/dev/null \
| cut -b $(( ${length} + 2 ))- | sed '/^$/d' | while read -r line; do
if [[ "${line[1]}" == "." ]]; then
continue
fi
echo "$line"
done
else
dir=$(dirname -- "$1")
length=$(echo -n "$dir" | wc -c)
if [ "$dir" = "/" ]; then
length=0
fi
seg=$(basename -- "$1")
starts_with_dir=$( \
find -L "$dir" -mindepth 1 -maxdepth 1 -type d \
2>/dev/null | cut -b $(( ${length} + 2 ))- | sed '/^$/d' \
| while read -r line; do
if [[ "${seg[1]}" != "." && "${line[1]}" == "." ]]; then
continue
fi
if [[ "$line" == "$seg"* ]]; then
echo "$line"
fi
done
)
if [ -n "$starts_with_dir" ]; then
echo "$starts_with_dir"
else
find -L "$dir" -mindepth 1 -maxdepth 1 -type d \
2>/dev/null | cut -b $(( ${length} + 2 ))- | sed '/^$/d' \
| while read -r line; do
if [[ "${seg[1]}" != "." && "${line[1]}" == "." ]]; then
continue
fi
if [[ "$line" == *"$seg"* ]]; then
echo "$line"
fi
done
fi
fi
}
_zic_list_generator() {
__zic_matched_subdir_list "${(Q)@[-1]}" | sort
}
_zic_complete() {
setopt localoptions nonomatch
local l matches fzf tokens base
l=$(_zic_list_generator $@)
if [ -z "$l" ]; then
zle ${__zic_default_completion:-expand-or-complete}
return
fi
fzf=$(__zic_fzf_prog)
if [ $(echo $l | wc -l) -eq 1 ]; then
matches=${(q)l}
else
matches=$(echo $l \
| FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} \
--reverse $FZF_DEFAULT_OPTS $FZF_COMPLETION_OPTS \
--bind 'shift-tab:up,tab:down'" ${=fzf} \
| while read -r item; do
echo -n "${(q)item} "
done)
fi
matches=${matches% }
if [ -n "$matches" ]; then
tokens=(${(z)LBUFFER})
base="${(Q)@[-1]}"
if [[ "$base" != */ ]]; then
if [[ "$base" == */* ]]; then
base="$(dirname -- "$base")"
if [[ ${base[-1]} != / ]]; then
base="$base/"
fi
else
base=""
fi
fi
LBUFFER="${tokens[1]} "
if [ -n "$base" ]; then
base="${(q)base}"
if [ "${tokens[2][1]}" = "~" ]; then
base="${base/#$HOME/~}"
fi
LBUFFER="${LBUFFER}${base}"
fi
LBUFFER="${LBUFFER}${matches}/"
fi
zle redisplay
typeset -f zle-line-init >/dev/null && zle zle-line-init
}
zic-completion() {
setopt localoptions noshwordsplit noksh_arrays noposixbuiltins
local tokens cmd
tokens=(${(z)LBUFFER})
cmd=${tokens[1]}
if [[ "$LBUFFER" =~ "^\ *cd$" ]]; then
zle ${__zic_default_completion:-expand-or-complete}
elif [ "$cmd" = cd ]; then
_zic_complete ${tokens[2,${#tokens}]/#\~/$HOME}
else
zle ${__zic_default_completion:-expand-or-complete}
fi
}
[ -z "$__zic_default_completion" ] && {
binding=$(bindkey '^I')
# $binding[(s: :w)2]
# The command substitution and following word splitting to determine the
# default zle widget for ^I formerly only works if the IFS parameter contains
# a space via $binding[(w)2]. Now it specifically splits at spaces, regardless
# of IFS.
[[ $binding =~ 'undefined-key' ]] || __zic_default_completion=$binding[(s: :w)2]
unset binding
}
zle -N zic-completion
bindkey -M emacs '^I' zic-completion
bindkey -M viins '^I' zic-completion

View File

@ -0,0 +1,35 @@
NAME=zsh-navigation-tools
INSTALL?=install -c
PREFIX?=/usr/local
SHARE_DIR?=$(DESTDIR)$(PREFIX)/share/$(NAME)
DOC_DIR?=$(DESTDIR)$(PREFIX)/share/doc/$(NAME)
all:
install:
$(INSTALL) -d $(SHARE_DIR)
$(INSTALL) -d $(SHARE_DIR)/.config
$(INSTALL) -d $(SHARE_DIR)/.config/znt
$(INSTALL) -d $(DOC_DIR)
cp zsh-navigation-tools.plugin.zsh _n-kill doc/znt-tmux.zsh $(SHARE_DIR)
cp README.md NEWS LICENSE doc/img/n-history2.png $(DOC_DIR)
if [ x"true" = x"`git rev-parse --is-inside-work-tree 2>/dev/null`" ]; then \
git rev-parse HEAD; \
else \
cat .revision-hash; \
fi > $(SHARE_DIR)/.revision-hash
:
for fname in n-*; do cp "$$fname" $(SHARE_DIR); done; \
for fname in znt-*; do cp "$$fname" $(SHARE_DIR); done; \
for fname in .config/znt/n-*; do cp "$$fname" $(SHARE_DIR)/.config/znt; done;
uninstall:
rm -f $(SHARE_DIR)/.revision-hash $(SHARE_DIR)/_* $(SHARE_DIR)/zsh-* $(SHARE_DIR)/n-* $(SHARE_DIR)/znt-* $(SHARE_DIR)/.config/znt/n-*
[ -d $(SHARE_DIR)/.config/znt ] && rmdir $(SHARE_DIR)/.config/znt || true
[ -d $(SHARE_DIR)/.config ] && rmdir $(SHARE_DIR)/.config || true
[ -d $(SHARE_DIR) ] && rmdir $(SHARE_DIR) || true
rm -f $(DOC_DIR)/README.md $(DOC_DIR)/LICENSE $(DOC_DIR)/n-history2.png
[ -d $(DOC_DIR) ] && rmdir $(DOC_DIR) || true
.PHONY: all install uninstall

View File

@ -0,0 +1,38 @@
# Make themes a unique array
typeset -Ua themes
if [[ "${(t)ZSH_THEME_RANDOM_CANDIDATES}" = array && ${#ZSH_THEME_RANDOM_CANDIDATES[@]} -gt 0 ]]; then
# Use ZSH_THEME_RANDOM_CANDIDATES if properly defined
themes=(${(@)ZSH_THEME_RANDOM_CANDIDATES:#random})
else
# Look for themes in $ZSH_CUSTOM and $ZSH and add only the theme name
themes=(
"$ZSH_CUSTOM"/*.zsh-theme(N:t:r)
"$ZSH_CUSTOM"/themes/*.zsh-theme(N:t:r)
"$ZSH"/themes/*.zsh-theme(N:t:r)
)
# Remove blacklisted themes from the list
for theme in random ${ZSH_THEME_RANDOM_BLACKLIST[@]}; do
themes=("${(@)themes:#$theme}")
done
fi
# Choose a theme out of the pool of candidates
N=${#themes[@]}
(( N = (RANDOM%N) + 1 ))
RANDOM_THEME="${themes[$N]}"
unset N themes theme
# Source theme
if [[ -f "$ZSH_CUSTOM/$RANDOM_THEME.zsh-theme" ]]; then
source "$ZSH_CUSTOM/$RANDOM_THEME.zsh-theme"
elif [[ -f "$ZSH_CUSTOM/themes/$RANDOM_THEME.zsh-theme" ]]; then
source "$ZSH_CUSTOM/themes/$RANDOM_THEME.zsh-theme"
elif [[ -f "$ZSH/themes/$RANDOM_THEME.zsh-theme" ]]; then
source "$ZSH/themes/$RANDOM_THEME.zsh-theme"
else
echo "[oh-my-zsh] Random theme '${RANDOM_THEME}' not found"
return 1
fi
echo "[oh-my-zsh] Random theme '${RANDOM_THEME}' loaded"