Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add way to push current directory onto the stack #53

Open
evanthegrayt opened this issue Dec 15, 2020 · 2 comments
Open

Add way to push current directory onto the stack #53

evanthegrayt opened this issue Dec 15, 2020 · 2 comments
Labels
enhancement New feature or request

Comments

@evanthegrayt
Copy link
Owner

If I'm in a directory, and it's not currently on the stack, there's no way to add it unless you use cdc DIR. It'd be nice if you could do cdc . and have it push to the stack.

Example:

cd ~/repo 
cd a/nested/subdir
# Now I want to go back to the root of `repo`, but can't use `cdc -n`

# SOLUTION
cd ~/repo # oh crap, I want this on the history stack
cdc .

Also, and I'm not sure about this one... but it'd be cool to add cdc .., and it would traverse up the directory tree until it found a file in the CDC_REPO_MARKERS, changed to that directory, and added it to the stack (if requested).

@evanthegrayt evanthegrayt added the enhancement New feature or request label Dec 15, 2020
@evanthegrayt
Copy link
Owner Author

I've been thinking more about this. I'm thinking that cdc . can serve both purposes. If $CDC_REPOS_ONLY == true or -r, then it will traverse up $PWD until it finds a $CDC_REPO_MARKER. If none is found, do nothing and print an error. If $CDC_REPOS_ONLY == false or -R, add the current directory.

I've also debated checking to make sure that one of $CDC_DIRS is in your current path... but not sure about this one.

@evanthegrayt
Copy link
Owner Author

evanthegrayt commented May 10, 2021

Was playing around but didn't create a branch yet. Sticking this here for now.

    ##
    # If the argument is `.` and the current directory contains one of the
    # $CDC_DIRS, add the root of the directory to the stack.
    if [[ $cd_dir == '.' ]]; then
        should_return=true
        for dir in ${CDC_DIRS[@]}; do
            if ! [[ $PWD =~ $dir ]]; then
                continue
            fi
            wdir=${PWD/$dir}
            echo $wdir
            if [[ -z $wdir ]]; then
                # TODO: add real output
                echo "you're in a cddir"
                break
            fi
            CDC_HISTORY+=("$wdir")
        done
    fi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant