Skip to content

Style/format md and zsh #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 18 additions & 20 deletions .za-bgn-bin-or-src-function-body
Original file line number Diff line number Diff line change
@@ -1,40 +1,38 @@
# Copyright (c) 2019 Sebastian Gniazdowski
# License MIT
#!/usr/bin/env zsh
# -*- mode: sh; sh-indentation: 2; sh-basic-offset: 2; indent-tabs-mode: nil; -*-
#
# Copyright (c) 2019-2020 Sebastian Gniazdowski and contributors
# Copyright (c) 2021-2022 zdharma-continuum and contributors

# FUNCTION: .za-bgn-bin-or-src-function-body
# Returns the body of the function wrapping a binary

local name="$2" bin="$3" dir="${4#%}"
integer run_type="$1" set_gem_home="$5" \
set_node_path="$6" set_virtualenv="$7" set_cwd="$8" \
use_all_null="$9" use_err_null="$10" use_out_null="$11"
integer run_type="$1" set_gem_home="$5" set_node_path="$6" set_virtualenv="$7" set_cwd="$8" use_all_null="$9" use_err_null="$10" use_out_null="$11"

local nl=$'\n' tab=$' '

REPLY="function ${(q)name} {
local bindir=${(qqq)bin:h}
${${(M)set_gem_home:#1}:+local -x GEM_HOME=${(qqq)dir}}
${${(M)set_node_path:#1}:+local -x NODE_PATH=${(qqq)dir}/node_modules}
${${(M)set_virtualenv:#1}:+local -x VIRTUALENV=${(qqq)dir}/venv}
local -xU PATH=${${(M)set_virtualenv:#1}:+${(qqq)dir}/venv/bin:}${${(M)set_node_path:#1}:+${(qqq)dir}/node_modules/.bin:}${${(M)set_gem_home:#1}:+${(qqq)dir}/bin:}\"\$bindir\":\"\$PATH\"
${${(M)set_cwd:#1}:+"local oldpwd=${(qqq)PWD}
() { setopt localoptions noautopushd; builtin cd -q ${(qqq)dir}; }"}
"
local bindir=${(qqq)bin:h}
${${(M)set_gem_home:#1}:+local -x GEM_HOME=${(qqq)dir}}
${${(M)set_node_path:#1}:+local -x NODE_PATH=${(qqq)dir}/node_modules}
${${(M)set_virtualenv:#1}:+local -x VIRTUALENV=${(qqq)dir}/venv}
local -xU PATH=${${(M)set_virtualenv:#1}:+${(qqq)dir}/venv/bin:}${${(M)set_node_path:#1}:+${(qqq)dir}/node_modules/.bin:}${${(M)set_gem_home:#1}:+${(qqq)dir}/bin:}\"\$bindir\":\"\$PATH\"
${${(M)set_cwd:#1}:+"local oldpwd=${(qqq)PWD}
() { setopt localoptions noautopushd; builtin cd -q ${(qqq)dir}; }"
}"

if (( run_type == 0 )); then
REPLY+="$tab\"\$bindir\"/${(qqq)bin:t} \"\$@\""
REPLY+="$tab\"\$bindir\"/${(qqq)bin:t} \"\$@\""
elif (( run_type == 1 )); then
REPLY+="$tab() { source \"\$bindir\"/${(qqq)bin:t}; } \"\$@\""
REPLY+="$tab() { source \"\$bindir\"/${(qqq)bin:t}; } \"\$@\""
elif (( run_type == 2 )); then
REPLY+="$tab() { eval \"\$(<\"\$bindir\"/${(qqq)bin:t})\"; } \"\$@\""
REPLY+="$tab() { eval \"\$(<\"\$bindir\"/${(qqq)bin:t})\"; } \"\$@\""
fi

(( use_all_null )) && REPLY+=" &>/dev/null"
(( use_err_null )) && REPLY+=" 2>/dev/null"
(( use_out_null )) && REPLY+=" >/dev/null"

REPLY+="$nl"
REPLY+="${${(M)set_cwd:#1}:+"$nl$tab() { setopt localoptions noautopushd; builtin cd -q \"\$oldpwd\"; }"}
}"

# vim:ft=zsh:sw=4:sts=4:et
REPLY+="${${(M)set_cwd:#1}:+"$nl$tab() { setopt localoptions noautopushd; builtin cd -q \"\$oldpwd\"; }"}}"
21 changes: 9 additions & 12 deletions .za-bgn-bin-or-src-function-body-cygwin
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# Copyright (c) 2019 Sebastian Gniazdowski
# License MIT
#!/usr/bin/env zsh
# -*- mode: sh; sh-indentation: 2; sh-basic-offset: 2; indent-tabs-mode: nil; -*-
#
# Copyright (c) 2019-2020 Sebastian Gniazdowski and contributors
# Copyright (c) 2021-2022 zdharma-continuum and contributors

# FUNCTION: .za-bgn-bin-or-src-function-body
# Returns the body of the function wrapping a binary

local name="$2" bin="$3" dir="${4#%}"
integer run_type="$1" set_gem_home="$5" \
set_node_path="$6" set_virtualenv="$7" set_cwd="$8" \
use_all_null="$9" use_err_null="$10" use_out_null="$11"
integer run_type="$1" set_gem_home="$5" set_node_path="$6" set_virtualenv="$7" set_cwd="$8" use_all_null="$9" use_err_null="$10" use_out_null="$11"

local nl=$'\n' tab=$' '

dir=`cygpath -w "$dir"`
local binh=`command cygpath -w "${bin:h}"` bint=`command cygpath -w "${bin:t}"`
dir=$(cygpath -w "$dir")
local binh=$(command cygpath -w "${bin:h}"` bint=`command cygpath -w "${bin:t}")

REPLY="
@echo off
Expand All @@ -38,7 +38,4 @@ fi
(( use_out_null )) && REPLY+=" >NUL"

REPLY+="$nl"
REPLY+="${${(M)set_cwd:#1}:+"${nl}cd %oldpwd%"
}"

# vim:ft=zsh:sw=4:sts=4:et
REPLY+="${${(M)set_cwd:#1}:+"${nl}cd %oldpwd%"}"
9 changes: 5 additions & 4 deletions .za-bgn-mod-function-body
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Copyright (c) 2019 Sebastian Gniazdowski
# License MIT
#!/usr/bin/env zsh
# -*- mode: sh; sh-indentation: 2; sh-basic-offset: 2; indent-tabs-mode: nil; -*-
#
# Copyright (c) 2019-2020 Sebastian Gniazdowski and contributors
# Copyright (c) 2021-2022 zdharma-continuum and contributors

# Returns the body of the function wrapping a function

local name="$1" target_func="$2" dir="${3#%}"
Expand All @@ -27,5 +30,3 @@ ${(qqq)target_func} \"\$@\""
REPLY+="$nl"
REPLY+="${${(M)set_cwd:#1}:+"() { setopt localoptions noautopushd; builtin cd -q \"\$oldpwd\"; }"}
}"

# vim:ft=zsh:sw=4:sts=4:et
14 changes: 7 additions & 7 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
This software is licensed under MIT.

MIT License
-----------

Copyright (c) 2019-2021 Sebastian Gniazdowski and contributors
Copyright (c) 2021-2022 zdharma-continuum

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -10,13 +10,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading