LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-13-2006, 09:39 AM   #1
lm317t
Member
 
Registered: Jan 2005
Location: Raleigh, NC
Distribution: Debian Etch, Slackware 10.2, Ubuntu 6.10, OpenWRT
Posts: 66

Rep: Reputation: 15
configuring bash


This is a noob bash question I know:

When I ssh to my newly installed Slackware 10.2 host, my bash prompt loses some configuration. If I hit the "Home" or "End" key I get a "~" instead of my cursor moving. I have looked a little bit into why this is. It is not related to the .bashrc or .bash_profile (doesn't exist), also /etc/bashrc doesn't seem to change this.

When I su to root (from ssh) it loses its dircolors setting too! I'll admit I was spoiled a bit by Mandrake 10.1's base configurations.

This is all different behavior from when I am logged in to a tty. In the tty all the settings seem to be OK. However, if I su in Konsole I lose dircolors too!

Code:
# .bashrc

# User specific aliases and functions

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

# enable programmable completion features
if [ -f /etc/bash_completion ]; then
        . /etc/bash_completion
fi
Code:
# /etc/bashrc

# System wide functions and aliases
# Environment stuff goes in /etc/profile

# by default, we want this to get set.
# Even for non-interactive, non-login shells.
if [ "`id -gn`" = "`id -un`" -a `id -u` -gt 99 ]; then
        umask 002
else
        umask 022
fi

# are we an interactive shell?
if [ "$PS1" ]; then
    case $TERM in
        xterm*)
            PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
            ;;
        *)
            ;;
    esac
    [ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ "

    if [ -z "$loginsh" ]; then # We're not a login shell
        for i in /etc/profile.d/*.sh; do
            if [ -x $i ]; then
                . $i
            fi
        done
    fi
fi

unset loginsh
Code:
# /etc/profile: This file contains system-wide defaults used by
# all Bourne (and related) shells.
 
# Set the values for some environment variables:
export MINICOM="-c on"
export MANPATH=/usr/local/man:/usr/man:/usr/X11R6/man
export HOSTNAME="`cat /etc/HOSTNAME`"
export LESSOPEN="|lesspipe.sh %s"
export LESS="-M"

# If the user doesn't have a .inputrc, use the one in /etc.
if [ ! -r "$HOME/.inputrc" ]; then
  export INPUTRC=/etc/inputrc
fi

# Set the default system $PATH:
PATH="/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games"

# For root users, ensure that /usr/local/sbin, /usr/sbin, and /sbin are in
# the $PATH.  Some means of connection don't add these by default (sshd comes
# to mind).
if [ "`id -u`" = "0" ]; then
  echo $PATH | grep /usr/local/sbin 1> /dev/null 2> /dev/null
  if [ ! $? = 0 ]; then
    PATH=/usr/local/sbin:/usr/sbin:/sbin:$PATH
  fi
fi

# I had problems using 'eval tset' instead of 'TERM=', but you might want to
# try it anyway. I think with the right /etc/termcap it would work great.
# eval `tset -sQ "$TERM"`
if [ "$TERM" = "" -o "$TERM" = "unknown" ]; then
 TERM=linux
fi

# Set ksh93 visual editing mode:
if [ "$SHELL" = "/bin/ksh" ]; then
  VISUAL=emacs
#  VISUAL=gmacs
#  VISUAL=vi
fi

# Set a default shell prompt: 
#PS1='`hostname`:`pwd`# ' 
if [ "$SHELL" = "/bin/pdksh" ]; then
 PS1='! $ '
elif [ "$SHELL" = "/bin/ksh" ]; then
 PS1='! ${PWD/#$HOME/~}$ '
elif [ "$SHELL" = "/bin/zsh" ]; then
 PS1='%n@%m:%~%# '
elif [ "$SHELL" = "/bin/ash" ]; then
 PS1='$ '
else
 PS1='\u@\h:\w\$ '
fi
PS2='> '
export PATH DISPLAY LESS TERM PS1 PS2

# Default umask.  A umask of 022 prevents new files from being created group
# and world writable.
umask 022

# Set up the LS_COLORS and LS_OPTIONS environment variables for color ls:
if [ "$SHELL" = "/bin/zsh" ]; then
 eval `dircolors -z`
elif [ "$SHELL" = "/bin/ash" ]; then
 eval `dircolors -s`
else
 eval `dircolors -b`
fi

# Notify user of incoming mail.  This can be overridden in the user's
# local startup file (~/.bash.login or whatever, depending on the shell)
if [ -x /usr/bin/biff ]; then
 biff y
fi

# Append any additional sh scripts found in /etc/profile.d/:
for profile_script in /etc/profile.d/*.sh ; do
  if [ -x $profile_script ]; then
    . $profile_script
  fi
done
unset profile_script

# For non-root users, add the current directory to the search path:
if [ ! "`id -u`" = "0" ]; then
 PATH="$PATH:."
fi
 
Old 02-13-2006, 09:55 AM   #2
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
How are you suing? If you want the environment configuration to be read, you MUST use "su -". Additionally, the prompt is set by the PS1 environment variable, set in /etc/bashrc.
 
Old 02-13-2006, 10:13 AM   #3
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
The functioning of your backspace and some other keys (like Del) may be related to your terminal settings (escape characters).

For instance, a trick I often use when a "telnet" doesn't know the Backspace key anymore after I login is:
stty erase <press_backspace_key_here>
This sets the tty's "erase" character to be the Backspace key.

Check out "man stty" for more info and possible also your terminal (xterm, vterm, dterm, etc) configuration options.
 
Old 02-13-2006, 10:56 AM   #4
lm317t
Member
 
Registered: Jan 2005
Location: Raleigh, NC
Distribution: Debian Etch, Slackware 10.2, Ubuntu 6.10, OpenWRT
Posts: 66

Original Poster
Rep: Reputation: 15
The "su -" helped me get dircolors back on my root prompt, just don't understand why it would change my settings, it didn't in Mandrake 10.1/10.0

I was unable to find the setting I was looking for in the manual for stty. It looks like stty does not control this, or calls going to the begining or end of a line something I don't see. Could you point me in the right direction?
 
Old 02-13-2006, 11:05 AM   #5
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
su doesn't change settings at all. "su -" causes the new bash session (started by su) to read in /etc/bashrc, /etc/profile, etc.

Try doing "echo $TERM" in the 'broken' environment and post the output here. You may just need to adjust an environment variable.
 
Old 02-13-2006, 11:11 AM   #6
lm317t
Member
 
Registered: Jan 2005
Location: Raleigh, NC
Distribution: Debian Etch, Slackware 10.2, Ubuntu 6.10, OpenWRT
Posts: 66

Original Poster
Rep: Reputation: 15
brian:~$ echo $TERM
xterm
 
Old 02-13-2006, 12:13 PM   #7
lm317t
Member
 
Registered: Jan 2005
Location: Raleigh, NC
Distribution: Debian Etch, Slackware 10.2, Ubuntu 6.10, OpenWRT
Posts: 66

Original Poster
Rep: Reputation: 15
This fixed all my problems:

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH
unset USERNAME
 
Old 03-17-2006, 03:51 AM   #8
dr_te_z
LQ Newbie
 
Registered: Mar 2006
Location: Zoetermeer, Holland
Distribution: slackware, debian
Posts: 11

Rep: Reputation: 0
TIP: When you use screen (I mean the program /usr/bin/screen) it is very usefull to include $TERM and $WINDOW in your PS1 variable.

So when you start screen you'll see:
Code:
screen(0), pietje@puk:~>
when you press cntr-a c you'll get the next screen:
Code:
screen(1), pietje@puk:~>
and so on.
 
  


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
Bash: Print usage statement & exit; otherwise continue using Bash shorthand operators stefanlasiewski Programming 9 02-07-2006 05:20 PM
Configuring Bash (.bashrc) for use with Java Sir Nerdalot Linux - General 2 11-13-2005 08:42 AM
$LINENO can't be modified in bash 3.0, while it can be in bash 2.05b Darwish Linux - Software 1 11-07-2005 02:57 PM
bash + html + javascript or just bash ? rblampain Programming 4 12-01-2004 07:53 AM
why did bash 2.05b install delete /bin/bash & "/bin/sh -> bash"? johnpipe Linux - Software 2 06-06-2004 06:42 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:27 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