Possibility of bbedit Terminal Command on SSH Connections

79 views
Skip to first unread message

Rick Gordon

unread,
Jul 11, 2018, 7:41:45 PM7/11/18
to bbe...@googlegroups.com
Is there any way that a bbedit command could be built to run in Terminal
on a remote system? I realize that it would have to be a different
creature, since that system would have no knowledge of BBEdit.

But I wondered about something like a command which might cause a file
to be delivered to the Mac via scp in to a watch folder on the Mac that
BBEdit could monitor, open, edit, and return the edited file to the host
system, with a result similar to opening a remote file via SSH on the Mac.

The end result would be an executable that could be stored on the host
system and run similar to the basic syntax for the command-line
executable as used on the Mac, such as:

bbedit path-to-file

Does that even make any sense, in term of logistics?

___________________________________________
RICK GORDON
EMERALD VALLEY GRAPHICS AND CONSULTING
___________________________________________
WWW: http://www.shelterpub.com

Jean-Christophe Helary

unread,
Jul 11, 2018, 7:48:10 PM7/11/18
to bbe...@googlegroups.com


On Jul 12, 2018, at 8:41, Rick Gordon <li...@rickgordon.com> wrote:

The end result would be an executable that could be stored on the host system and run similar to the basic syntax for the command-line executable as used on the Mac, such as:

bbedit path-to-file

Does that even make any sense, in term of logistics?

If you have scp on the host system already a bash script would probably do, wouldn't it?

Jean-Christophe Helary
-----------------------------------------------
http://mac4translators.blogspot.com @brandelune


Steve deRosier

unread,
Jul 11, 2018, 7:51:09 PM7/11/18
to bbedit
Yup, this is exactly how I use it on my Linux systems.  I have a bash function that exists in my .bashrc that ssh's back to my mac and starts bbedit with a commandline to open the relevant file via sftp.

Here's the snipit from by .bashrc:

export REMOTEHOST=`echo $SSH_CLIENT | cut -d ' ' -f 1`
export HOSTIP=`echo $SSH_CONNECTION | cut -d ' ' -f 3`

function bbedit {

# bbedit won't open a remote file via sftp if it doesn't exist. So, if it's a new file
# create it, call bbedit to open, and then kill it.
FCREATED=0
if [ ! -e "$PWD/$1" ]
then
touch "$PWD/$1"
FCREATED=1
fi
ssh derosier@$REMOTEHOST /usr/local/bin/bbedit -c -u --front-window "sftp://$USER@$HOSTIP/$PWD/$1"
# The above call will background and return immediately. The file will open in bbedit
# but since we've created it, and we don't want to leave it around, we kill it right away.
# If the user saves it, it gets recreated and content is saved. If not, there's no file,
# so we're cool too. It's a bit odd, but it works.
if [ "$FCREATED" -eq "1" ]
then
rm "$PWD/$1"
fi
}

The really important part is the ssh line.  The rest is just to create/clear new files.  If you do `bbedit .` it will open an sftp browser in that directory, and if you do `bbedit filename` it will open that file.

The other important thing to note is I have my .ssh/config file set to always use IPv4 on these hosts.  I'm sure I could fix it but IPv6 screws it up and I haven't bothered to figure out why. 

Additionally, I have bbedit used as my CSCOPE_EDITOR.  This can't use functions, so I have a little script, ~/bin/bbeditcscope that contains this one line:

ssh derosier@$REMOTEHOST /usr/local/bin/bbedit --front-window $1 "sftp://$USER@$HOSTIP/$PWD/$2"

Note that this really only works properly with current versions of BBEdit as they recently fixed a bug for me (talk about good customer service) that relates to the line number syntax.

I hope that helps,
- Steve
 

--
This is the BBEdit Talk public discussion group. If you have a
feature request or would like to report a problem, please email
"sup...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>
---
You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+un...@googlegroups.com.
To post to this group, send email to bbe...@googlegroups.com.
Visit this group at https://groups.google.com/group/bbedit.

Rick Gordon

unread,
Jul 11, 2018, 9:00:25 PM7/11/18
to bbe...@googlegroups.com
Steve, that's great!

Not quite working for me though. I successfully get logged into my Mac,
but get an error:

error opening
sftp://REDACTED_USER@REDACTED_IP//REDACTED_PATH/SOME_FILE.txt:
This server operation couldn’t be completed because the connection was
unexpectedly lost (application error code: 22807).
bbedit: error: 22807

This seems to relate to errors being discussed on this page:

http://blog.kenweiner.com/2011/02/edit-remote-ec2-text-files-with.html

…where a similar workflow for TextWrangler is being discussed.

Running BBEdit 12.x on OS 10.11.6.

Thanks in advance for any suggestions.

Rick Gordon

--------------------
On July 11, 2018 at 5:54:03 PM [-0700],
Steve Derosier wrote in an email entitled
"Re: Possibility of bbedit Terminal Command on SSH Connections":

Steve deRosier

unread,
Jul 11, 2018, 9:14:19 PM7/11/18
to bbedit
Well, first off, I am going from a Mac to Linux, where I have full control over my ssh server configuration.  I don't off the top of my head know what configurations on the Mac side would get in the way.

Second off, I use keys for all of my ssh sessions, not passwords. Perhaps that's an issue here?

Finally, I did have wonky errors until I forced IPv4 in my ssh config:

Host XXXXXX.local
HostName XXXXXX.local
ForwardX11 yes
ForwardX11Trusted yes
TCPKeepAlive yes
ServerAliveInterval 60
AddressFamily inet

Granted, I'm sure I could debug and fix the IPv6 stuff, but it worked before with IPv4 so forcing it back to that solved my issues.

Beyond that, I'm not sure what to suggest.

- Steve


Rick Gordon

unread,
Jul 11, 2018, 9:15:51 PM7/11/18
to bbe...@googlegroups.com
Figured it out. I forgot that I needed to supply an alternate port number.

Thanks. That's awesome!

Rick Gordon

--------------------
On July 11, 2018 at 6:14:44 PM [-0700],
Rick Gordon wrote in an email entitled

Charlie Garrison

unread,
Jul 11, 2018, 11:29:57 PM7/11/18
to bbe...@googlegroups.com

On 12 Jul 2018, at 9:41, Rick Gordon wrote:

Does that even make any sense, in term of logistics?

Yes, and there is already a script for it:

Everyone else using a different method; is there something that would make rbbedit more useful for you?

-cng

--

Charlie Garrison                   <cha...@garrison.com.au>
Garrison Computer Services      <http://www.garrison.com.au>
PO Box 380
Tumbarumba NSW 2653  Australia

Charlie Garrison

unread,
Jul 12, 2018, 12:34:54 AM7/12/18
to bbe...@googlegroups.com

On 12 Jul 2018, at 14:08, Christopher Stone wrote:

I suggest you change this to `curl`, since `wget` is not installed by default in any macOS.

I suspect curl is also used by the install script. Any chance I could get you to submit an "issue" on GitHub so I don't forget to make that change.

-cng

PS. Really?!! curl is not installed on new systems? Thanks for pointing it out, and wow, that surprises me.

PPS. I just realised that the instruction/command you refer to is for installing on remote host (which may or may not be an OSX host). In general (across all distros), I wonder whether curl or wget is more likely to be installed.

Reply all
Reply to author
Forward
0 new messages