by kuba-orlik on 12/6/23, 8:03 AM with 43 comments
by julianeon on 12/7/23, 4:35 AM
I have abbreviations for about 20 directories, which essentially combine "cd" and the directory path in one string, no spaces.
It works because I probably spend about 50-80% of my time in those directories, it's not too much to remember, and nothing can be faster than a one-word command abbreviation to that exact directory.
by JNRowe on 12/7/23, 2:35 AM
Simply use "CDPATH=here:there" without the export, get the same functionality and no additional breakage.
Plus, on zsh you can use the tied variable cdpath instead of CDPATH(see typeset -T¹). cdpath is an array that accepts all the regular array operations. For bonus points you can even declare it with -U to remove the need to consider duplicates in your config. Other common -- and useful -- tied variables include path/PATH and fpath/FPATH².
¹ https://zsh.sourceforge.io/Doc/Release/Shell-Builtin-Command...
² https://zsh.sourceforge.io/Doc/Release/Parameters.html#Param...
by ughitsaaron on 12/7/23, 6:26 AM
by ARandomerDude on 12/7/23, 2:20 AM
by amelius on 12/7/23, 10:17 AM
by tedunangst on 12/7/23, 3:44 AM
by betenoire on 12/7/23, 5:18 AM
function p
set -l argc (count $argv)
if test $argc -eq 0
cd ~/projects
return
end
set -l project $argv[1]
cd ~/projects/$project
test $argc -eq 1; and return
set -l file (fzf -q (string join " " $argv[2..-1]))
test -z $file; and return
$EDITOR $file
end
Jumps to my project roots, and even opens my editor with extra args. Completion, too. set -l commands (command ls -p ~/projects/ | grep "/" | tr '\n/' ' ')
complete -c p -f \
-n "not __fish_seen_subcommand_from $commands" \
-a $commands
Maybe someone who uses Fish will find this usefulby from-nibly on 12/7/23, 3:14 AM
I don't go anywhere else in my filesystem often enough to want anything more than that.
by philsnow on 12/7/23, 5:47 AM
It will also break your shell history.
I’m probably in the minority but I’m wary of tools like this (asdf’s .tool-versions and similar things like rbenv/pyenv, and especially direnv) that change behavior based on the state of your shell’s working directory.
I like being able to ^R to a shell command from a month ago and just run it without worrying whence I’m running it.
I do like that you can directly use shims from asdf/pyenv/etc.
by polm23 on 12/7/23, 2:51 AM
by yasser_kaddoura on 12/7/23, 9:52 AM
by thelastknowngod on 12/7/23, 7:44 AM
by hiAndrewQuinn on 12/7/23, 7:29 AM
For my money, I just use fzf's built in Alt+C keybindings, as I outlined here [1] some months ago. It's been a game changer.
by spelufo on 12/7/23, 3:44 PM
by abhinickz on 12/7/23, 10:51 AM