Search code examples
iterm2iterm

iterm 2 issuing commands in multiple panes with parameters


I am using iterm for deployment into multiple servers and use the feature to run the common command to issue to all the panels. This is a good feature. However, there are times when I need to run the parametrized commands.i.e, hostname will be different and I would parametrize the hostname. Is this possible to issue parametrized command in iterm2.


Solution

  • You can Broadcast to multiple shells using env. variables assigned to different values in each shell:

    shell #1:

    >echo $RANDOM
    11798
    

    and shell #2 shows:

    >echo $RANDOM
    21342
    

    So assign your hostname to a local env. variable (i.e. DEPLOYMENTHOSTNAME=DifferentHost) in each shell before enabling broadcasting and then you can enable broadcasting:

    >cd ~/releasebuild
    >scp newlibrary.so pradeep@$DEPLOYMENTHOSTNAME:/remote/deploy/directory