mirror of
https://github.com/Cian-H/dotfiles.git
synced 2026-01-04 16:21:58 +00:00
Changed . token to _dot
This change allows the dotfiles to work with chezmoi (e.g: on windows) and improves grepability with neovim/telescope
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
# Function to extract archives with different extensions.
|
||||
export def extract [name:string] {
|
||||
let handlers = [ [extension command];
|
||||
['tar\.bz2|tbz|tbz2' 'tar xvjf']
|
||||
['tar\.gz|tgz' 'tar xvzf']
|
||||
['tar\.xz|txz' 'tar xvf']
|
||||
['tar\.Z' 'tar xvZf']
|
||||
['bz2' 'bunzip2']
|
||||
['deb' 'ar x']
|
||||
['gz' 'gunzip']
|
||||
['pkg' 'pkgutil --expand']
|
||||
['rar' 'unrar x']
|
||||
['tar' 'tar xvf']
|
||||
['xz' 'xz --decompress']
|
||||
['zip|war|jar|nupkg' 'unzip']
|
||||
['Z' 'uncompress']
|
||||
['7z' '7za x']
|
||||
]
|
||||
let maybe_handler = ($handlers | where $name =~ $'\.(($it.extension))$')
|
||||
if ($maybe_handler | is-empty) {
|
||||
error make { msg: "unsupported file extension" }
|
||||
} else {
|
||||
let handler = ($maybe_handler | first)
|
||||
nu -c ($handler.command + ' ' + $name)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user