File tree workaround for Helix
2023-08-02
Categories: Development Environment
Many people have expressed that the absence of a file tree is what prevents them from using Helix.
If, for some reasons, you cannot use the PR #5768, here’s a workaround to create a file tree using WezTerm and nnn
The idea here is to implement a custom opener in nnn.
When navigating to a file, it will be opened using hx
in the right pane.
When opening another file, it checks if there is a running instance of hx
in the right pane and sends the :open $1\r
command to that pane.
Here’s the implementation:
1#!/usr/bin/env sh 2 3fpath="$1" 4 5pane_id=$(wezterm cli get-pane-direction right) 6if [ -z "${pane_id}" ]; then 7 pane_id=$(wezterm cli split-pane --right --percent 80) 8fi 9 10program=$(wezterm cli list | awk -v pane_id="$pane_id" '$3==pane_id { print $6 }') 11if [ "$program" = "hx" ]; then 12 echo ":open ${fpath}\r" | wezterm cli send-text --pane-id $pane_id --no-paste 13else 14 echo "hx ${fpath}" | wezterm cli send-text --pane-id $pane_id --no-paste 15fi 16 17wezterm cli activate-pane-direction --pane-id $pane_id right
1$ export NNN_OPENER=nnn-hx.sh 2$ nnn -c
This allows you to efficiently manage your files and work with Helix using WezTerm and nnn
.
Related Posts:
- Turning Helix into an IDE with the help of WezTerm and CLI tools
- Debug Rust in Helix using lldb-vscode: display the contents of local string variables
- How to debug Rust in Helix?
- WezTerm: quickly select a command and open it in a new pane
- Open same file in already running instance of Helix