How to open a terminal with a specific circuit to which it is connected?

How to use the terminal to open another terminal window, but with the specified path?

I use a machine to download my work material when I get started, but I need to know how to do this:

Open a terminal and type:
β€’ cd Work / Company / Project /
β€’ script / server

And then a new tab in this terminal window and the CD in the same folder.

+5
source share
4 answers

This opens a new terminal window from the command line on Mac OSX, runs "cd /", and then holds the window at the top:

osascript -e 'tell application "terminal"' -e 'do script "cd /"' -e 'end tell'

You can put this in a script like this:

#!/bin/sh
osascript -e 'tell application "terminal"' -e "do script \"cd $1\"" -e 'end tell'

, .

+6

applescript .

.

+2

script cd

, script, - cd /user/music - , myscript.sh chmod +x myscript.sh.

OS X

0

:

1) , "cd mydir"

2) , , ( 0), ,

. , , , . , , AppleScriptObjC - :

https://apple.stackexchange.com/questions/39204/script-to-raise-a-single-window-to-the-front http://tom.scogland.com/blog/2013/06/08/mac-raise-window-by-title/

Script 1 - :

< > /usr/local/bin/terminal-here.sh

#!/bin/sh
osascript `dirname $0`/terminal-here.scpt $1 > /dev/null 2> /dev/null

Script 2 - " AppleScript", :

< > /usr/local/bin/terminal-here.scpt

# AppleScript to cd (change directory) to a path passed as an argument

# If Terminal.app is running, the script will open a new window and cd to the path
# If Terminal.app is NOT running, we'll use the window that Terminal opens automatically on launch

# Run script with passed arguments (if any)
on run argv
    if (count of argv) > 0 then
        # There was an argument passed so consider it to be the path
        set mypath to item 1 of argv
    else
        # Since no argument was passed, default to the home directory
        set mypath to "~"
    end if
    tell application "System Events"
        if (count (processes whose bundle identifier is "com.apple.Terminal")) is 0 then
            # Terminal isn't running so we'll make sure to run the 'cd' in Terminal first window (0)
            tell application "/Applications/Utilities/Terminal.app"
                # Turn off echo, run the 'cd', clear screen, empty the scrollback, re-enable echo
                do script "stty -echo; cd " & (mypath as text) & ";clear; printf \"\\e[3J\"; stty echo" in window 0
                activate last window
            end tell
        else
            # Terminal is already running so we'll let it open a new window for our 'cd' command
            tell application "/Applications/Utilities/Terminal.app"
                # Turn off echo, run the 'cd', clear screen, empty the scrollback, re-enable echo
                do script "stty -echo; cd " & (mypath as text) & ";clear; printf \"\\e[3J\"; stty echo"
                activate last window
            end tell
        end if
    end tell
end run
0

All Articles