Compare commits
2 Commits
4ab5ad76cf
...
d7056e8f38
Author | SHA1 | Date | |
---|---|---|---|
d7056e8f38 | |||
9147a68f0b |
@ -87,6 +87,7 @@
|
||||
"share.tbmrs.nl"
|
||||
"vault.local.tbmrs.nl"
|
||||
"paperless.local.tbmrs.nl"
|
||||
"monitor.local.tbmrs.nl"
|
||||
];
|
||||
};
|
||||
|
||||
|
@ -1,9 +1,38 @@
|
||||
{ config, lib, ... }:
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
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 {
|
||||
options = {
|
||||
settings.applications.zellij.enable = lib.mkOption {
|
||||
@ -19,6 +48,15 @@ in {
|
||||
enable = true;
|
||||
};
|
||||
|
||||
programs.zoxide = {
|
||||
enable = true;
|
||||
enableZshIntegration = true;
|
||||
};
|
||||
|
||||
home.packages = [
|
||||
sesh
|
||||
];
|
||||
|
||||
home.file.zellij = {
|
||||
target = ".config/zellij/config.kdl";
|
||||
text = ''
|
||||
@ -26,6 +64,7 @@ in {
|
||||
keybinds {
|
||||
normal {
|
||||
bind "Ctrl e" { ToggleFloatingPanes; SwitchToMode "normal"; }
|
||||
bind "Ctrl d" { Detach; }
|
||||
bind "Alt 1" { GoToTab 1; }
|
||||
bind "Alt 2" { GoToTab 2; }
|
||||
bind "Alt 3" { GoToTab 3; }
|
||||
|
@ -22,6 +22,7 @@ in {
|
||||
btop
|
||||
git
|
||||
yazi
|
||||
zoxide
|
||||
|
||||
just
|
||||
];
|
||||
|
Loading…
x
Reference in New Issue
Block a user