LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 02-11-2022, 05:13 AM   #1
zrdc28
Member
 
Registered: Dec 2007
Location: Alabama USA
Distribution: Slackware current
Posts: 309

Rep: Reputation: 55
# sign instead of $ when user terminal


I just did a clean install of Slackware 15, everything went well except I have 2 problems. when in user mode terminal displays a # sign.
I have searched and tried everything I found on web but to no joy.


My second problem is that I cannot get .bashrc to run when in root
to be able to add colors, aliases etc. I assume that one problem solved will probably correct both. but I have not been able to find that solution.

https://www.linuxquestions.org/quest...eply&p=6163004

I found the answer in my own posts from about 18 months ago. getting old is
not always fun!

Last edited by zrdc28; 02-11-2022 at 05:15 PM. Reason: update
 
Old 02-11-2022, 05:31 AM   #2
marav
LQ Sage
 
Registered: Sep 2018
Location: Gironde
Distribution: Slackware
Posts: 5,395

Rep: Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122
You can find a lot of .bashrc examples here:

http://dotshare.it/category/shells/bash/
 
1 members found this post helpful.
Old 02-11-2022, 05:38 AM   #3
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,910

Rep: Reputation: 5026Reputation: 5026Reputation: 5026Reputation: 5026Reputation: 5026Reputation: 5026Reputation: 5026Reputation: 5026Reputation: 5026Reputation: 5026Reputation: 5026
Here's what I use:

Code:
# ~/.bash_profile ######################################################

case $- in
*i* )  # Interactive shell
       if [ -f ~/.bashrc ]; then
          . ~/.bashrc
       fi
       ;;
esac

########################################################################
Code:
# ~/.bashrc ############################################################

[ -r "$ENV" ]  &&  . "$ENV"
[ -r /etc/bashrc ]  &&  . /etc/bashrc


shopt -s checkwinsize          # Keep track of terminal size

# Aliases:

alias less='less -XFRM'

# Bail out if we're not on a full-feature terminal:
if [ "$TERM" == 'dumb' ]; then
  return 0
fi

# ANSI Terminal control sequences to implement text styles,
# for use in prompts (and/or elsewhere):
declare -A style=(
  [default]=$( tput -S <<< $'sgr0\nop' )
  [prompt]=$( tput -S <<< $'sgr0\nop\nbold' )
  [input]=$( tput -S <<< $'sgr0\nop\nbold\nsetaf 5' )
  [warning]=$( tput -S <<< $'sgr0\nop\nbold\nsetaf 3' )
  [error]=$( tput -S <<< $'sgr0\nop\nbold\nsetaf 1' )
)

# Bash prompts:
#   'trap' ensures we clean up after ourselves on exit.
trap "tput -S <<< $'sgr0\nop'" EXIT
PS1=\\[${style[prompt]}\\]\\$\ \\[${style[input]}\\]
PS2=\\[${style[prompt]}\\]\>\ \\[${style[input]}\\]
PS0=${style[default]}

########################################################################
 
Old 02-11-2022, 07:55 AM   #4
shelldweller
Member
 
Registered: Mar 2019
Distribution: Slackware
Posts: 300

Rep: Reputation: Disabled
Quote:
Originally Posted by zrdc28 View Post
I just did a clean install of Slackware 15, everything went well except I have 2 problems. when in user mode terminal displays a # sign.
I have searched and tried everything I found on web but to no joy.
That sounds like you are logging in as root user. Is it safe to assume you have created a non-root user and are logging in with that user? The # symbol indicates a root terminal, usually. Forgive me if this is too obvious and you have already ruled that out.
 
Old 02-11-2022, 08:01 AM   #5
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,910

Rep: Reputation: 5026Reputation: 5026Reputation: 5026Reputation: 5026Reputation: 5026Reputation: 5026Reputation: 5026Reputation: 5026Reputation: 5026Reputation: 5026Reputation: 5026
PS1=$ will display a '$'
PS1=\$ will also display a '$'
PS1=\\$ will display a '$' for non-root and a '#' for root.

And if that \\$ is followed by a word that could be interpreted as a shell variable, you need to do: PS1=\\\$word

Also, whether or not you use single or double quotes or not can confuse matters.

When setting PS1, you need to get the shell-escaping right in order to get the desired result.

Last edited by GazL; 02-11-2022 at 08:07 AM.
 
Old 02-11-2022, 08:16 AM   #6
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,930

Rep: Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321
you can find good pages on the net regarding PS1, like this: https://bashrcgenerator.com/
 
Old 02-11-2022, 08:48 AM   #7
pm_a_cup_of_tea
Member
 
Registered: May 2021
Posts: 58

Rep: Reputation: Disabled
For what its worth here is my .bashrc:

Code:
FILES=~/.config/bash/*

for f in $FILES; do
    source $f
done
Code:
$ls ~/.config/bash/

aliases  bashPrompt  colouredMan  dirColors  functions
Code:
$cat bashPrompt

#!/bin/bash

# Test to see what terminal we have and change the prompt accordingly
if [ $TERM == linux ]; then
        if [[ $(id -u) == 0 ]]; then
                export PS1="[\[\e[31m\]\u\[\e[m\]]-[\[\e[32m\]\w\[\e[m\]] \n\[$(tput sgr0)\][\[\e[36m\]\A\[\e[m\]]--> "
        else
                export PS1="[\[\e[1;34m\]\u\[\e[m\]]-[\[\e[32m\]\w\[\e[m\]] \n\[$(tput sgr0)\][\[\e[36m\]\A\[\e[m\]]--> "
        fi
else
        compile_prompt () {
           local EXIT=$?
           local CONNECTBAR_DOWN=$'\u250C\u2500\u257C'
           local CONNECTBAR_UP=$'\u2514\u2500\u257C'
           local SPLITBAR=$'\u257E\u2500\u257C'
           local ARROW=$'\u25B6'
           local c_gray='\e[01;30m'
           local c_blue='\e[0;34m'
           local c_cyan='\e[0;36m'
           local c_reset='\e[0m'
           # If root change color of prompt
           if [[ $(id -u) == 0 ]] 
           then
                  local c_blue='\e[0;31m'
                  local c_gray='\e[00;30m'
           fi
         
           # > Connectbar Down
           # Format:
           #   (newline)(bright colors)(connectbar down)
           PS1="\n${c_gray}"
           PS1+="$CONNECTBAR_DOWN"
         
           # > Username
           # Format:
           #   (bracket open)(username)(bracket close)(splitbar)
           PS1+="[${c_blue}\u${c_gray}]"
           PS1+="$SPLITBAR"
         
           # > Jobs
           # Format:
           #   (bracket open)(jobs)(bracket close)(splitbar)
           PS1+="[${c_blue}\j${c_gray}]"
         
           # > Exit Status
           # Format:
           #   (bracket open)(last exit status)(bracket close)(splitbar)
           PS1+="[${c_blue}${EXIT}${c_gray}]"
           PS1+="$SPLITBAR"
         
           # > Time
           # Format:
           #   (bracket open)(time)(bracket close)(newline)(connectbar up)
           PS1+="[${c_blue}\D{%H:%M:%S}${c_gray}]\n"
           PS1+="$CONNECTBAR_UP"
         
           # > Working Directory
           # Format:
           #   (bracket open)(working directory)(bracket close)(newline)
           PS1+="[${c_blue}\w${c_gray}]\n"
         
           # > Arrow
           # NOTE: Color must be escaped with '\[\]' to fix the text overflow bug!
           # Format:
           #   (arrow)(color reset)
           PS1+="$ARROW \[\e[0m\]"
         }
         
         PROMPT_COMMAND='compile_prompt'
fi
The xterm prompt was lifted from the nord color theme, with some changes.

The chances are you do not want to do it the way that I have

Last edited by pm_a_cup_of_tea; 02-11-2022 at 08:56 AM.
 
Old 02-11-2022, 01:14 PM   #8
TheRealGrogan
Member
 
Registered: Oct 2010
Location: Ontario, Canada
Distribution: Slackware, LFS, Manjaro (for gaming)
Posts: 570

Rep: Reputation: 413Reputation: 413Reputation: 413Reputation: 413Reputation: 413
You didn't, on the off chance, make your user UID 0 did you? (i.e. that is allowed so you can have multiple root accounts by doing that)

That would cause your prompt to show #
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] why my phpldapadmin there is no + sign only "?" that sign aryafedrik Linux - Newbie 2 11-07-2018 07:45 PM
£ sign doesn't appear correctly in terminal and vim ilnli Linux - General 1 09-18-2011 08:06 AM
Can not sign in as root in the terminal of kubnutu ,xubuntu or edubuntu kotter Linux - Newbie 6 02-20-2008 08:04 PM
sign on invisible in gaim - NOT invi after sign on saravkrish Linux - Software 7 09-12-2005 10:55 PM
Shorten a Qmail user name to "user" instead of "user@domain.com" anorman Linux - Software 0 12-12-2003 08:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 08:03 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration