supercrabtree / k

k is the new l, yo
1.78k stars 124 forks source link

How to separate folders and files #100

Closed delucca closed 3 years ago

delucca commented 4 years ago

Hi!

Great tool, I've been using it for a while now ;)

I would like to separate folders from files (folders first, files last) and both sorted. How can I do it?

kankaristo commented 3 years ago

I was looking for this, and didn't find any "configuration" for k, but you can create an alias (in your .bashrc, .zshrc, etc.):

alias k="k --human --group-directories-first"

Note that by doing this, you can't "unset" these options (they're always enabled, you can't do k --not-human, etc.).


If you want to have multiple aliases with different options, you may need to rename the function (or have the main k alias only have options that are shared by all other aliases).

For example, if k feels a bit too slow, you could have 2 different aliases: one with VCS/Git support, one without.

This is getting a bit hacky, so use at your own peril (function rename "trick" from Stack Overflow):

eval "$(echo "_k() {"; declare -f k | tail -n +2)"
alias kk="_k --human --group-directories-first"
alias k="_k --human --group-directories-first --no-vcs"

With the above, you have 3 different commands:

delucca commented 3 years ago

Great! Thanks :)