mirror of
https://github.com/elwrcl/copnix.git
synced 2026-10-31 14:28:02 +03:00
helix
This commit is contained in:
1 parent
ec8d0d2432
commit
e73e6faf1e
3 files changed
+81
-41
No files matched your search
@@ -3,8 +3,8 @@
|
|||||||
flake.homeModules.home-helix-keys =
|
flake.homeModules.home-helix-keys =
|
||||||
{ ... }:
|
{ ... }:
|
||||||
let
|
let
|
||||||
float = cmd: ":sh zellij run --floating --close-on-exit -- ${cmd}";
|
float = cmd: ":sh zellij run --floating --close-on-exit -- ${cmd} | ignore";
|
||||||
floatKeep = cmd: ":sh zellij run --floating -- ${cmd}";
|
floatKeep = cmd: ":sh zellij run --floating -- ${cmd} | ignore";
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
programs.helix.settings.keys = {
|
programs.helix.settings.keys = {
|
||||||
|
|||||||
@@ -283,7 +283,6 @@
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
# Written every time `jj describe`/`jj commit` opens $EDITOR.
|
|
||||||
name = "jjdescription";
|
name = "jjdescription";
|
||||||
rulers = [
|
rulers = [
|
||||||
51
|
51
|
||||||
|
|||||||
@@ -3,44 +3,78 @@
|
|||||||
flake.homeModules.home-helix-sidebar =
|
flake.homeModules.home-helix-sidebar =
|
||||||
{ config, pkgs, ... }:
|
{ config, pkgs, ... }:
|
||||||
let
|
let
|
||||||
|
open = pkgs.writeShellApplication {
|
||||||
|
name = "hx-open";
|
||||||
|
runtimeInputs = [
|
||||||
|
config.programs.zellij.finalPackage
|
||||||
|
pkgs.gnused
|
||||||
|
];
|
||||||
|
text = ''
|
||||||
|
if [ "$#" -eq 0 ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
quote() {
|
||||||
|
printf "'%s'" "$(printf '%s' "$1" | sed "s/'/&&/g")"
|
||||||
|
}
|
||||||
|
zellij action move-focus right >/dev/null 2>&1 || true
|
||||||
|
|
||||||
|
if [ "$#" -eq 1 ] && [ -d "$1" ]; then
|
||||||
|
command=":cd $(quote "$1")"
|
||||||
|
else
|
||||||
|
args=""
|
||||||
|
for path in "$@"; do
|
||||||
|
args="$args $(quote "$path")"
|
||||||
|
done
|
||||||
|
command=":open$args"
|
||||||
|
fi
|
||||||
|
|
||||||
|
zellij action write 27 >/dev/null 2>&1
|
||||||
|
zellij action write-chars "$command" >/dev/null 2>&1
|
||||||
|
zellij action write 13 >/dev/null 2>&1
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
sidebarConfig = pkgs.writeTextDir "yazi.toml" ''
|
sidebarConfig = pkgs.writeTextDir "yazi.toml" ''
|
||||||
[mgr]
|
[mgr]
|
||||||
ratio = [ 0, 1, 0 ]
|
ratio = [ 1, 1, 2 ]
|
||||||
show_hidden = false
|
show_hidden = false
|
||||||
show_symlink = false
|
show_symlink = true
|
||||||
linemode = "none"
|
linemode = "size"
|
||||||
scrolloff = 4
|
scrolloff = 4
|
||||||
|
sort_by = "natural"
|
||||||
|
sort_dir_first = true
|
||||||
|
|
||||||
|
[[plugin.prepend_fetchers]]
|
||||||
|
url = "*"
|
||||||
|
run = "git"
|
||||||
|
group = "git"
|
||||||
|
|
||||||
|
[[plugin.prepend_fetchers]]
|
||||||
|
url = "*/"
|
||||||
|
run = "git"
|
||||||
|
group = "git"
|
||||||
|
|
||||||
|
[opener]
|
||||||
|
edit = [
|
||||||
|
{ run = '$EDITOR "$@"', block = false, for = "unix" },
|
||||||
|
]
|
||||||
'';
|
'';
|
||||||
|
|
||||||
sidebar = pkgs.writeShellApplication {
|
sidebar = pkgs.writeShellApplication {
|
||||||
name = "hx-sidebar";
|
name = "hx-sidebar";
|
||||||
runtimeInputs = [
|
runtimeInputs = [
|
||||||
pkgs.yazi
|
pkgs.yazi
|
||||||
config.programs.zellij.finalPackage
|
pkgs.git
|
||||||
pkgs.coreutils
|
|
||||||
];
|
];
|
||||||
text = ''
|
text = ''
|
||||||
cd "''${1:-.}"
|
cd "''${1:-.}"
|
||||||
|
|
||||||
export YAZI_CONFIG_HOME=${sidebarConfig}
|
export YAZI_CONFIG_HOME=${sidebarConfig}
|
||||||
|
export EDITOR=${open}/bin/hx-open
|
||||||
|
export VISUAL="$EDITOR"
|
||||||
|
|
||||||
marker="''${XDG_RUNTIME_DIR:-/tmp}/hx-sidebar.''${ZELLIJ_SESSION_NAME:-none}"
|
echo $$ > "''${XDG_RUNTIME_DIR:-/tmp}/hx-sidebar.''${ZELLIJ_SESSION_NAME:-none}"
|
||||||
chooser=$(mktemp -t hx-sidebar.XXXXXX)
|
exec yazi .
|
||||||
trap 'rm -f "$chooser" "$marker"' EXIT
|
|
||||||
echo $$ > "$marker"
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
: > "$chooser"
|
|
||||||
yazi . --chooser-file="$chooser"
|
|
||||||
|
|
||||||
picked=$(head -n 1 "$chooser")
|
|
||||||
[ -n "$picked" ] || break
|
|
||||||
|
|
||||||
zellij action move-focus right
|
|
||||||
zellij action write 27
|
|
||||||
zellij action write-chars ":open '$picked'"
|
|
||||||
zellij action write 13
|
|
||||||
done
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -57,28 +91,35 @@
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
marker="''${XDG_RUNTIME_DIR:-/tmp}/hx-sidebar.''${ZELLIJ_SESSION_NAME}"
|
marker="''${XDG_RUNTIME_DIR:-/tmp}/hx-sidebar.''${ZELLIJ_SESSION_NAME}"
|
||||||
|
pid=""
|
||||||
if [ -e "$marker" ] && kill -0 "$(cat "$marker")" 2>/dev/null; then
|
if [ -r "$marker" ]; then
|
||||||
zellij action toggle-fullscreen
|
pid=$(cat "$marker")
|
||||||
else
|
|
||||||
rm -f "$marker"
|
|
||||||
|
|
||||||
id=$(zellij action new-pane \
|
|
||||||
--direction right \
|
|
||||||
--name files \
|
|
||||||
--close-on-exit \
|
|
||||||
-- ${sidebar}/bin/hx-sidebar "$PWD")
|
|
||||||
|
|
||||||
zellij action move-pane --pane-id "$id" left
|
|
||||||
for _ in 1 2 3 4 5; do
|
|
||||||
zellij action resize --pane-id "$id" decrease right
|
|
||||||
done
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "$pid" ] && [ "$(cat "/proc/$pid/comm" 2>/dev/null || true)" = "yazi" ]; then
|
||||||
|
kill "$pid"
|
||||||
|
rm -f "$marker"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -f "$marker"
|
||||||
|
|
||||||
|
id=$(zellij action new-pane \
|
||||||
|
--direction right \
|
||||||
|
--name files \
|
||||||
|
--close-on-exit \
|
||||||
|
-- ${sidebar}/bin/hx-sidebar "$PWD")
|
||||||
|
|
||||||
|
zellij action move-pane --pane-id "$id" left >/dev/null
|
||||||
|
for _ in 1 2 3 4 5; do
|
||||||
|
zellij action resize --pane-id "$id" decrease right >/dev/null 2>&1
|
||||||
|
done
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
home.packages = [
|
home.packages = [
|
||||||
|
open
|
||||||
sidebar
|
sidebar
|
||||||
toggle
|
toggle
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in new issue
Block a user