Coder Social home page Coder Social logo

mklement0 / ttab Goto Github PK

View Code? Open in Web Editor NEW
269.0 9.0 14.0 512 KB

macOS and Linux CLI for opening a new terminal tab/window, optionally with a command to execute and/or display settings

Makefile 29.05% Shell 48.10% AppleScript 22.19% Ruby 0.65%
cli macos terminal tabs-management tabs ttab

ttab's People

Contributors

dependabot[bot] avatar joelbernstein avatar ksvirsky avatar leemm avatar mklement0 avatar tlevine avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ttab's Issues

Support iTerm

iTerm is quite popular among devs who work on OS X. But ttab gives you error:

79:307: execution error: System Events got an error: Can’t get application process "Terminal". (-1728)

It would be great if iTerm can be supported.

In Gnome Terminal, pressing Ctrl-C while a startup command is running doesn't keep the session open.

As reported by @barankyle here:

The design intent of ttab is to run commands specified on the command line in an instance of the user's default shell.

This means that you should be able to abort such startup commands by pressing Ctrl-C, without terminating the shell session as a whole.

While this works as intended on macOS, with Gnome Terminal on Linux the shell session is currently terminated, thereby (typically) closing the new tab.

Note that an unavoidable limitation of using ttab with Gnome Terminal is that keeping the session open can only be emulated: that is, for technical reasons a new instance of the user's default shell must be created that replaces the instance that ran the startup command - as such, the original shell's environment isn't fully preserved.

ttab consistently opens new windows instead of tabs

When stringing a chain of commands together ttab consistently opens new windows instead of tabs, any idea why this would happen?

For example:

ttb -t 'title1' <some cmd> && ttab -t 'title2' <some cmd> && sleep 5 && ttab -t 'title3' <some cmd>

The title3 tab will be opened in a new terminal window rather than a tab.

Add support for Linux terminals

nice work, I am writing a library and the library writes out log files and I give the user the option to tail those files. Instead of making the user find those files and then write a command four times to tail each one, my library just has a single command and without any args will open up the four windows on the behalf of the user.

however, the problems I have are:

  1. these are 4 separate Terminal.app windows, which aren't very cool
  2. the windows aren't sized right (ideally, maximized)
  3. they don't have proper titles in the window titlebar, they are all titled the same, so it's impossible to easily differentiate between them
  4. I get this weird situation* after I hit control+c in the terminal window:

screenshot 2016-06-13 21 46 47

Please let me know if you think your lib can help - I would also really love to see *nix support and full support for iTerm2! thanks!

*they way I open up new windows is with:

I run this with a node child_process:

#!/usr/bin/env bash
open -a Terminal.app `dirname $0`/tail.sh

which in term runs this:

#!/usr/bin/env bash
tail -F ${FILE_TO_TAIL}

bug? ttab not working when iTerm2 is excluded from Dock

My iTerm2 settings had it excluded from the Dock (Appearance/General/Exclude from Dock and Tab Application Switcher)

This created an issue, that the ttab stopped working correctly, essentially nothing happened when you tried to use a command except for --help.

Removing the setting solves the issue.

Quoted commands fail

Certain commands are not (AFAIK) possible with ttab, because of precedence rules.

ttab -t 'code & git' (git branch; git status)
ttab -t 'code & git' (git branch && git status)

It might seem that putting quotes around the command would fix this, passing it all to ttab as a single argument that could be unpacked before being issued to the shell, but it does not work.

Allowing the command and its arguments to be either single or double quoted (but not requiring it!) would be very helpful, as it would allow commands like those given above to succeed.

No longer working in iTerm2

I'm using iTerm2 version 3.4.12.

When I run my script the parameters of the script are changed during the process.

Screenshot 2021-11-19 at 12 26 59

Above is the image of the current output. The task is supposed to run a 'npm run serve' command. However, the directory is changed when the script is run. There's a semicolon after the user directory /users/USERNAME/folder/folder; npm run serve

Ssh then perform ops?

Is it possible to, for example:

ssh somesite
cd some/dir
./somescript

Seems that it opens ssh but then doesn't fire the remaining scripts..

ttab 'ssh somesite; cd /home/somewhere'

Cannot run ttab - SyntaxError: Unexpected token '{'

I'm having the issue below. It went from working to not working on a project seemingly after changing my project's branch and reinstalling node_modules but that hasn't changed the package version of ttab or the way it's being used

