Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
OSX CLI for opening a new terminal tab/window, optionally with a command to execute and/or display settings
Contents
An OS X CLI for programmatically opening a new terminal tab/window in the standard terminal application, Terminal.app
, optionally with a command to execute and/or a specific title and specific display settings.
Important: Irrespective of installation method, ttab
needs to be granted access for assistive devices in order to operate, which is a one-time operation that requires administrative privileges.
If you're not prompted on first run and get an error message instead, go to System Preferences > Security & Privacy
, tab Privacy
, select Accessibility
, unlock, and make sure Terminal.app
is in the list on the right and has a checkmark.
For more information, see Apple's support article on the subject
With Node.js installed, install via the npm registry (you may have to prepend sudo
):
npm install ttab -g
bash
script as ttab
.chmod +x ttab
.$PATH
, such as /usr/local/bin
# Open a new tab in the current terminal window.
ttab
# Open a new tab in a new terminal window.
ttab -n
# Open a new tab and execute the specified command.
ttab ls -l "$HOME/Library/Application Support"
# Open a new tab, switch to the specified dir., then execute the specified command.
ttab -d ~/Library/Application\ Support ls -1
# Open a new tab with title 'How Green Was My Valley' and settings 'Grass'
ttab -t 'How Green Was My Valley' -s Grass
# Open a new tab and execute the specified script.
ttab /path/to/someScript
# Open a new tab, execute the specified script, then close the tab on termination.
ttab exec /path/to/someScript
# Open a new tab, execute a command, wait for a keypress, then close the tab.
ttab eval "ls \$HOME/Library/Application\ Support; echo Press a key to exit.; read -s -n 1; exit"
$ ttab --help
SYNOPSIS:
ttab [-w] [-s settings] [-t title] [-g|-G] [-d dir] [command [param1 ...]]
DESCRIPTION:
Opens a new Terminal.app tab and optionally executes a command and assigns settings,
among other options.
The new tab will run a login shell (i.e., load the user's shell profile) and by default
inherit the working directory from the parent shell.
-w creates the new tab in a new window rather than in Terminal's front window.
-s specifies the settings to apply to the new tab, as defined in Terminal.app's
Preferences > Settings; e.g.: 'Grass'; settings determine the appearance and behavior
of the new tab; name matching is case-insensitive.
-t specifies a custom title to assign to the new tab; otherwise, if a command is specified,
its first token will become the new tab's title.
-d explicitly specifies a working directory for the new tab; by default, the invoking shell's
working directory is inherited (even if -w is also specified).
-g (back*g*round) causes Terminal not to activate, but within Terminal, the new tab
will become the active tab; useful in scripts that activate other applications beforehand.
-G causes Terminal not to activate *and* the active element within Terminal not to change;
i.e., the active window and tab stay the same. If Terminal happens to be active, the new
tab will effectively open in the background.
NOTE: With -g or -G specified, for technical reasons, Terminal or the new tab will still activate
*briefly, temporarily* in most scenarios.
Quoted parameters are handled properly and there's no need to quote the command as a whole,
provided it is a *single* command.
To specify *multiple* commands, use 'eval' followed by a single, *double*-quoted string
in which the commands are separated by ';' Do NOT use backslash-escaped double quotes inside
this string; rather, use single-character backslash-escaping as needed.
Use 'exit' as the last command to automatically close the tab when the command
terminates; precede it with 'read -s -n 1' to wait for a keystroke first.
Alternatively, pass a script name or path; prefix with 'exec' to automatically
close the tab when the script terminates.
EXAMPLES:
ttab -t Green -s Grass # create new tab with title 'Green' using settings 'Grass'
ttab ls -l "$HOME/Library/Application Support"
ttab -d "\~/Library/Application Support" ls -1
ttab eval "ls \$HOME/Library/Application\ Support; echo Press a key to exit.; read -s -n 1; exit"
ttab /path/to/someScript # execute a script and keep the tab open on termination
ttab exec /path/to/someScript # execute a script and close the tab on termination.
Copyright (c) 2015 Michael Klement mklement0@gmail.com (http://same2u.net), released under the MIT license.
This project gratefully depends on the following open-source components, according to the terms of their respective licenses.
npm dependencies below have optional suffixes denoting the type of dependency; the absence of a suffix denotes a required run-time dependency: (D)
denotes a development-time-only dependency, (O)
an optional dependency, and (P)
a peer dependency.
Versioning complies with semantic versioning (semver).
v0.1.2 (2015-06-01):
v0.1.1 (2015-06-01):
v0.1.0 (2015-06-01):
FAQs
OSX CLI for opening a new terminal tab/window, optionally with a command to execute and/or display settings
The npm package ttab receives a total of 4,112 weekly downloads. As such, ttab popularity was classified as popular.
We found that ttab demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.