it2 variable set
Set value of a variable
Synopsis
it2 variable set <scope> <name> <value> [identifier]
Description
Set the value of a variable in a specific scope.
Scopes:
app - Application-wide variables
session - Session-specific variables (requires session-id)
tab - Tab-specific variables (requires tab-id)
window - Window-specific variables (requires window-id)
Note: Variable names must begin with "user." for user-defined variables.
Examples
# Set app-level variable
$ it2 variable set app user.my_var "hello world"
# Set session variable
$ it2 variable set session user.env "production" abc123
# Set current session variable
$ it2 variable set session user.status "active" $ITERM_SESSION_ID
# Set tab variable
$ it2 variable set tab user.tab_name "build" tab-123
# Set window variable
$ it2 variable set window user.window_type "dev" window-123
# Set variable with command output
$ it2 variable set app user.hostname "$(hostname)"
# Set timestamp
$ it2 variable set session user.start_time "$(date +%s)" $ITERM_SESSION_ID
Options inherited from parent commands
-
--format(default "text") - Output format (text, json, yaml) - affects how command results are displayed
-
--timeout - Timeout for API operations - how long to wait for iTerm2 to respond
-
--url - WebSocket URL for iTerm2 API - typically ws://localhost:1912 for local iTerm2
See Also
- it2 variable - Manage iTerm2 variables
- it2 variable delete - Delete/unset a variable
- it2 variable export - Export variables to JSON
- it2 variable get - Get value of a variable
- it2 variable import - Import variables from JSON file
- it2 variable list - List variables
- it2 variable monitor - Monitor variable changes in real-time