Add basic tmux support
This commit is contained in:
parent
af58abcf3c
commit
d483cad685
8 changed files with 120 additions and 4 deletions
|
@ -3,5 +3,6 @@
|
||||||
./nvim
|
./nvim
|
||||||
./vscode.nix
|
./vscode.nix
|
||||||
./intellij.nix
|
./intellij.nix
|
||||||
|
./tmux.nix
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -188,10 +188,7 @@ in {
|
||||||
type = "lua";
|
type = "lua";
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
barbar-nvim
|
||||||
plugin = barbar-nvim;
|
|
||||||
config = builtins.readFile ./plugin/barbar.lua;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
{
|
||||||
plugin = nvim-surround;
|
plugin = nvim-surround;
|
||||||
|
@ -204,6 +201,12 @@ in {
|
||||||
rainbow-delimiters-nvim
|
rainbow-delimiters-nvim
|
||||||
|
|
||||||
rustaceanvim
|
rustaceanvim
|
||||||
|
|
||||||
|
{
|
||||||
|
plugin = vim-tmux-navigator;
|
||||||
|
config = builtins.readFile ./plugin/vim-tmux-navigator.lua;
|
||||||
|
type = "lua";
|
||||||
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
extraLuaConfig = ''
|
extraLuaConfig = ''
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
vim.keymap.set("", "<Space>", "<Nop>")
|
||||||
|
vim.keymap.set("", "<C-Space>", "<Nop>")
|
||||||
vim.g.mapleader = " "
|
vim.g.mapleader = " "
|
||||||
vim.g.maplocalleader = " "
|
vim.g.maplocalleader = " "
|
||||||
|
|
||||||
|
|
5
home/features/coding/nvim/plugin/vim-tmux-navigator.lua
Normal file
5
home/features/coding/nvim/plugin/vim-tmux-navigator.lua
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
-- Navigate vim panes better
|
||||||
|
vim.keymap.set("n", "<c-k>", ":wincmd k<CR>")
|
||||||
|
vim.keymap.set("n", "<c-j>", ":wincmd j<CR>")
|
||||||
|
vim.keymap.set("n", "<c-h>", ":wincmd h<CR>")
|
||||||
|
vim.keymap.set("n", "<c-l>", ":wincmd l<CR>")
|
43
home/features/coding/tmux.nix
Normal file
43
home/features/coding/tmux.nix
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
{pkgs, ...}: {
|
||||||
|
home.packages = [pkgs.tmuxinator-fzf-start];
|
||||||
|
programs.tmux = {
|
||||||
|
enable = true;
|
||||||
|
keyMode = "vi";
|
||||||
|
customPaneNavigationAndResize = true;
|
||||||
|
mouse = true;
|
||||||
|
tmuxinator.enable = true;
|
||||||
|
shortcut = "Space";
|
||||||
|
extraConfig = ''
|
||||||
|
bind % split-window -h -c "#{pane_current_path}"
|
||||||
|
bind \'%\' split-window -v -c "#{pane_current_path}"
|
||||||
|
'';
|
||||||
|
plugins = with pkgs; [
|
||||||
|
tmuxPlugins.vim-tmux-navigator
|
||||||
|
{
|
||||||
|
plugin = tmuxPlugins.catppuccin;
|
||||||
|
extraConfig = ''
|
||||||
|
set -g status-position top
|
||||||
|
|
||||||
|
set -g @catppuccin_window_left_separator ""
|
||||||
|
set -g @catppuccin_window_right_separator " "
|
||||||
|
set -g @catppuccin_window_middle_separator " █"
|
||||||
|
set -g @catppuccin_window_number_position "right"
|
||||||
|
|
||||||
|
set -g @catppuccin_window_default_fill "number"
|
||||||
|
set -g @catppuccin_window_default_text "#W"
|
||||||
|
|
||||||
|
set -g @catppuccin_window_current_fill "number"
|
||||||
|
set -g @catppuccin_window_current_text "#W"
|
||||||
|
|
||||||
|
set -g @catppuccin_status_modules_right "directory session"
|
||||||
|
set -g @catppuccin_status_left_separator " "
|
||||||
|
set -g @catppuccin_status_right_separator ""
|
||||||
|
set -g @catppuccin_status_fill "icon"
|
||||||
|
set -g @catppuccin_status_connect_separator "no"
|
||||||
|
|
||||||
|
set -g @catppuccin_directory_text "#{pane_current_path}"
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
|
@ -6,4 +6,5 @@
|
||||||
feishin-appimage = pkgs.callPackage ./feishin {};
|
feishin-appimage = pkgs.callPackage ./feishin {};
|
||||||
protonup-rs = pkgs.callPackage ./protonup-rs {};
|
protonup-rs = pkgs.callPackage ./protonup-rs {};
|
||||||
rofi-audio-switcher = pkgs.callPackage ./rofi-audio-switcher {};
|
rofi-audio-switcher = pkgs.callPackage ./rofi-audio-switcher {};
|
||||||
|
tmuxinator-fzf-start = pkgs.callPackage ./tmuxinator-fzf-start {};
|
||||||
}
|
}
|
||||||
|
|
6
pkgs/tmuxinator-fzf-start/default.nix
Normal file
6
pkgs/tmuxinator-fzf-start/default.nix
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
{pkgs, ...}:
|
||||||
|
pkgs.stdenv.mkDerivation rec {
|
||||||
|
name = "tmuxinator-fzf-start";
|
||||||
|
dontUnpack = true;
|
||||||
|
installPhase = "install -Dm755 ${./tmuxinator-fzf-start.sh} $out/bin/tmuxinator-fzf-start";
|
||||||
|
}
|
55
pkgs/tmuxinator-fzf-start/tmuxinator-fzf-start.sh
Executable file
55
pkgs/tmuxinator-fzf-start/tmuxinator-fzf-start.sh
Executable file
|
@ -0,0 +1,55 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
###############################################################
|
||||||
|
# Tmuxinator FZF Start
|
||||||
|
###############################################################
|
||||||
|
#
|
||||||
|
# Uses fzf to provide a selection list for tmuxinator projects.
|
||||||
|
#
|
||||||
|
# Overview:
|
||||||
|
#
|
||||||
|
# tmuxinator-fzf-start.sh will open fzf with a multi select
|
||||||
|
# list of tmuxinator projects. Upon selecting project/s each
|
||||||
|
# project will have `tmuxinator start` run, and when complete
|
||||||
|
# tmux will be attached, or if tmux is already running, a
|
||||||
|
# session selection interface will be provided.
|
||||||
|
#
|
||||||
|
# If an initial query is provided, and only one match results,
|
||||||
|
# the project will be automatically opened without user input.
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
#
|
||||||
|
# tmuxinator-fzf-start.sh
|
||||||
|
# tmuxinator-fzf-start.sh "Query"
|
||||||
|
#
|
||||||
|
# Expectations:
|
||||||
|
#
|
||||||
|
# - tmuxinator is on $PATH
|
||||||
|
# - fzf is on $PATH
|
||||||
|
# - tmux is on $PATH
|
||||||
|
|
||||||
|
# Allow the user to select projects via fzf
|
||||||
|
SELECTED_PROJECTS=$(tmuxinator list -n |
|
||||||
|
tail -n +2 |
|
||||||
|
fzf --prompt="Project: " -m -1 -q "$1")
|
||||||
|
|
||||||
|
if [ -n "$SELECTED_PROJECTS" ]; then
|
||||||
|
# Set the IFS to \n to iterate over \n delimited projects
|
||||||
|
IFS=$'\n'
|
||||||
|
|
||||||
|
# Start each project without attaching
|
||||||
|
for PROJECT in $SELECTED_PROJECTS; do
|
||||||
|
tmuxinator start "$PROJECT" --no-attach # force disable attaching
|
||||||
|
done
|
||||||
|
|
||||||
|
# If inside tmux then select session to switch, otherwise just attach
|
||||||
|
if [ -n "$TMUX" ]; then
|
||||||
|
SESSION=$(tmux list-sessions -F "#S" | fzf --prompt="Session: ")
|
||||||
|
if [ -n "$SESSION" ]; then
|
||||||
|
tmux switch-client -t "$SESSION"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
tmux attach-session
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
Loading…
Reference in a new issue