Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@shello
Last active November 28, 2018 02:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shello/dea96c183f9e8e7fe181ef12335b44cf to your computer and use it in GitHub Desktop.
Save shello/dea96c183f9e8e7fe181ef12335b44cf to your computer and use it in GitHub Desktop.
# 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
}
@shello
Copy link
Author

shello commented Nov 28, 2018

Regarding the error message: you can redirect that output (which tmux writes to stderr, file descriptor 2) to /dev/null with the shell redirection 2>/dev/null. I made this change, along with your se fix, to the gist!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment