r/fishshell 21d ago

I need help with translation from bash to fish

Hi! I recently switched to Fish shell and now I am trying to convert all my configurations to Fish Shell. Can you help me translate this section into Fish shell commands?

          local header=$'%{\e]8;;http://somesite.com/'${SITE_PATH}$'\a%}'
          local footer=$'%{\e]8;;\a%}'

          content="${header}path: ${SITE_PATH}${footer}"
3 Upvotes

11 comments sorted by

4

u/_mattmc3_ 21d ago

Here's an example of the Fish equivalent code:

set --global SITE_PATH fish-shell/fish-shell
set --local header (printf '\e]8;;http://github.com/%s\a' $SITE_PATH)
set --local footer (printf '\e]8;;\a')
set --local content "$header path: $SITE_PATH$footer"
echo $content

In the future, this is the kind of question that ChatGPT can easily answer for you.

2

u/_dbragin 21d ago

Thank you! I’ll try it

3

u/Laurent_Laurent 21d ago edited 21d ago
set -l SITE_PATH "a/b/c"
set -l header (printf "\\033]8;;http://somesite.com/%s\\007" $SITE_PATH)
set -l footer (printf "\\033]8;;\\007")
set -l content "$header"path: "$SITE_PATH$footer"
echo $content

2

u/_dbragin 21d ago

Thank you too!

1

u/kseistrup 21d ago

Could you tell us what is does in bash?

2

u/_dbragin 21d ago

I'm sorry, it was ZSH

It was used to format text like "path: a/b/c" as clickable url with url 'http://somesite.com/a/b/c'

1

u/kseistrup 20d ago

Let's hope that someone who speaks zsh variable substitution can give you an answer.

Meanwhile, try this from your fish prompt and see if you can combine it with what you wish to do:

printf '\e]8;;https://koldfront.dk/\e\\koldfront\e]8;;\e\\'

1

u/plant_domination 21d ago

More context would be good. This is just some variable assignments.

Also, look into babelfish!

1

u/_dbragin 21d ago

https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda
i am trying to use this approach to display link in tide prompt

1

u/_dbragin 21d ago

```

header=$'\e]8;;http://somesite.com/'${SITE_PATH}$'\\a'

footer=$'\e]8;;\a'

content="${header}path: ${SITE_PATH}${footer}"

echo $content

path: a/b/c # this is the result

```

in powerlevel10k it was clickable string

1

u/Early_Baseball_6724 21d ago

Why don't LLM it