Skip to content

Commit

Permalink
Add --cwd option
Browse files Browse the repository at this point in the history
  • Loading branch information
js-everts committed Feb 3, 2023
1 parent c37284f commit 1607230
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,15 @@ So the following may help you.
$ nohup sh -c 'killall tym; sleep 1; systemctl --user start tym-daemon.service; tym' >/dev/null 2>&1 &
```


### `--cwd=<path>`

This sets the terminal's working directory. `<path>` must be an absolute path. If unspecified `tym` will use the current working directory of the terminal invocation.

```console
$ tym --cwd=/home/user/projects
```

### `--<config option>`

You can set config value via command line option.
Expand Down
12 changes: 11 additions & 1 deletion src/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,13 @@ void on_dbus_call_method(

int on_local_options(GApplication* gapp, GVariantDict* values, void* user_data)
{
Option* option = (Option*)(user_data);
const char* cwd = option_get_str(option, "cwd");
if (cwd != NULL && !g_path_is_absolute(cwd)) {
g_warning("cwd must be an absolute path");
return 1;
}

df();
return -1;
}
Expand Down Expand Up @@ -630,7 +637,10 @@ int on_command_line(GApplication* gapp, GApplicationCommandLine* cli, void* user
shell_env = g_environ_setenv(shell_env, "TYM_ID", id_str, true);
g_free(id_str);

char* cwd = g_application_command_line_get_cwd(cli);
char* cwd = option_get_str(option, "cwd");
if (cwd == NULL) {
cwd = g_application_command_line_get_cwd(cli);
}

#ifdef TYM_USE_VTE_SPAWN_ASYNC
vte_terminal_spawn_async(
Expand Down
6 changes: 6 additions & 0 deletions src/meta.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,12 @@ GOptionEntry* meta_get_option_entries(Meta* meta)
.arg_data = new_empty_bool(),
.description = "Start as an isolated instance",
.arg_description = NULL,
}, {
.long_name = "cwd",
.arg = G_OPTION_ARG_STRING,
.arg_data = new_empty_str(),
.description = "Set the terminal's working directory. Must be an absolute path.",
.arg_description = "<path>",
}
};

Expand Down
3 changes: 3 additions & 0 deletions tym.1.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ Use <PATH> instead of default config file.
.IP "\fB\-t\fR, \fB\-\-theme\fR=\fI<PATH>\fR"
Use <PATH> instead of default theme file.

.IP "\fB\-\-cwd\fR=\fI<PATH>\fR"
Use <PATH> as the terminal's working directory. Must be an absolute path.

.IP "\fB\-\-\fR\fI<OPTION>\fR=\fI<VALUE>\fR"
Replace <OPTION> config option, where \fI<OPTION>\fR is a config option and
\fI<VALUE>\fR is a value of its option.
Expand Down

0 comments on commit 1607230

Please sign in to comment.