mirror of
https://codeberg.org/leana8959/.files.git
synced 2025-12-06 14:49:14 +00:00
fish: drop fish-based tmux scripts
This commit is contained in:
parent
f6a9abe226
commit
c031e42fd2
7 changed files with 5 additions and 124 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue