Tip: show the last 3 directories in the shell prompt


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Tip: show the last 3 directories in the shell prompt
# 1  
Old 04-26-2017
Lightbulb Tip: show the last 3 directories in the shell prompt

tcsh: have the following in .cshrc (or .tcshrc)
Code:
set prompt="[%C3]: "

zsh: have the following in .zshrc
Code:
PS1="[%3C]%# "

bash: have the following in .bashrc
Code:
PS1='[${PWD#${PWD%/*/*/*}/}]\$ '

Lacking direct support this is a good approximation.
These 2 Users Gave Thanks to MadeInGermany For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

[Tip] Housekeeping Tasks Made Easy - User Home directories and Leftover Files

We have regularly questions about how to create users and user accounts. But regularly user accounts need to be deleted too. It is quite easy to delete the user account itself but usually the HOME directory of the user remains. It is good style to remove these directories but simply deleting... (3 Replies)
Discussion started by: bakunin
3 Replies

2. UNIX for Advanced & Expert Users

Tip: how to get the deepest directories

A couple of times there was the question: in a directory hierarchy how to display the deepest directories only. For example in Help with listing only subfolders. My hot solution at that time was (in short) find . -depth -type d | awk -F / 'NF>=p; {p=NF}' But another article has opened my eyes... (6 Replies)
Discussion started by: MadeInGermany
6 Replies

3. Shell Programming and Scripting

[Solved] Shell : Can someone show me how to used these ?

${var%pattern} removes the shortest suffix of $var patching pattern ${var%%pattern} removes the longest suffix of $var patching pattern ${var#pattern} removes the shortest prefix of $var patching pattern ${var##pattern} removes the longest prefix of $var patching pattern (2 Replies)
Discussion started by: popeye
2 Replies

4. Web Development

Php localhost/ directories show ?? ICONS

I have been troubleshooting a couple of problems all day that have to do with this all day. I do not know if you need to know the code I used in php but if you do I will post it. I hope that you can see the .pngs. Thanks ahead of time. Using phpMyAdmin and creating files.... somehow... (2 Replies)
Discussion started by: iHaveAQuestion
2 Replies

5. UNIX for Dummies Questions & Answers

show all text files in directories and subdirectories

Hi! I am trying to find all text files in my home directory that contain the string "C-d" so I tyied this : cd ~ find . -type f -exec grep -l "C-d" {} + but it took very long so I tryed this : ls -aR | xargs file |grep text but it didn't descend in the directories and it said :... (3 Replies)
Discussion started by: kelamahim
3 Replies

6. UNIX for Dummies Questions & Answers

Shell Scripts - Show all directories with full information ( and no files)

Hello all, i'm stumped.... I need to list all directories with all there info and exclude the files, then vice versa. I am not sure if I need to string several ls commands together or how to even do that. I believe I need to do some variation of ls -l but need to figure out how to take out the... (5 Replies)
Discussion started by: citizencro
5 Replies

7. UNIX for Dummies Questions & Answers

How can I show my "current" directory as the KSH prompt?

Hi All, This is an embarrassingly simple question and couldn't think of "keywords" to search for the answer, but how do I change my UNIX/KSH prompt to show the machine name and my "current" but not "full" directory? For example: if the machine name is "machine" and I'm currently in... (4 Replies)
Discussion started by: chatguy
4 Replies

8. Web Development

403 Forbidden / show directories

I have a directory that I want to just list the items when going to the URL instead of having an index.html page in the folder. I keep getting a 403 forbidden even though it is in my document root. I tried to add: Alias /keys/ "/var/www/html/keys/" <Directory "/var/www/html/keys"> ... (6 Replies)
Discussion started by: ippy98
6 Replies

9. UNIX for Advanced & Expert Users

User friendly Unix ksh prompt to type directories/files

Hello, I wanted to setup user friendly ksh command prompt, by typing first character of files or directories and then tab bring up whole word. No need to type whole file/directory/command names. Example: cat a file like university just typing un and then tab bring up whole university wod.... (3 Replies)
Discussion started by: abdurrouf
3 Replies

10. UNIX for Dummies Questions & Answers

No shell prompt?

When I login to a specific machine (running Solaris 2.8; actually serveral machines behave this way), with a known good account, I don't get any shell prompt, and no screen responses to various commands such as ID and PWD. Any ideas on what is causing this, and how to change this behavior? (2 Replies)
Discussion started by: Mufasa
2 Replies
Login or Register to Ask a Question