<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<atom:link href="https://dev1galaxy.org/extern.php?action=feed&amp;tid=4242&amp;type=rss" rel="self" type="application/rss+xml" />
		<title><![CDATA[Dev1 Galaxy Forum / ssh-tabbed xfce4-terminal]]></title>
		<link>https://dev1galaxy.org/viewtopic.php?id=4242</link>
		<description><![CDATA[The most recent posts in ssh-tabbed xfce4-terminal.]]></description>
		<lastBuildDate>Mon, 05 Apr 2021 10:55:25 +0000</lastBuildDate>
		<generator>FluxBB</generator>
		<item>
			<title><![CDATA[Re: ssh-tabbed xfce4-terminal]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=28825#p28825</link>
			<description><![CDATA[<p>Thanks. That&#039;s quite useful. Much of it valid! The script obviously is a &quot;works-for-me&quot; kind of script <img src="https://dev1galaxy.org/img/smilies/smile.png" width="15" height="15" alt="smile" /></p><p>The line 36 note is misconceived though as that line actually needs the globbing and word splitting; the other ones are good if not terribly important.</p><p>And line 29 should rather include a <span class="bbc">sed</span> filtering to discard all but the lilne numbers; I&#039;m not sure a while loop will work since bash runs those in sub processes(?); does a history command in the sub change the history list of the parent?</p><p>But in any case I&#039;ll leave those improvements as exercise.</p><p>EDIT: also, the grep at line 29 should rather be <span class="bbc">grep -nFx &quot;$TABBED&quot; &quot;$HISTFILE&quot;</span> to match the input verbatim (i.e., to avoid that it gets interpreted as a pattern).</p>]]></description>
			<author><![CDATA[dummy@example.com (ralph.ronnquist)]]></author>
			<pubDate>Mon, 05 Apr 2021 10:55:25 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=28825#p28825</guid>
		</item>
		<item>
			<title><![CDATA[Re: ssh-tabbed xfce4-terminal]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=28822#p28822</link>
			<description><![CDATA[<p>I ran the script through <a href="https://www.shellcheck.net/" rel="nofollow">https://www.shellcheck.net/</a> and it had some observations:</p><div class="codebox"><pre class="vscroll"><code>Line 14:
    exec env TABBED=&quot;$*&quot; xfce4-terminal -e $0 || exit 1
                                           ^-- SC2086: Double quote to prevent globbing and word splitting.

Did you mean: (apply this, apply all SC2086)
    exec env TABBED=&quot;$*&quot; xfce4-terminal -e &quot;$0&quot; || exit 1
 
Line 18:
    HISTFILE=$HOME/.$(basename $0)
                               ^-- SC2086: Double quote to prevent globbing and word splitting.

Did you mean: (apply this, apply all SC2086)
    HISTFILE=$HOME/.$(basename &quot;$0&quot;)
 
Line 22:
    read -e -i &quot;$TABBED&quot; -p &quot;ssh: &quot; TABBED
    ^-- SC2162: read without -r will mangle backslashes.
 
Line 24:
        printf &quot;\033]0;$(hostname)\007&quot;
               ^-- SC2059: Don&#039;t use variables in the printf format string. Use printf &#039;..%s..&#039; &quot;$foo&quot;.
 
Line 29:
    for N in $(grep -n &quot;^$TABBED\$&quot; $HISTFILE | sort -rn) ; do
             ^-- SC2013: To read lines rather than words, pipe/redirect to a &#039;while read&#039; loop.
                                    ^-- SC2086: Double quote to prevent globbing and word splitting.

Did you mean: (apply this, apply all SC2086)
    for N in $(grep -n &quot;^$TABBED\$&quot; &quot;$HISTFILE&quot; | sort -rn) ; do
 
Line 30:
        history -d ${N%%:*}
                   ^-- SC2086: Double quote to prevent globbing and word splitting.

Did you mean: (apply this, apply all SC2086)
        history -d &quot;${N%%:*}&quot;
 
Line 35:
printf &quot;\033]0;${TABBED%% *}\007&quot;
       ^-- SC2059: Don&#039;t use variables in the printf format string. Use printf &#039;..%s..&#039; &quot;$foo&quot;.
 
Line 36:
exec ssh $TABBED
         ^-- SC2086: Double quote to prevent globbing and word splitting.

Did you mean: (apply this, apply all SC2086)
exec ssh &quot;$TABBED&quot;</code></pre></div><p>I would also observe that for a bash script <span class="bbc">[[</span> should probably be preferred over <span class="bbc">[</span>: <a href="http://mywiki.wooledge.org/BashGuide/Practices#Bash_Tests" rel="nofollow">http://mywiki.wooledge.org/BashGuide/Pr … Bash_Tests</a></p><p>If <span class="bbc">[[</span> is used then you don&#039;t have to quote the variable because that keyword doesn&#039;t perform word splitting or glob expansion.</p>]]></description>
			<author><![CDATA[dummy@example.com (Head_on_a_Stick)]]></author>
			<pubDate>Mon, 05 Apr 2021 09:46:22 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=28822#p28822</guid>
		</item>
		<item>
			<title><![CDATA[ssh-tabbed xfce4-terminal]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=28820#p28820</link>
			<description><![CDATA[<p>If you use xfc4-terminal for running different ssh in its tabs, then this little scriptlet might suit you.</p><p>I have it set up to run in a launcher on the panel, for starting an xfce-terminal that begins by asking for the ssh command line arguments before connecting like so; an empty argument line&#160; starts a local shell tab. Then the same happens on every C-S-T tab in that terminal. Quite handy.</p><p>File <span class="bbc">/home/ralph/bin/remote.xfce4</span></p><div class="codebox"><pre class="vscroll"><code>#!/bin/bash
#
# Start an xfce4-terminal that runs ssh in each new tab, prompting for
# ssh command arguments, or drops to an interactive shell for empty
# arguments. Typically invoked by a launcher or a command line as
#     /whatever/the/path/remote.xfce4
# or with initial ssh arguments
#    /whatever/the/path/remote.xfce4 &lt;arguments...&gt;
#
# The script defines and uses the environment variable TABBED
# which gets cleared for a local shell.

if [ -z &quot;$TABBED&quot; ] ; then
    exec env TABBED=&quot;-&quot; xfce4-terminal -e &quot;$0 $1&quot; || exit 1
fi
TABBED=&quot;$*&quot;
if [ -z &quot;$TABBED&quot; ] ; then
    HISTFILE=&quot;$HOME/.$(basename $0)&quot;
    history -r
    # The following line defaults to reusing the last ssh argument line
    TABBED=&quot;$(history -p &quot;!!&quot; )&quot;
    read -e -r -i &quot;$TABBED&quot; -p &quot;ssh: &quot; TABBED
    if [ -z &quot;$TABBED&quot; ] ; then
	printf &quot;\033]0;%s\007&quot; &quot;$(hostname)&quot;
	[ -z &quot;$SHELL&quot; ] &amp;&amp; SHELL=/bin/bash
	exec $SHELL -i || exit 1
    fi
    # The following 3 lines remove any prior duplicate ssh argument lines
    for N in $(grep -nFx &quot;$TABBED&quot; $HISTFILE | sed &#039;s/:.*//&#039; | sort -rn) ; do
	history -d $N
    done
    history -s &quot;$TABBED&quot;
    history -w
fi
printf &quot;\033]0;%s\007&quot; &quot;${TABBED%% *}&quot;
exec ssh $TABBED</code></pre></div><p>Note that the history fiddling in the script, which makes the script look complicated, is not really required for the &quot;tabbed ssh&quot; functionality. It could be edited out, but it&#039;s there in order to make the ssh arguments input interaction &quot;friendlier&quot; by allowing for up/down arrow stepping through the history of such inputs.</p><p>Enjoy</p><p>EDIT: Note that the xfce4-terminal preferences also needs to be set up to run the script as custom command for tabs in order for the script (rather than shell) to be run for tabs.</p><p>EDIT 2: changed the code for bug fixing and to incorporate @Head_on_a_stick&#039;s touch up points (below). This might be a final verrsion <img src="https://dev1galaxy.org/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[dummy@example.com (ralph.ronnquist)]]></author>
			<pubDate>Mon, 05 Apr 2021 03:55:25 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=28820#p28820</guid>
		</item>
	</channel>
</rss>
