-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Retrieve env prompt prefixes for use in p10k #992
Comments
Hey @ChampiYann! Great to see you diving into the depths of pkgx and p10k. I remember our last dance around the digital bonfire. How’s the coding journey treating you this time? To display the console.error(`%s %s`, blurple('env'), pkgs.map(x => `+${utils.pkg.str(x)}`).join(' ')) This line of code formats the activated packages to have a For example, if you had a way to execute your application such that it only performed the function pkgx_env_prompt() {
# Assuming `app.ts` can be executed to just output the activated environments
local pkgx_output="$(deno run --allow-env src/app.ts --internal-activate)"
[[ -n "$pkgx_output" ]] && echo "$pkgx_output"
}
# Then in your POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS or POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
# add a custom element that calls this function
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(... pkgx_env_prompt ...) This is a hypothetical example. You would need to adjust the execution command ( Remember, for this to work:
Regarding your question about the The function performs several key operations:
Given the context, to invoke this function, one would need to call it from another TypeScript or JavaScript file, passing the required Example of how it might be invoked in code (not directly from the provided context but based on the function signature): import activate from 'src/modes/internal.activate.ts';
// Example directory and options
const dir = new Path('/path/to/directory');
const options = {
powder: [{ /* PackageRequirement objects */ }],
logger: {/* Logger object */}
};
// Invoke the function
activate(dir, options).then(() => {
console.log('Activation complete.');
}).catch(error => {
console.error('Activation failed:', error);
}); This example assumes the existence of The structure of the
Therefore, the {
project: string;
constraint: string;
update?: boolean;
} I hope this helps! If you have any more questions, feel free to ask. Sources
|
I fixed it in a different and, I guess, more correct way by using the PKGX_POWDER and PKGX_PKGENV environment variables. function prompt_pkgx() {
# Check if POWDER and PKGENV variables are set
if [ -z "$PKGX_POWDER" ] || [ -z "$PKGX_PKGENV" ]; then
return
fi
# Variable to store matched values
matched_values=""
# Loop through each value in POWDER
for powder_value in ${(s: :)PKGX_POWDER}; do
# Loop through each value in PKGENV
for pkgenv_value in ${(s: :)PKGX_PKGENV}; do
# Check if PKGENV value starts with POWDER value
if [[ "$pkgenv_value" == "$powder_value"* ]]; then
# Append the matched value to the variable
matched_values="$matched_values $pkgenv_value"
fi
done
done
p10k segment -i PACKAGE_ICON -t "$matched_values" -r
} The function first checks if the variables exit. Of course, with p10k you can put the segment anywhere you want. I just decided to add it above the prompt line on the right. |
That's pretty cool, @ChampiYann ; we'll have to find a place in the docs for that. |
Hi,
I just started using pkgx and I already love it.
One of the things I couldn't get to work was to get de
(+pkg)
to show up at the beginning of my command prompt.I am using p10k but even without I still can't get it to work.
It is possible to build custom prompt extensions in p10k so I would like to try that but I can't find where I would be able to find the currently activated environments.
Can anyone tell me how I would be able to list them?
Thanks!
The text was updated successfully, but these errors were encountered: