4 ms·
Nice tip. What got rid of most of my use of `ls` in fish was running `ls` automatically when you changed directories: function ls_on_cd --on-variable PWD
by networked 2y ago
Nice tip. What got rid of most of my use of `ls` in fish
was running `ls` automatically when you changed directories:
function ls_on_cd --on-variable PWD
ls
end
- fastasucan 2y agoA word of a warning if you have folders with _a lot_ of files.
- blooalien 2y agoOoo! Thank you! That is a nice tip! Stealing it right now. :)
- macintux 2y agoSeems like that would strongly encourage me to keep my directories tidier.
- creshal 2y agoIt absolutely did for me. Sadly, it also serves as constant reminder that ~ is a bloody mess because people still can't get used to .local/.share/.config.
- enriquto 2y ago> people still can't get used to .local/.share/.config I'm one of those people... I don't want yet more hidden stuff in my home dir; I want less. My dream is to have zero hidden directories in my home. What I want is something really clean like this: $ ls -a ~ . .. config fun local pro tmp This is almost possible, thanks to XDG_ environment variables. But unfortunately many programs still use hardcoded names for the local userdirs. If you want to get closer to that goal, the xdg-ninja [0] package can help you. Also, do something like "touch ~/.local ; chmod 000 ~/.local" to force programs that use hardcoded names to fail spectacularly (instead of recreating the hidden dir). [0] https://github.com/b3nj5m1n/xdg-ninja https://github.com/b3nj5m1n/xdg-ninja
- b112 2y agoSo it's OK to hide the mess, by throwing everything from the living room into the closet, I guess? Not to mention, in the old days, that stuff was modtly in dot files. (Users install graphical file manager. User has file manager set to bizarrely show dotfiles by default. User gets mad at prior hidden "clutter". Now dotfiles hidden one dir down.)
- wadim 2y ago> So it's OK to hide the mess, by throwing everything from the living room into the closet, I guess? Yes? This is literally how every human in the world does it. You put your things, according to catrgories, into their respective room/cabinet. If somebody asks you where your sweaters are, you don't say "just search the ground", you say " in the closet". Same thing here. You don't have to guess where files are, you know by convention.
- b112 2y agoMy counterpoint was merely that ~/.<programname> hid things, unless you did weird things. Like explicitly ask to see all hidden things. Having a file manager set to see all dotfiles by default, is like ripping all the doors off your closets.
- NetOpWibby 2y agoUnsettling concept tbh
- xelamonster 2y agoI don't think it's all that weird, it's one of the first things I'd do in any file manager and I make sure Windows Explorer shows me system files too. If never had to interact with the hidden config it would be one thing, but I very often do and I don't want extra friction in getting to them.
- creshal 2y agoYou're completely missing the point. ~/.programname is an unorganized mess, where someone stuff their dirty laundry, their trash, their food and their passport into the same closet. It doesn't matter if the closet is open or not, nobody but the mentally ill hoarder who created the mess can navigate it. ~/.(local|share|cache) means people put their food in the fridge, their trash into the bin and their sensitive documents in a fire proof safe. Which means other people can take care of basic tasks like taking out the trash and creating backups of their sensitive documents.
- samatman 2y agoTaking this opportunity to remind folks: if you're going to emit a config file from your program, check for $XDG_CONFIG_HOME and use what you find by preference. ~/.config is a decent fallback. Sticking it in ~? It's not the 1980s anymore, please, don't.
- creshal 2y agoConfig files are the lesser problem, although it's really, really, really useful for programs to realize that $XDG_CONFIG_HOME exists. More importantly, please put your caches under $XDG_CACHE_HOME so they don't trash up my backups or git. And if you're feeling really fancy, put all your runtime stuff in a separate dir in $XDG_RUNTIME_DIR so /tmp doesn't look like someone detonated a zip bomb in there. I want to use it for my temporary files and still find them, thank you very much.
- ktm5j 2y agoOh cool idea! But gosh I think I would hate that.. I typically know what files are in directories that I'm working in, and usually care more about the output of previous commands I've run. I feel like this would teach me to never change directories
- xk3 2y agoWhen I want to cd I usually don't type cd. I use zoxide which is a modern autojump. In fish shell you can also just type the directory path and press enter and it will change the working directory.
- idunnoman1222 2y agoAlso good practice
- diggan 2y agoNeat idea, thanks! So obvious in hindsight... Just need to add some logic to it so it doesn't output more than N files. For others (like me) who use zsh: function chpwd() { ls }
- tutipop 2y agoI do the same in bash, but it's a bit wordier: _chpwd_hook() { if [[ "$PWD" != "$PREVPWD" ]]; then ls PREVPWD="$PWD" fi } PROMPT_COMMAND=(_chpwd_hook) Goes well with shopt -s autocd alias r='cd -'
- mbivert 2y agoNot strictly equivalent, but shorter (and should work with multiple shells): $ cd() { builtin cd $* && ls; } $ cd / bin boot cdrom dev etc home lib lib64 [...]
- oxygen_crisis 2y ago$* will break on directory names containing spaces and other bash "word" delimiters, use "$@": cd() { builtin cd "$@" && ls; }