Skip to content

SCP Fails without error \033[?25l\033[?7l\033[38;5;12m\033[1m .',;::::;,'.]]]]

The error message

When you try to copy a file from a remote host to your local machine, the command fails without any error message.

laurence@WLPPSSWI1-67864:~$ scp carbon:/etc/hosts .
\033[?25l\033[?7l\033[38;5;12m\033[1m             .',;::::;,'.]]]]

Problem

The problem is neofetch or another application in .bashrc is outputting ANSI escape codes. These escape codes are not interpreted by scp and cause the command to fail without an error message.

Solution

Update the .bashrc file to only output ANSI escape codes when the shell is interactive.

This is my updated bashrc with if statement around neofetch, so it is only executed with interactive sessions.

$ cat ~/.bashrc
# Only if interactive terminal
if [[ $- == *i* ]]; then
    if command -v neofetch &>/dev/null; then
        neofetch --disable packages wm theme de icons --color_blocks off
    fi
fi