···
9
+
tmux-sessionizer = pkgs.writeScriptBin "tmux-sessionizer" ''
12
+
hist_file=~/.cache/sessionizer.hist
14
+
if [[ $# -eq 1 ]]; then
17
+
selected=$((tac "$hist_file"; find ~/ ~/projects -mindepth 1 -maxdepth 1 -type d -not -path '*/[.]*'; echo /etc/nixos) | awk '!seen[$0]++' | fzf --print-query | tail -n 1)
20
+
if [[ -z $selected ]]; then
24
+
echo "$selected" >> $hist_file
26
+
selected_name=$(basename "$selected" | tr . _)
27
+
tmux_running=$(pgrep tmux)
29
+
if [[ -z $TMUX ]] && [[ -z $tmux_running ]]; then
30
+
tmux new-session -s $selected_name -c $selected
34
+
if ! tmux has-session -t=$selected_name 2> /dev/null; then
35
+
tmux new-session -ds $selected_name -c $selected
38
+
tmux switch-client -t $selected_name
···
···
# https://github.com/ThePrimeagen/.dotfiles/blob/master/bin/.local/scripts/tmux-sessionizer
182
-
sessionizer = pkgs.writeScript "sessionizer.sh" ''
183
-
#!/usr/bin/env bash
185
-
hist_file=~/.cache/sessionizer.hist
187
-
if [[ $# -eq 1 ]]; then
190
-
selected=$((tac "$hist_file"; find ~/ ~/projects -mindepth 1 -maxdepth 1 -type d -not -path '*/[.]*'; echo /etc/nixos) | awk '!seen[$0]++' | fzf --print-query | tail -n 1)
193
-
if [[ -z $selected ]]; then
197
-
echo "$selected" >> $hist_file
199
-
selected_name=$(basename "$selected" | tr . _)
200
-
tmux_running=$(pgrep tmux)
202
-
if [[ -z $TMUX ]] && [[ -z $tmux_running ]]; then
203
-
tmux new-session -s $selected_name -c $selected
207
-
if ! tmux has-session -t=$selected_name 2> /dev/null; then
208
-
tmux new-session -ds $selected_name -c $selected
211
-
tmux switch-client -t $selected_name
···
bind -T copy-mode-vi v send-keys -X begin-selection
bind -T copy-mode-vi y send-keys -X copy-selection-and-cancel
246
-
bind-key -r f run-shell "tmux neww ${sessionizer}"
246
+
bind-key -r f run-shell "tmux neww tmux-sessionizer"
bind-key r source-file ~/.config/tmux/tmux.conf