100 Days of Code: Day 07

zsh: segmentation fault (core dumped)  build/waybar
zsh: segmentation fault (core dumped)  build/waybar
zsh: segmentation fault (core dumped)  build/waybar
zsh: segmentation fault (core dumped)  build/waybar
zsh: segmentation fault (core dumped)  build/waybar
zsh: segmentation fault (core dumped)  build/waybar
zsh: segmentation fault (core dumped)  build/waybar

I know what breaks it, but I don’t know why.

100 Days of Code: Day 06

The way I implemented caching was flawed. I cached the entire formatted directory, for example:

# this is: -t c6 --pre '%F{magenta}'
__prompt_dir_glob__cache[/tmp/something]='%F{magenta}somet\u2025'

This will break if the user wants the last directory to always be not-truncated.

So, we now cache only the glob that matches, and check prefix/suffix/truncate every time.

The second thing I did was to split ::add_glob out to its own file, and add a --help for it.

Finally, I also renamed things to use underscores. While I prefer hyphens in functions, the P10K API requires segments to be called prompt_$name. To prevent confusion, I just renamed everything. I may revert this in the future, though.

100 Days of Code: Day 05

Things are in place enough that I can make the demo more interesting. The demo now shows three use cases:

  • /some/path with the default separator (causing all / to be colored as the previous dir).
  • /some/path with a colored separator.
  • / 〉some 〉path (but using nerd-fonts powerline symbols) with a seperated root.

(Ignore my bad cropping job pls)

/img/p10k-demo-day-05.png

The better demo in action.

The demo, of course, turned up some more bugs, so I took care of those too. I came up with an idea for next time, so I wrote a TODO as well.

I’m pretty confident 3 or 4 more days on this will do it.

100 Days of Code: Day 04

After some discussion on the issue, it was decided that the WidnowId class isn’t consistently defined as signed or unsigned. So, by not specifying either, we can adapt if projects do eventually agree.

Neat.


Anyway, not much happening today due to a family event.

The most code I wrote today was in response to a Reddit post, where I showed someone how zparseopts works. Here’s a link to the demo code on TIO. I think I want to make a more comprehensive post on zparseopts, maybe write a compatible Bash function to do the same thing. (Or maybe I should stop taking on new projects.)

That said, I also fixed a bug in p10k-dir-glob.

100 Days of Code: Day 03

More writing my custom powerlevel10k segment. It’s to a point where I have it in my $ZDOTDIR/.zshrc. I split the main logic into its own autoloaded function file, since I expect most users to have cache misses on 90% of their sessions. Now that I’m using it daily, I’ll probably get distracted by whatever paper cuts still remain in the project.

I also made an error? miscalculation? in a contribution to waybar. I’m curious what is wrong, because I made what looks like a fix to me, but not to the owner. They are almost certainly right, but I’m hoping to learn why.

100 Days of Code: Day 01

One of the most popular languages out there is C++. I have next to no experience in it, but I might as well try.

Today’s project was hacking on Waybar, regarding this issue.

My changes wouldn’t build, but I’m hoping to get feedback or have someone else fix them. Either way, it will help me learn how namespaces work in C++, and contribute to this project in the future.

100 Days of Code: Day 00

Today, I started by pulling up a partially finished project: A replacement for Powerlevel10k’s default directory segment.

I intend to talk with romkatv (the author of P10k) to get some insight on how I can use the cache when displaying the prompt.

I ran a diff between my existing code and where I ended today, it can be found here.

The project will live here.

Intermediate Sed Usage

If you’ve been using Linux for any small length of time, you’ve likely used sed before. Most of the time, you’ve seen it in the form of sed "s/find/replace/g", so you simply go to it whenever there’s a replacement you want to do.

But sed stands for stream editor, and as a tool it can do more than just find and replace.

[Read More]
sed  linux  code 

Neodots

Ah, dotfile management… Tools like GNU Stow for symlink management and tools like Chezmoi for templating.

Everyone has their own solution, and none of them are for me.

[Read More]