diff --git a/nix/homeModules/common/fish/default.nix b/nix/homeModules/common/fish/default.nix index d5ce080e..ab3f5afc 100644 --- a/nix/homeModules/common/fish/default.nix +++ b/nix/homeModules/common/fish/default.nix @@ -52,21 +52,11 @@ in { # # Scripts and functions # - xdg.configFile = let - allFunctions = - lib.mapAttrs' - (path: _: - lib.nameValuePair "fish/functions/${path}" {source = "${./functions}/${path}";}) - (builtins.readDir ./functions); - in - builtins.removeAttrs allFunctions [ - "fish/functions/__tmux-attach-or-switch.fish" - "fish/functions/__tmux-maybe-create.fish" - "fish/functions/__tmux-register-session.fish" - "fish/functions/tmux-home.fish" - "fish/functions/tmux-last.fish" - "fish/functions/tmux-sessionizer.fish" - ]; + xdg.configFile = + lib.mapAttrs' + (path: _: + lib.nameValuePair "fish/functions/${path}" {source = "${./functions}/${path}";}) + (builtins.readDir ./functions); programs.fish = { interactiveShellInit = builtins.readFile ./shellInit.fish; diff --git a/nix/homeModules/common/fish/functions/__tmux-attach-or-switch.fish b/nix/homeModules/common/fish/functions/__tmux-attach-or-switch.fish deleted file mode 100644 index d88c56ed..00000000 --- a/nix/homeModules/common/fish/functions/__tmux-attach-or-switch.fish +++ /dev/null @@ -1,12 +0,0 @@ -function __tmux-attach-or-switch \ - --description "Attach (not in tmux) or switch (in tmux) to a session" - ### Arguments: - set session_name $argv[1] - - if [ -z "$TMUX" ] - tmux attach-session -t $session_name - else - tmux switch-client -t $session_name - end - -end diff --git a/nix/homeModules/common/fish/functions/__tmux-maybe-create.fish b/nix/homeModules/common/fish/functions/__tmux-maybe-create.fish deleted file mode 100644 index b3bf71a4..00000000 --- a/nix/homeModules/common/fish/functions/__tmux-maybe-create.fish +++ /dev/null @@ -1,13 +0,0 @@ -function __tmux-maybe-create \ - --description "Create a tmux session with sensible defaults if it doesn't exist yet" - ### Arguments: - set session_name $argv[1] - set session_dir $argv[2] - - if pgrep tmux 2>&1 >/dev/null; or ! tmux has -t=$session_name 2>/dev/null - # Note: - # Maybe it can be interesting to read from an envvar of array, where each element is a call back - tmux new-session -ds $session_name -c $session_dir - end - -end diff --git a/nix/homeModules/common/fish/functions/__tmux-register-session.fish b/nix/homeModules/common/fish/functions/__tmux-register-session.fish deleted file mode 100644 index e6bd60fc..00000000 --- a/nix/homeModules/common/fish/functions/__tmux-register-session.fish +++ /dev/null @@ -1,11 +0,0 @@ -function __tmux-register-session \ - --description "Register the session, if it's not set yet" - ### Effects: - set last /tmp/TMUX_LAST - - set this (tmux display-message -p '#S') - if [ ! -f "$last" ]; or [ (cat "$last") != "$this" ] - echo "$this" >"$last" - end - -end diff --git a/nix/homeModules/common/fish/functions/tmux-home.fish b/nix/homeModules/common/fish/functions/tmux-home.fish deleted file mode 100644 index 92457d8c..00000000 --- a/nix/homeModules/common/fish/functions/tmux-home.fish +++ /dev/null @@ -1,19 +0,0 @@ -function tmux-home \ - --description "Take me back to ~" - - set session_name home - - if pgrep tmux 2>&1 >/dev/null - __tmux-register-session - end - - if pgrep tmux 2>&1 >/dev/null; or ! tmux has -t=$session_name 2>/dev/null - tmux \ - new-session -ds home \; \ - new-window -t home \; \ - select-window -t "home":1 - end - - __tmux-attach-or-switch $session_name - -end diff --git a/nix/homeModules/common/fish/functions/tmux-last.fish b/nix/homeModules/common/fish/functions/tmux-last.fish deleted file mode 100644 index d0aac1f6..00000000 --- a/nix/homeModules/common/fish/functions/tmux-last.fish +++ /dev/null @@ -1,16 +0,0 @@ -function tmux-last \ - --description "Toggle the last tmux session" - - set tmux_last /tmp/TMUX_LAST - if [ ! -f $tmux_last ] - echo "Last session is not yet set" - return 1 - end - - set session_name (cat $tmux_last) - - __tmux-register-session - __tmux-maybe-create $session_name /tmp - __tmux-attach-or-switch $session_name - -end diff --git a/nix/homeModules/common/fish/functions/tmux-sessionizer.fish b/nix/homeModules/common/fish/functions/tmux-sessionizer.fish deleted file mode 100644 index 5f5ab762..00000000 --- a/nix/homeModules/common/fish/functions/tmux-sessionizer.fish +++ /dev/null @@ -1,38 +0,0 @@ -function tmux-sessionizer \ - --description "Manage tmux sessions in specific folders with fzf" - - set selected \ - (begin - fd . $REPO_PATH --exact-depth 2 --hidden --type d - fd . $WORKTREE_PATH --exact-depth 3 --hidden --type d - fd . $PLAYGROUND_PATH --exact-depth 1 --hidden --type d - echo "dotfiles" - echo "password-store" - end 2> /dev/null | sed -e "s|^$HOME|~|" | fzf) - - set selected (echo $selected | sed -e "s|^~|$HOME|") - - if [ -z "$selected" ] - commandline --function repaint - return 0 - end - - # derive session name based on selected path - # dots are meaningful in tmux, remove them - set session_name (echo $selected | tr . _) - - # fixup special cases, override derived session_name if necessary - # this should be id for non-special cases - switch $selected - case dotfiles - set selected ~/.dotfiles - case password-store - set selected $PASSWORD_STORE_DIR - end - - # effects - __tmux-register-session $session_name - __tmux-maybe-create $session_name $selected - __tmux-attach-or-switch $session_name - -end