merge: cleanup tmux

This commit is contained in:
2026-03-10 00:55:57 +01:00
5 changed files with 55 additions and 63 deletions

View File

@@ -1,7 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
source "$XDG_CONFIG_HOME/zsh/scripts.zsh"
if [[ $# -eq 1 ]]; then if [[ $# -eq 1 ]]; then
selected=$1 selected=$1
else else
@@ -12,7 +10,7 @@ if [[ -z $selected ]]; then
exit 0 exit 0
fi fi
ggman clone $selected ggman clone "$selected"
echo "" echo ""
read -p "press enter to continue..." read -p "press enter to continue..."

View File

@@ -6,8 +6,6 @@ if [[ -z ${NAME:+x} ]]; then
exit 1 exit 1
fi fi
source "$XDG_CONFIG_HOME/zsh/scripts.zsh"
read -p "name: " project_name read -p "name: " project_name
if [[ -z $project_name ]]; then if [[ -z $project_name ]]; then
@@ -19,7 +17,7 @@ if [[ -d "$GGROOT/no-remote/$project_name" ]]; then
fi fi
project="$GGROOT/no-remote/$project_name" project="$GGROOT/no-remote/$project_name"
git init $project git init "$project"
echo "# $project_name" >>"$project/README.md" echo "# $project_name" >>"$project/README.md"
gitignore_template=$( gitignore_template=$(
@@ -28,7 +26,7 @@ gitignore_template=$(
| fzf --cycle --bind 'tab:toggle-up,btab:toggle-down' | fzf --cycle --bind 'tab:toggle-up,btab:toggle-down'
) )
if ! [[ -z $gitignore_template ]]; then if [[ -n $gitignore_template ]]; then
gitignore="$GGROOT/github.com/github/gitignore/$gitignore_template.gitignore" gitignore="$GGROOT/github.com/github/gitignore/$gitignore_template.gitignore"
echo "$gitignore" echo "$gitignore"
echo "$project/.gitignore" echo "$project/.gitignore"
@@ -41,10 +39,8 @@ license_template=$(
| fzf --cycle --bind 'tab:toggle-up,btab:toggle-down' | fzf --cycle --bind 'tab:toggle-up,btab:toggle-down'
) )
if ! [[ -z $license_template ]]; then if [[ -n $license_template ]]; then
license="$GGROOT/git.janezic.dev/janezicmatej/license/$license_template.license" license="$GGROOT/git.janezic.dev/janezicmatej/license/$license_template.license"
export YEAR="$(date '+%Y')" export YEAR="$(date '+%Y')"
envsubst <"$license" >"$project/LICENSE" envsubst <"$license" >"$project/LICENSE"
fi fi
ggcompile

View File

@@ -18,17 +18,15 @@ if [[ -z $selected ]]; then
exit 0 exit 0
fi fi
selected_name="$(echo $selected | shasum -a 256 | head -c 4)_$(basename $selected | tr . _ | head -c 10)" selected_name="$(echo "$selected" | shasum -a 256 | head -c 4)_$(basename "$selected" | tr . _ | head -c 10)"
tmux_running=$(pgrep tmux) if [[ -z $TMUX ]] && ! tmux list-sessions 2>/dev/null; then
tmux new-session -s "$selected_name" -c "$selected"
if [[ -z $TMUX ]] && [[ -z $tmux_running ]]; then
tmux new-session -s $selected_name -c $selected
exit 0 exit 0
fi fi
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"

View File

@@ -4,17 +4,17 @@ function _preview {
file=$1; shift file=$1; shift
host=$1; shift host=$1; shift
j=$(cat $file \ j=$(cat "$file" \
| jc --ssh-conf \ | jc --ssh-conf \
| jq -r ".[] \ | jq -r ".[] \
| select(.host == \"$host\") \ | select(.host == \"$host\") \
| .jumps = (if (.proxyjump | type == \"array\" and length > 0) then (.proxyjump | join(\",\")) else \"null\" end)" \ | .jumps = (if (.proxyjump | type == \"array\" and length > 0) then (.proxyjump | join(\",\")) else \"null\" end)" \
) )
user=$(jq -r '.user' <<<$j) user=$(jq -r '.user' <<<"$j")
port=$(jq -r '.port' <<<$j) port=$(jq -r '.port' <<<"$j")
hostname=$(jq -r '.hostname' <<<$j) hostname=$(jq -r '.hostname' <<<"$j")
jumps=$(jq -r '.jumps' <<<$j) jumps=$(jq -r '.jumps' <<<"$j")
echo "$(cat <<EOF echo "$(cat <<EOF
@@ -29,11 +29,11 @@ EOF)"
echo "" echo ""
host $hostname host "$hostname"
echo "" echo ""
ping -c 1 -W 1 $hostname &>/dev/null \ ping -c 1 -W 1 "$hostname" &>/dev/null \
&& echo "Host is reachable!" \ && echo "Host is reachable!" \
|| echo "Host is not reachable!" || echo "Host is not reachable!"
} }
@@ -60,18 +60,17 @@ function main() {
fi fi
selected_name="ssh_$selected" selected_name="ssh_$selected"
tmux_running=$(pgrep tmux)
if [[ -z $TMUX ]] && [[ -z $tmux_running ]]; then if [[ -z $TMUX ]] && ! tmux list-sessions 2>/dev/null; then
tmux new-session -s $selected_name -c $selected ssh "$selected" tmux new-session -s "$selected_name" ssh "$selected"
exit 0 exit 0
fi fi
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 ssh "$selected" tmux new-session -ds "$selected_name" ssh "$selected"
fi fi
tmux switch-client -t $selected_name tmux switch-client -t "$selected_name"
} }
main "$@" main "$@"

View File

@@ -1,53 +1,54 @@
set -g default-terminal "xterm-256color" # server options
set -ga terminal-overrides ",xterm-256color:RGB"
set -ga terminal-features ",xterm-256color:clipboard"
set -g allow-passthrough on
set -g set-clipboard on
set -s escape-time 0 set -s escape-time 0
# terminal
set -g default-terminal "tmux-256color"
set -ga terminal-overrides ",xterm-ghostty:RGB,xterm-256color:RGB"
set -ga terminal-features ",xterm-ghostty:clipboard,xterm-256color:clipboard"
set -g set-clipboard on
# general
set -g prefix C-s
set -g base-index 1
set -g focus-events on
set -g update-environment "SSH_AUTH_SOCK SSH_CONNECTION SSH_TTY DISPLAY" set -g update-environment "SSH_AUTH_SOCK SSH_CONNECTION SSH_TTY DISPLAY"
unbind C-b # status bar
set-option -g prefix C-s
bind r source-file "$XDG_CONFIG_HOME/tmux/tmux.conf"
set -g base-index 1
set -g status-style 'bg=default fg=default' set -g status-style 'bg=default fg=default'
set -g status-left-length 20 set -g status-left-length 20
set-window-option -g mode-keys vi # window options
set -wg mode-keys vi
set -g pane-base-index 1
set -g renumber-windows on
# prefix
unbind C-b
# copy mode
bind -T copy-mode-vi v send-keys -X begin-selection bind -T copy-mode-vi v send-keys -X begin-selection
# differentiate copy on linux and max # navigation
if-shell -b '[ "$(uname -s)" = "Linux" ]' {
bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard'
}
if-shell -b '[ "$(uname -s)" = "Darwin" ]' {
bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'pbcopy'
}
# vim-like pane switching
bind ^ last-window bind ^ last-window
bind k select-pane -U bind k select-pane -U
bind j select-pane -D bind j select-pane -D
bind h select-pane -L bind h select-pane -L
bind l select-pane -R bind l select-pane -R
# reload
bind r source-file "$XDG_CONFIG_HOME/tmux/tmux.conf"
# sessionizer # sessionizer
bind-key f run-shell "tmux neww ~/.config/tmux/tmux-sessionizer" bind f run-shell "tmux neww ~/.config/tmux/tmux-sessionizer"
bind-key R run-shell "tmux neww ~/.config/tmux/tmux-sessionizer ~" bind R run-shell "tmux neww ~/.config/tmux/tmux-sessionizer ~"
bind-key g run-shell "tmux neww ~/.config/tmux/tmux-sessionizer ~/.config" bind g run-shell "tmux neww ~/.config/tmux/tmux-sessionizer ~/.config"
bind-key T run-shell "tmux neww ~/.config/tmux/tmux-sessionizer ~/temp" bind T run-shell "tmux neww ~/.config/tmux/tmux-sessionizer ~/temp"
# clone # clone
bind-key G run-shell "tmux neww ~/.config/tmux/tmux-ggclone" bind G run-shell "tmux neww ~/.config/tmux/tmux-ggclone"
# ssh # ssh
bind-key F run-shell "tmux neww ~/.config/tmux/tmux-ssher" bind F run-shell "tmux neww ~/.config/tmux/tmux-ssher"
# project # project
bind-key N run-shell "tmux neww ~/.config/tmux/tmux-new-project" bind N run-shell "tmux neww ~/.config/tmux/tmux-new-project"