mirror of
https://github.com/callumio/nixfiles.git
synced 2025-12-17 11:39:19 +00:00
homeConfigurations
This commit is contained in:
parent
d578b55e7d
commit
e897059004
19 changed files with 5 additions and 1 deletions
66
home/c/programs/tmux/default.nix
Normal file
66
home/c/programs/tmux/default.nix
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
{pkgs, ...}: {
|
||||
programs.tmux = {
|
||||
enable = true;
|
||||
shortcut = "x";
|
||||
baseIndex = 0;
|
||||
escapeTime = 0;
|
||||
clock24 = true;
|
||||
mouse = true;
|
||||
|
||||
plugins = with pkgs.tmuxPlugins; [
|
||||
sensible
|
||||
yank
|
||||
{
|
||||
plugin = onedark-theme;
|
||||
extraConfig = "\n";
|
||||
}
|
||||
{
|
||||
plugin = resurrect;
|
||||
extraConfig = ''
|
||||
set -g @resurrect-strategy-vim 'session'
|
||||
set -g @resurrect-strategy-nvim 'session'
|
||||
set -g @resurrect-capture-pane-contents 'on'
|
||||
'';
|
||||
}
|
||||
{
|
||||
plugin = continuum;
|
||||
extraConfig = ''
|
||||
set -g @continuum-restore 'on'
|
||||
set -g @continuum-boot 'off'
|
||||
set -g @continuum-save-interval '10'
|
||||
'';
|
||||
}
|
||||
];
|
||||
|
||||
extraConfig = ''
|
||||
set-option -g status-position top
|
||||
set-option -g default-terminal "tmux-256color"
|
||||
set-option -sa terminal-features ',xterm-256color:RGB'
|
||||
set-window-option -g mode-keys vi
|
||||
|
||||
bind / split-window -h -c "#{pane_current_path}"
|
||||
bind \\ split-window -v -c "#{pane_current_path}"
|
||||
bind c new-window -c "#{pane_current_path}"
|
||||
|
||||
bind-key -r s run-shell "tmux display-popup -E 'tmux-sessionizer -s'"
|
||||
bind-key -r f run-shell "tmux display-popup -E 'tmux-sessionizer -p'"
|
||||
bind-key -r m run-shell "tmux switch-client -t main"
|
||||
bind S choose-tree
|
||||
|
||||
bind -r k select-pane -U
|
||||
bind -r j select-pane -D
|
||||
bind -r h select-pane -L
|
||||
bind -r l select-pane -R
|
||||
'';
|
||||
};
|
||||
|
||||
home.packages = [
|
||||
(pkgs.writeShellApplication {
|
||||
name = "tmux-sessionizer";
|
||||
runtimeInputs = [pkgs.tmux pkgs.ghq];
|
||||
text = ''
|
||||
${builtins.readFile ./tmux-sessionizer.sh}
|
||||
'';
|
||||
})
|
||||
];
|
||||
}
|
||||
59
home/c/programs/tmux/tmux-sessionizer.sh
Executable file
59
home/c/programs/tmux/tmux-sessionizer.sh
Executable file
|
|
@ -0,0 +1,59 @@
|
|||
#!/bin/env bash
|
||||
|
||||
pick_session() {
|
||||
selected=$(ghq list -p | fzf || exit 0)
|
||||
|
||||
if [[ -z $selected ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
selected_name=$(basename "$selected" | tr . _)
|
||||
tmux_running=$(pgrep tmux)
|
||||
|
||||
if [[ -z $TMUX ]] && [[ -z $tmux_running ]]; then
|
||||
tmux new-session -s "$selected_name" -c "$selected"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! tmux has-session -t="$selected_name" 2>/dev/null; then
|
||||
tmux new-session -ds "$selected_name" -c "$selected"
|
||||
fi
|
||||
|
||||
tmux switch-client -t "$selected_name"
|
||||
}
|
||||
|
||||
switch_session() {
|
||||
selected=$(tmux list-sessions -F "#{session_name}" | fzf || exit 0)
|
||||
|
||||
if [[ -z $selected ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
tmux switch-client -t "$selected"
|
||||
}
|
||||
|
||||
selections=()
|
||||
while getopts "sp" opt; do
|
||||
case ${opt} in
|
||||
p) selections+=("pick") ;;
|
||||
s) selections+=("switch") ;;
|
||||
\?)
|
||||
echo "Invalid usage"
|
||||
exit
|
||||
;;
|
||||
esac
|
||||
done 2>/dev/null
|
||||
|
||||
case ${#selections[@]} in
|
||||
1) selection=${selections[0]} ;;
|
||||
*)
|
||||
echo "Please make exactly one selection (-p or -s)" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
shift $((OPTIND - 1))
|
||||
|
||||
case $selection in
|
||||
"pick") pick_session ;;
|
||||
"switch") switch_session ;;
|
||||
esac
|
||||
Loading…
Add table
Add a link
Reference in a new issue