(scripts) fixed minor annoynances
This commit is contained in:
@@ -3,16 +3,24 @@
|
|||||||
DEFAULT_SESSION='quak'
|
DEFAULT_SESSION='quak'
|
||||||
DUMMY_SESSION='dummy'
|
DUMMY_SESSION='dummy'
|
||||||
|
|
||||||
# start dummy session to avoid error messages on `has-session`
|
function create_default_session {
|
||||||
tmux new-session -d -s "$DUMMY_SESSION"
|
if [[ -n "$TMUX" ]]; then
|
||||||
|
echo "already attached to a session. don't nest tmux sessions"
|
||||||
|
# return failure so the external attach command is not run
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# check if the default session exists
|
||||||
|
# redirect stderr to /dev/null because `session not found` is
|
||||||
|
# not a relevant error in this case
|
||||||
|
if $(tmux has-session -t ${DEFAULT_SESSION} 2>/dev/null); then
|
||||||
|
# return success so the external attach command is run
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# start dummy session to avoid error messages on `has-session`
|
||||||
|
tmux new-session -d -s "$DUMMY_SESSION"
|
||||||
|
|
||||||
# check if the default session exists
|
|
||||||
# redirect stderr to /dev/null because `session not found` is
|
|
||||||
# not a relevant error in this case
|
|
||||||
if $(tmux has-session -t ${DEFAULT_SESSION} 2>/dev/null); then
|
|
||||||
echo "default session <${DEFAULT_SESSION}> already exists"
|
|
||||||
# no action needed if the session exists, the attach command is run externally
|
|
||||||
else
|
|
||||||
# dont forget the '-d' option, otherwise the session is closed
|
# dont forget the '-d' option, otherwise the session is closed
|
||||||
# before the rest of the commands are executed
|
# before the rest of the commands are executed
|
||||||
tmux new-session -d -s "$DEFAULT_SESSION" -n "temp" -c "$HOME" # create dummy window to set default path for new windows
|
tmux new-session -d -s "$DEFAULT_SESSION" -n "temp" -c "$HOME" # create dummy window to set default path for new windows
|
||||||
@@ -28,6 +36,8 @@ else
|
|||||||
# `tmux attach` on successful execution
|
# `tmux attach` on successful execution
|
||||||
|
|
||||||
#tmux attach -t "$DEFAULT_SESSION"
|
#tmux attach -t "$DEFAULT_SESSION"
|
||||||
fi
|
|
||||||
|
|
||||||
tmux kill-session -t "$DUMMY_SESSION"
|
tmux kill-session -t "$DUMMY_SESSION"
|
||||||
|
}
|
||||||
|
|
||||||
|
create_default_session
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
[[ "$-" != "*i*" ]] || return
|
||||||
|
|
||||||
function __search-history {
|
function __search-history {
|
||||||
current_line="${READLINE_LINE}"
|
current_line="${READLINE_LINE}"
|
||||||
command=($(fc -lnr 1 | fzf --scheme=history --tmux --expect=tab,right -q "${current_line}"))
|
command=($(fc -lnr 1 | fzf --scheme=history --tmux --expect=tab,right -q "${current_line}"))
|
||||||
|
|||||||
Reference in New Issue
Block a user