Last active
December 9, 2016 19:37
-
-
Save colstrom/6c0218c587c830f870a060b4cbd36f1d to your computer and use it in GitHub Desktop.
without-leading.fish: removes a pattern from the start of a string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function without-leading --argument string | |
| if empty "$string" | |
| usage without-leading '<string>' | |
| return (failure EINVAL) | |
| end | |
| sed -E "s/^$string+//" | |
| end |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In
fish >= 2.3.0this can be done withstring trim --left --chars "$string"orstring replace --regex "$string\$" ''