Last active
October 10, 2024 23:25
-
-
Save shuntksh/d681c4c530fd9d4c94c0968b0c0ab3eb to your computer and use it in GitHub Desktop.
Automatically starts zellij when in terminal but not in vscode terminal pane.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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