add(fish): clone_repo function, tmux-vim function and bindings

This commit is contained in:
Léana 江 2023-04-01 22:27:20 +02:00
parent 67c4b31e8a
commit a801d13874
4 changed files with 40 additions and 9 deletions

View file

@ -1,14 +1,32 @@
# idea stolen from the one and only primeagen
# aiming to create one session per directory
# Inspired by the one and only primeagen
function tmux-vim
set -f session (snakecase $PWD)
# This script names each session with the name of the directory where tmux is invoked
# If there's already a session present for that directory, fuzzy search your way through
function tmux-vim --description 'NeoVim, but in tmux (better)'
tmux start-server
if not tmux has-session -t $session > /dev/null 2>&1
tmux new-session -d -s $session -n 'nvim' "nvim $argv"
if not tmux has-session -t "$PWD" > /dev/null 2>&1
# create new session and attach to it
tmux new-session -s "$PWD" -n "nvim" "nvim $argv"
return $status
else
# attach to existing session(s)
set -f choice (string join ';' "new" (tmux list-sessions -F "#{session_name}") | tr ';' '\n' | fzf)
end
tmux attach-session -t $session
if test -z $choice
echo "[empty choice]"
else if test $choice = "new"
read -l -P "How would you like to name this session? " custom_name
tmux new-session -s "$custom_name"@"$PWD" -n 'nvim' "nvim $argv"
return $status
else
tmux attach-session -t "$choice"
return $status
end
commandline --function repaint
end