Skip to content

Instantly share code, notes, and snippets.

@ulfaslak
Last active February 2, 2024 11:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ulfaslak/250947819d6944d771184e2c60071abc to your computer and use it in GitHub Desktop.
Save ulfaslak/250947819d6944d771184e2c60071abc to your computer and use it in GitHub Desktop.
newpy () {
local lowercase_string="$(echo "$1" | tr '[:upper:]' '[:lower:]')" # Convert folder name to lowercase
local hyphenated_string="$(echo "$lowercase_string" | tr -c '[:alnum:]' '-')" # Convert non-alphanumeric characters to hyphens
local clean_string="$(echo "$hyphenated_string" | sed -e 's/^-*//' -e 's/-*$//')" # Remove leading and trailing hyphens
folder_name=$(date +%Y%m%d)-$clean_string # Prepend date, formatted like YYYYMMDD
mkdir -p <repository-where-i-want-my-adhoc-analysis-folders-to-reside>/$folder_name # Create folder
cd <repository-where-i-want-my-adhoc-analysis-folders-to-reside>/$folder_name # ... cd into it
virtualenv env # Create virtual env
source env/bin/activate # ... activate it
pip3 install -U flake8 black # Install packages you always use
code . # Launch VSCode
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment