Score:0

How to fix bash syntax error while setting up Solarized themes for WSLtty?

br flag

I am trying set up the Solarized themes for the WSLtty terminal, so I followed this 2 step guide.

I did not want to install fish, so I only concentrated on the first 2 steps.

But when I ran:

eval (dircolors -c ~/.dir_colors | sed 's/>&\/dev\/null$//')

it is giving me this error:

-bash: syntax error near unexpected token `dircolors'
hr flag
Your link isn't working for me, however the syntax for *command substitution* in bash is `$(command)` rather than the fish shell's `(command)` - see for example [Fish equivalent of bash $(command) notation](https://stackoverflow.com/a/20918951/4440445)
Godspeed avatar
br flag
I changed the link now. I ran the same command like this eval $(dircolors -c ~/.dir_colors | sed 's/>&\/dev\/null$//') and it is giving me this error now setenv: command not found
muru avatar
us flag
It looks like that is supposed to be run in `fish`? The article puts it in `~/.config/fish/conf.d/omf.fish`. What is it you want to happen with that command?
Godspeed avatar
br flag
I want to set up solarized theme for my wsltty terminal. The command will be used to install the base colors.
pLumo avatar
in flag
This tutorial is clearly for `fish`, so not working in `bash`. You won't run `python` code with `php`.
Artur Meinild avatar
vn flag
I don't believe there is any point in running that command at all.
Score:0
vn flag

I would propose that you are:

  • Following a guide that is almost 4 years old to setup your WSL. WSL is only about 6 years old, and a lot has changed in the last few years. Even the fish shell has evolved quite a bit in that time period (although fish changes are not part of your issue).

  • Trying to "skip some steps", such as the usage of the fish shell. That particular guide was clearly written with fish in mind, and as pointed out in the comments, at least that command is written in fish-syntax, rather than Bash/POSIX.

  • Asking about WSLtty, which is a Windows program, on AskUbuntu.com. We do consider WSL questions to be on-topic here as long as they related to Ubuntu, but you'll find much more Ubuntu expertise here than WSL, and even less on WSLtty.

    That said, expertise on WSLtty is probably in short supply most anywhere nowadays. This is another side-effect of the fact that things were very different 4 years ago. Back then, I used WSLtty, considered it the best terminal option for WSL, and could have offered assistance on it.


So let me propose some alternatives, since I can't help you out (and most likely no one here on Ask Ubuntu can) on WSLtty:

First, while WSLtty was great for its time, most of the WSL world has moved on now that Windows Terminal has been around for a few years. Windows Terminal is:

  • From Microsoft
  • Open-source (Github repo)
  • Able to automatically detect and configure profiles for WSL (as well as PowerShell, CMD, Git Bash, and more) on launch
  • Actively developed
  • Designed to be the replacement for the legacy Windows Console Host (the terminal that launches when you just run "Ubuntu" in WSL from the Start Menu by default in Windows 10).
  • Configurable as the default terminal in Windows 11
  • Feature-rich: tabbed, configurable keybindings, has built-in color schemes (including solarized light and dark), etc.

Catch that last part? Solarized themes are included by default in Windows Terminal. You can easily switch by either:

  • Changing the default Appearance settings for all terminal profiles
  • Changing the Appearance settings for a particular profile
  • Starting from the command-line with a particular color-scheme
  • Ctrl+Shift+P to bring up the Command Palette, searching for "Color Scheme" and selecting it via GUI.
  • Creating a keybinding directly to switch the color scheme to that of your preference

The only thing that seems to be missing is a built-in way of doing it from the command-line. It's possible, certainly, by creating a utility to modify the settings.json directly, since Windows Terminal automatically detects changes. It's just not built-in.


You may or may not need the dircolors scheme. Try it out with just the top-level Solarized themes first. If you find you do want to utilize the dircolors color scheme, you'll find the general (non-fish) instructions on that project's Github Readme. It seems to be simply:

eval `dircolors /path/to/dircolorsdb`

Note that use of backticks for command substitution is discouraged (courtesy this answer), so I'd instead recommend:

eval $(dircolors /path/to/dircolorsdb)

With adjustment, of course, for the name of the theme you are switching to.


Side note: I love the fish shell myself, but I do recommend that newcomers learn a more POSIX-compliant shell first. The fish shell syntax is not POSIX-compliant; in other words, it won't work in other shells, and the standard syntax of other shells (often) will need tweaks to work in fish.

That said, there's good reason for that incompatibility. Subjectively, the fish shell syntax is better than (or at least as good as) POSIX in 95%+ of cases -- Sometimes much better than. However, sometimes a missing fish feature will make things more difficult.

The great thing about (eventually) learning and knowing both is that you can always run bash scripts inside of fish when you do need to drop back to the "standard" syntax.

In other words, you are probably doing the right thing by "skipping" fish for now, but do come back and check it out when you feel more comfortable in Linux.


Side-note/recommendation #2: Check out exa, a modern replacement for ls. It's much more "colorized" by default.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.