ogham / exa

A modern replacement for ‘ls’.
https://the.exa.website/
MIT License
23.53k stars 662 forks source link

Feature request: configuration files #511

Open tbodt opened 5 years ago

tbodt commented 5 years ago

Having to configure exa using a shell alias is less than convenient. ripgrep allows you to set a RIPGREP_CONFIG_PATH environment variable to point to a file that contains a list of default options, one per line (https://github.com/BurntSushi/ripgrep/blob/master/GUIDE.md#configuration-file). I think exa should do this too.

bkuhlmann commented 3 years ago

I would like this too. One suggestion would be to adhere to the XDG specification so our Dotfiles don't get so cluttered. With XDG, we could have this instead: ~/.config/exa/configuration.yml. :tada:

NOTE: Doesn't have to be a YAML configuration but can be any configuration format that makes sense.

ariasuni commented 3 years ago

Here’s a suggested, hypothetical config file, inspired by ui_styles.rs/default_theme.rs:

~/.config/exa/exa.toml ```toml # The [colors] table has all that’s possible to configure with EXA_COLORS # and filekinds too, in a much more readable way!! [colors.ui] punctuation = "black bold" # date = "" # inode = "" # blocks = "" # header = "" # link_path = "" # control_char = "" # broken_path = "" [colors.filetypes] # file = "" # directory = "" # executable = "" # pipe = "" # socket = "" # block_device = "" # char_device = "" # symlink = "" # broken_symlink = "" [colors.filekinds] temp = "white" # build = "yellow bold" image = "purple" video = "purple bold" music = "cyan" lossless = "cyan bold" crypto = "green bold" document = "green" # compressed = "red" compiled = "yellow" [colors.perms] # ur = "" # uw = "" # ux_file = "" # ux_other = "" # gr = "" # gw = "" # gx = "" # or = "" # ow = "" # ox = "" # special_user_file = "" # special_other = "" # extended_attribute = "" [colors.sizes] # the two first are default, and overridden by the more specific variants. # nums = "" # units = "" num-byte = "green" num-kilo = "green bold" num-mega = "yellow" num-giga = "red" num-huge = "purple" unit-byte = "green" unit-kilo = "green bold" unit-mega = "yellow" unit-giga = "red" unit-huge = "purple" # major = "" # minor = "" [colors.users] # user-you = "" # user-other = "" # group-yours = "" # group-other = "" [colors.links] # normal = "" # multi = "" [colors.git] # new = "" # modified = "" # deleted = "" # renamed = "" # changed = "" ## The [[ and ]] signals that colors.custom is an array of table. [[colors.custom]] patterns = ["*.md", "*.rst"] style = "yellow bold" [[colors.custom]] patterns = [".py"] style = "red underline" ## Everything else that was controlled by environment variables. [options] # columns = strict = true # grid_rows # icon_spacing ```

I’m not sure about some names (I’m totally not sure what’s special_user_file and special_other, and if the same distinction between ux_file and ux_other).

But mostly I think it’s an interesting draft. Any thoughts?

fredericrous commented 3 years ago

nice draft ariasuni. where would the file extension icon fit into this config? maybe colors.custom could be replaced by something like [[file_extension]]? Also, how would you define filekinds like the group of extensions behind image? in a separate config file? I would suggest not to put too much effort into color definitions per file extension. These can already be defined by LS_COLORS and there already is an excellent tool that handles configuring these with config files: Vivid. See config file examples for vivid here: https://github.com/sharkdp/vivid/blob/master/themes/jellybeans.yml and there https://github.com/sharkdp/vivid/blob/master/config/filetypes.yml

ariasuni commented 3 years ago

Well a great first step would be to be able to have a configuration file at all.

More advanced features, like colors based on file glob/pattern and custom file icons mapping, should probably be handled separately afterwards — e.g. to discuss if things like vivid are the way we want to handle colors.

edent commented 1 year ago

Is there currently any way to do this? I always run

exa -l -s modified --no-permissions --icons --no-user

Is there a way to set those defaults so I just need to type exa?

zhengpd commented 1 year ago

It could be a config file supporting simple options at first step, and after that extend to complex options/features.

zhengpd commented 1 year ago

My workaround before official conf file (with zsh & exa installed by homebrew on macos):

  1. create ~/.bin/exa (~/.bin/ should be placed before /opt/homebrew/bin in PATH)
    
    #!/usr/bin/env zsh

args=($@)

opts_file=$HOME/.exarc [[ -f $opts_file ]] || touch $opts_file

opts=(${(@f)$(<$opts_file)})

/opt/homebrew/bin/exa $opts $args


2. create `~/.exarc` with desired exa options

--sort=Name --git --time-style=long-iso