mirror of
https://github.com/Cian-H/dotfiles.git
synced 2026-01-04 08:11:58 +00:00
This change allows the dotfiles to work with chezmoi (e.g: on windows) and improves grepability with neovim/telescope
40 lines
978 B
Nu
40 lines
978 B
Nu
# Append a suffix to an input string or list of strings.
|
|
#
|
|
# Examples:
|
|
# Output 'hello world'
|
|
# > 'hello' | str append ' world'
|
|
#
|
|
# Output file names suffixed with '_world'
|
|
# > ls | get name | str append _world
|
|
export def append [
|
|
suffix: string
|
|
]: [string -> string, list<string> -> list<string>] {
|
|
let input = $in
|
|
let append = { $in + $suffix }
|
|
if ($input | describe) == string {
|
|
$input | do $append
|
|
} else {
|
|
$input | each $append
|
|
}
|
|
}
|
|
|
|
# Prepend a prefix to an input string or list of strings.
|
|
#
|
|
# Examples:
|
|
# Output 'hello world'
|
|
# > 'world' | str prepend 'hello '
|
|
#
|
|
# Output file names prefixed with 'hello_'
|
|
# > ls | get name | str prepend hello_
|
|
export def prepend [
|
|
prefix: string
|
|
]: [string -> string, list<string> -> list<string>] {
|
|
let input = $in
|
|
let prepend = { $prefix + $in }
|
|
if ($input | describe) == string {
|
|
$input | do $prepend
|
|
} else {
|
|
$input | each $prepend
|
|
}
|
|
}
|