Re: base-files 1.6 (source all) uploaded to master
Hi,
>>"Riku" == Riku Voipio <riku.voipio@iki.fi> writes:
Riku> Ofcourse the right thing to do is a /etc/profile.d
Riku> directory.
I think the right thing to do is to leave the default prompts
alone, and teach people how to set up prompts. There is no way you
can cater to all tastes and all shells, people invariably change
them, and anyway, we should make it easy for people to change
prompts.
The defaults are functional, though not pretty. No one can
agree on what is pretty. I think users should be allowed to make
their own choices.
I append my personal prompt setting scheme, in hopes this
inspires someone else (any improvements greatly appreciated)
manoj
.bashrc
______________________________________________________________________
# Set up a basic FixPrompt command, the aliases file changes this
PROMPT_COMMAND='PS1="\u@\h\$ "'
if test "$TERM" = "xterm" ; then
PROMPT_COMMAND='PS1="__> " ';
else
if test "$TERM" = "emacs" ; then
PROMPT_COMMAND='PS1="__> " '
else
if test -f $default_dir/.bashprompt ; then
. $default_dir/.bashprompt
else
if test -f ~/.bashprompt ; then
. ~/.bashprompt
fi
fi
fi
fi
______________________________________________________________________
.bashprompt
______________________________________________________________________
#!/bin/bash
if [ -x /bin/tempfile ]; then
termcapfile=`tempfile -p tcap -m 0600 `;
outfile=`tempfile -p outp -m 0600 `;
else
set -e
mkdir /tmp/prompt$$
termcapfile=/tmp/prompt$$/tcap
outfile=/tmp/prompt$$/output
fi
if [ "$TERMCAP" != "" ]; then
printenv TERMCAP | tr ':2' '\012 ' > $termcapfile;
fi
if [ -f $termcapfile ] && [ -s $termcapfile ]&& [ -O $termcapfile ]; then
cat $termcapfile | awk '/^me=/ {print substr($0, 4)}' | \
sed 's/\\E//' >& $outfile
export norm_vid="`cat $outfile`"
cat $termcapfile | awk ' /^so=/ {print substr($0, 4)}' | \
sed 's/\\E/\/' >& $outfile
export rev_vid="`cat $outfile`"
cat $termcapfile | awk ' /^mh=/ {print substr($0, 4)}' | \
sed 's/\\E//' >& $outfile
export dim_vid="`cat $outfile`"
cat $termcapfile | awk ' /^md=/ {print substr($0, 4)}' | \
sed 's/\\E//' >& $outfile
export bld_vid="`cat $outfile`"
fi
rm -f $outfile $termcapfile
if [ -d /tmp/prompt$$ ]; then
rmdir /tmp/prompt$$
fi
PROMPT_COMMAND='PS1="$host_pfx$rev_vid<\u@\h:$norm_vid[$dim_vid$PROMPTCOMMENT${workdir}${norm_vid}]> "'
______________________________________________________________________
__> type -a cd
cd is a function
cd ()
{
if [ -O "$CDEXIT" ] && [ -f "$CDEXIT" ]; then
source $CDEXIT;
fi;
if [ "X$1" = "X" ]; then
builtin cd ~/.;
else
builtin cd "$1";
fi;
last_dir="$this_dir";
this_dir="`pwd`";
if [ "$TERM" = "xterm" ]; then
workdir=`prunepwd 30`;
perl -e 'printf "%c]2;%s%c", 27, @ARGV, 7 ; ' "$WHOAMI@$HOST:$workdir";
else
workdir=`prunepwd 20`;
fi;
if [ -O "$CDENTER" ] && [ -f "$CDENTER" ]; then
source $CDENTER;
fi;
ls -asCF | more -ds
}
______________________________________________________________________
__> type -a pd
pd is a function
pd ()
{
if [ -O "$CDEXIT" ] && [ -f "$CDEXIT" ]; then
source $CDEXIT;
fi;
pushd $1 >/dev/null;
last_dir="$this_dir";
this_dir="`pwd`";
if [ "$TERM" = "xterm" ]; then
workdir=`prunepwd 30`;
perl -e 'printf "%c]2;%s%c", 27, @ARGV, 7 ; ' "$WHOAMI@$HOST:$workdir";
else
workdir=`prunepwd 20`;
fi;
if [ -O "$CDENTER" ] && [ -f "$CDENTER" ]; then
source $CDENTER;
fi;
ls -asCF | more -ds
}
______________________________________________________________________
__> type -a pop
pop is a function
pop ()
{
if [ -O "$CDEXIT" ] && [ -f "$CDEXIT" ]; then
source $CDEXIT;
fi;
if [ "X$1" = "X" ]; then
popd;
else
popd "$1" >/dev/null;
fi;
last_dir="$this_dir";
this_dir="`pwd`";
if [ "$TERM" = "xterm" ]; then
workdir=`prunepwd 30`;
perl -e 'printf "%c]2;%s%c", 27, @ARGV, 7 ; ' "$WHOAMI@$HOST:$workdir";
else
workdir=`prunepwd 20`;
fi;
if [ -O "$CDENTER" ] && [ -f "$CDENTER" ]; then
source $CDENTER;
fi;
ls -asCF | more -ds
}
______________________________________________________________________
bin/prunepwd
______________________________________________________________________
#!/usr/bin/perl
##
## prunepwd.pl - Prune a `pwd` string
##
## prunepwd prunes the current working directory path to a size that
## is reasonable for a prompt. The size limit is specified by
## optional command line argument. The default is 25.
##
## If the path is a descendent of the home directory path, the leading
## home directory path is replaced with ``~''. Otherwise, a leading
## //node_name (ala Apollo) is replaced with ``node_name:''.
## Directories are trimmed from the beginning of the path (following
## the node name) until the path length (including node name) is less
## than the limit. The last directory in the path is never pruned,
## even if its length exceeds the limit. The set of pruned
## directories is replaced by ``...''.
##
## Examples:
##
## //srivasta/usr/abc/def/ghi/jkl/mno/pqr/stu/vwx (before)
## srivasta:/.../pqr/stu/vwx (after)
##
## //srivasta/user/mse/learn/perl/chapter1 (before)
## ~/learn/perl/chapter1 (after)
##
$pwdsz = shift || 25; # limit for pwd string
chop($cwd=`pwd`);
chdir ($ENV{'HOME'});
chop($home=`pwd`);
###print "$cwd $home\n";
if ($cwd eq "//"){
print $cwd;
exit ();
}
if (index ($cwd, $home) == 0) {
$node = "";
$cwd = "~" . substr ($cwd, length ($home));
} else {
if ($cwd =~ m|^//|) {
## Apollo style path (//node/path/...)
($node, $cwd) = ($cwd =~ m|//([^/]*)(.*)|o);
$node .= ":";
} else {
## Unix style path (/path/...)
$node = "";
}
}
$len = length ($node) + length ($cwd);
if ($len > $pwdsz) {
@path = split (/\//, $cwd);
##
## always leave the final component of the path even if its
## length is greater than the limit.
##
if ($#path > 1) {
##
## Find number of leading components in path to skip
##
for ($skip = 0; $len > $pwdsz && $skip < ($#path); $skip++) {
$len -= (length ($path[$skip]) + 1);
if ($skip == 0) {
$len += 3; # length of "..."
}
}
$path[$skip-1] = "...";
if ($skip > 1) {
splice (@path, 0, $skip-1 );
}
}
$cwd = join ("/", @path);
}
print $node, $cwd;
______________________________________________________________________
--
I think an embryo/fetus/baby becomes a "person" when it is smarter
than a non-primate like a dog. By those standards, chimpanzees and
gorillas are persons (although somewhat cognitively impaired -- kind
of like Fundamentalist Christians), but human newborns are not. Dave
Touretzsky
Manoj Srivastava <srivasta@acm.org> <http://www.datasync.com/%7Esrivasta/>
Key C7261095 fingerprint = CB D9 F4 12 68 07 E4 05 CC 2D 27 12 1D F5 E8 6E
--
To UNSUBSCRIBE, email to debian-devel-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Reply to: