Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load default configurations. This closes #5 #7

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,18 @@ Under the hood `tmux-up` will:

If you detach from the `example/dev` session, simply re-run `tmux-up dev.conf` which will reattach you to the session.

## Default Configurations

You can place default configurations in `~/.tmux/`, for example `~/.tmux/default.conf`. To attach a default configuration just run

```
❯ tmux-up default.conf
```

in any directory. This will create a `tmux` session named `default` and invoke each line in `~/.tmux/default.conf`.

If you have a `default.conf` in your current directory, it will take precedence over the configuration in `~/.tmux/`.

## Alternatives

There are quite a lot of other approaches to this problem already floating around.
Expand Down
7 changes: 7 additions & 0 deletions tmux-up
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ then
exit 0
fi

CONF_DIR=$HOME/.tmux
CONF=${1:-.tmux.conf}

# try default configuration directory
[ ! -f "$CONF" ] && CONF="$CONF_DIR/$CONF"

if [ ! -f "$CONF" ]
then
echo "$0: cannot stat ‘${CONF}’: No such file"
Expand All @@ -52,6 +56,9 @@ NAME=$(basename "$CONF" .conf)
if [ "$NAME" = 'tmux' ] || [ "$NAME" = '.tmux' ]
then
SESSION=$BASE
elif [ ! -f "${NAME}.conf" ]
then
SESSION=$NAME
else
SESSION=$BASE/$NAME
fi
Expand Down