Friday, 27 July 2018

bash - Can I tell if I'm in an scp session in my .bashrc?


Inside my .bashrc, I'm doing a bunch of magic that causes problems when I'm trying to do an scp. The solution I've been going with is to manually ssh to the target machine, disable my .bashrc, do the copy, and then re-enable my .bashrc. Is there a way to get around this?



Answer



My standard bashrc on debian had this as the first lines:


if [ -z "$PS1" ]; then
return
fi

This checks if the variable $PS1 is set (which only is set if you're on an interactive shell), and prevents the execution of the rest if it isn't.


No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...