Skip to main content

A simple .env file manager with IDE autocompletion support and global variable access

Project description

mydotenv

A simple Python package to manage environment variables in your .env file with command-line interface and direct variable access in Python code.

Installation

Using pipx (Recommended)

pipx install mydotenv

Using pip

pip install mydotenv

From Source

git clone https://github.com/banddude/mydotenv.git
cd mydotenv
pip install -e .

Usage

Python Usage

To access environment variables directly in your code without prefixes:

# Import this way for direct variable access
from mydotenv import *

# Now you can use environment variables directly
print(HI)  # Prints the value of HI from your .env file

The package also provides IDE autocompletion support through type hints, so your IDE won't show errors for environment variables.

Command Line Interface

  1. Print a variable's value:
mydotenv API_KEY
  1. Add or update a variable:
mydotenv NEW_KEY=value
mydotenv "KEY_WITH_SPACES=value with spaces"
  1. Delete a variable:
mydotenv delete VARIABLE_NAME
  1. View all variables:
mydotenv
  1. Open the .env file in your default editor:
mydotenv open

Custom Command Name

You can set a custom command name to use instead of mydotenv:

mydotenv --set-command dotman

Now you can use either mydotenv or dotman to run commands:

dotman NEW_KEY=value
dotman delete NEW_KEY
dotman open  # Opens the .env file in your editor

When you set a new command name, it replaces any previous custom command name.

Features

  • Manage environment variables from the command line
  • Access environment variables directly in Python code without prefixes
  • IDE autocompletion support through auto-generated type hints
  • Set custom command names for easier use
  • Open and edit your .env file with a simple command
  • Preserves comments and formatting in .env file
  • Handles values with spaces and special characters
  • Works from any directory
  • Creates and manages .env file in your current directory

Dependencies

  • python-dotenv >= 1.0.0

Configuration

  • The package stores its configuration in ~/.config/mydotenv/config.env
  • Custom command names are managed through symlinks in ~/.local/bin

License

MIT License - feel free to use this package in your projects!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mydotenv-0.2.2.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mydotenv-0.2.2-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file mydotenv-0.2.2.tar.gz.

File metadata

  • Download URL: mydotenv-0.2.2.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for mydotenv-0.2.2.tar.gz
Algorithm Hash digest
SHA256 f13aab87e7db45749896ee2ff286f1aaad7d79ac8bde22db991e0c24acb0a7e1
MD5 c54c49b047bf1ede4399dfac24eee6c1
BLAKE2b-256 a401d09de5a4c37a09b8d3e3e34a200dcecaab2d2054f7884f317bbac457d9a6

See more details on using hashes here.

File details

Details for the file mydotenv-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: mydotenv-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for mydotenv-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 cce502de5f5dcd5216bc6e708a6ac68192b8b1d52ee82fcbc736aba27926530e
MD5 896bf084d511c97374a8124bf2b437bf
BLAKE2b-256 f0a700a374899c3c494e399249b6f88e04e24d7968278c50a1c6863d6fbae0e8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page