OSX bash (zsh. Tried both but same issue)
ttab v0.7.2 (tried v0.7.3 but same issue)

kTHIS_NAME=${BASH_SOURCE##*/}
            ^

SyntaxError: Unexpected token '{'

Screenshot 2023-01-09 at 12 10 24

Issue when run after tab is closed

I was trying to make a script that opens a tab and runs a command for the user using exec. It works fine right after iterm2 is launched. However, once the tab is closed (when the command ends) and I run ttab again, it just hangs forever. I don't see anything in ps aux that would be killable as a hung up task so I'm at a loss on what it could be.

travisb at traviss-mbp in ~   × @12:19
> ttab -w exec sudo lsyncd /Users/travisb/Code/local/ims_v3/sync.lua
travisb at traviss-mbp in ~    @12:20
> ttab exec sudo lsyncd /Users/travisb/Code/local/ims_v3/sync.lua
^C
travisb at traviss-mbp in ~   × @12:22

Publish homebrew formula

It would make the installation even easier if the homebrew formula for ttab was published to a homebrew tap.

iTerm2 execution error: Can’t get application "iTerm"

When trying to use ttab via iTerm2:

0:7: execution error: Can’t get application "iTerm". (-1728)
139:145: syntax error: Expected end of line but found class name. (-2741)

macOS: 10.12.6
Node: v8.6.0
Installed with: npm i -g ttab

feature: Support for tmux

Would love for this to support tmux, which currently I use with Alacritty. Happy to be assigned this, to act as a reminder for me to get this done.

-g and -G flags still focus the new tab?

Hi, I just started using ttab and it looks like when I pass in ttab -G -t 'Datastore Emulator' gcloud beta emulators datastore start, the new tab still receives focus. I've attached a gif, to clarify

200w_d

it may be a little easier to follow here

Re-apply tab title when shell is re-executed

This is admittedly a minor cosmetic issue, but hopefully it's a simple change.

When gnome-terminal is in use, and the change that was added last week to re-execute $SHELL when the running process closes is triggered, the new shell doesn't have the title that was applied to the original tab. It would be nice if the title could be re-applied.

ttab 0.6.1 no longer sets title to iTerm 3.3.7

Hello,

before I was able to set iTerm2 title with -t switch but it at some point stopped working.
I am not sure if after iTerm2 or ttab update.

now if I do ttab -t abc a new tab title says bash

Throw Incompatible OS Error Only on Use Rather than On Install

Greetings!

I use ttab for development purposes on my macOS machine. I've noticed that when pushing my node js build for production on a node:carbon (linux) docker image, ttab causes the build to fail because [the] platform "linux" is incompatible with this module. Would it be possible to throw this error only when used rather than when installed ( or to support Linux #5 )?

Cheers ✨

Option to include a function or read an interrupt

Scenario: I have a script that edits a few files and runs the npm project. If it was all part of one script, i could trap the interrupt (ctrl+c) and perform a custom clean up function that may checkout or delete files.

Problem: Since, on using ttab, a new window or tab is opened, i can't assign the same trap function to the new tab or window since the context is lost. Hence, can't perform clean up on interruption.

Proposal: Maybe if there is a way to attach a function or set of actions when an interrupt happens.

# trap ctrl-c interrupt and call cleanup
trap ctrl_c INT

ctrl_c(){
    tput setaf 3; echo -e "\nTerminating Process...\n"; tput sgr0
    cleanUp()
}

this is how i was trapping the interrupt.

cleanUp(){
    tput setaf 3; echo "Cleaning up before exiting"; tput sgr0
    git -C "./project-dir/" clean -df
    git -C "./project-dir/" checkout .
    tput setaf 2; echo "Undid changes. Exiting..."; tput sgr0
    exit
}

this is the clean up function, that would checkout . to remove changes to tracked files and delete untracked files

Windows and other platform support

I need such functionality in my windows environment.but this isnt supporting windows or linux.giving error in installation as

 Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

Is there any plan to add it or not?

ttab SIGTERM

If i start project with ttab, closing the tab warns me that the application will terminate but it doesn't. It remains running and holds on to the port, preventing me from restarting the application

ttab 'npm run dev'

If i start the application with out ttab, closing the tab warns me that the application will terminate and it actually does.

npm run dev

Can you provide any guidance for ensuring that my sub-command does exit?

Not working in macOS Ventura

Quite frequently, in the macOS Ventura beta, ttab <command> will result in the command being run in the current window, and a new, empty tab being opened. Happens about half the time.

Just running default command not working unless I select the Terminal menu bar

When I just run ttab, the frontmost terminal window doesn't open a new tab until I select the Terminal menu bar with my mouse.

(FWIW, when running ttab -w, a new Terminal window opens just fine). Not familiar with apple script, but using the macOS script editor to manually run the generated apple script (from --dry-run) has the same results as above.

I have enabled Accessibility for Terminal.app in Security & Privacy settings, and I'm on macOS 10.12.4.

Any help debugging would be appreciated. Absolutely loved this utility when it was working to help manage tabs and windows in scripts.

License question

Dear Mr. Klement,

Thank you very much for the ttab utility! It is an exceptional piece of work both implementation- and design-wise. In fact, I have just forked the whole project with the intent of using it as a template for my next one, lint. The lint project will be solely my own responsibility, but I must and very much willing to give full credit to the project of yours I am basing it on. And I am not sure how to properly reflect it in the LICENSE.md file. Please let me know if the following line will be satisfactory:

Copyright (c) 2017 Alec Missine [email protected], released under the MIT license. Based off of ttab.

Thank you,
Alec

ttab command opens new tab but no command prompt (Mac)

Hi,

I apologize if this has already been resolved. I can use ttab just fine. The only thing that bothers me is that I have to use Ctrl-C to return to the command prompt after I open tab in current window. Otherwise, it just hangs.

Thanks for all the effort put into this. It's much appreciated :)

Setting tab title in OS X Ventura with Terminal app does not set the title

When invoking the command below:

ttab -d ~/Developer/docker_es -g -t 'Docker ES' docker-compose up es01

The tab opens and briefly sets the title to "Docker ES", after which the title is immediately replaced with "cd /Users/username/Developer/docker_es".

I've turned off all of the Terminal preferences that relate to Window to Tab titles.

Am I doing it wrong?

Install fails on linux

Hi there,

I know this is a module for mac, but could you please not throw an exception on installation when the OS is not a Mac?

Whenever I try to install my dependencies, I cannot complete the installation, because it throws me an error in the process of installing because I'm not on a mac and then exits the installation.

I am definitely sure this is ttab, because it works fine when i remove the dependency on a ubuntu distro and then intall the dependencies again.

image

Maybe it's possible to show an info message instead of an outright error and just skip the installation if the system is not a Mac?

Not working after electron-packager

When I try to use ttab under my Electron project, it works under dev mode(1), but after building it with electron-packager(2) and executing the binary file, an error appears.

It works with this execution command to debug: # electron .
It fails with this compilation command to package the project: # electron-packager . MyProject --platform=darwin --arch=x64 --version=1.3.5 --overwrite

This is the source code:

var childProcess = require('child_process');

childProcess.execFile(__dirname+'/node_modules/ttab/bin/ttab', ['-w'], function(error, stdout, stderr) {
    console.log('stdout: ' + stdout);
    console.error('stderr: ' + stderr);
    if (error !== null) {
        console.error('exec error: ' + error);
    }
});

Console displays this error:

stdout: 
stderr: 56:62: syntax error: Expected end of line but found “script”. (-2741)

My Env
My node version: v4.5.0
My electron version: v1.3.5

Specify whether or not to keep tab open after command ends

In my experiments, when I Ctrl+C out of long-running commands, it sometimes leaves the tab open, and closes it other times, apparently depending on the program. I'm not sure what's the intended default here, but this seems like behavior I'd want to set per tab anyway. Any way to add a flag for this?

Create Homebrew tap

Thanks for this project, @mklement0! However, I find it a bit annoying that I have to use npm to install it, when it's just a simple bash script. Have you considered putting it into Homebrew, as well?

I made a pull request to add this project to Homebrew, but one of the maintainers suggested that this project isn't popular/notable enough to put in the core tap. However, anyone can create their own tap, and I feel like it makes the most sense for the tap for this project to be on your GitHub account, if you're OK with that.

Would you like to create a Homebrew tap, copy my formula file into it, and mention it on the README for this project?

Is there a way to get the new terminal to open in the VSCode integrated terminal

Hey there,

Say I have the following command in my package.json scripts:

    "sayHello": "ttab echo hello",

And I run npm run sayHello from the vscode integrated terminal. Is there a way to have it so that the new terminal that is created is created within the integrated terminal instead of from (in my case) the default mac terminal application?

Thanks very much!
Thomas

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.