Thanks Steve !
interesting how you handle the "new file" creation. I was under the
impression that bbedit could override it via sftp/scp. Another challenge is
the handling after "sudo su - toor" as then all SSH information is gone. (
Some applications can't handle sudo - especially when an error occurred and
- from a user point of view - sudo is stuck. So I am using the ZSH
customised toor user for these root actions.
There might be a possibility to use sudoedit instead a complete switch to
toor, but that would also mean taht I need to wrap your scripting in
something like rbbedit as sudoedit is calling SUDO_EDITOR ...
Anyhow, good to know there are some workarounds available, while BareBones
is not supporting such a use case out of the box.
Steve schrieb am Freitag, 6. November 2020 um 17:25:10 UTC+1:
> I can't speak for rbbedit, but I do pretty much the same thing with a
> simple set of lines in my .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 $USER@$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
> }
>
> And then I just `bbedit file.txt` all day long. I spend all day ssh'd
> into Linux boxes editing kernel code and embedded Linux systems. I
> expect there's many ways to do this and make it compatible with sudo
> if you tinkered sufficiently. Note for cscope to work, you actually
> need a script. I have this and then I set my CSCOPE_EDITOR to the
> path:
> $ cat ~/bin/bbeditcscope
> #!/bin/bash
> # $1 : Line number from cscope in +## format
> # $2 : File name, relative to cscope's location
> ssh $USER@$REMOTEHOST /usr/local/bin/bbedit --front-window $1
> "sftp://$USER@$HOSTIP/$PWD/$2"
>
> I probably would've used rbbedit if it had existed when I started
> doing this, but the above works well for me and I've never had a
> reason to change my method.
>
> - Steve
>
>
> On Fri, Nov 6, 2020 at 5:43 AM Peace Keeper <[email protected]> wrote:
> >
> > Thanks Charlie,
> >
> > I have read some threads here in the forum about rbbedit. I just looked
> through the code on github and it is a nice script. I think for me a
> one-liner with scp might be enough. On the other side I think about
> changing my workflow a bit. As I am using anyhow tmux from the macOS with
> bbedit installed, Only challenge are files owned by root as I don't allow
> ssh connection for root. But I could change my workflow to use first git
> and push the file to my Mac as remote, then make changes with bbedit on my
> private "github" on my make includeing a checkin, then initate a git pull
> from remote. This workflow would bring me some additional improvments: all
> files are versioned, all files are backuped, a centralized repository for
> distributing the changes to all other server would be available.
> >
> > As I understand that BareBones is focusing on the macOS, a bbedit-daemon
> on remote systems would be a nice feature and might be needed anyhow in the
> future: if people switch from laptop to tablets only , they will
> program/work directly on the remote machines using the tablet only as a
> front-end ( Something like a dump terminal with some local features) In
> this case. In a CI and CD environment that would be a nice feature.
> >
> > Charlie Garrison schrieb am Donnerstag, 5. November 2020 um 23:38:18
> UTC+1:
> >>
> >> On 6 Nov 2020, at 8:30, Peace Keeper wrote:
> >>
> >> Too bad, that I can't use bbedit from a remote tmux session to initiate
> an edit of a local file on a remote server. Seems I still have to initiate
> that from macOS
> >>
> >> It's not the actual editor, but rbbedit will help with editing files
> using BBEdit, that you have on remote servers.
> >>
> >> https://github.com/cngarrison/rbbedit
> >>
> >> Edit local (server) files on remote (users) workstation using BBEdit.
> >>
> >> -cng
> >>
> >> --
> >>
> >> Charlie Garrison <[email protected]>
> >> Garrison Computer Services <http://www.garrison.com.au>
> >> PO Box 380
> >> Tumbarumba NSW 2653 Australia
> >
> > --
> > This is the BBEdit Talk public discussion group. If you have a feature
> request or need technical support, please email "[email protected]"
> rather than posting here. Follow @bbedit on Twitter: <
> https://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 [email protected].
> > To view this discussion on the web visit
> https://groups.google.com/d/msgid/bbedit/4ae46a8d-38c4-4388-8d78-76963208c6bfn%40googlegroups.com
> .
>
--
This is the BBEdit Talk public discussion group. If you have a feature request
or need technical support, please email "[email protected]" rather than
posting here. Follow @bbedit on Twitter: <https://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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/bbedit/6d7cfb62-a345-4040-a081-c3f4b725d93cn%40googlegroups.com.