This commit is contained in:
parent
533b8db65f
commit
2c66524d18
7 changed files with 38 additions and 108 deletions
|
@ -23,16 +23,14 @@
|
|||
tmux-sessionizer = {
|
||||
enable = true;
|
||||
|
||||
directories =
|
||||
searchPaths =
|
||||
let
|
||||
inherit (config.xdg.userDirs) documents extraConfig;
|
||||
|
||||
repos = extraConfig.XDG_REPOS_DIR;
|
||||
in
|
||||
options.cli.tmux-sessionizer.directories.default
|
||||
++ [
|
||||
[
|
||||
repos
|
||||
"${repos}/*"
|
||||
documents
|
||||
];
|
||||
};
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
enable = true;
|
||||
enableDmenuIntegration = true;
|
||||
|
||||
directories =
|
||||
searchPaths =
|
||||
let
|
||||
inherit (config.xdg.userDirs) documents extraConfig;
|
||||
|
||||
|
|
|
@ -15,56 +15,49 @@ in
|
|||
enable = mkEnableOption "Enable tmux-sessionizer";
|
||||
enableDmenuIntegration = mkEnableOption "Enable dmenu integration";
|
||||
|
||||
directories = mkOption {
|
||||
searchPaths = mkOption {
|
||||
default = [ config.home.homeDirectory ];
|
||||
type = types.listOf types.str;
|
||||
description = "List of directories for tmux-sessionizer to use.";
|
||||
description = "List of search paths for tmux-sessionizer to use.";
|
||||
};
|
||||
|
||||
# TODO: add TS_EXTRA_SEARCH_PATHS.
|
||||
# TODO: add TS_MAX_DEPTH.
|
||||
# TODO: add TS_SESSION_COMMANDS once I figure out what they're for.
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
home.packages = with pkgs; [
|
||||
tmux-sessionizer
|
||||
] ++ (optional cfg.enableDmenuIntegration (
|
||||
pkgs.writeShellApplication {
|
||||
name = "tmux-sessionizer-dmenu";
|
||||
];
|
||||
|
||||
text = ''
|
||||
# shellcheck disable=SC2046
|
||||
selected=$(find $(eval echo "$(xargs < "$XDG_CONFIG_HOME/tmux-sessionizer/directories")") -mindepth 1 -maxdepth 1 -type d | dmenu -i -l 20)
|
||||
home.file.".tmux-sessionizer".source = "${
|
||||
pkgs.writeShellApplication {
|
||||
name = ".tmux-sessionizer";
|
||||
|
||||
${pkgs.coreutils}/bin/nohup st -e tmux-sessionizer "$selected" >/dev/null 2>&1 &
|
||||
'';
|
||||
}
|
||||
));
|
||||
runtimeInputs = with pkgs; [
|
||||
tmux
|
||||
];
|
||||
|
||||
xdg.configFile = {
|
||||
"tmux-sessionizer/default".source = "${
|
||||
pkgs.writeShellApplication {
|
||||
name = ".tmux-sessionizer";
|
||||
text = ''
|
||||
set +o errexit
|
||||
set +o nounset
|
||||
|
||||
runtimeInputs = with pkgs; [
|
||||
tmux
|
||||
];
|
||||
|
||||
text = ''
|
||||
set +o errexit
|
||||
set +o nounset
|
||||
|
||||
if [[ "$PWD" == "${config.xdg.userDirs.extraConfig.XDG_REPOS_DIR}/os" || "$PWD" == "${config.xdg.userDirs.extraConfig.XDG_REPOS_DIR}/personal" || "$PWD" == "${config.xdg.userDirs.extraConfig.XDG_REPOS_DIR}/work" ]]; then
|
||||
clear
|
||||
|
||||
return
|
||||
fi
|
||||
|
||||
tmux new-window -d -n scratch
|
||||
nvim .
|
||||
if [[ "$PWD" == "${config.xdg.userDirs.extraConfig.XDG_REPOS_DIR}/os" || "$PWD" == "${config.xdg.userDirs.extraConfig.XDG_REPOS_DIR}/personal" || "$PWD" == "${config.xdg.userDirs.extraConfig.XDG_REPOS_DIR}/work" ]]; then
|
||||
clear
|
||||
'';
|
||||
}
|
||||
}/bin/.tmux-sessionizer";
|
||||
|
||||
"tmux-sessionizer/directories".text = builtins.concatStringsSep "\n" cfg.directories;
|
||||
};
|
||||
return
|
||||
fi
|
||||
|
||||
tmux new-window -d -n scratch
|
||||
nvim .
|
||||
clear
|
||||
'';
|
||||
}
|
||||
}/bin/.tmux-sessionizer";
|
||||
|
||||
xdg.configFile."tmux-sessionizer/tmux-sessionizer.conf".text = ''
|
||||
TS_SEARCH_PATHS=(${builtins.concatStringsSep " " cfg.searchPaths})
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
@ -4,13 +4,13 @@ with pkgs;
|
|||
|
||||
stdenv.mkDerivation {
|
||||
pname = "tmux-sessionizer";
|
||||
version = "unstable-2024-10-30";
|
||||
version = "unstable-2025-06-19";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "theprimeagen";
|
||||
repo = "tmux-sessionizer";
|
||||
rev = "6ebd16e2e30a8c0ebd77f0c2ce18cb46db8397fa";
|
||||
sha256 = "bZXt9TyMU1Ed/WR0/ahMQ4oyIi6yXLKnXKYPPNBt/s4=";
|
||||
rev = "7edf8211e36368c29ffc0d2c6d5d2d350b4d729b";
|
||||
sha256 = "sha256-4QGlq/cLbed7AZhQ3R1yH+44gmgp9gSzbiQft8X5NwU=";
|
||||
};
|
||||
|
||||
buildInputs = [
|
||||
|
@ -19,22 +19,11 @@ stdenv.mkDerivation {
|
|||
tmux
|
||||
];
|
||||
|
||||
patches = [
|
||||
./move-default-script.patch
|
||||
|
||||
(fetchpatch {
|
||||
name = "feat: Made folders more dynamic";
|
||||
url = "https://patch-diff.githubusercontent.com/raw/ThePrimeagen/tmux-sessionizer/pull/2.patch";
|
||||
sha256 = "sha256-4/4rzve49T3FHnl9WWUPJVcb0NQojMQjIVnEZGwVAsY=";
|
||||
})
|
||||
|
||||
./shorten-suggested-paths.patch
|
||||
./sort-suggestions.patch
|
||||
];
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cp tmux-sessionizer $out/bin/tmux-sessionizer
|
||||
chmod +x $out/bin/tmux-sessionizer
|
||||
'';
|
||||
|
||||
# TODO: create another patch to sort results.
|
||||
}
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
diff --git a/tmux-sessionizer b/tmux-sessionizer
|
||||
index fa1bec5..536d4b0 100755
|
||||
--- a/tmux-sessionizer
|
||||
+++ b/tmux-sessionizer
|
||||
@@ -14,8 +14,8 @@ has_session() {
|
||||
hydrate() {
|
||||
if [ -f $2/.tmux-sessionizer ]; then
|
||||
tmux send-keys -t $1 "source $2/.tmux-sessionizer" c-M
|
||||
- elif [ -f $HOME/.tmux-sessionizer ]; then
|
||||
- tmux send-keys -t $1 "source $HOME/.tmux-sessionizer" c-M
|
||||
+ elif [ -f "$XDG_CONFIG_HOME/tmux-sessionizer/default" ]; then
|
||||
+ tmux send-keys -t $1 "source $XDG_CONFIG_HOME/tmux-sessionizer/default" c-M
|
||||
fi
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
diff --git a/tmux-sessionizer b/tmux-sessionizer
|
||||
index 8fa4153..3e607d7 100755
|
||||
--- a/tmux-sessionizer
|
||||
+++ b/tmux-sessionizer
|
||||
@@ -22,13 +22,16 @@ hydrate() {
|
||||
if [[ $# -eq 1 ]]; then
|
||||
selected=$1
|
||||
else
|
||||
- selected=$(find $(eval echo $(xargs < "$XDG_CONFIG_HOME/tmux-sessionizer/directories")) -mindepth 1 -maxdepth 1 -type d | fzf)
|
||||
+ selected=$(find $(eval echo $(xargs < "$XDG_CONFIG_HOME/tmux-sessionizer/directories")) -mindepth 1 -maxdepth 1 -type d | sed "s|$HOME/||" | fzf)
|
||||
fi
|
||||
|
||||
if [[ -z $selected ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
+# Add Home path back.
|
||||
+selected="$HOME/$selected"
|
||||
+
|
||||
selected_name=$(basename "$selected" | tr . _)
|
||||
tmux_running=$(pgrep tmux)
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
diff --git a/tmux-sessionizer b/tmux-sessionizer
|
||||
index 3e607d7..27729b1 100755
|
||||
--- a/tmux-sessionizer
|
||||
+++ b/tmux-sessionizer
|
||||
@@ -22,7 +22,7 @@ hydrate() {
|
||||
if [[ $# -eq 1 ]]; then
|
||||
selected=$1
|
||||
else
|
||||
- selected=$(find $(eval echo $(xargs < "$XDG_CONFIG_HOME/tmux-sessionizer/directories")) -mindepth 1 -maxdepth 1 -type d | sed "s|$HOME/||" | fzf)
|
||||
+ selected=$(find $(eval echo $(xargs < "$XDG_CONFIG_HOME/tmux-sessionizer/directories")) -mindepth 1 -maxdepth 1 -type d | sed "s|$HOME/||" | sort | fzf)
|
||||
fi
|
||||
|
||||
if [[ -z $selected ]]; then
|
Loading…
Add table
Add a link
Reference in a new issue