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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
02-13-2006, 10:39 AM
|
#1
|
Member
Registered: Jan 2005
Location: Raleigh, NC
Distribution: Debian Etch, Slackware 10.2, Ubuntu 6.10, OpenWRT
Posts: 66
Rep:
|
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
|
|
|
02-13-2006, 10:55 AM
|
#2
|
LQ Guru
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507
Rep:
|
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.
|
|
|
02-13-2006, 11:13 AM
|
#3
|
Senior Member
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515
Rep:
|
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.
|
|
|
02-13-2006, 11:56 AM
|
#4
|
Member
Registered: Jan 2005
Location: Raleigh, NC
Distribution: Debian Etch, Slackware 10.2, Ubuntu 6.10, OpenWRT
Posts: 66
Original Poster
Rep:
|
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?
|
|
|
02-13-2006, 12:05 PM
|
#5
|
LQ Guru
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507
Rep:
|
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.
|
|
|
02-13-2006, 12:11 PM
|
#6
|
Member
Registered: Jan 2005
Location: Raleigh, NC
Distribution: Debian Etch, Slackware 10.2, Ubuntu 6.10, OpenWRT
Posts: 66
Original Poster
Rep:
|
brian:~$ echo $TERM
xterm
|
|
|
02-13-2006, 01:13 PM
|
#7
|
Member
Registered: Jan 2005
Location: Raleigh, NC
Distribution: Debian Etch, Slackware 10.2, Ubuntu 6.10, OpenWRT
Posts: 66
Original Poster
Rep:
|
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
|
|
|
03-17-2006, 04:51 AM
|
#8
|
LQ Newbie
Registered: Mar 2006
Location: Zoetermeer, Holland
Distribution: slackware, debian
Posts: 11
Rep:
|
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.
|
|
|
All times are GMT -5. The time now is 01:17 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|