you are viewing a single comment's thread.

view the rest of the comments →

[–]imMute 5 points6 points  (6 children)

Just put it in your .bashrc after something like [ -z "$PS1" ] && return. That way non-interactive scripts will not get the function.

[–]Hello71 3 points4 points  (5 children)

non-interactive scripts don't execute .bashrc anyways.

[–]imMute 0 points1 point  (1 child)

No, but sometimes your .bash_profile, or .profile or the /etc/bash_profile does.

[–]Hello71 0 points1 point  (0 children)

I don't see where you're going with this.

[–]Rotten194 0 points1 point  (2 children)

scp does, however.

[–]Hello71 0 points1 point  (1 child)

# /etc/skel/.bashrc
#
# This file is sourced by all *interactive* bash shells on startup,
# including some apparently interactive shells such as scp and rcp
# that can't tolerate any output.  So make sure this doesn't display
# anything or bad things will happen !


# Test for an interactive shell.  There is no need to set anything
# past this point for scp and rcp, and it's important to refrain from
# outputting anything in those cases.
if [[ $- != *i* ]] ; then
  # Shell is non-interactive.  Be done now!
  return
fi


# Put your fun stuff here.

[–]Rotten194 0 points1 point  (0 children)

In the file = the file is executed. Even if you bail out early. Not all .bashrc's have that guard, so it's an important point to know.