Skip to content
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

A theme viewer #616

Open
amrinder-cs opened this issue Sep 26, 2024 · 6 comments
Open

A theme viewer #616

amrinder-cs opened this issue Sep 26, 2024 · 6 comments

Comments

@amrinder-cs
Copy link

Okay i might sound too ambitious with this, but i believe we could have a theme viewer/selector to select the theme we need.

Like a small tool which can help us choose the theme which suits us the best, it could be something fzf based which shows us the bash PS1 in each line and we should be able to simply select it .

Here's kinda what i mean:
omb with fzf

But instead of showing simply the theme names, it should show the different available bash prompts.

It can be a nice QOL update. I'm a bash noob honestly and im not very familiar with oh-my-bash code, but i wish someone would help me make it 🥺

@RobLoach
Copy link
Contributor

While a prompt viewer may be a challenge, there is the Themes wiki page:
https://github.com/ohmybash/oh-my-bash/wiki/Themes

If you find any missing, feel free to add them.

@RobLoach
Copy link
Contributor

RobLoach commented Oct 2, 2024

I've added the themes plugin over at #620 which gives you an easy way to switch between the themes.

Would be pretty cool to add to it and have a dynamic switcher.
Screenshot from 2024-10-02 00-27-58

@amrinder-cs
Copy link
Author

I tried using the command echo -e $PS1 > file.txt, but when I ran cat -e file.txt, it printed gibberish like \u and \w instead of evaluating them.

What I need is a way to output my $PS1 variable as it appears in the terminal into files. Once I have that, the rest should be straightforward.

Here's a snippet I’m working with:

for file in *; do [ -f "$file" ] && head -n 1 "$file"; done | fzf --height 40% --info=inline --ansi

Or perhaps we can have the PS1's one in each line to make it simple, idk.

Output Preview:

theme previewer

These files would contain the actual $PS1 values. The challenge I'm facing is figuring out how to get those $PS1 values correctly.

@akinomyoga
Copy link
Contributor

I tried using the command echo -e $PS1 > file.txt,

You can use printf '%s\n' "${PS1@P}" > file.txt

@amrinder-cs
Copy link
Author

You can use printf '%s\n' "${PS1@P}" > file.txt
Thanks a lot, so far i've come up with:
fzf --height 40% --info=inline --preview "printf '%s' \"${PS1@P}\""

currently it just shows the current theme in the preview section, but with that omb theme implemented, i guess we can have a theme switcher, which takes in the arguments from the {+} (as theme name ) and switch the theme before preview.

However im very unsure about how to switch theme, tried foolishly setting export OSH_THEME="whatever" but it didnt work , ,

@amrinder-cs
Copy link
Author

So i did OSH_THEME=random and manually saved the files with theme names, and added preview via fzf:

omb_theme_viewer

However i think we could have something better than this, need suggestions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants