Skip to content

Instantly share code, notes, and snippets.

@colstrom
Last active December 9, 2016 19:37
Show Gist options
  • Select an option

  • Save colstrom/6c0218c587c830f870a060b4cbd36f1d to your computer and use it in GitHub Desktop.

Select an option

Save colstrom/6c0218c587c830f870a060b4cbd36f1d to your computer and use it in GitHub Desktop.
without-leading.fish: removes a pattern from the start of a string
name = without-leading
author = Chris Olstrom
license = MIT
provides = fish/functions/without-leading
requires
command/sed
fish/builtin/end
fish/builtin/function
fish/builtin/if
fish/builtin/return
fish/builtin/string
fish/functions/empty
fish/functions/failure
fish/functions/usage
function without-leading --argument string
if empty "$string"
usage without-leading '<string>'
return (failure EINVAL)
end
sed -E "s/^$string+//"
end
@colstrom
Copy link
Author

colstrom commented May 4, 2016

In fish >= 2.3.0 this can be done with string trim --left --chars "$string" or string replace --regex "$string\$" ''

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment