Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 12-10-2015, 07:58 AM   #1
LQ Newbie
Registered: Dec 2015
Posts: 1

Rep: Reputation: Disabled
PROMPT_COMMAND does not work when using Nano

Hi all,

I wanted the amount of free space to be printed in the prompt and succeeded by typing:
PROMPT_COMMAND="echo -n [$(df -h /root | awk '{print $4}' | grep "[0-9]")]
It does the job and i'm content (it was quite an accomplishment for me as a newbee )
Now i wanted to make a small script in Nano so that i can run it..
I made the script, with the exact same line, nothing different and called it mydf

When running it (by typing: sh mydf ), it just shows the exact same prompt. No error or anything, but just the same prompt.

What am i missing here?

Thank you for replying!

Old 12-10-2015, 09:14 AM   #2
Senior Member
Registered: Nov 2013
Location: Tokyo
Distribution: Redhat/Centos, Ubuntu, Raspbian, Fedora, Alpine, Cirros, OpenSuse/SLES
Posts: 3,462

Rep: Reputation: 913Reputation: 913Reputation: 913Reputation: 913Reputation: 913Reputation: 913Reputation: 913Reputation: 913
When you run the script, you create a new shell, which has its own environment. PROMPT_COMMAND is part of that environment. When that shell exits, the environment goes away as well.

You can't modify the environment of the current shell by running other shells.

What you want can be achieved by running source mydf, which does not create a new shell.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
[SOLVED] $PROMPT_COMMAND in Konsole Title Bar? Woodsman Slackware 5 03-20-2011 05:23 AM
Ominous text [ PROMPT_COMMAND='pwd>&8;kill -STOP $$'] in my bash history file. zapo Linux - Security 2 01-12-2011 01:28 AM
Appending to PROMPT_COMMAND ahtoot Linux - Newbie 4 09-30-2010 01:12 AM
Trying to get mouse wheel to work:/etc/X11/xorg.conf and Nano fullmetalgerbil Slackware 5 03-25-2009 09:18 AM
Is there a way to get the mouse to work in nano? or use a different editor? thriftee Debian 14 01-27-2009 08:02 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:51 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration