Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.user > #165201
| From | Teemu Likonen <tlikonen@iki.fi> |
|---|---|
| Newsgroups | linux.debian.user |
| Subject | Re: cd as much as possible |
| Date | 2016-03-10 08:20 +0100 |
| Message-ID | <rb334-3w5-21@gated-at.bofh.it> (permalink) |
| References | <rb1ui-2rw-11@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
[Multipart message — attachments visible in raw view] - view raw
kamaraju kusumanchi [2016-03-10 00:35:33-05] wrote:
> Is it possible to change the behaviour of the "cd" command or have a
> new command which works like cd but with an extra feature so that it
> goes into the directory as deep as possible.
>
> For example, if I do
> cd a1/a2/a3/a4
>
> If all the directories are present, we cd into a1/a2/a3/a4.
> If all the directories are present except for a4, we cd into a1/a2/a3
> If a1 and a2 directories exist but not a3, we cd into a1/a2
> etc.,
>
> If it matters, I am using zsh on a machine running Debian Jessie. But
> I am open to experiment with other shells if needed. Any thoughts?
I don't know about zsh but here's a sh/bash function:
mycd() {
local dir=$1
while ! cd -- "$dir"; do
dir=$(dirname -- "$dir")
done
}
--
/// Teemu Likonen - .-.. <https://github.com/tlikonen> //
// PGP: 4E10 55DC 84E9 DFF6 13D7 8557 719D 69D3 2453 9450 ///
Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
cd as much as possible kamaraju kusumanchi <raju.mailinglists@gmail.com> - 2016-03-10 06:40 +0100
Re: cd as much as possible Teemu Likonen <tlikonen@iki.fi> - 2016-03-10 08:20 +0100
Re: cd as much as possible kamaraju kusumanchi <raju.mailinglists@gmail.com> - 2016-03-11 04:50 +0100
Re: cd as much as possible Jude DaShiell <jdashiel@panix.com> - 2016-03-11 13:10 +0100
Re: cd as much as possible Teemu Likonen <tlikonen@iki.fi> - 2016-03-11 13:30 +0100
Re: cd as much as possible kamaraju kusumanchi <raju.mailinglists@gmail.com> - 2016-03-11 05:10 +0100
Re: cd as much as possible Jens Bauer <jens-lists@gpio.dk> - 2016-03-16 03:10 +0100
Re: cd as much as possible kamaraju kusumanchi <raju.mailinglists@gmail.com> - 2016-03-18 05:20 +0100
csiph-web