# reads a config file export def read_file [app: string, filename = "config.toml"] { get_path $app | path join $filename | open } # returns the path to an apps config dir export def get_path [app: string] { let home = $env.HOME? if $home == null { return "/etc" | path join $app } let local = ( $home | path join ".config" | path join $app ) if ( $local | path exists ) { $local } else { let etc_cfg = ( "/etc" | path join $app ) if ( $etc_cfg | path exists ) { $etc_cfg } else { mkdir $local $local } } }