From 200edc9c963c62184cadeeede6fa6c731eedce38 Mon Sep 17 00:00:00 2001 From: emilis Date: Thu, 5 Jan 2023 19:34:10 +0000 Subject: [PATCH] has_prefix fish util --- fish/functions/has_prefix.fish | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 fish/functions/has_prefix.fish diff --git a/fish/functions/has_prefix.fish b/fish/functions/has_prefix.fish new file mode 100755 index 0000000..864ca81 --- /dev/null +++ b/fish/functions/has_prefix.fish @@ -0,0 +1,17 @@ +#!/usr/bin/env fish + +function has_prefix + set -f input_str $argv[2] + set -f match $argv[1] + if test -z $input_str; or test -z $match + log -c red "input[$input_str]/match[$match] empty" + return 1 + end + set -f m_len (string length $match) + set -f input_len (string length $input_str) + if test $m_len -gt $input_len + return 1 + end + set -f cut_input (string sub -l $m_len $input_str) + return (test "$cut_input" = "$match") +end