Flexible context #55
Description
*Maybe
Instead of needing to follow a strict file structure, let users create a file that sets the account for that directory and all its children, unless one of its children also has the file.
This will mean users won't need to have a root directory that contains all their repos if they don't want.
For example, it would enable something like this:
/home/john/
|-- personal/
| |-- memes/
| |-- finances/
| |-- repos/
| |-- .gh_account
|-- school/
| |-- maths/
| |-- computer-science/
| |-- reports/
| |-- repos/
| |-- .gh_account
The two repos/
directories do not share the same parent, but they each contain a .gh_account
file which can be read by gamon to set the correct account.
For users (like me) who like having all their repos together, it is easy to achieve the same result as using GAM_REPO_ROOT_DIR
:
/home/john/
|-- repos/
| |-- personal/
| | |-- .gh_account
| |-- work/
| |-- .gh_account
|-- memes/
|-- finances/
I might create a new command (e.g. gam account [path]
that will use the promptui
module that will list the available accounts (from ~/.config/gh/hosts.yml
) and let you select one, which should make it a bit harder for users to just create .gh_account
and put whatever they want in it.
Activity
peter-bread commentedon Feb 27, 2024
This will not actually be breaking. Not for now at least.
I will make it so it checks for a config file first, and if it doesn't find one, then attempt to use the original method.
peter-bread commentedon Feb 27, 2024
Might be something along the lines of this:
peter-bread commentedon Feb 27, 2024
Realised as well I can add code in here to load specific
.gitconfig
files based on the account in.gh_account
.peter-bread commentedon Feb 27, 2024
peter-bread commentedon Sep 28, 2024
Simpler solution:
Use something like direnv or mise, and in that file set an environment variable like
GH_ACCOUNT
.Then just check against that variable
peter-bread commentedon Oct 28, 2024
Need to do this bc its annoying me
peter-bread commentedon Jan 19, 2025
Also an option:
Create a main config file which has a default account to use, then a list of paths and which account to use when in them or their children. Can still have the option of overriding with a local file: