I am trying to set PS1 so that it prints out something just right after login, but preceded with a newline later.
Suppose export PS1=\"\\h:\\W \\u
Try the following:
function __ps1_newline_login {
if [[ -z "${PS1_NEWLINE_LOGIN}" ]]; then
PS1_NEWLINE_LOGIN=true
else
printf '\n'
fi
}
PROMPT_COMMAND='__ps1_newline_login'
export PS1="\h:\W \u\$ "
Explanation:
PROMPT_COMMAND is a special bash variable which is executed every time before the prompt is set. -z flag to check if the length of a string is 0.