Compare commits

...

2 Commits

3 changed files with 42 additions and 1 deletions

View File

@ -87,6 +87,7 @@
"share.tbmrs.nl" "share.tbmrs.nl"
"vault.local.tbmrs.nl" "vault.local.tbmrs.nl"
"paperless.local.tbmrs.nl" "paperless.local.tbmrs.nl"
"monitor.local.tbmrs.nl"
]; ];
}; };

View File

@ -1,9 +1,38 @@
{ config, lib, ... }: { config, lib, pkgs, ... }:
with lib; with lib;
let let
cfg = config.settings.applications.zellij; cfg = config.settings.applications.zellij;
sesh = pkgs.writeScriptBin "sesh" ''
#! /usr/bin/env sh
# Taken from https://github.com/zellij-org/zellij/issues/884#issuecomment-1851136980
# select a directory using zoxide
ZOXIDE_RESULT=$(${pkgs.zoxide}/bin/zoxide query --interactive)
# checks whether a directory has been selected
if [[ -z "$ZOXIDE_RESULT" ]]; then
# if there was no directory, select returns without executing
exit 0
fi
# extracts the directory name from the absolute path
SESSION_TITLE=$(echo "$ZOXIDE_RESULT" | sed 's#.*/##')
# get the list of sessions
SESSION_LIST=$(zellij list-sessions -n | awk '{print $1}')
# checks if SESSION_TITLE is in the session list
if echo "$SESSION_LIST" | grep -q "^$SESSION_TITLE$"; then
# if so, attach to existing session
zellij attach "$SESSION_TITLE"
else
# if not, create a new session
echo "Creating new session $SESSION_TITLE and CD $ZOXIDE_RESULT"
cd $ZOXIDE_RESULT
zellij attach -c "$SESSION_TITLE"
fi
'';
in { in {
options = { options = {
settings.applications.zellij.enable = lib.mkOption { settings.applications.zellij.enable = lib.mkOption {
@ -19,6 +48,15 @@ in {
enable = true; enable = true;
}; };
programs.zoxide = {
enable = true;
enableZshIntegration = true;
};
home.packages = [
sesh
];
home.file.zellij = { home.file.zellij = {
target = ".config/zellij/config.kdl"; target = ".config/zellij/config.kdl";
text = '' text = ''
@ -26,6 +64,7 @@ in {
keybinds { keybinds {
normal { normal {
bind "Ctrl e" { ToggleFloatingPanes; SwitchToMode "normal"; } bind "Ctrl e" { ToggleFloatingPanes; SwitchToMode "normal"; }
bind "Ctrl d" { Detach; }
bind "Alt 1" { GoToTab 1; } bind "Alt 1" { GoToTab 1; }
bind "Alt 2" { GoToTab 2; } bind "Alt 2" { GoToTab 2; }
bind "Alt 3" { GoToTab 3; } bind "Alt 3" { GoToTab 3; }

View File

@ -22,6 +22,7 @@ in {
btop btop
git git
yazi yazi
zoxide
just just
]; ];