extend tmux-sessionizer
This commit is contained in:
parent
6718ba7716
commit
a34cbeca73
1 changed files with 28 additions and 2 deletions
|
@ -4,9 +4,10 @@ HOMEDIR=~
|
|||
SEL_DIR=$(find ~ -not -path "*/.*" -type d -print 2>/dev/null | fzf)
|
||||
SEL_NAME=$(basename "$SEL_DIR")
|
||||
|
||||
if [[ -z "$SEL_DIR" ]] || [[ -n "$SEL_DIR" ]] && [[ "$SEL_DIR" == "$HOMEDIR" ]]; then
|
||||
new_session_name(){
|
||||
RET=0
|
||||
while [[ $RET -eq 0 ]]; do
|
||||
clear
|
||||
read -p "New session name: " SEL_NAME
|
||||
if [[ -z "$SEL_NAME" ]]; then
|
||||
clear
|
||||
|
@ -14,10 +15,35 @@ if [[ -z "$SEL_DIR" ]] || [[ -n "$SEL_DIR" ]] && [[ "$SEL_DIR" == "$HOMEDIR" ]];
|
|||
RET=1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
if [[ -z "$SEL_DIR" ]] || [[ -n "$SEL_DIR" ]] && [[ "$SEL_DIR" == "$HOMEDIR" ]]; then
|
||||
new_session_name
|
||||
else
|
||||
RET=0
|
||||
while [[ $RET -eq 0 ]]; do
|
||||
clear
|
||||
read -r -p "Choose a different session-name? [y/n] " USR_CHOICE
|
||||
echo $USR_CHOICE
|
||||
if [[ "$USR_CHOICE" == "y" ]]; then
|
||||
clear
|
||||
new_session_name
|
||||
RET=1
|
||||
elif [[ "$USR_CHOICE" == "n" ]]; then
|
||||
clear
|
||||
RET=1
|
||||
else
|
||||
clear
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
SEL_NAME=$(tr "[:lower:]" "[:upper:]" <<< "$SEL_NAME")
|
||||
|
||||
tmux new-session -d -s "$SEL_NAME" -c "$SEL_DIR"
|
||||
tmux switch-client -t "$SEL_NAME"
|
||||
if [[ -e "$TMUX" ]]; then
|
||||
tmux switch-client -t "$SEL_NAME"
|
||||
else
|
||||
tmux attach -t "$SEL_NAME"
|
||||
fi
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue