Sponsored Content
Top Forums UNIX for Advanced & Expert Users Tip: show the last 3 directories in the shell prompt Post 302996436 by MadeInGermany on Wednesday 26th of April 2017 07:55:42 AM
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:
 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
shells(4)							   File Formats 							 shells(4)

NAME
shells - shell database SYNOPSIS
/etc/shells DESCRIPTION
The shells file contains a list of the shells on the system. Applications use this file to determine whether a shell is valid. See getuser- shell(3C). For each shell a single line should be present, consisting of the shell's path, relative to root. A hash mark (#) indicates the beginning of a comment; subsequent characters up to the end of the line are not interpreted by the routines which search the file. Blank lines are also ignored. The following default shells are used by utilities: /bin/bash, /bin/csh, /bin/jsh, /bin/ksh, /bin/pfcsh, /bin/pfksh, /bin/pfsh, /bin/sh, /bin/tcsh, /bin/zsh, /sbin/jsh, /sbin/sh, /usr/bin/bash, /usr/bin/csh, /usr/bin/jsh, /usr/bin/ksh, /usr/bin/pfcsh, /usr/bin/pfksh, /usr/bin/pfsh, and /usr/bin/sh, /usr/bin/tcsh, /usr/bin/zsh. Note that /etc/shells overrides the default list. Invalid shells in /etc/shells may cause unexpected behavior (such as being unable to log in by way of ftp(1)). FILES
/etc/shells lists shells on system SEE ALSO
vipw(1B), ftpd(1M), sendmail(1M), getusershell(3C), aliases(4) SunOS 5.10 4 Jun 2001 shells(4)
All times are GMT -4. The time now is 09:35 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy