Skip to content
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

Mention $XONSH_INTERACTIVE #47

Open
wants to merge 5 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
3 changes: 2 additions & 1 deletion project-template/{{ project_repo_name }}/.gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.xsh text linguist-language=Python
*.xsh* text linguist-language=Python
*.py* text linguist-language=Python
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@ print('This is {{ project_repo_name }}!')
# Note! If you want to create new env variables please name it with the beginning of the xontrib name
# i.e. if the xontrib called xontrib-hello-world name the variables as XONTRIB_HELLO_WORLD_NEW_VARIABLE
{% if pure_py %}
# Some code in Using Python API:
var = XSH.env.get("VAR", "default")
result = XSH.subproc_captured_stdout(['echo', '1'])
# If your xontrib was made only for interactive mode it's good practice to check this before executing.
if XSH.env.get("XONSH_INTERACTIVE"):
# Some code in Using Python API:
var = XSH.env.get("VAR", "default")
result = XSH.subproc_captured_stdout(['echo', '1'])
{% else %}
var = ${...}.get('VAR', 'default')
result = $(echo 1)
# If your xontrib was made only for interactive mode it's good practice to check this before executing.
if $XONSH_INTERACTIVE:
var = XSH.env.get('VAR', 'default')
result = $(echo 1)
{% endif %}
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@


def _load_xontrib_(xsh: XonshSession, **_):
# getting environment variable
var = xsh.env.get("VAR", "default")

print("Autoloading xontrib: {{ project_repo_name }}")
# If your xontrib was made only for interactive mode it's good practice to check this before executing.
if XSH.env.get("XONSH_INTERACTIVE"):
var = xsh.env.get("VAR", "default")
print("Autoloading xontrib: {{ project_repo_name }}")

{% if has_events %}
from .event_hooks import listen_cd
xsh.builtins.events.on_chdir(listen_cd)
{% endif %}
{% if has_aliases %}
from .aliases import git_log
xsh.aliases["gl"] = git_log
{% endif %}
{% if has_events %}
from .event_hooks import listen_cd
xsh.builtins.events.on_chdir(listen_cd)
{% endif %}
{% if has_aliases %}
from .aliases import git_log
xsh.aliases["gl"] = git_log
{% endif %}
Loading