#!/usr/bin/env bash # scp /tmp/abc.sh SERVER1:~/bin && ssh SERVER1 "~/bin/abc.sh" echo "Hello Stack Exchange" echo "thanks for the help
I would like to be able to use a keyboard mapping to be able to do
<leader>r when my cursor is on line 2 and run the command in the bash shell. To do this, I need to be able to remove the
# at the start of line two.
:.w writes the whole line and it appears there is no way to use
:w ! bash on a partial line. I've also tried
:.w !sed "s/^# \(.*\)/\1/" but sed appears to have a problem with the
# as part of command (E194).
It seems this should be relatively easy but I'm at my wits end. I'm running a Mac with Bash 5.2. Any help appreciated.