Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I use sd (kinda like cd) when working with on mac with finder. With sd, you can select a file in finder, CMD+C and sd filepath.txt. The nice thing is that it goes to the same directory as the file so you don't have to delete the last part of the path manually. If you are sd-ing into a directory, it behaves like cd.

    sd () {
        if [ -f "$*" ]
        then
                cd "$(dirname "$*")"
        else
                cd "$*"
        fi
    }
Also cwd which is like pwd but it also copies the current path to your clipboard.

    cwd='pwd | tr -d "\n" | pbcopy && pwd'


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: