diff options
| author | Stefan Weigl-Bosker <stefan@s00.xyz> | 2025-03-24 18:22:17 -0400 |
|---|---|---|
| committer | Stefan Weigl-Bosker <stefan@s00.xyz> | 2025-03-24 18:22:17 -0400 |
| commit | 41b2d2f32f7da48b0113ca65cbda4380c5c4590e (patch) | |
| tree | 10998ac306e8714dbdd12421d8ba176ec710e709 /modules | |
| parent | 2b9b97ca70a7eb6121489f5ba2b40ee3077f332b (diff) | |
| download | home-41b2d2f32f7da48b0113ca65cbda4380c5c4590e.tar.gz | |
session management
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/neovim/default.nix | 1 | ||||
| -rw-r--r-- | modules/tmux/default.nix | 10 | ||||
| -rw-r--r-- | modules/tmux/session-load.sh | 37 |
3 files changed, 46 insertions, 2 deletions
diff --git a/modules/neovim/default.nix b/modules/neovim/default.nix index 525eee5..c584148 100644 --- a/modules/neovim/default.nix +++ b/modules/neovim/default.nix @@ -50,6 +50,7 @@ in base16-nvim telescope-nvim telescope-fzf-native-nvim + vim-obsession ]; extraLuaConfig = '' ${builtins.readFile ./nvim/init.lua} diff --git a/modules/tmux/default.nix b/modules/tmux/default.nix index 17a03eb..1897b89 100644 --- a/modules/tmux/default.nix +++ b/modules/tmux/default.nix @@ -7,8 +7,14 @@ in enable = lib.mkEnableOption "tmux"; }; - config = { - programs.tmux = lib.mkIf cfg.enable { + config = lib.mkIf cfg.enable { + home.packages = with pkgs; [ + fd + fzf + (writeShellScriptBin "session-load" "${builtins.readFile ./session-load.sh}") + ]; + + programs.tmux = { enable = true; customPaneNavigationAndResize = true; prefix = "C-Space"; diff --git a/modules/tmux/session-load.sh b/modules/tmux/session-load.sh new file mode 100644 index 0000000..509dabe --- /dev/null +++ b/modules/tmux/session-load.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +# usage: to create a project/session, create a symlink in .projects to the working directory +# the name of the symlink is the name of the project + +# if there is no path specific, prompt via fzf +if [[ $# -eq 1 ]]; then + input=$1 +else + input=$(cd $HOME/.projects; find . -type l | sed 's/^\.\///' | fzf) +fi + +if [[ -z $input ]]; then + exit 0 +fi + +project_name=$input +project_path=$(readlink "$HOME/.projects/$project_name") + +if [[ -z $(pgrep tmux) ]]; then + tmux start-sever # blocking +fi + +if ! tmux has-session -t $project_name 2> /dev/null; then + tmux new -ds $project_name -c $project_dir +fi + +if ! [[ -f ${project_path}/Session.vim ]] then + $(cd $project_path; nvim --headless +Obsession +q >/dev/null 2>&1) +fi + +if [[ $TMUX ]]; then + tmux switch-client -t $project_name +else + tmux a -t $project_name +fi + |