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

Re: cd as much as possible



On Thu, 10 Mar 2016, kamaraju kusumanchi wrote:

Date: Thu, 10 Mar 2016 22:45:09
From: kamaraju kusumanchi <raju.mailinglists@gmail.com>
To: "debian-user@lists.debian.org" <debian-user@lists.debian.org>,
    tlikonen@iki.fi
Subject: Re: cd as much as possible
Resent-Date: Fri, 11 Mar 2016 03:45:45 +0000 (UTC)
Resent-From: debian-user@lists.debian.org

On Thu, Mar 10, 2016 at 2:11 AM, Teemu Likonen <tlikonen@iki.fi> wrote:

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
    }


This is exactly what I wanted. Thanks. It works in zsh too.

raju

The find command probably can handle this maybe in a shorter form. I don't know as much syntax of that command as I'd like otherwise this could probably written in a single line of code.

 --


Reply to: