Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 22 Sep 2014 11:24:29 -0700
From:      leeoliveshackelford@surewest.net
To:        Freebsd questions <freebsd-questions@freebsd.org>
Subject:   .bashrc guru needed
Message-ID:  <e3a6a1a24c1c0af8e75577d8ecf1a8ea@surewest.net>

next in thread | raw e-mail | index | archive | help
 

Greetings, dear FreeBSD enthusiasts. Is there a bash guru who can help
me correct the following script for .bashrc. I copied this script from a
web page whose location I failed to record, and have forgotten. It is
supposed to write each word of the prompt in a different color, which it
does correctly. This color scheme is generated by the function
bash_prompt(). It is also supposed to write the current directory in an
abridged format in which the portion of the filepath that refers to the
home directory, if any, is replaced by a tilde (~), and then, long path
descriptions are truncated on the left at 25 characters, with two
periods then added. This result is created by the function
bash_prompt_command(). This function does not work. In place of the
value of the variable NEW_PWD, the operating system simply prints the
error message "unbound variable, then generates a prompt line listing
the variable's name, $NEW_PWD, in place of its value. This variable is
given values on three lines, 18, 22, and 24. Where does it loose its
binding? I have made several modifications to the function in an attempt
to get it to work, but to no avail. Following is a partial listing. 

BLOCKSIZE="${BLOCKSIZE:-1024}"; export BLOCKSIZE
CVSROOT="${CVSROOT:-/home/ncvs}"; export CVSROOT
TMPDIR="${TMPDIR:-/tmp}"; export TMPDIR 

set +H #disables bash!-completion 

export PATH=$PATH:$HOME/.local/bin 

#Inserted here are a group of alias commands.
# The following statements control the prompt. 

export CLICOLOR="YES" 

bash_prompt_command() { 

# How many characters of the $PWD should be kept 

local pwdmaxlen=25 

# Indicate that there has been dir truncation 

local trunc_symbol=".." 

local dir=${PWD##*/} 

pwdmaxlen=$(( ( pwdmaxlen < ${#dir} ) ? ${#dir} : pwdmaxlen )) 

NEW_PWD=${PWD/#$HOME/~} 

local pwdoffset=$(( ${#NEW_PWD} - pwdmaxlen )) 

if [ ${pwdoffset} -gt "0" ] 

then 

NEW_PWD=${NEW_PWD:$pwdoffset:$pwdmaxlen} 

else 

NEW_PWD=${trunc_symbol}/${NEW_PWD#*/} 

fi } 

bash_prompt() 

 { 

#Inserted here are a list of variables set to descriptions of various
colors. 

local UC=$EMG # user's color 

[ $UID -eq "0" ] && UC=$EMR # root's color 

PS1="${UC}s ${EMW}${NEW_PWD} ${UC}\$ ${NONE}" 

 } 

PROMPT_COMMAND=bash_prompt_command; bash_prompt; unset bash_prompt 

export PROMPT_COMMAND 

# End of statements to control prompt 

I added the export statements on lines 1, 2, and 3. I added the
semi-colons on line 35, and the export PROMP_COMMAND on line 36. I
inserted the "else" statement on line 23. None of these modifications
helped. What is the programmer telling or trying to tell the interpreter
to do on line 16, "local dir=${PWD/##*/}" ? What is the programmer
telling, or trying to tell the interpreter to do on line 18,
"NEW_PWD=${PWD/#$HOME/~}" ? Please, to those coming from the world of c
programming language, bash syntax seems to be a mystery. Any and all
suggestions will be appreciated. Newby Lee 
From owner-freebsd-questions@FreeBSD.ORG  Mon Sep 22 18:29:21 2014
Return-Path: <owner-freebsd-questions@FreeBSD.ORG>
Delivered-To: freebsd-questions@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))
 (No client certificate requested)
 by hub.freebsd.org (Postfix) with ESMTPS id 275DEDFF
 for <freebsd-questions@freebsd.org>; Mon, 22 Sep 2014 18:29:21 +0000 (UTC)
Received: from nightmare.dreamchaser.org (nightmare.dreamchaser.org
 [12.32.44.142])
 (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
 (Client did not present a certificate)
 by mx1.freebsd.org (Postfix) with ESMTPS id CD3D9162
 for <freebsd-questions@freebsd.org>; Mon, 22 Sep 2014 18:29:20 +0000 (UTC)
Received: from breakaway.dreamchaser.org (breakaway.dreamchaser.org.
 [12.32.36.73])
 by nightmare.dreamchaser.org (8.13.6/8.13.6) with ESMTP id s8MITCe2016305
 for <freebsd-questions@freebsd.org>; Mon, 22 Sep 2014 12:29:12 -0600 (MDT)
 (envelope-from freebsd@dreamchaser.org)
Message-ID: <54206A78.6070609@dreamchaser.org>
Date: Mon, 22 Sep 2014 12:29:12 -0600
From: Gary Aitken <freebsd@dreamchaser.org>
Reply-To: freebsd@dreamchaser.org
User-Agent: Mozilla/5.0 (X11; FreeBSD amd64;
 rv:31.0) Gecko/20100101 Thunderbird/31.0
MIME-Version: 1.0
To: FreeBSD Mailing List <freebsd-questions@freebsd.org>
Subject: pkg autoremove option to just list?
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.0.2
 (nightmare.dreamchaser.org [12.32.36.65]);
 Mon, 22 Sep 2014 12:29:12 -0600 (MDT)
X-BeenThere: freebsd-questions@freebsd.org
X-Mailman-Version: 2.1.18-1
Precedence: list
List-Id: User questions <freebsd-questions.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/options/freebsd-questions>, 
 <mailto:freebsd-questions-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/freebsd-questions/>;
List-Post: <mailto:freebsd-questions@freebsd.org>
List-Help: <mailto:freebsd-questions-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-questions>, 
 <mailto:freebsd-questions-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Mon, 22 Sep 2014 18:29:21 -0000

Thought this would be easy but couldn't find what I needed.

Is there a way to do the equivalent of "pkg autoremove" without actually doing
the remove -- i.e. to get a list of what pkg autoremove would try to do?  I
thought there would be an option for this but didn't see one.

Thanks,

Gary



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?e3a6a1a24c1c0af8e75577d8ecf1a8ea>