You are not logged in.

#1 2013-02-07 14:20:51

BaBaTiKiDiDo
Member
From: Montreal, QC
Registered: 2013-02-07
Posts: 4

[SOLVED] Can't get my PS1 to be customised when connecting over SSH

Hi all,

I am somewhat experienced with Linux, I have been playing with OpenSuSE 12.2 on my home server. I recently inherited a laptop with a broken screen so I thought I would try and install Arch Linux on it to turn it into a video surveillance system.

First of all, wow
I had no idea Arch Linux could be so lightweight yet so great to use. The wiki is definitely the best around with very detailed and accurate step by step guides with all the explanations needed to understand what is going on. Really impressed, congrats!!! And it's nice to have service files already written when installing a daemon (yes, I'm looking at you OpenSuSE).

Now, I followed the instructions there: https://wiki.archlinux.org/index.php/Co … stallation to try and modify my PS1.

I copy pasted the example files, uncommented the bit about fortune at logon and set it to brown as in the example. I installed fortune-mod, pkgfile and bash-completion. I did the modifications for /etc/skel and made sure ~/.bashrc didn't exist and rebooted. Twice. To make sure.

When I login over ssh, the fortune is displayed alright in what I assume to be brown (looks more like a poopy yellow) but the prompt is still what it's always been since I installed (root@hotsname ~ $ )

What am I doing wrong?

--edit2: Solved, see post #5
--edit: my /etc/bash.bashrc

# /etc/bash.bashrc
#
# https://wiki.archlinux.org/index.php/Color_Bash_Prompt
#
# 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 not running interactively, don't do anything!
[[ $- != *i* ]] && return

# Bash won't get SIGWINCH if another process is in the foreground.
# Enable checkwinsize so that bash will check the terminal size when
# it regains control.
# http://cnswww.cns.cwru.edu/~chet/bash/FAQ (E11)
shopt -s checkwinsize

# Enable history appending instead of overwriting.
shopt -s histappend

case ${TERM} in
	xterm*|rxvt*|Eterm|aterm|kterm|gnome*)
		PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'
		;;
	screen)
		PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033_%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'
		;;
esac

# fortune is a simple program that displays a pseudorandom message
# from a database of quotations at logon and/or logout.
# Type: "pacman -S fortune-mod" to install it, then uncomment the
# following line:

[[ "$PS1" ]] && echo -e "\e[00;33m$(/usr/bin/fortune)\e[00m"

# Set colorful PS1 only on colorful terminals.
# dircolors --print-database uses its own built-in database
# instead of using /etc/DIR_COLORS. Try to use the external file
# first to take advantage of user additions. Use internal bash
# globbing instead of external grep binary.

# sanitize TERM:
safe_term=${TERM//[^[:alnum:]]/?}
match_lhs=""

[[ -f ~/.dir_colors ]] && match_lhs="${match_lhs}$(<~/.dir_colors)"
[[ -f /etc/DIR_COLORS ]] && match_lhs="${match_lhs}$(</etc/DIR_COLORS)"
[[ -z ${match_lhs} ]] \
	&& type -P dircolors >/dev/null \
	&& match_lhs=$(dircolors --print-database)

if [[ $'\n'${match_lhs} == *$'\n'"TERM "${safe_term}* ]] ; then
	
	# we have colors :-)

	# Enable colors for ls, etc. Prefer ~/.dir_colors
	if type -P dircolors >/dev/null ; then
		if [[ -f ~/.dir_colors ]] ; then
			eval $(dircolors -b ~/.dir_colors)
		elif [[ -f /etc/DIR_COLORS ]] ; then
			eval $(dircolors -b /etc/DIR_COLORS)
		fi
	fi

	PS1="$(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h'; else echo '\[\033[01;32m\]\u@\h'; fi)\[\033[01;34m\] \w \$([[ \$? != 0 ]] && echo \"\[\033[01;31m\]:(\[\033[01;34m\] \")\$\[\033[00m\] "

	# Use this other PS1 string if you want \W for root and \w for all other users:
	# PS1="$(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h\[\033[01;34m\] \W'; else echo '\[\033[01;32m\]\u@\h\[\033[01;34m\] \w'; fi) \$([[ \$? != 0 ]] && echo \"\[\033[01;31m\]:(\[\033[01;34m\] \")\$\[\033[00m\] "

	alias ls="ls --color=auto"
	alias dir="dir --color=auto"
	alias grep="grep --colour=auto"

else

	# show root@ when we do not have colors

	PS1="\u@\h \w \$([[ \$? != 0 ]] && echo \":( \")\$ "

	# Use this other PS1 string if you want \W for root and \w for all other users:
	# PS1="\u@\h $(if [[ ${EUID} == 0 ]]; then echo '\W'; else echo '\w'; fi) \$([[ \$? != 0 ]] && echo \":( \")\$ "

fi

PS2="> "
PS3="> "
PS4="+ "

# Try to keep environment pollution down, EPA loves us.
unset safe_term match_lhs

# Try to enable the auto-completion (type: "pacman -S bash-completion" to install it).
[ -r /usr/share/bash-completion/bash_completion ] && . /usr/share/bash-completion/bash_completion

# Try to enable the "Command not found" hook ("pacman -S pkgfile" to install it).
# See also: https://wiki.archlinux.org/index.php/Bash#The_.22command_not_found.22_hook
[ -r /usr/share/doc/pkgfile/command-not-found.bash ] && . /usr/share/doc/pkgfile/command-not-found.bash

Last edited by BaBaTiKiDiDo (2013-02-07 16:02:08)


LG P300 - 320 GB storage - 4 GB RAM (3.7 GB free, thanks Arch Linux!!) - Broken screen

Offline

#2 2013-02-07 14:30:07

HungGarTiger
Member
From: nz/auckland/
Registered: 2012-06-27
Posts: 186

Re: [SOLVED] Can't get my PS1 to be customised when connecting over SSH

without more info it's impossible to tell, a copy of your .bashrc would be a good start


"No sympathy for the devil. If you buy the ticket, take the ride."
- Hunter S. Thompson

Offline

#3 2013-02-07 14:36:13

BaBaTiKiDiDo
Member
From: Montreal, QC
Registered: 2013-02-07
Posts: 4

Re: [SOLVED] Can't get my PS1 to be customised when connecting over SSH

Added it to first post

Last edited by BaBaTiKiDiDo (2013-02-07 15:11:30)


LG P300 - 320 GB storage - 4 GB RAM (3.7 GB free, thanks Arch Linux!!) - Broken screen

Offline

#4 2013-02-07 15:26:57

HungGarTiger
Member
From: nz/auckland/
Registered: 2012-06-27
Posts: 186

Re: [SOLVED] Can't get my PS1 to be customised when connecting over SSH

BaBaTiKiDiDo wrote:

Added it to first post

It seems very complicated, I'm not skilled enough to look through it but it looks like your missing a few "[ / ]" characters. This is my .baschrc, maybe you can copy and see how it goes. Like everything with Arch, simple is best - get to know it and learn it.

  1 #
  2 # ~/.bashrc
  3 #
  4 
  5 # If not running interactively, don't do anything
  6 command cowsay $(fortune)
  7 
  8 [[ $- != *i* ]] && return
  9 
 10 PATH="$HOME/bin:$PATH"
 11 
 12 
 13 ########## Colours and Jazz ##########
 14 
 15 alias ls='ls --color=auto'
 16 PS1='\[\033[0;35m\]┌[\[\033[0m\033[0;35m\]\e[0m\u\[\033[0m\]@\[\033[0;36m\]\h\[\033[0m\033[0;35\]][\[\033[0;36m\]\w\[\033[0;35m\]]\n\[\033[0;35m\]└\[\e[0m\] '
 17 
 18 
 19 
 20 
 21 ########## Bash Functions ##########
 22 
 23 extract () {
 24      if [ -f $1 ] ; then
 25          case $1 in
 26              *.tar.bz2)   tar xjf $1        ;;
 27              *.tar.gz)    tar xzf $1     ;;
 28              *.bz2)       bunzip2 $1       ;;
 29              *.rar)       rar x $1     ;;
 30              *.gz)        gunzip $1     ;;
 31              *.tar)       tar xf $1        ;;
 32              *.tbz2)      tar xjf $1      ;;
 33              *.tgz)       tar xzf $1       ;;
 34              *.zip)       unzip $1     ;;
 35              *.Z)         uncompress $1  ;;
 36              *.7z)        7z x $1    ;;
 37              *)           echo "'$1' cannot be extracted via extract()" ;;
 38          esac
 39      else
 40          echo "'$1' is not a valid file"
 41      fi
 42 }
 43 
 44 
 45 
 46 
 47 ########## Aliases ##########
 48 
 49 # pacman aliases 
 50 alias pac="sudo pacman -S"      # default action     - install one or more packages
 51 alias pacu="sudo pacman -Syu"   # '[u]pdate'         - upgrade all packages to their newest ver
 52 alias pacs="sudo pacman -Ss"    # '[s]earch'         - search for a package using one or more k
 53 alias paci="sudo pacman -Si"    # '[i]nfo'           - show information about a package
 54 alias pacr="sudo pacman -R"     # '[r]emove'         - uninstall one or more packages
 55 alias pacl="sudo pacman -Sl"    # '[l]ist'           - list all packages of a repository
 56 alias pacll="sudo pacman -Qqm"  # '[l]ist [l]ocal'   - list all packages which were locally ins
 57 alias paclo="sudo pacman -Qdt"  # '[l]ist [o]rphans' - list all packages which are orphaned
 58 alias paco="sudo pacman -Qo"    # '[o]wner'          - determine which package owns a given fil
 59 alias pacf="sudo pacman -Ql"    # '[f]iles'          - list all files installed by a given pack
 60 alias pacc="sudo pacman -Sc"    # '[c]lean cache'    - delete all not currently installed packa
 61 alias pacm="sudo makepkg -fci"  # '[m]ake'           - make package from PKGBUILD file in curre
 62 
 63 # services
 64 alias rc.d="systemctl -t service list-unit-files | grep -v static"  # list of services enabled/

