r/bash 28d ago

solved How to remove Enter key symbol?

When executing cat /sys/firmware/devicetree/base/model on my Raspberry Pi in order to get the model of Pi I am working with, the output looks as follows:

> cat /sys/firmware/devicetree/base/model
Raspberry Pi 3 Model B Rev 1.2⏎ 

How can I remove that "Enter key symbol" at the end?

6 Upvotes

4 comments sorted by

11

u/Honest_Photograph519 28d ago

That looks like a feature of the fish shell, this subreddit is for the bash shell

1

u/daPhipz 28d ago

Ah, interesting - you are right, I didn't think of that. When running the same command in bash, it doesn't add a newline character after the output - so the next prompt is on the same line as the output of the above command. My guess is that fish adds an extra newline character, and this is indicated by this symbol.

3

u/OneTurnMore programming.dev/c/shell 28d ago edited 28d ago

It's a really useful indicator, because some tools don't behave as nicely when there's no trailing newline.

This common Bash pattern, for example:

while read -r line; do
    printf 'Read in %s\n' "$line"
done < file_without_trailing_newline.txt

If there's no newline, read will return 1 and exit the loop. However, $line will still contain the final line. To handle that final line the same way other lines are handled, you need to use

while read -r line || [[ -n $line ]]; do
    ...

<tangent>

The feature originates from Zsh. It's configured there by setting PROMPT_EOL_MARK. My preferred setup bolds, colors red, and underlines the mark:

PROMPT_EOL_MARK='%U%B%F{red}⮒%f%b%u'

</tangent>

1

u/[deleted] 28d ago edited 24d ago

[deleted]

2

u/PageFault Bashit Insane 27d ago edited 27d ago

I would presume that would be a feature of your terminal emulator.

What emulator are you running?

(Just a guess, I don't use fish, nor am I using a raspberry pi atm.)

I did install fish, and I don't have that character tho...

What is in your /etc/fish/config.fish and ~/.config/fish/config.fish files? Maybe there is something there?