granted icon indicating copy to clipboard operation
granted copied to clipboard

Set Default Chrome Browser Profile

Open davidgfitzgerald opened this issue 5 months ago • 1 comments

Problem

Every time I run assume, I have to pass --browser-profile "Work" to open with my Chrome profile. I wish there was a way to configure this as a default.

If I don't open with this browser profile, Chrome opens in an anonymous profile in a new window. I don't want this, I always want to use my Chrome profile.

Otherwise this makes using assume verbose for me.

Feature Request

Instead of:

assume -s stepfn some-aws-profile --browser-profile "Work"

I should just be able to run:

assume -s stepfn some-aws-profile

Whether this be configurable as an env var or a setting in ~/.granted/config, I don't really mind.

I would expect to run:

granted settings set

and have the choice to set the default browser profile.

davidgfitzgerald avatar Jul 14 '25 09:07 davidgfitzgerald

Just found a workaround.

Edit ~/.zshenv and replace the assume alias with the following function:

# Augment assume calls with -c or -s to open
# in the default (chrome) browser.
assume() {
    export DEFAULT_BROWSER_PROFILE="Work"
    export GRANTED_ALIAS_CONFIGURED="true"

    # Check if any arguments contain -s or -c
    if [[ " $* " =~ " -s " ]] || [[ " $* " =~ " -c " ]]; then
        # When opening the browser, open the default chrome profile
        . assume "$@" --browser-profile $DEFAULT_BROWSER_PROFILE
    else
        # Run assume normally
        . assume "$@"
    fi
}

# Replace/remove the below 
# alias assume=". assume"

This has the effect of passing --browser-profile to assume calls, but only those that include -s or -c (calls that open the browser). The problem, as I discovered, with passing it all the time is that it means simple calls like assume inadvertently would open the browser since --browser-profile was passed.

davidgfitzgerald avatar Jul 14 '25 10:07 davidgfitzgerald