# Add the following code your your .aliases, .zshrc, .bashrc or .bash_profile
# Then restart your shell 
# Now you can use `python` or `py` to run your python files


# Python
alias python=python3
alias python2='/usr/bin/python'
alias py2='/usr/bin/python'
alias python=PATH=/usr/local/bin:/usr/local/sbin:~/bin:$PATH


check_venv_dirs() {
    local venv_dirs=(".env" "env" ".venv" "venv")
    for dir in "${venv_dirs[@]}"; do
        if [ -d "$PWD/$dir" ]; then

            return 0  # At least one directory exists
        fi
    done
    return 1  # None of the directories exist
}

# Conditional alias for 'py'
if check_venv_dirs; then
    # If any of the directories exist, set the 'py' alias to the Python interpreter in the current working directory's virtual environment
    for dir in ".env" "env" ".venv" "venv"; do
        if [ -d "$PWD/$dir" ]; then
            alias py="$PWD/$dir/bin/python"
            # echo "Alias 'py' set to Python interpreter in the current directory's virtual environment: $dir"
            break
        fi
    done
else
    # If none of the directories exist, use the system Python interpreter or set a different alias
    alias py="/opt/homebrew/bin/python3"
    alias py='$HOME/.pyenv/shims/python'
    alias py="alias py="python3"
    # echo "Alias 'py' set to the system Python interpreter"
fi

open -e  ~/.zshrc
// add
alias python="python3"
// Save and restart console

Shell/Bash相关代码片段

git workflow call

kill running port one liner ubuntu

bash check if running as root

how to install openssl in windows

openssh latest version for raspbian

sed lines after match

pip install is very slow

gitlab connect error fix in git

Intellij removing space changes git

install kubernetes alma linux 8.9

how to remove quotes from a string in bash

how to install grafana-prometheus kubernetes

show laptop battery health windows 10

ubuntu terminal won't open

uninstall pip ubuntu

fatal: detected dubious ownership in repository

docker npm network timeout

install nvidia drivers pop os

how to list apt holds

how to install yo code generator

install notion ubuntu

zsh-autocomplete

install yabai macos

cwpanel install rocky linux 9

tar command not found

Correct use of command substitution in Bash

how to push changes to github from terminal

ollama uninstall

rocky 9 mysql

nodejs jest only on specific file

windows ubuntu wsl

ignore a folder in SVN

npm install for express the version 5

add local .env to vercel env

pihole unbound install and config

Create SSH Key

kitty terminal install

X server (windows, macos and linux) for docker gui

rename a local Git branch

delete a Git branch locally and remotely

laravel generate sitemap xml

max github file size

find-large-files-linux

git pull accept all incoming changes

upgrade to fedora 40 from terminal

upgrade all packages pnpm

imperative configmap command

how to show ip address in linux

linux libreoffice cli convert docx to txt

how to install .run file in ubuntu

start tensorboard

how to install xampp in ubuntu

matlab install toolbox

how to open matlab after installation

matlab installation key

rebasing git

how to check if apache is installed

install dual boot ubuntu windows 10

yay install pip

Hold linux kernel packages

Install apache utils

Install necessary software properties

Configure automatic restart

list pods all namespaces

Change remote origin url

echo path replace : with linebreak

git unstage all

install miniconda

docker keeps creating new containers

set git credentials with access token

docker ststus

instalar insomnia linux

install jenkins docker

install docker debian 5

AddDbContext

AddNewtonsoftJson

zip except folder

install openmpi ubuntu

remove anydesk from startup linux

stabalize a linux shell with one python command