Re: Turning off current directory display in a terminal window

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Tim:
> > Depending on your terminal, you *may* be able to have the full path
> > showing in the title bar, and just the current directory name at the
> > command prompt.
> > 
> > Changing the \w to \W in your PS1= .bashrc string does it for some of
> > them (just shows the last directory of the filepath).
> > 
> > By way of example, typing this into my command line let me change the
> > current prompt without making permanent changes to my settings:
> > 
> > export PS1="[\u@\h \W]$ "
> > 
> > [username@hostname directory]$ 


Robert Moskowitz:
> That is quite better than what I hand coded, as it tracks changes in
> the current directory.
> 
>     
> 
> Maybe to add coloration.

I deliberately left colouring out for a simple example, but I normally
have this in my ~/.bashrc file:

export PS1="\[\e[44m\][\u@\h \w]\$\[\e[0m\] "

Which gives me the full path, and colouring.  If I change the \w to \W
by typing this into the command line:

export PS1="\[\e[44m\][\u@\h \W]\$\[\e[0m\] "

Then the command line changes to just the last directory name before
the prompt, but my Mate terminal window title bar is still showing the
full path.

I get the prompt prefix back-coloured blue, and the rest of the line
goes back to normal.  I do something similar for root, but have it
back-coloured red.  It makes it easier to see where a command line was
written when scrolling back through a long output.

Of course typing all that would be a pain, so you could either play cut
and paste games with .bashrc, or make it into an alias, or write a
script.  You could add the following to your ~/.bashrc under where it
tells you to put user-specific aliases and functions:

alias short='export PS1="\[\e[44m\][\u@\h \W]\$\[\e[0m\] "'
alias long='export PS1="\[\e[44m\][\u@\h \w]\$\[\e[0m\] "'

Now typing short or long into the command line sets prompt accordingly.
I don't think those aliases are stomping on anything else that
currently exists (at least they don't on my system).

Or, for the sake of a silly example, one could go mad, and colour the
path different from other things in the prompt prefix:

PS1="\[\e[44m\][\u@\h \[\e[45m\]\w\[\e[44m]\]\$\[\e[0m\] "

There's a lot of confusing-to-read escaping in there, because the
square brackets have different meanings and are part of the ANSI colour
codes, as well as where you see them just typed as brackets in the
prompt.  The ones that are just typed to show up as [ and ] around the
prompt prefix are the [ before \u and the \] just before \$

-- 
 
uname -rsvp
Linux 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
 
Boilerplate:  All unexpected mail to my mailbox is automatically deleted.
I will only get to see the messages that are posted to the mailing list.
 

-- 
_______________________________________________
users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/users@xxxxxxxxxxxxxxxxxxxxxxx
Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue



[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux