https://github.com/mdouchement/upathex
Handle Bash tilde & env vars in path.
https://github.com/mdouchement/upathex
env environment environment-variables path tilde
Last synced: 12 months ago
JSON representation
Handle Bash tilde & env vars in path.
- Host: GitHub
- URL: https://github.com/mdouchement/upathex
- Owner: mdouchement
- Created: 2022-08-13T17:44:47.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-08-13T17:49:39.000Z (almost 4 years ago)
- Last Synced: 2025-02-24T17:17:12.855Z (over 1 year ago)
- Topics: env, environment, environment-variables, path, tilde
- Language: Go
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# upathex
`upathex` is a package that expands paths like a shell interpreter.
## Usage
```go
path := upathex.ExpandTilde("~/bin")
// => /home/mdouchement/bin
path := upathex.ExpandTilde("~root/bin")
// => /root/bin
path := upathex.ExpandEnv("$HOME/bin")
// => /home/mdouchement/bin
path := upathex.ExpandEnv("${HOME}/bin")
// => /home/mdouchement/bin
path := upathex.ExpandEnvWithCustom("$TROLOLO/bin", map[string]string{
"TROLOLO": "trololo-lolo",
})
// => trololo-lolo/bin
```
## License
**MIT**
## Contributing
All PRs are welcome.
1. Fork it
2. Create your feature branch (git checkout -b my-new-feature)
3. Commit your changes (git commit -am 'Add some feature')
5. Push to the branch (git push origin my-new-feature)
6. Create new Pull Request