mirror of
https://github.com/m-housh/dotfiles.git
synced 2026-02-15 06:32:40 +00:00
Update tmux-sessionator, and some other configs
This commit is contained in:
@@ -52,6 +52,9 @@ vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()')
|
|||||||
keymap('n', '<leader>f', '<cmd>:Format<CR>', default_options)
|
keymap('n', '<leader>f', '<cmd>:Format<CR>', default_options)
|
||||||
keymap('n', '<leader>F', '<cmd>:FormatWrite<CR>', default_options)
|
keymap('n', '<leader>F', '<cmd>:FormatWrite<CR>', default_options)
|
||||||
|
|
||||||
|
-- Turn off highlighting after search.
|
||||||
|
keymap('n', '<leader>n', '<cmd>:noh<cr>', default_options)
|
||||||
|
|
||||||
-- LuaSnip Keymaps
|
-- LuaSnip Keymaps
|
||||||
--local ls = require('luasnip')
|
--local ls = require('luasnip')
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,15 @@
|
|||||||
|
|
||||||
DEBUG=
|
DEBUG=
|
||||||
|
|
||||||
|
#################### Options ####################
|
||||||
|
|
||||||
declare -a paths=()
|
declare -a paths=()
|
||||||
|
declare chooseOpt=
|
||||||
|
|
||||||
|
zparseopts -D -- \
|
||||||
|
{c,-choose}=chooseOpt
|
||||||
|
|
||||||
|
#################### Helpers ####################
|
||||||
|
|
||||||
function debug_print {
|
function debug_print {
|
||||||
if [ -n "$DEBUG" ]; then
|
if [ -n "$DEBUG" ]; then
|
||||||
@@ -12,6 +20,7 @@ function debug_print {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function path_prepend() {
|
function path_prepend() {
|
||||||
declare arg
|
declare arg
|
||||||
for arg in "$@"; do
|
for arg in "$@"; do
|
||||||
@@ -19,27 +28,43 @@ function path_prepend() {
|
|||||||
# Check that arg is a directory but not a symlink
|
# Check that arg is a directory but not a symlink
|
||||||
# Bc on some of my machines ~/projects is a symlink to $REPOS
|
# Bc on some of my machines ~/projects is a symlink to $REPOS
|
||||||
test -d $arg && ! test -L $arg || continue
|
test -d $arg && ! test -L $arg || continue
|
||||||
|
paths=${paths//$arg}
|
||||||
|
paths=${paths/#$arg}
|
||||||
|
paths=${paths/%$arg}
|
||||||
paths=($arg $paths)
|
paths=($arg $paths)
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
#################### MAIN ####################
|
function setup_fuzzy_find_paths() {
|
||||||
|
|
||||||
if [[ $# -eq 1 ]]; then
|
|
||||||
selected=$1
|
|
||||||
else
|
|
||||||
path_prepend "$HOME" \
|
path_prepend "$HOME" \
|
||||||
"$HOME/projects" \
|
"$HOME/projects" \
|
||||||
"$REPOS/local" \
|
"$REPOS/local" \
|
||||||
$(find $REPOS/github.com -mindepth 1 -maxdepth 1 -type d -print | sort)
|
$(find "$REPOS/github.com" -mindepth 1 -maxdepth 1 -type d -print 2> /dev/null)
|
||||||
|
}
|
||||||
|
|
||||||
|
#################### MAIN ####################
|
||||||
|
|
||||||
|
declare choose="${chooseOpt[-1]}"
|
||||||
|
|
||||||
|
if [[ -n $choose ]]; then
|
||||||
|
debug_print "Choose from existing."
|
||||||
|
selected=$(
|
||||||
|
tmux list-sessions -F \#S | gum filter \
|
||||||
|
--placeholder "Pick a session..."
|
||||||
|
)
|
||||||
|
elif [[ "$#" -eq 1 ]]; then
|
||||||
|
debug_print "Using existing session: $1"
|
||||||
|
selected=$1
|
||||||
|
else
|
||||||
|
setup_fuzzy_find_paths
|
||||||
|
debug_print "fuzzy find paths: $paths"
|
||||||
|
|
||||||
debug_print "paths: $paths"
|
|
||||||
if [ -n "$DEBUG" ]; then
|
if [ -n "$DEBUG" ]; then
|
||||||
debug_print "Exiting because in debug mode."
|
debug_print "Exiting because in debug mode."
|
||||||
exit 0
|
exit 0
|
||||||
else
|
|
||||||
selected=$(find "${(@)paths}" -mindepth 1 -maxdepth 1 -type d | fzf)
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
selected=$(find "${(@)paths}" -mindepth 1 -maxdepth 1 -type d | fzf)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z $selected ]]; then
|
if [[ -z $selected ]]; then
|
||||||
@@ -50,13 +75,13 @@ selected_name=$(basename "$selected" | tr . _)
|
|||||||
tmux_running=$(pgrep tmux)
|
tmux_running=$(pgrep tmux)
|
||||||
|
|
||||||
if [[ -z $TMUX ]] && [[ -z $tmux_running ]]; then
|
if [[ -z $TMUX ]] && [[ -z $tmux_running ]]; then
|
||||||
tmux new-session -s $selected_name -c $selected
|
tmux new-session -s "$selected_name" -c "$selected"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create a session if it doesn't exist.
|
# Create a session if it doesn't exist.
|
||||||
if ! tmux has-session -t $selected_name 2> /dev/null; then
|
if ! tmux has-session -t "$selected_name" 2> /dev/null; then
|
||||||
tmux new-session -ds $selected_name -c $selected
|
tmux new-session -ds "$selected_name" -c "$selected"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
tmux switch-client -t $selected_name
|
tmux switch-client -t "$selected_name"
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
if [ $# -eq 1 ]; then
|
|
||||||
session=${1}
|
|
||||||
else
|
|
||||||
session=$(tmux list-sessions -F \#S | gum filter --placeholder "Pick a session...")
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$session" ]; then
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
tmux switch-client -t "$session" || tmux attach -t "$session"
|
|
||||||
@@ -6,7 +6,7 @@ if wezterm.config_builder then
|
|||||||
end
|
end
|
||||||
|
|
||||||
--config.color_scheme = 'rose-pine'
|
--config.color_scheme = 'rose-pine'
|
||||||
config.color_scheme = 'nightfox'
|
config.color_scheme = 'terrafox'
|
||||||
|
|
||||||
-- Font
|
-- Font
|
||||||
config.font = wezterm.font_with_fallback {
|
config.font = wezterm.font_with_fallback {
|
||||||
|
|||||||
@@ -195,6 +195,8 @@ alias gs='git status'
|
|||||||
alias l='ls -lah --color=auto'
|
alias l='ls -lah --color=auto'
|
||||||
alias reload='exec zsh -l'
|
alias reload='exec zsh -l'
|
||||||
alias t='tmux'
|
alias t='tmux'
|
||||||
|
alias ts='$SCRIPTS/tmux-sessionator'
|
||||||
|
alias tss='$SCRIPTS/tmux-sessionator --choose'
|
||||||
alias tls='tmux list-sessions'
|
alias tls='tmux list-sessions'
|
||||||
alias temp='cd $(mktemp -d)'
|
alias temp='cd $(mktemp -d)'
|
||||||
alias vi='nvim'
|
alias vi='nvim'
|
||||||
|
|||||||
Reference in New Issue
Block a user