This is great, thank you! Just a couple of minor changes to handle softlinks to folders...
function fcd() {
local dir;
while true; do
# exit with ^D
dir="$(ls -a1F | grep '[/@]$' | grep -v '^./$' | sed 's/@$//' | fzf --height 40% --reverse --no-multi --preview 'pwd' --preview-window=up,1,border-none --no-info)"
if [[ -z "${dir}" ]]; then
break
elif [[ -d "${dir}" ]]; then
cd "${dir}"
fi
done
}
This is the best reason ever, and not just for you: seeing your GIF I thought "could I achieve that with fzf?". Turns out, yes I can:
function fcd() {
local dir;
while true; do
# exit with ^D
dir="$(ls -a1p | grep '/$' | grep -v '^./$' | fzf --height 40% --reverse --no-multi --preview 'pwd' --preview-window=up,1,border-none --no-info)"
if [[ -z "${dir}" ]]; then
break
else
cd "${dir}"
fi
done
}
Certainly not the best code (and definitely not a jab at your implementation!) but, hey, it was purely for the heck of it.
Lately I've been trying to find the joy in programming again, these kind of fun little challenges help a lot, so thanks for sharing, enthusiasm and creativity is contaminating :)
I highly recommend autojump[1] as a simple way to jump to commonly-used working directories. It's saved me a lot of repetitive typing since I discovered it.
I don’t just want specific directories to autocomplete. Whatever I navigate to is likely something I never even opened but was generated by a script and I now want to do manual changes to the contents. This approach makes for me the rare case as usable as the common one.
Smart idea. Good job! Could you extend bd to jump to bookmarked directories. I often jump between /data... and ~/dir/containing/code/ -- would be useful to have one command help with both scenarios.
And yeah, didn't think of that. It would be neat to be able to tag files or directories and then execute a command to see all the directories with that tag and then enter that directory easily. Maybe i'll try adding that to the next version. Can you think of anything else that would be useful?
I have a bunch of directories I always go to, and instead of cd-ing on a relative path from where I am, I prefer using an interactive way to select where to go (I’ve aliased this script as “c”):
edit: okay done
http://i.imgur.com/n12DYUu.png
Two examples in case you have a preference w/ or w/o the preview:
http://ix.io/4rtn/shSent from a LLM
reply