Last edited by HungGarTiger (2013-02-07 15:29:10)


"No sympathy for the devil. If you buy the ticket, take the ride."
- Hunter S. Thompson

Offline

#5 2013-02-07 15:47:12

BaBaTiKiDiDo
Member
From: Montreal, QC
Registered: 2013-02-07
Posts: 4

Re: [SOLVED] Can't get my PS1 to be customised when connecting over SSH

I found out why.

the file /etc/DIR_COLORS contains a list of the terminals that are colorizable. I am SSHing using Mac OS X's Terminal app and this app is set to advertise itself as xterm-color (Preferences > Settings > Advanced).
However, xterm-color is not in /etc/DIR_COLORS. I added the line TERM xterm-color and it's no colouring my prompt.

I guess I should edit the wiki?


LG P300 - 320 GB storage - 4 GB RAM (3.7 GB free, thanks Arch Linux!!) - Broken screen

Offline

#6 2013-02-07 15:59:32

HungGarTiger
Member
From: nz/auckland/
Registered: 2012-06-27
Posts: 186

Re: [SOLVED] Can't get my PS1 to be customised when connecting over SSH

BaBaTiKiDiDo wrote:

I found out why.

the file /etc/DIR_COLORS contains a list of the terminals that are colorizable. I am SSHing using Mac OS X's Terminal app and this app is set to advertise itself as xterm-color (Preferences > Settings > Advanced).
However, xterm-color is not in /etc/DIR_COLORS. I added the line TERM xterm-color and it's no colouring my prompt.

I guess I should edit the wiki?

Maybe, but I would atleast change your OP (topic) to show you are ssh'ing into the shell. that will narrow down searches for those with similar issues - your OP doesn't reflect the fact you are ssh'ing into this shell and thats where your problem seems to arrise.

Last edited by HungGarTiger (2013-02-07 16:00:13)


"No sympathy for the devil. If you buy the ticket, take the ride."
- Hunter S. Thompson

Offline

#7 2013-02-07 16:03:21

BaBaTiKiDiDo
Member
From: Montreal, QC
Registered: 2013-02-07
Posts: 4

Re: [SOLVED] Can't get my PS1 to be customised when connecting over SSH

HungGarTiger wrote:
BaBaTiKiDiDo wrote:

I found out why.

the file /etc/DIR_COLORS contains a list of the terminals that are colorizable. I am SSHing using Mac OS X's Terminal app and this app is set to advertise itself as xterm-color (Preferences > Settings > Advanced).
However, xterm-color is not in /etc/DIR_COLORS. I added the line TERM xterm-color and it's no colouring my prompt.

I guess I should edit the wiki?

Maybe, but I would atleast change your OP (topic) to show you are ssh'ing into the shell. that will narrow down searches for those with similar issues - your OP doesn't reflect the fact you are ssh'ing into this shell and thats where your problem seems to arrise.

Yes, forgot to mention that. THe screen on the laptop is broken so it's a headless laptop and I always SSH into it. I forgot to mention it because it's the usual way of logging in for me.


LG P300 - 320 GB storage - 4 GB RAM (3.7 GB free, thanks Arch Linux!!) - Broken screen

Offline

Board footer

Powered by FluxBB