tmuxp_config.sh
Export tmuxp var and/or set tmuxp.yaml
file to start tmux session
Description
If TMUXP_CONFIGDIR is set in .envrc.ini
, export it to define where to
store tmuxp configuration per directory.
Then depending on variables set in modules, will either use an existing tmuxp project or copy an existing template for the directory.
Finally, this will start a tmux session with tmuxp in detached state.
Parameters in .envrc.ini
are:
Name | Description |
---|---|
TMUXP_CONFIGDIR |
Directory location where to look/store tmuxp configurations. |
tmuxp_session_name |
(optional) Name of the tmux session (default set to dirname). |
tmuxp_template |
(optional) Name of the tmuxp configuration template to copy (default set to default)1 |
tmuxp_project |
(optional) Specify the name of the tmuxp file and the tmux session (default set to default)1 |
Parameters
TMUXP_CONFIGDIR
Export a environment variable to specify to tmuxp where to look for
tmuxp session configuration files. Default set to
XDG_CONFIG_DIR/tmuxp
.
tmuxp_session_name
Define the name of the tmux session, default set to dirname.
tmuxp_template
Mutually exclusive with tmuxp_project
Define the tmuxp template to use. This will copy the file
${TMUXP_CONFIGDIR}/${tmuxp_template}.yaml
to
${TMUXP_CONFIGDIR}/${tmuxp_session_name}.yaml
and will create
a symlink to it at ${DIRENV_ROOT}
.
If file ${TMUXP_CONFIGDIR}/${tmuxp_template}.yaml
does not
exists yet, it will be copied from
templates/tmuxp/${tmuxp_template}.yaml
.
If templates/tmuxp/${tmuxp_template}.yaml
does not exists an
error will be print and nothing related to tmuxp module will be done.
tmuxp_project
Mutually exclusive with tmuxp_template
Define the tmuxp project to use. This will use the file
${TMUXP_CONFIGDIR}/${tmuxp_project}.yaml
to start a session
based on the project file and will create a symlink to it at
${DIRENV_ROOT}
.
If file ${TMUXP_CONFIGDIR}/${tmuxp_template}.yaml
does not
exists yet, it will be copied from
templates/tmuxp/${tmuxp_template}.yaml
.
If templates/tmuxp/${tmuxp_template}.yaml
does not exists an
error will be print and nothing related to tmuxp module will be done.
.envrc.ini
example
Corresponding entry in .envrc.ini.template
are:
# tmuxp module
# ------------------------------------------------------------------------------
# Start a tmux session from tmuxp config in detached states
[tmuxp_config]
# Location where tmuxp file are stored
TMUXP_CONFIGDIR="${XDG_CONFIG_DIR:-${HOME}/.config/}tmuxp/"
# Name of the session
tmuxp_session_name="cmd: dirname ${DIRENV_ROOT}"
# Template to use (copy and symlink)
#tmuxp_template="default"
# Project to use (run an instance)
tmuxp_project="default"
check_source_exist()
Check that name of template or project is valid
Check that name of template or project is valid, i.e. a template exists in templates/tmuxp/ directory in direnv dotfiles.
Arguments
Arguments | Description |
---|---|
$1 |
Name of the template in direnv dotfiles to use. |
Output
- Log error if any.
Returns
- 1: If name is not valid
- 0: If name is valid
check_tmuxp_config_exist()
Check if tmuxp configuration file already exists
Arguments
Arguments | Description |
---|---|
$1 |
String, name of the tmuxp configuration file. |
Returns
- 1: If tmuxp configuration file does not exists.
- 0: If tmuxp configuration file already exists.
check_mutually_exclusive_var()
Check if mutually exclusive variable are not set in .envrc.ini
Output
- Error log if any
Returns
- 1: If mutually exclusive variables are set.
- 0: If mutually exclusive variables are not set.
setup_tmuxp_config()
Install tmuxp configuration from templates and needed symlinks
Arguments
Arguments | Description |
---|---|
$1 |
type of configuration to use (template or project) |
Output
- Error and Info log and configuration files.
process_tmuxp()
Mainly process tmuxp configuration and load tmuxp configuration
Arguments
Arguments | Description |
---|---|
$1 |
Name of the tmux session |
$2 |
Name of the file template to use |
Output
- Error and Info log and configuration files.
tmuxp_config()
Setup tmuxp config file if needed and start a tmux session
If file does not exists in ${TMUXP_CONFIGDIR}
, will create it based
on variable set in .envrc.ini
.
Then, depending on the value of variable tmuxp_*
in .envrc.ini
will either:
- Create a new file for the project and create a symlink in the
${DIRENV_ROOT}
based on template and start a tmux session - Create a symlink in the
${DIRENV_ROOT}
based on template and start a tmux session
Globals
DIRENV_ROOT
DIRENV_TEMPLATE_FOLDER
Returns
- 1 if something went wrong
- 0 if the module is correctly loaded
deactivate_tmuxp_config()
Unset exported variables for tmuxp_config module
Unset TMUXP_CONFIGDIR
variable previously exported.
Globals
TMUXP_CONFIGDIR
-
tmuxp_template
andtmuxp_project
are mutually exclusive as the first will make a copy of the template while the later will use (ERB)[tmuxp/tmuxp#erb]. ↩↩