Last active
November 28, 2018 02:00
-
-
Save shello/dea96c183f9e8e7fe181ef12335b44cf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Via: https://sts10.github.io/2018/11/27/syncthing-and-tmux.html | |
# Changes to `ss` and `se`: | |
# - Start session with command on `new-session`: avoids creating a shell | |
# session just for `syncthing`; also use only `kill-session` instead of | |
# sending keys. | |
# - Test if the sessions exist (or don't exist) before creating/killing them. | |
# in ~/.bash_profile or ~/.bashrc | |
function ss { | |
if tmux has-session -t synct 2>/dev/null; then | |
echo "Syncthing session already started." >&2 | |
return 1 | |
fi | |
echo "Starting up Syncthing at http://127.0.0.1:8384/" | |
tmux new-session -d -s synct "syncthing -no-browser" | |
} | |
function se { | |
if ! tmux has-session -t synct 2>/dev/null; then | |
echo "No Syncthing session to end." >&2 | |
return 1 | |
fi | |
echo "Stopping Syncthing and killing the tmux session" | |
tmux send-keys -t synct C-c | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Regarding the error message: you can redirect that output (which tmux writes to
stderr
, file descriptor 2) to/dev/null
with the shell redirection2>/dev/null
. I made this change, along with yourse
fix, to the gist!