thinknoob.blogg.se

Run ssh on mac terminal and open a new terminal window
Run ssh on mac terminal and open a new terminal window







run ssh on mac terminal and open a new terminal window

Thus, by using this -s option, and still as a self-contained solution, it would be like: xterm -e bash -init-file /dev/fd/3 -s 3<<'EOF' The Bash's (and POSIX) -s option allows you to specify arguments to an interactive shell just like you do to a non-interactive one 1.

run ssh on mac terminal and open a new terminal window

It would instead be needed if, by taking your question's title literally, you'd wish a job-controlling shell yet not a fully interactive one. Note also that I left the set -m command for familiarity to your original script and because it's harmless, but it is actually superfluous here because -init-file implies an interactive bash which implies -m. bashrc, as that is Bash's standard behavior for interactive shells. On a side-note, depending on your setup you might consider sourcing /etc/bash.bashrc too, prior to the user's. ~/.bashrc set -m vim Bash's versions below 4.4 we can obtain the same by using its printf %q, like this (as Here Document for better readability, but would do the same as a Here String like above): printf -v files ' %q' -e bash -init-file /dev/fd/3 3< run ssh on mac terminal and open a new terminal window

This trick works fine as long as no intermediate process closes the file-descriptors it received from its parent. On the other hand it has a possible caveat wrt the file-descriptor's actual persistence from the script all the way through to the inner shell. This is especially handy here because the contents of the -init-file is dynamic due to the expansion. ~/.bashrc set -m vim bonus point of this file-descriptor-on-filesystem trick is that you have a self-contained solution, as it does not depend on external helper files such as your. Such file-descriptor might refer to a Here String where you would handle the filenames, like this: xterm -e bash -init-file /dev/fd/3 3<<<". It consists in making your script expand its array, thus doing it on behalf of the inner interactive bash, and you might use the /dev/fd/X file-descriptor-on-filesystem facility (if available on your system) as parameter to the -init-file argument. However, as that may also be a matter of taste, I'm covering both. I could think of a couple of methods, and I think the first one is less hackish on Bash mainly because it seems (to me) to have quirks that can be more easily handled. Results in a new terminal with Bash and a suspendable Vim.īut this way I cannot see how the files Vim should open could be specified. ~/.bashrcĪnd now, calling xterm -e bash -init-file ~/.vimbashrc bashrc) can be specified for Bash to source. The answers there explain how a differentįile (instead of. Run an interactive bash subshell with initial commands Other programs which run interactively in the terminal and receive arguments would benefit from a solution. Special chars ( *!&|$.) happen to show up in the file names. On the other hand, the script should not break if such The script would be executed by a file-manager, the selected text files being supplied as arguments.ĭo not worry, I am sane and usually do not name my files like that. It would receive the files asĪrguments: script 'my|file*' '!another file&' I cannot figure out a script to carry out steps 1Īnd 2 without relinquishing step 3 (job-control).

  • Vim becomes a suspended job, the Bash prompt is presented again.
  • Vim starts, with my|file* and !another file& to be edited.
  • It has all the machinery you need to run commands.In an X session, I can follow these steps: Here's my awesome script, it creates a new terminal window if needed and switches to the directory Finder is in if Finder is frontmost.

    #Run ssh on mac terminal and open a new terminal window mac os x

    Running a command in a new Mac OS X Terminal window









    Run ssh on mac terminal and open a new terminal window