diff --git a/zsh/.oh-my-zsh/cache/.gitkeep b/zsh/.oh-my-zsh/cache/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/zsh/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/highlighters/main/test-data/alias-precommand-option-argument3.zsh b/zsh/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/highlighters/main/test-data/alias-precommand-option-argument3.zsh new file mode 100644 index 0000000..2c78121 --- /dev/null +++ b/zsh/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/highlighters/main/test-data/alias-precommand-option-argument3.zsh @@ -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 +) diff --git a/zsh/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/highlighters/main/test-data/alias-precommand-option-argument4.zsh b/zsh/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/highlighters/main/test-data/alias-precommand-option-argument4.zsh new file mode 100644 index 0000000..d47dccb --- /dev/null +++ b/zsh/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/highlighters/main/test-data/alias-precommand-option-argument4.zsh @@ -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 +) diff --git a/zsh/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/highlighters/main/test-data/alias-unknown-token1.zsh b/zsh/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/highlighters/main/test-data/alias-unknown-token1.zsh new file mode 100644 index 0000000..9c996bf --- /dev/null +++ b/zsh/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/highlighters/main/test-data/alias-unknown-token1.zsh @@ -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 +) diff --git a/zsh/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/highlighters/main/test-data/alias-unknown-token2.zsh b/zsh/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/highlighters/main/test-data/alias-unknown-token2.zsh new file mode 100644 index 0000000..ab9facd --- /dev/null +++ b/zsh/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/highlighters/main/test-data/alias-unknown-token2.zsh @@ -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 +) diff --git a/zsh/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/highlighters/main/test-data/command-substitution-adjacent.zsh b/zsh/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/highlighters/main/test-data/command-substitution-adjacent.zsh new file mode 100644 index 0000000..3d5c0b9 --- /dev/null +++ b/zsh/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/highlighters/main/test-data/command-substitution-adjacent.zsh @@ -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' # ) +) diff --git a/zsh/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/highlighters/main/test-data/empty-command-newline.zsh b/zsh/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/highlighters/main/test-data/empty-command-newline.zsh new file mode 100644 index 0000000..783f4b6 --- /dev/null +++ b/zsh/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/highlighters/main/test-data/empty-command-newline.zsh @@ -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' # : +) diff --git a/zsh/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/highlighters/main/test-data/loop-newline.zsh b/zsh/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/highlighters/main/test-data/loop-newline.zsh new file mode 100644 index 0000000..d39ee11 --- /dev/null +++ b/zsh/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/highlighters/main/test-data/loop-newline.zsh @@ -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 +) diff --git a/zsh/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/highlighters/main/test-data/option-dollar-quote-isnt-filename.zsh b/zsh/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/highlighters/main/test-data/option-dollar-quote-isnt-filename.zsh new file mode 100644 index 0000000..897a02e --- /dev/null +++ b/zsh/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/highlighters/main/test-data/option-dollar-quote-isnt-filename.zsh @@ -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' +) diff --git a/zsh/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/highlighters/main/test-data/precommand-type1.zsh b/zsh/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/highlighters/main/test-data/precommand-type1.zsh new file mode 100644 index 0000000..4ce817c --- /dev/null +++ b/zsh/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/highlighters/main/test-data/precommand-type1.zsh @@ -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 +) diff --git a/zsh/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/highlighters/main/test-data/precommand-type2.zsh b/zsh/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/highlighters/main/test-data/precommand-type2.zsh new file mode 100644 index 0000000..bf75f4b --- /dev/null +++ b/zsh/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/highlighters/main/test-data/precommand-type2.zsh @@ -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 +) diff --git a/zsh/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/highlighters/main/test-data/precommand-type3.zsh b/zsh/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/highlighters/main/test-data/precommand-type3.zsh new file mode 100644 index 0000000..7fc7e4c --- /dev/null +++ b/zsh/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/highlighters/main/test-data/precommand-type3.zsh @@ -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 +) diff --git a/zsh/.oh-my-zsh/lib/cli.zsh b/zsh/.oh-my-zsh/lib/cli.zsh new file mode 100644 index 0000000..e25a9f0 --- /dev/null +++ b/zsh/.oh-my-zsh/lib/cli.zsh @@ -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 < [options] + +Available commands: + + help Print this help message + pr 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 < [options] + +Available commands: + + clean Delete all PR branches (ohmyzsh/pull-*) + test 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 " + 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- 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 + } + ) +} diff --git a/zsh/.oh-my-zsh/log/.gitkeep b/zsh/.oh-my-zsh/log/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/zsh/.oh-my-zsh/plugins/bazel/README.md b/zsh/.oh-my-zsh/plugins/bazel/README.md new file mode 100644 index 0000000..e5ffe6e --- /dev/null +++ b/zsh/.oh-my-zsh/plugins/bazel/README.md @@ -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. diff --git a/zsh/.oh-my-zsh/plugins/bazel/_bazel b/zsh/.oh-my-zsh/plugins/bazel/_bazel new file mode 100644 index 0000000..827ce54 --- /dev/null +++ b/zsh/.oh-my-zsh/plugins/bazel/_bazel @@ -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 +} diff --git a/zsh/.oh-my-zsh/plugins/direnv/README.md b/zsh/.oh-my-zsh/plugins/direnv/README.md new file mode 100644 index 0000000..8deaf38 --- /dev/null +++ b/zsh/.oh-my-zsh/plugins/direnv/README.md @@ -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 diff --git a/zsh/.oh-my-zsh/plugins/direnv/direnv.plugin.zsh b/zsh/.oh-my-zsh/plugins/direnv/direnv.plugin.zsh new file mode 100644 index 0000000..5e32c4c --- /dev/null +++ b/zsh/.oh-my-zsh/plugins/direnv/direnv.plugin.zsh @@ -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 diff --git a/zsh/.oh-my-zsh/plugins/jfrog/README.md b/zsh/.oh-my-zsh/plugins/jfrog/README.md new file mode 100644 index 0000000..1d85862 --- /dev/null +++ b/zsh/.oh-my-zsh/plugins/jfrog/README.md @@ -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) +``` diff --git a/zsh/.oh-my-zsh/plugins/jfrog/jfrog.plugin.zsh b/zsh/.oh-my-zsh/plugins/jfrog/jfrog.plugin.zsh new file mode 100644 index 0000000..064ffa2 --- /dev/null +++ b/zsh/.oh-my-zsh/plugins/jfrog/jfrog.plugin.zsh @@ -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 \ No newline at end of file diff --git a/zsh/.oh-my-zsh/plugins/lxd/README.md b/zsh/.oh-my-zsh/plugins/lxd/README.md new file mode 100644 index 0000000..cea45e3 --- /dev/null +++ b/zsh/.oh-my-zsh/plugins/lxd/README.md @@ -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) diff --git a/zsh/.oh-my-zsh/plugins/lxd/lxd.plugin.zsh b/zsh/.oh-my-zsh/plugins/lxd/lxd.plugin.zsh new file mode 100644 index 0000000..a6a0742 --- /dev/null +++ b/zsh/.oh-my-zsh/plugins/lxd/lxd.plugin.zsh @@ -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 diff --git a/zsh/.oh-my-zsh/plugins/rustup/README.md b/zsh/.oh-my-zsh/plugins/rustup/README.md new file mode 100644 index 0000000..ba037f8 --- /dev/null +++ b/zsh/.oh-my-zsh/plugins/rustup/README.md @@ -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) +``` diff --git a/zsh/.oh-my-zsh/plugins/rustup/_rustup b/zsh/.oh-my-zsh/plugins/rustup/_rustup new file mode 100644 index 0000000..dab3353 --- /dev/null +++ b/zsh/.oh-my-zsh/plugins/rustup/_rustup @@ -0,0 +1,1143 @@ +#compdef rustup + +autoload -U is-at-least + +_rustup() { + typeset -A opt_args + typeset -a _arguments_options + local ret=1 + + if is-at-least 5.2; then + _arguments_options=(-s -S -C) + else + _arguments_options=(-s -C) + fi + + local context curcontext="$curcontext" state line + _arguments "${_arguments_options[@]}" \ +'-v[Enable verbose output]' \ +'--verbose[Enable verbose output]' \ +'(-v --verbose)-q[Disable progress output]' \ +'(-v --verbose)--quiet[Disable progress output]' \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +'::+toolchain -- release channel (e.g. +stable) or custom toolchain to set override:_files' \ +":: :_rustup_commands" \ +"*::: :->rustup" \ +&& ret=0 + case $state in + (rustup) + words=($line[2] "${words[@]}") + (( CURRENT += 1 )) + curcontext="${curcontext%:*:*}:rustup-command-$line[2]:" + case $line[2] in + (dump-testament) +_arguments "${_arguments_options[@]}" \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +&& ret=0 +;; +(show) +_arguments "${_arguments_options[@]}" \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +":: :_rustup__show_commands" \ +"*::: :->show" \ +&& ret=0 +case $state in + (show) + words=($line[1] "${words[@]}") + (( CURRENT += 1 )) + curcontext="${curcontext%:*:*}:rustup-show-command-$line[1]:" + case $line[1] in + (active-toolchain) +_arguments "${_arguments_options[@]}" \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +&& ret=0 +;; +(home) +_arguments "${_arguments_options[@]}" \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +&& ret=0 +;; +(profile) +_arguments "${_arguments_options[@]}" \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +&& ret=0 +;; +(keys) +_arguments "${_arguments_options[@]}" \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +&& ret=0 +;; +(help) +_arguments "${_arguments_options[@]}" \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +&& ret=0 +;; + esac + ;; +esac +;; +(install) +_arguments "${_arguments_options[@]}" \ +'--profile=[]: :(minimal default complete)' \ +'--no-self-update[Don'\''t perform self-update when running the `rustup install` command]' \ +'--force[Force an update, even if some components are missing]' \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +':toolchain -- Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see `rustup help toolchain`:_files' \ +&& ret=0 +;; +(uninstall) +_arguments "${_arguments_options[@]}" \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +':toolchain -- Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see `rustup help toolchain`:_files' \ +&& ret=0 +;; +(update) +_arguments "${_arguments_options[@]}" \ +'--no-self-update[Don'\''t perform self update when running the `rustup update` command]' \ +'--force[Force an update, even if some components are missing]' \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +'::toolchain -- Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see `rustup help toolchain`:_files' \ +&& ret=0 +;; +(check) +_arguments "${_arguments_options[@]}" \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +&& ret=0 +;; +(default) +_arguments "${_arguments_options[@]}" \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +'::toolchain -- Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see `rustup help toolchain`:_files' \ +&& ret=0 +;; +(toolchain) +_arguments "${_arguments_options[@]}" \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +":: :_rustup__toolchain_commands" \ +"*::: :->toolchain" \ +&& ret=0 +case $state in + (toolchain) + words=($line[1] "${words[@]}") + (( CURRENT += 1 )) + curcontext="${curcontext%:*:*}:rustup-toolchain-command-$line[1]:" + case $line[1] in + (list) +_arguments "${_arguments_options[@]}" \ +'-v[Enable verbose output with toolchain information]' \ +'--verbose[Enable verbose output with toolchain information]' \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +&& ret=0 +;; +(update) +_arguments "${_arguments_options[@]}" \ +'--profile=[]: :(minimal default complete)' \ +'*-c+[Add specific components on installation]' \ +'*--component=[Add specific components on installation]' \ +'*-t+[Add specific targets on installation]' \ +'*--target=[Add specific targets on installation]' \ +'--no-self-update[Don'\''t perform self update when running the`rustup toolchain install` command]' \ +'--force[Force an update, even if some components are missing]' \ +'--allow-downgrade[Allow rustup to downgrade the toolchain to satisfy your component choice]' \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +':toolchain -- Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see `rustup help toolchain`:_files' \ +&& ret=0 +;; +(add) +_arguments "${_arguments_options[@]}" \ +'--profile=[]: :(minimal default complete)' \ +'*-c+[Add specific components on installation]' \ +'*--component=[Add specific components on installation]' \ +'*-t+[Add specific targets on installation]' \ +'*--target=[Add specific targets on installation]' \ +'--no-self-update[Don'\''t perform self update when running the`rustup toolchain install` command]' \ +'--force[Force an update, even if some components are missing]' \ +'--allow-downgrade[Allow rustup to downgrade the toolchain to satisfy your component choice]' \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +':toolchain -- Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see `rustup help toolchain`:_files' \ +&& ret=0 +;; +(install) +_arguments "${_arguments_options[@]}" \ +'--profile=[]: :(minimal default complete)' \ +'*-c+[Add specific components on installation]' \ +'*--component=[Add specific components on installation]' \ +'*-t+[Add specific targets on installation]' \ +'*--target=[Add specific targets on installation]' \ +'--no-self-update[Don'\''t perform self update when running the`rustup toolchain install` command]' \ +'--force[Force an update, even if some components are missing]' \ +'--allow-downgrade[Allow rustup to downgrade the toolchain to satisfy your component choice]' \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +':toolchain -- Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see `rustup help toolchain`:_files' \ +&& ret=0 +;; +(remove) +_arguments "${_arguments_options[@]}" \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +':toolchain -- Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see `rustup help toolchain`:_files' \ +&& ret=0 +;; +(uninstall) +_arguments "${_arguments_options[@]}" \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +':toolchain -- Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see `rustup help toolchain`:_files' \ +&& ret=0 +;; +(link) +_arguments "${_arguments_options[@]}" \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +':toolchain -- Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see `rustup help toolchain`:_files' \ +':path:_files' \ +&& ret=0 +;; +(help) +_arguments "${_arguments_options[@]}" \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +&& ret=0 +;; + esac + ;; +esac +;; +(target) +_arguments "${_arguments_options[@]}" \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +":: :_rustup__target_commands" \ +"*::: :->target" \ +&& ret=0 +case $state in + (target) + words=($line[1] "${words[@]}") + (( CURRENT += 1 )) + curcontext="${curcontext%:*:*}:rustup-target-command-$line[1]:" + case $line[1] in + (list) +_arguments "${_arguments_options[@]}" \ +'--toolchain=[Toolchain name, such as '\''stable'\'', '\''nightly'\'', or '\''1.8.0'\''. For more information see `rustup help toolchain`]' \ +'--installed[List only installed targets]' \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +&& ret=0 +;; +(install) +_arguments "${_arguments_options[@]}" \ +'--toolchain=[Toolchain name, such as '\''stable'\'', '\''nightly'\'', or '\''1.8.0'\''. For more information see `rustup help toolchain`]' \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +':target -- List of targets to install; "all" installs all available targets:_files' \ +&& ret=0 +;; +(add) +_arguments "${_arguments_options[@]}" \ +'--toolchain=[Toolchain name, such as '\''stable'\'', '\''nightly'\'', or '\''1.8.0'\''. For more information see `rustup help toolchain`]' \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +':target -- List of targets to install; "all" installs all available targets:_files' \ +&& ret=0 +;; +(uninstall) +_arguments "${_arguments_options[@]}" \ +'--toolchain=[Toolchain name, such as '\''stable'\'', '\''nightly'\'', or '\''1.8.0'\''. For more information see `rustup help toolchain`]' \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +':target:_files' \ +&& ret=0 +;; +(remove) +_arguments "${_arguments_options[@]}" \ +'--toolchain=[Toolchain name, such as '\''stable'\'', '\''nightly'\'', or '\''1.8.0'\''. For more information see `rustup help toolchain`]' \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +':target:_files' \ +&& ret=0 +;; +(help) +_arguments "${_arguments_options[@]}" \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +&& ret=0 +;; + esac + ;; +esac +;; +(component) +_arguments "${_arguments_options[@]}" \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +":: :_rustup__component_commands" \ +"*::: :->component" \ +&& ret=0 +case $state in + (component) + words=($line[1] "${words[@]}") + (( CURRENT += 1 )) + curcontext="${curcontext%:*:*}:rustup-component-command-$line[1]:" + case $line[1] in + (list) +_arguments "${_arguments_options[@]}" \ +'--toolchain=[Toolchain name, such as '\''stable'\'', '\''nightly'\'', or '\''1.8.0'\''. For more information see `rustup help toolchain`]' \ +'--installed[List only installed components]' \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +&& ret=0 +;; +(add) +_arguments "${_arguments_options[@]}" \ +'--toolchain=[Toolchain name, such as '\''stable'\'', '\''nightly'\'', or '\''1.8.0'\''. For more information see `rustup help toolchain`]' \ +'--target=[]' \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +':component:_files' \ +&& ret=0 +;; +(remove) +_arguments "${_arguments_options[@]}" \ +'--toolchain=[Toolchain name, such as '\''stable'\'', '\''nightly'\'', or '\''1.8.0'\''. For more information see `rustup help toolchain`]' \ +'--target=[]' \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +':component:_files' \ +&& ret=0 +;; +(help) +_arguments "${_arguments_options[@]}" \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +&& ret=0 +;; + esac + ;; +esac +;; +(override) +_arguments "${_arguments_options[@]}" \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +":: :_rustup__override_commands" \ +"*::: :->override" \ +&& ret=0 +case $state in + (override) + words=($line[1] "${words[@]}") + (( CURRENT += 1 )) + curcontext="${curcontext%:*:*}:rustup-override-command-$line[1]:" + case $line[1] in + (list) +_arguments "${_arguments_options[@]}" \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +&& ret=0 +;; +(add) +_arguments "${_arguments_options[@]}" \ +'--path=[Path to the directory]' \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +':toolchain -- Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see `rustup help toolchain`:_files' \ +&& ret=0 +;; +(set) +_arguments "${_arguments_options[@]}" \ +'--path=[Path to the directory]' \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +':toolchain -- Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see `rustup help toolchain`:_files' \ +&& ret=0 +;; +(remove) +_arguments "${_arguments_options[@]}" \ +'--path=[Path to the directory]' \ +'--nonexistent[Remove override toolchain for all nonexistent directories]' \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +&& ret=0 +;; +(unset) +_arguments "${_arguments_options[@]}" \ +'--path=[Path to the directory]' \ +'--nonexistent[Remove override toolchain for all nonexistent directories]' \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +&& ret=0 +;; +(help) +_arguments "${_arguments_options[@]}" \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +&& ret=0 +;; + esac + ;; +esac +;; +(run) +_arguments "${_arguments_options[@]}" \ +'--install[Install the requested toolchain if needed]' \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +':toolchain -- Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see `rustup help toolchain`:_files' \ +':command:_files' \ +&& ret=0 +;; +(which) +_arguments "${_arguments_options[@]}" \ +'--toolchain=[Toolchain name, such as '\''stable'\'', '\''nightly'\'', or '\''1.8.0'\''. For more information see `rustup help toolchain`]' \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +':command:_files' \ +&& ret=0 +;; +(docs) +_arguments "${_arguments_options[@]}" \ +'--toolchain=[Toolchain name, such as '\''stable'\'', '\''nightly'\'', or '\''1.8.0'\''. For more information see `rustup help toolchain`]' \ +'--path[Only print the path to the documentation]' \ +'--alloc[The Rust core allocation and collections library]' \ +'--book[The Rust Programming Language book]' \ +'--cargo[The Cargo Book]' \ +'--core[The Rust Core Library]' \ +'--edition-guide[The Rust Edition Guide]' \ +'--nomicon[The Dark Arts of Advanced and Unsafe Rust Programming]' \ +'--proc_macro[A support library for macro authors when defining new macros]' \ +'--reference[The Rust Reference]' \ +'--rust-by-example[A collection of runnable examples that illustrate various Rust concepts and standard libraries]' \ +'--rustc[The compiler for the Rust programming language]' \ +'--rustdoc[Generate documentation for Rust projects]' \ +'--std[Standard library API documentation]' \ +'--test[Support code for rustc'\''s built in unit-test and micro-benchmarking framework]' \ +'--unstable-book[The Unstable Book]' \ +'--embedded-book[The Embedded Rust Book]' \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +'::topic -- Topic such as 'core', 'fn', 'usize', 'eprintln!', 'core::arch', 'alloc::format!', 'std::fs', 'std::fs::read_dir', 'std::io::Bytes', 'std::iter::Sum', 'std::io::error::Result' etc...:_files' \ +&& ret=0 +;; +(doc) +_arguments "${_arguments_options[@]}" \ +'--toolchain=[Toolchain name, such as '\''stable'\'', '\''nightly'\'', or '\''1.8.0'\''. For more information see `rustup help toolchain`]' \ +'--path[Only print the path to the documentation]' \ +'--alloc[The Rust core allocation and collections library]' \ +'--book[The Rust Programming Language book]' \ +'--cargo[The Cargo Book]' \ +'--core[The Rust Core Library]' \ +'--edition-guide[The Rust Edition Guide]' \ +'--nomicon[The Dark Arts of Advanced and Unsafe Rust Programming]' \ +'--proc_macro[A support library for macro authors when defining new macros]' \ +'--reference[The Rust Reference]' \ +'--rust-by-example[A collection of runnable examples that illustrate various Rust concepts and standard libraries]' \ +'--rustc[The compiler for the Rust programming language]' \ +'--rustdoc[Generate documentation for Rust projects]' \ +'--std[Standard library API documentation]' \ +'--test[Support code for rustc'\''s built in unit-test and micro-benchmarking framework]' \ +'--unstable-book[The Unstable Book]' \ +'--embedded-book[The Embedded Rust Book]' \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +'::topic -- Topic such as 'core', 'fn', 'usize', 'eprintln!', 'core::arch', 'alloc::format!', 'std::fs', 'std::fs::read_dir', 'std::io::Bytes', 'std::iter::Sum', 'std::io::error::Result' etc...:_files' \ +&& ret=0 +;; +(man) +_arguments "${_arguments_options[@]}" \ +'--toolchain=[Toolchain name, such as '\''stable'\'', '\''nightly'\'', or '\''1.8.0'\''. For more information see `rustup help toolchain`]' \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +':command:_files' \ +&& ret=0 +;; +(self) +_arguments "${_arguments_options[@]}" \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +":: :_rustup__self_commands" \ +"*::: :->self" \ +&& ret=0 +case $state in + (self) + words=($line[1] "${words[@]}") + (( CURRENT += 1 )) + curcontext="${curcontext%:*:*}:rustup-self-command-$line[1]:" + case $line[1] in + (update) +_arguments "${_arguments_options[@]}" \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +&& ret=0 +;; +(uninstall) +_arguments "${_arguments_options[@]}" \ +'-y[]' \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +&& ret=0 +;; +(upgrade-data) +_arguments "${_arguments_options[@]}" \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +&& ret=0 +;; +(help) +_arguments "${_arguments_options[@]}" \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +&& ret=0 +;; + esac + ;; +esac +;; +(set) +_arguments "${_arguments_options[@]}" \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +":: :_rustup__set_commands" \ +"*::: :->set" \ +&& ret=0 +case $state in + (set) + words=($line[1] "${words[@]}") + (( CURRENT += 1 )) + curcontext="${curcontext%:*:*}:rustup-set-command-$line[1]:" + case $line[1] in + (default-host) +_arguments "${_arguments_options[@]}" \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +':host_triple:_files' \ +&& ret=0 +;; +(profile) +_arguments "${_arguments_options[@]}" \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +':profile-name:(minimal default complete)' \ +&& ret=0 +;; +(help) +_arguments "${_arguments_options[@]}" \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +&& ret=0 +;; + esac + ;; +esac +;; +(completions) +_arguments "${_arguments_options[@]}" \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +'::shell:(zsh bash fish powershell elvish)' \ +'::command:(rustup cargo)' \ +&& ret=0 +;; +(help) +_arguments "${_arguments_options[@]}" \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +&& ret=0 +;; + esac + ;; +esac +} + +(( $+functions[_rustup_commands] )) || +_rustup_commands() { + local commands; commands=( + "dump-testament:Dump information about the build" \ +"show:Show the active and installed toolchains or profiles" \ +"install:Update Rust toolchains" \ +"uninstall:Uninstall Rust toolchains" \ +"update:Update Rust toolchains and rustup" \ +"check:Check for updates to Rust toolchains" \ +"default:Set the default toolchain" \ +"toolchain:Modify or query the installed toolchains" \ +"target:Modify a toolchain's supported targets" \ +"component:Modify a toolchain's installed components" \ +"override:Modify directory toolchain overrides" \ +"run:Run a command with an environment configured for a given toolchain" \ +"which:Display which binary will be run for a given command" \ +"doc:Open the documentation for the current toolchain" \ +"man:View the man page for a given command" \ +"self:Modify the rustup installation" \ +"set:Alter rustup settings" \ +"completions:Generate tab-completion scripts for your shell" \ +"help:Prints this message or the help of the given subcommand(s)" \ + ) + _describe -t commands 'rustup commands' commands "$@" +} +(( $+functions[_rustup__show__active-toolchain_commands] )) || +_rustup__show__active-toolchain_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup show active-toolchain commands' commands "$@" +} +(( $+functions[_rustup__add_commands] )) || +_rustup__add_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup add commands' commands "$@" +} +(( $+functions[_rustup__component__add_commands] )) || +_rustup__component__add_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup component add commands' commands "$@" +} +(( $+functions[_rustup__override__add_commands] )) || +_rustup__override__add_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup override add commands' commands "$@" +} +(( $+functions[_rustup__target__add_commands] )) || +_rustup__target__add_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup target add commands' commands "$@" +} +(( $+functions[_rustup__toolchain__add_commands] )) || +_rustup__toolchain__add_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup toolchain add commands' commands "$@" +} +(( $+functions[_rustup__check_commands] )) || +_rustup__check_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup check commands' commands "$@" +} +(( $+functions[_rustup__completions_commands] )) || +_rustup__completions_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup completions commands' commands "$@" +} +(( $+functions[_rustup__component_commands] )) || +_rustup__component_commands() { + local commands; commands=( + "list:List installed and available components" \ +"add:Add a component to a Rust toolchain" \ +"remove:Remove a component from a Rust toolchain" \ +"help:Prints this message or the help of the given subcommand(s)" \ + ) + _describe -t commands 'rustup component commands' commands "$@" +} +(( $+functions[_rustup__default_commands] )) || +_rustup__default_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup default commands' commands "$@" +} +(( $+functions[_rustup__set__default-host_commands] )) || +_rustup__set__default-host_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup set default-host commands' commands "$@" +} +(( $+functions[_rustup__doc_commands] )) || +_rustup__doc_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup doc commands' commands "$@" +} +(( $+functions[_docs_commands] )) || +_docs_commands() { + local commands; commands=( + + ) + _describe -t commands 'docs commands' commands "$@" +} +(( $+functions[_rustup__docs_commands] )) || +_rustup__docs_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup docs commands' commands "$@" +} +(( $+functions[_rustup__dump-testament_commands] )) || +_rustup__dump-testament_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup dump-testament commands' commands "$@" +} +(( $+functions[_rustup__component__help_commands] )) || +_rustup__component__help_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup component help commands' commands "$@" +} +(( $+functions[_rustup__help_commands] )) || +_rustup__help_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup help commands' commands "$@" +} +(( $+functions[_rustup__override__help_commands] )) || +_rustup__override__help_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup override help commands' commands "$@" +} +(( $+functions[_rustup__self__help_commands] )) || +_rustup__self__help_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup self help commands' commands "$@" +} +(( $+functions[_rustup__set__help_commands] )) || +_rustup__set__help_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup set help commands' commands "$@" +} +(( $+functions[_rustup__show__help_commands] )) || +_rustup__show__help_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup show help commands' commands "$@" +} +(( $+functions[_rustup__target__help_commands] )) || +_rustup__target__help_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup target help commands' commands "$@" +} +(( $+functions[_rustup__toolchain__help_commands] )) || +_rustup__toolchain__help_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup toolchain help commands' commands "$@" +} +(( $+functions[_rustup__show__home_commands] )) || +_rustup__show__home_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup show home commands' commands "$@" +} +(( $+functions[_rustup__install_commands] )) || +_rustup__install_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup install commands' commands "$@" +} +(( $+functions[_rustup__target__install_commands] )) || +_rustup__target__install_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup target install commands' commands "$@" +} +(( $+functions[_rustup__toolchain__install_commands] )) || +_rustup__toolchain__install_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup toolchain install commands' commands "$@" +} +(( $+functions[_rustup__show__keys_commands] )) || +_rustup__show__keys_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup show keys commands' commands "$@" +} +(( $+functions[_rustup__toolchain__link_commands] )) || +_rustup__toolchain__link_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup toolchain link commands' commands "$@" +} +(( $+functions[_rustup__component__list_commands] )) || +_rustup__component__list_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup component list commands' commands "$@" +} +(( $+functions[_rustup__override__list_commands] )) || +_rustup__override__list_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup override list commands' commands "$@" +} +(( $+functions[_rustup__target__list_commands] )) || +_rustup__target__list_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup target list commands' commands "$@" +} +(( $+functions[_rustup__toolchain__list_commands] )) || +_rustup__toolchain__list_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup toolchain list commands' commands "$@" +} +(( $+functions[_rustup__man_commands] )) || +_rustup__man_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup man commands' commands "$@" +} +(( $+functions[_rustup__override_commands] )) || +_rustup__override_commands() { + local commands; commands=( + "list:List directory toolchain overrides" \ +"set:Set the override toolchain for a directory" \ +"unset:Remove the override toolchain for a directory" \ +"help:Prints this message or the help of the given subcommand(s)" \ + ) + _describe -t commands 'rustup override commands' commands "$@" +} +(( $+functions[_rustup__set__profile_commands] )) || +_rustup__set__profile_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup set profile commands' commands "$@" +} +(( $+functions[_rustup__show__profile_commands] )) || +_rustup__show__profile_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup show profile commands' commands "$@" +} +(( $+functions[_rustup__component__remove_commands] )) || +_rustup__component__remove_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup component remove commands' commands "$@" +} +(( $+functions[_rustup__override__remove_commands] )) || +_rustup__override__remove_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup override remove commands' commands "$@" +} +(( $+functions[_rustup__remove_commands] )) || +_rustup__remove_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup remove commands' commands "$@" +} +(( $+functions[_rustup__target__remove_commands] )) || +_rustup__target__remove_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup target remove commands' commands "$@" +} +(( $+functions[_rustup__toolchain__remove_commands] )) || +_rustup__toolchain__remove_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup toolchain remove commands' commands "$@" +} +(( $+functions[_rustup__run_commands] )) || +_rustup__run_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup run commands' commands "$@" +} +(( $+functions[_rustup__self_commands] )) || +_rustup__self_commands() { + local commands; commands=( + "update:Download and install updates to rustup" \ +"uninstall:Uninstall rustup." \ +"upgrade-data:Upgrade the internal data format." \ +"help:Prints this message or the help of the given subcommand(s)" \ + ) + _describe -t commands 'rustup self commands' commands "$@" +} +(( $+functions[_rustup__override__set_commands] )) || +_rustup__override__set_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup override set commands' commands "$@" +} +(( $+functions[_rustup__set_commands] )) || +_rustup__set_commands() { + local commands; commands=( + "default-host:The triple used to identify toolchains when not specified" \ +"profile:The default components installed" \ +"help:Prints this message or the help of the given subcommand(s)" \ + ) + _describe -t commands 'rustup set commands' commands "$@" +} +(( $+functions[_rustup__show_commands] )) || +_rustup__show_commands() { + local commands; commands=( + "active-toolchain:Show the active toolchain" \ +"home:Display the computed value of RUSTUP_HOME" \ +"profile:Show the current profile" \ +"keys:Display the known PGP keys" \ +"help:Prints this message or the help of the given subcommand(s)" \ + ) + _describe -t commands 'rustup show commands' commands "$@" +} +(( $+functions[_rustup__target_commands] )) || +_rustup__target_commands() { + local commands; commands=( + "list:List installed and available targets" \ +"add:Add a target to a Rust toolchain" \ +"remove:Remove a target from a Rust toolchain" \ +"help:Prints this message or the help of the given subcommand(s)" \ + ) + _describe -t commands 'rustup target commands' commands "$@" +} +(( $+functions[_rustup__toolchain_commands] )) || +_rustup__toolchain_commands() { + local commands; commands=( + "list:List installed toolchains" \ +"install:Install or update a given toolchain" \ +"uninstall:Uninstall a toolchain" \ +"link:Create a custom toolchain by symlinking to a directory" \ +"help:Prints this message or the help of the given subcommand(s)" \ + ) + _describe -t commands 'rustup toolchain commands' commands "$@" +} +(( $+functions[_rustup__self__uninstall_commands] )) || +_rustup__self__uninstall_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup self uninstall commands' commands "$@" +} +(( $+functions[_rustup__target__uninstall_commands] )) || +_rustup__target__uninstall_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup target uninstall commands' commands "$@" +} +(( $+functions[_rustup__toolchain__uninstall_commands] )) || +_rustup__toolchain__uninstall_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup toolchain uninstall commands' commands "$@" +} +(( $+functions[_rustup__uninstall_commands] )) || +_rustup__uninstall_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup uninstall commands' commands "$@" +} +(( $+functions[_rustup__override__unset_commands] )) || +_rustup__override__unset_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup override unset commands' commands "$@" +} +(( $+functions[_rustup__self__update_commands] )) || +_rustup__self__update_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup self update commands' commands "$@" +} +(( $+functions[_rustup__toolchain__update_commands] )) || +_rustup__toolchain__update_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup toolchain update commands' commands "$@" +} +(( $+functions[_rustup__update_commands] )) || +_rustup__update_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup update commands' commands "$@" +} +(( $+functions[_rustup__self__upgrade-data_commands] )) || +_rustup__self__upgrade-data_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup self upgrade-data commands' commands "$@" +} +(( $+functions[_rustup__which_commands] )) || +_rustup__which_commands() { + local commands; commands=( + + ) + _describe -t commands 'rustup which commands' commands "$@" +} + +_rustup "$@" \ No newline at end of file diff --git a/zsh/.oh-my-zsh/plugins/shell-proxy/README.md b/zsh/.oh-my-zsh/plugins/shell-proxy/README.md new file mode 100644 index 0000000..6f2cd13 --- /dev/null +++ b/zsh/.oh-my-zsh/plugins/shell-proxy/README.md @@ -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`: +- OpenSSH manual: + +## Maintainer + +- + +## The oh-my-zsh plugin (shell-proxy) + +Public Domain diff --git a/zsh/.oh-my-zsh/plugins/shell-proxy/proxy.py b/zsh/.oh-my-zsh/plugins/shell-proxy/proxy.py new file mode 100755 index 0000000..2b62f6c --- /dev/null +++ b/zsh/.oh-my-zsh/plugins/shell-proxy/proxy.py @@ -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() diff --git a/zsh/.oh-my-zsh/plugins/shell-proxy/shell-proxy.plugin.zsh b/zsh/.oh-my-zsh/plugins/shell-proxy/shell-proxy.plugin.zsh new file mode 100644 index 0000000..fd0e2fe --- /dev/null +++ b/zsh/.oh-my-zsh/plugins/shell-proxy/shell-proxy.plugin.zsh @@ -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' diff --git a/zsh/.oh-my-zsh/plugins/shell-proxy/ssh-agent.py b/zsh/.oh-my-zsh/plugins/shell-proxy/ssh-agent.py new file mode 100755 index 0000000..61cf84c --- /dev/null +++ b/zsh/.oh-my-zsh/plugins/shell-proxy/ssh-agent.py @@ -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) diff --git a/zsh/.oh-my-zsh/plugins/shell-proxy/ssh-proxy.py b/zsh/.oh-my-zsh/plugins/shell-proxy/ssh-proxy.py new file mode 100755 index 0000000..5efd5fd --- /dev/null +++ b/zsh/.oh-my-zsh/plugins/shell-proxy/ssh-proxy.py @@ -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) diff --git a/zsh/.oh-my-zsh/plugins/vagrant/vagrant.plugin.zsh b/zsh/.oh-my-zsh/plugins/vagrant/vagrant.plugin.zsh new file mode 100644 index 0000000..a4e9b06 --- /dev/null +++ b/zsh/.oh-my-zsh/plugins/vagrant/vagrant.plugin.zsh @@ -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" diff --git a/zsh/.oh-my-zsh/plugins/wakeonlan/README.md b/zsh/.oh-my-zsh/plugins/wakeonlan/README.md new file mode 100644 index 0000000..3fcb6d7 --- /dev/null +++ b/zsh/.oh-my-zsh/plugins/wakeonlan/README.md @@ -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 +``` + +...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. diff --git a/zsh/.oh-my-zsh/plugins/z/README.md b/zsh/.oh-my-zsh/plugins/z/README.md new file mode 100644 index 0000000..ea8d461 --- /dev/null +++ b/zsh/.oh-my-zsh/plugins/z/README.md @@ -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)). + diff --git a/zsh/.oh-my-zsh/plugins/zsh-interactive-cd/README.md b/zsh/.oh-my-zsh/plugins/zsh-interactive-cd/README.md new file mode 100644 index 0000000..c8337fb --- /dev/null +++ b/zsh/.oh-my-zsh/plugins/zsh-interactive-cd/README.md @@ -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 fzf’s [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) diff --git a/zsh/.oh-my-zsh/plugins/zsh-interactive-cd/zsh-interactive-cd.plugin.zsh b/zsh/.oh-my-zsh/plugins/zsh-interactive-cd/zsh-interactive-cd.plugin.zsh new file mode 100644 index 0000000..b0520c2 --- /dev/null +++ b/zsh/.oh-my-zsh/plugins/zsh-interactive-cd/zsh-interactive-cd.plugin.zsh @@ -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 diff --git a/zsh/.oh-my-zsh/plugins/zsh-navigation-tools/Makefile b/zsh/.oh-my-zsh/plugins/zsh-navigation-tools/Makefile new file mode 100644 index 0000000..f34af0c --- /dev/null +++ b/zsh/.oh-my-zsh/plugins/zsh-navigation-tools/Makefile @@ -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 diff --git a/zsh/.oh-my-zsh/themes/random.zsh-theme b/zsh/.oh-my-zsh/themes/random.zsh-theme new file mode 100644 index 0000000..6cb7cc5 --- /dev/null +++ b/zsh/.oh-my-zsh/themes/random.zsh-theme @@ -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"