tmux start session from dir
This commit is contained in:
parent
667badeb9c
commit
9d2915895b
@ -1,7 +1,7 @@
|
|||||||
readonly TARGETS="\
|
readonly TARGETS="\
|
||||||
colors:.config/terminal-colors.d
|
colors:.config/terminal-colors.d
|
||||||
less:.lesskey .infokey
|
less:.lesskey .infokey
|
||||||
tmux:.config/tmux .tmux .config/systemd/user/tmux.service .local/bin/tmux_start_session.sh .local/bin/tmux_list_sessions.sh .local/bin/tmux_attach_session.sh .local/bin/tmux_kill_sessions.sh
|
tmux:.config/tmux .tmux .config/systemd/user/tmux.service .local/bin/tmux_start_session.sh .local/bin/tmux_list_sessions.sh .local/bin/tmux_attach_session.sh .local/bin/tmux_kill_sessions.sh .local/bin/tmux_start_projects.sh
|
||||||
t:
|
t:
|
||||||
note:
|
note:
|
||||||
zsh:.config/zsh .zshenv .inputrc %colors
|
zsh:.config/zsh .zshenv .inputrc %colors
|
||||||
|
|||||||
@ -207,4 +207,5 @@ bind -T copy-mode-vi WheelDownPane select-pane \; send-keys -X -N 2 scroll-down
|
|||||||
# Session managment
|
# Session managment
|
||||||
bind a display-popup -EE -w 80% -h 80% -B '~/.local/bin/tmux_attach_session.sh'
|
bind a display-popup -EE -w 80% -h 80% -B '~/.local/bin/tmux_attach_session.sh'
|
||||||
bind s display-popup -EE -w 80% -h 80% -B '~/.local/bin/tmux_start_session.sh'
|
bind s display-popup -EE -w 80% -h 80% -B '~/.local/bin/tmux_start_session.sh'
|
||||||
|
bind S display-popup -EE -w 40% -h 80% -B '~/.local/bin/tmux_start_projects.sh'
|
||||||
bind k display-popup -EE -w 80% -h 80% -B '~/.local/bin/tmux_kill_sessions.sh'
|
bind k display-popup -EE -w 80% -h 80% -B '~/.local/bin/tmux_kill_sessions.sh'
|
||||||
|
|||||||
35
home/user/.local/bin/tmux_start_projects.sh
Executable file
35
home/user/.local/bin/tmux_start_projects.sh
Executable file
@ -0,0 +1,35 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
|
||||||
|
export FZF_DEFAULT_OPTS="\
|
||||||
|
${FZF_DEFAULT_OPTS}
|
||||||
|
--no-multi
|
||||||
|
--marker=''
|
||||||
|
--border=rounded
|
||||||
|
--border-label-pos=bottom
|
||||||
|
--border-label=' Start session '
|
||||||
|
--color='border:grey,label:grey'
|
||||||
|
"
|
||||||
|
|
||||||
|
|
||||||
|
project_dir="$(find "${HOME}" -maxdepth 3 -type d -not -path '*/.*' | sed "s%^${HOME}%~%" | fzf | sed "s%^~%${HOME}%")"
|
||||||
|
readonly project_dir
|
||||||
|
|
||||||
|
|
||||||
|
if [ -z "${project_dir}" ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d "${project_dir}" ]; then
|
||||||
|
printf 'Directory "%s" not found' "${project_dir}" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
session="$(basename "${project_dir}")"
|
||||||
|
|
||||||
|
if ! tmux has-session -t "${session}" 2>/dev/null; then
|
||||||
|
tmux new-session -d -n 1 -c "${project_dir}" -s "$(basename "${project_dir}")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
tmux switch-client -t "${session}"
|
||||||
Loading…
x
Reference in New Issue
Block a user