Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
YouTube Security VideosGoogle Cloud Tech: Vibe coding in the pit lane 🏁(23.09.2026 um 01:00 Uhr)
Sichere ProgrammierungBuild an Explainable Vendor-Risk Gate in Node.js(23.09.2026 um 00:27 Uhr)
Sichere ProgrammierungFrom p=none to Enforcement: A Working Sequence for DMARC Rollout(23.09.2026 um 00:40 Uhr)
Sichere ProgrammierungWhen OPA's Bundle Loader Runs Past a `.manifest` Typo(23.09.2026 um 00:53 Uhr)
Sichere ProgrammierungGovernance Attack Surface Review: Bybit(23.09.2026 um 01:00 Uhr)
Linux Tipps & HardeningOpenShot video editor is now available as a snap(23.09.2026 um 00:09 Uhr)
KI & AI VideosAI Revolution: AI Robots Are Beating Humans Now(23.09.2026 um 00:32 Uhr)
YouTube Security VideosGoogle Cloud Tech: Vibe coding in the pit lane 🏁(23.09.2026 um 01:00 Uhr)
Sichere ProgrammierungBuild an Explainable Vendor-Risk Gate in Node.js(23.09.2026 um 00:27 Uhr)
Sichere ProgrammierungFrom p=none to Enforcement: A Working Sequence for DMARC Rollout(23.09.2026 um 00:40 Uhr)
Sichere ProgrammierungWhen OPA's Bundle Loader Runs Past a `.manifest` Typo(23.09.2026 um 00:53 Uhr)
Sichere ProgrammierungGovernance Attack Surface Review: Bybit(23.09.2026 um 01:00 Uhr)
Linux Tipps & HardeningOpenShot video editor is now available as a snap(23.09.2026 um 00:09 Uhr)
KI & AI VideosAI Revolution: AI Robots Are Beating Humans Now(23.09.2026 um 00:32 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

Envar — Centrally manage environment variables to switch per directory

I've created a command-line tool called Envar. kakkun61 / envar This is a command-line tool that automatically switches values of environment variables based on the…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

I've created a command-line tool called Envar.







GitHub logo

kakkun61
/
envar



This is a command-line tool that automatically switches values of environment variables based on the current directory path.







envar



This is a command-line tool that automatically switches values of environment variables based on the current directory path.



  1. Place the envar binary

  2. Install the shell hook

  3. Write the configuration file



Place the envar binary



Run go build and place the binary file in your PATH.



Install the shell hook



Add this line to your .bashrc:



eval "$(envar hook)"



and add this line to your .bash_logout:



envar hook logout $$




Write the configuration file




The configuration file uses YAML. It is located at $CONFIG_DIR/envar/vars.yaml and $CONFIG_DIR/envar/execs.yaml. $CONFIG_DIR is the value returned by os.UserConfigDir().


vars.yaml is used to define environment variable values. For example:



FOO_VAR:
path/to/dir: foo-value-1
other/path: foo-value-2
other/path/never: foo-value-3
# This is a comment line
~/projects: foo-value-4
"spacial dir/path": foo-value-5
BAR_VAR:
another/dir: bar-value-1



The directory path/to/dir








This is a tool that allows switching environment variable values on a per-directory basis.



For example, you can configure an environment variable named FOO to return the value hoge when in the directory path/to/A, and fuga when in the directory path/to/B. This configuration is specified in a vars.yaml file like this:




FOO:
path/to/A: hoge
path/to/B: fuga






You can also configure environment variables to derive their values from the output of other commands.



This example is excerpted from my own configuration files and demonstrates switching between personal and work accounts when using the gh command.




# vars.yaml
GH_TOKEN:
/home/kazuki/Projects/Work:
gh: kakkun61_work
/home/kazuki/Projects:
gh: kakkun61









# execs.yaml
gh: gh auth token --user %s









Frequently Asked Questions Maybe



What's the difference between this and direnv?



Direnv works by writing configuration files containing environment variables you want to set in that directory, primarily for environment variables needed by all users of a project. These are project-specific environment variables.



In contrast, envar stores configuration files in the user-specific settings directory (e.g., ~/.config/envar). It's designed for setting environment variables that serve personal needs, such as account switching in the above example.



Which shell versions are supported?



Currently, only bash is supported. If there's demand, I may add support for zsh as well.






Mainly translated by Plamo Translation.

Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Envar — Centrally manage environment variables to switch per directory

Thematisch verwandte Begriffe: Envar, Centrally, manage, environment · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-58268 | SIPGO is a library for writing SIP services in the GO language. Prior to…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick