From 2667e44ca957ec75f61266305e375c011fc52cd8 Mon Sep 17 00:00:00 2001
From: Patrick Spek
Date: Tue, 24 Oct 2023 15:31:45 +0200
Subject: Add shell functions for Python venvs
It is an ugly system, and it seems it is practically inescapable. Truly
an homage to the quality of the programming language and the devs who
love it without question.
---
.bashrc | 3 +++
.config/shell/functions.d/venv | 48 ++++++++++++++++++++++++++++++++++++++++++
.zshrc | 11 +++++++++-
3 files changed, 61 insertions(+), 1 deletion(-)
create mode 100644 .config/shell/functions.d/venv
diff --git a/.bashrc b/.bashrc
index f526efa..ca3a9d3 100644
--- a/.bashrc
+++ b/.bashrc
@@ -72,6 +72,9 @@ __precmd()
PS1+="\001$SHELLC_F_LIGHTGRAY\002:\001$SHELLC_RESET_COLOR_F\002"
PS1+="\001$SHELLC_F_BLUE\002\w\001$SHELLC_RESET_COLOR_F\002"
+ # Add venv indicator
+ PS1+="\001$SHELLC_F_CYAN\002#$(awk -F/ '{ print $(NF-1) }' <<< "$PYTHON_VENV_DIR")\001$SHELLC_RESET_COLOR_F\002"
+
# Add git status
if git rev-parse --is-inside-work-tree &> /dev/null
then
diff --git a/.config/shell/functions.d/venv b/.config/shell/functions.d/venv
new file mode 100644
index 0000000..50a91e9
--- /dev/null
+++ b/.config/shell/functions.d/venv
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+venv() {
+ if ! command -v "venv_$1" | grep -q " function "
+ then
+ cat <