summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fish/conf.d/tmux.fish33
-rw-r--r--tmux/tmux.conf4
2 files changed, 30 insertions, 7 deletions
diff --git a/fish/conf.d/tmux.fish b/fish/conf.d/tmux.fish
index 707bd24..84cc6c3 100644
--- a/fish/conf.d/tmux.fish
+++ b/fish/conf.d/tmux.fish
@@ -16,20 +16,30 @@ end
function tmux::new
set -l session $argv[1]
+ set -l dir $argv[2]
_tmux::cleanup_default
if test -z "$session"
tmux::new (string join "" T (date +%s))
else
- tmux new-session -d -s $session
- tmux -2 attach-session -t $session || tmux -2 switch-client -t $session
+ set -l new_session_args -d -s $session
+ if test -n "$dir"
+ set new_session_args $new_session_args -c $dir
+ end
+ tmux new-session $new_session_args
+ if test -n "$TMUX"
+ tmux -2 switch-client -t "=$session"
+ else
+ tmux -2 attach-session -t "=$session"
+ end
end
end
function tmux::project
if test (count $argv) -eq 0
- set -l git_root (basename (git rev-parse --show-toplevel 2>/dev/null))
+ set -l git_root (git rev-parse --show-toplevel 2>/dev/null)
if test -n "$git_root"
- tmux::attach (basename $git_root)
+ set -l session_name (basename $git_root | string replace -a '.' '_')
+ tmux::attach $session_name $git_root
return
end
echo "tp: no argument given and not in a git repo"
@@ -42,16 +52,25 @@ function tmux::project
return 1
end
- cd $dir
- tmux::attach (basename $dir)
+ set -l session_name (basename $dir | string replace -a '.' '_')
+ tmux::attach $session_name $dir
end
function tmux::attach
set -l session $argv[1]
+ set -l dir $argv[2]
if test -z "$session"
+ if test -n "$TMUX"
+ echo "ta: no session name given and already inside tmux"
+ return 1
+ end
tmux attach-session || tmux::new
else
- tmux attach-session -t $session || tmux::new $session
+ if test -n "$TMUX"
+ tmux switch-client -t "=$session" 2>/dev/null; or tmux::new $session $dir
+ else
+ tmux attach-session -t "=$session" 2>/dev/null; or tmux::new $session $dir
+ end
end
end
diff --git a/tmux/tmux.conf b/tmux/tmux.conf
index a71c1ac..78c7a51 100644
--- a/tmux/tmux.conf
+++ b/tmux/tmux.conf
@@ -38,3 +38,7 @@ set-option -g pane-active-border-style fg=magenta,bold
set -g status-right '#{@hexai_status} #[fg=colour8]| %H:%M'
set -g status-right-length 120
set-environment -g HEXAI_TMUX_STATUS_THEME white-on-purple
+
+# Use csi-u (Kitty) extended key encoding for unambiguous modifier+key combos.
+# The default xterm format causes ambiguity with Ctrl/Alt/Shift combinations.
+set -g extended-keys-format csi-u