Required
Shell
Before we proceed further, I will quickly install my shell next, so I don’t go insane from using bash
.
Of course, you can use any shell you want.
In this case we’re using nu
Just say it: I use rust
btw.
In this case, we’ll be using xonsh.
There are some known slowdown issues with xonsh.
For a UNIX system, all Windows files (/mnt/c
) have the executable bit set,
so when WSL appends the Windows paths to $PATH
, like e.g. C:\Windows\System32
,
xonsh
thinks they’re all executables.
In reality, only .exe
s are executable but xonsh
isn’t interested in that fact,
causing massive slowdowns and hiccups, especially when using prompt-toolkit
.
You can mitigate this issue by
-
manually removing all
/mnt/c
paths from$PATH
in the Xonsh init file~/.config/xonsh/user.xsh [$PATH.remove(path) for path in $PATH.paths if path.startswith("/mnt/c/")](the
user.xsh
file gets loaded by my Xonshrc.xsh
file) -
disabling the addition of the Windows
PATH
for this WSL distribution/etc/wsl.conf [Interop]appendWindowsPath = False
This causes you to loose access to the win32yank.exe
executable, however,
as well as clip.exe
used by Xonsh’s prompt-toolkit
.
You will therefore either need to use your terminal emulator from within WSL, together with the native option above,
or manually add the aforementioned executables to Xonsh’s $PATH
.
-
Add
win32yank.exe
to theenv.xsh
file~/.config/xonsh/env.xsh windows = ["/mnt/c/Users/<username>/scoop/apps/win32yank/current"]$PATH.extend(windows) -
Terminal window sudo ln -s /mnt/c/Windows/System32/clip.exe /usr/bin/clip.exe
Install missing tools
To properly utilize my shell setup, I need to have the following tools available
- carapace-bin (command completer),
- starship (prompt),
- zoxide (smarter
cd
) - eza (better
ls
)
I am personally often using Zellij, despite Nushell recently implementing proper support for background jobs, as outlined in the corresponding section of the Nushell 0.103.0 patch notes.
This adds the job spawn
, job list
, job kill
and job unfreeze
(for unfreezing Ctrl + Z
jobs) commands to Nushell.
My dotfiles also still integrate pueue,
utilizing task.nu
.
For that, after installing pueue, you simply need a quick
systemctl --user enable pueuedsystemctl --user start pueued
to get started.
I would definitely recommend installing prompt_toolkit, While you’re at it, it shouldn’t be too hard to install pygments and setproctitle, too.
Set it as default
If you remember correctly, we set the login shell to bash
when creating the custom user,
so you might wonder why we didn’t directly set it to nu
.
Well nushell isn’t POSIX compliant, and neither does it want to be.
Therefore running nu
as a login shell might not be the absolute best experience you’ll ever have.
Instead, I include a code snippet in my dotfile’s ~/.bash_profile
that will let nu
take over any interactive shell,
while scripts, etc. that expect a POSIX
compliant shell can have their way.
if [[ $- == *i* && $(ps --no-header --pid $PPID --format comm) != "nu" && -z ${BASH_EXECUTION_STRING} ]] then exec nufi
-
Make sure that
xonsh
is listed in/etc/shells
(or add it)/etc/shells /usr/bin/xonsh -
Set your login shell
Terminal window chsh -s /usr/bin/xonsh
Special case for WezTerm
I’m previously used the terminal emulator WezTerm to run WSL.
There is a weird behaviour, however, with nushell, where a \n
gets inserted above the prompt on every keystroke.
If you look inside ~/.config/nushell/config.nu
$env.config.shell_integration.osc133 = ("WEZTERM_PANE" not-in $env)
osc133
is disabled while using WezTerm, mitigating the aformentioned issue.
This works flawlessly in windows, but unfortunately wezterm_pane
isn’t automatically set within wsl.
To hack this, i just add an export
to my ~/.bashrc
, which gets sourced by my dotfiles’ ~/.bash_profile
export WEZTERM_PANE=0
You could theoretically install wezterm
under WSL and use it that way,
but I prefer to launch WSL through Wezterm’s domain funcionality (domain "WSL:Arch"
) from Windows,
as fullscreen isn’t working correctly with Wayland and WSLg for me.
Nothing special to do for Xonsh, as far as I’m aware.