![]() ![]() Osascript -e "$CMD_SAVE_ACTIVE_WIN" -e "$cmd" -e "$CMD_SETTITLE" -e "$CMD_REACTIVATE_PREV_WIN" >/dev/null If (( inBackground = 2 )) then # Restore the previously active window after creating the new one. # Note: $CMD_NEWWIN is not needed, as $cmd implicitly creates a new window. Osascript -e "$CMD_ACTIVATE" -e "$CMD_NEWTAB" -e "$cmd in front window" -e "$CMD_SETTITLE" >/dev/null Osascript -e "$CMD_SAVE_ACTIVE_APPNAME" -e "$CMD_ACTIVATE" -e "$CMD_NEWTAB" -e "$cmd in front window" -e "$CMD_SETTITLE" -e "$CMD_REACTIVATE_PREV_APP" >/dev/null Osascript -e "$CMD_SAVE_ACTIVE_APPNAME" -e "$CMD_SAVE_ACTIVE_TAB" -e "$CMD_ACTIVATE" -e "$CMD_NEWTAB" -e "$cmd in front window" -e "$CMD_SETTITLE" -e "$CMD_REACTIVATE_PREV_APP" -e "$CMD_REACTIVATE_PREV_TAB" >/dev/null ![]() If (( inBackground = 2 )) then # Restore the previously active tab after creating the new one. # !! Sadly, because we must create a new tab by sending a keystroke to Terminal, we must briefly activate it, then reactivate the previously active application. # '>/dev/null' suppresses AppleScript's output when it creates a new tab. # Open new tab or window, execute command, and assign tab title. Local CMD_NEWTAB='tell application "System Events" to keystroke "t" using \"" Local CMD_ACTIVATE='tell application "Terminal" to activate' # Sadly, there is no direct way to open a new tab in an existing window, so we must activate Terminal first, then send a keyboard shortcut. # Commands for opening a new tab in the current Terminal window. Local CMD_NEWWIN=$CMD_PREFIX # Curiously, simply executing 'do script' with no further arguments opens a new *window*. ![]() # Command for opening a new Terminal window (with a single, new tab). Local CMD_PREFIX='tell application "Terminal" to do script' # All remaining parameters, if any, make up the command to execute in the new tab/window. ![]() *) # 1st argument reached proceed with argument-parameter analysis below. Local targetDesc='new tab in the active Terminal window' # If this function was invoked directly by a function named 'newwin', we open a new *window* instead # When invoked via a function named 'newwin', opens a new Terminal *window* instead. #Mac command tab delay code#Code source (coller dans votre profil bash, par exemple): # Opens a new tab in the current Terminal window and optionally executes a command. # Open new tab and execute script, but don't activate the new tab.ĬAVEAT : Lorsque vous exécutez newtab(ou newwin) à partir d'un script, le dossier de travail initial du script sera le dossier de travail dans le nouvel onglet / fenêtre, même si vous modifiez le dossier de travail à l'intérieur du script avant d' appeler newtab/ newwin- passer evalavec une cdcommande comme solution de contournement (voir l'exemple ci-dessus). # Open new tab, execute script, close tab. Newtab eval "ls \$HOME/Library/Application\ Support echo Press a key to exit. # Open new tab, execute commands, close tab. Newtab eval "cd ~/Library/Application\ Support ls" # Double-quote the command passed to `eval` and use backslash-escaping inside. # Open a new tab with a given working directory and execute a command Newtab ls -l "$Home/Library/Application Support" # Open new tab and execute command (quoted parameters are supported). Exemples d'appels: # Get command-line help. Si une commande est spécifiée, son premier jeton sera utilisé comme titre du nouvel onglet. Une fois installé, exécutez ttab -hpour obtenir des informations d'utilisation concises ou man ttabpour afficher le manuel.Įn s'appuyant sur la réponse acceptée, vous trouverez ci-dessous une fonction de commodité bash pour ouvrir un nouvel onglet dans la fenêtre actuelle du Terminal et éventuellement exécuter une commande (en prime, il existe une fonction de variante pour créer une nouvelle fenêtre à la place). (selon la façon dont vous avez installé Node.js, vous devrez peut-être ajouter sudo). #Mac command tab delay install#Si Node.js est installé, exécutez simplement: npm install -g ttab #Mac command tab delay plus#Mise à jour : Cette réponse a gagné en popularité grâce à la fonction shell publiée ci-dessous, qui fonctionne toujours à partir d'OSX 10.10 (à l'exception de l' -goption).Ĭependant, une version de script plus complète, plus robuste et testée est maintenant disponible dans le registre npm en tant que CLI ttab, qui prend également en charge iTerm2 : ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |