Skip to content

Instantly share code, notes, and snippets.

@shuntksh
Last active October 10, 2024 23:25
Show Gist options
  • Save shuntksh/d681c4c530fd9d4c94c0968b0c0ab3eb to your computer and use it in GitHub Desktop.
Save shuntksh/d681c4c530fd9d4c94c0968b0c0ab3eb to your computer and use it in GitHub Desktop.
Automatically starts zellij when in terminal but not in vscode terminal pane.
# Zellij - Launch zellij if not launched yet and not in vscode integrated shell
if not set -q VSCODE_SHELL_INTEGRATION
if set -q ZELLIJ
else
zellij
end
end
# Python - Activate python virtual env
function __auto_source_venv --on-variable PWD --description "Activate/Deactivate virtualenv on directory change"
status --is-command-substitution; and return
# Check if we are inside a git directory
if git rev-parse --show-toplevel &>/dev/null
set gitdir (realpath (git rev-parse --show-toplevel))
set cwd (pwd -P)
# While we are still inside the git directory, find the closest
# virtualenv starting from the current directory.
while string match "$gitdir*" "$cwd" &>/dev/null
if test -e "$cwd/.venv/bin/activate.fish"
source "$cwd/.venv/bin/activate.fish" &>/dev/null
return
else
set cwd (path dirname "$cwd")
end
end
end
# If virtualenv activated but we are not in a git directory, deactivate.
if test -n "$VIRTUAL_ENV"
deactivate
end
end
__auto_source_venv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment