Blog: 2023-08-07

From razwiki
Jump to navigation Jump to search

Currently waiting on nushell to download, straight from cargo. Apparently it hasn't been packaged for debian/ubuntu, which is a bit surprising. That might be a worthwhile project, if nushell is any good.

Reading vim koans made me think maybe I'm barking up the wrong tree trying to replace tmux with vim. But I'm pretty tired of tmux, and generally environments that have a bespoke configuration language. And the command line interface of tmux is a bit wack. I tried at one point to make tmux automatically start, but canceled that for some reason, maybe having to do with tmux updates. Probably a tool I don't need.

Anyways that reminds me of the ideas I had which prompted me to blog:

  • an old one from an April blog:

Idea: a spellchecker kinda thing that fixes common typos in a variety of places, like command line, email, text editor. Really just spellchecker that doesn't do things you don't want, like smart quotes

Much like lsp, it would be nice to have this functionality abstracted such that different environments could reuse the core logic of what replacements are to be done. I suppose a bunch of applications have a spelling corrections list, and this is even built in to MacOS. But I don't use macos much any more. Anyways it could be good, since a command line could implement typo fixes using abbrs, email web client using javascript, text editor using built in abbrs or something. But ideally the corrections would be stored in a single location. not a super high priority tho

Ok the other idea is this sort of tree of programming, where I document what depends on what, and then identify proprietary / suboptimal components I'd like to get rid of. Like

computing experience

hardware
  operating system
    desktop environment
    browser

programming language: c, make, python

python: depends on c
  package manager: pip, poetry
  web framework: django, flask

text editor: vim, emacs, neovim

and then rate the various components, thus understanding what is a solid foundation and what isn't Like how I'm using reattach-to-user-namespace with tmux, don't like that leaf, figure out if I can get rid of it. What problems does it solve, what problems does it create.

That's a sorta silly example since that only depends on macos, but tmux is a good example, I've used it for years, it has some use, but it has some frustrations too.

Started trying to write up my patch for fish tab completion:

I have a patch https://github.com/razzius/fish-shell/commit/5338832bd3733ff8df58613a5342a4baf08046af which implements what @krobelus and @krackers discussed above, namely it removes the `COMPLETE_REPLACES_TOKEN` logic that removed the different-case options from the tab completion. It's similar to the @krackers comment https://github.com/fish-shell/fish-shell/issues/7944#issuecomment-1455792841 but smaller since it only deals with smart-case tab completion.

Working on this led me to a design question. Currently the tab completion underlines the prefix of the result that matches the token you have typed:

![image](https://github.com/fish-shell/fish-shell/assets/2244895/a0bd2e0a-b0a0-4080-9c41-caa2deaa6ed2)

However if the result matches the token but is a different case, should the corresponding characters with different case also be underlined?

The way the current display code works, the prefix is set in one place and printed before each of the results, which doesn't work if the case is different between the results. My patch removes the prefix underlining entirely; it was simple to implement but is a regression in functionality. Here's a screenshot of how my patch looks:

![image](https://github.com/fish-shell/fish-shell/assets/2244895/627f4149-ad09-456c-a450-fb5f2f3fe54d)

As you can see, the options with different case are now showing, but the underlined `c` in the results is gone.

I don't expect my patch will be merged as-is since it removes the prefix underlining entirely but I hope it is useful as a starting point.

I imagine the ideal solution is keep prefix underlining and to underline the prefix of different case, preserving the case of the result. So it would look like:

<img width="650" alt="underlined" src="https://github.com/fish-shell/fish-shell/assets/2244895/1494eb06-baa8-4aef-8909-0aecf09d58e4">

---

To implement this would require changing `pager.set_prefix` behavior to be smart about the case of the prefix it prints, since depending on the result, the prefix in the result could show as lowercase or uppercase.

Tests would be a welcome addition to pin down the expected behavior. Unfortunately the test file relating to tab completion, `tests/checks/tmux-complete.fish`, is apparently flakey and disabled on CI; perhaps that should be tracked as another issue.

But now I'm realizing the other comment has the functionality I describe as the ideal... maybe. Should try to get that patch working. But it also has a reference to a function in another file `set_completions` which has a different signature now, and I'm not sure how the logic maps.

So maybe the move is to ask for the full patch, ideally in commit form.