by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Fabian Homborg
@faho
There is no $PS1 where you get to use special sequences.
Minerva Orlova
@mnrvwl
wouldn't that slow the prompt significantly?
Fabian Homborg
@faho
There is no difference between $PS1 and $PROMPT_COMMAND, there is only fish_prompt, which is a function
If you use slow commands, sure.
Minerva Orlova
@mnrvwl
I see
Fabian Homborg
@faho
But a basename? That's microseconds.
I suggest you take a look at the default prompt - funced fish_prompt.
Minerva Orlova
@mnrvwl
yes, around 0.005 to be precise
Fabian Homborg
@faho
Which just isn't a problem.
Minerva Orlova
@mnrvwl
I was enjoying fish because I could get syntax highlighting, autocompletion and suggestions with about 0.060s less than in zsh+relevant plugins, because said things are zsh scripts at best there and they're baked in the shell in fish
Johannes Altmanninger
@krobelus
@mnrvwl you can use string match -r '[^/]*$' as faster replacement to basename if you want
Minerva Orlova
@mnrvwl
thank you for this idea @krobelus 💛
Johannes Altmanninger
@krobelus
Hmm this is stuff in __fish_print_help is annoying. We can probably get rid of ul since it just converts some weird bold/underline sequences to ANSI ones, and less can read both.
I wish we could just use man /usr/share/man/man1/fish.1.gz but that takes 300ms(!) here, three times slower than __fish_print_help..
Kamran Khan
@krkhan
Is there a way to instruct fish to use only file-path completions for some commands? E.g., I want rm to only be completing actual files and not look into the command history
Fabian Homborg
@faho
@krkhan If you're talking about the suggestions, there are no configuration options for those, so no
Kamran Khan
@krkhan
@faho is --force-files option for complete something that can help? although it looks like it's only to override effects of an earlier --no-files
Fabian Homborg
@faho
@krkhan You are talking about the "suggestions". The greyed-out things that appear in the commandline that you can accept with right-arrow. Those are, again, not configurable. There is no knob for you to change. This is on purpose.
Matt Sacks
@mattsacks
Hi! Can't quite figure this one out: in Vim, I'm getting different a different variable value from system('set') and system('set -U') after using a script that calls set -Ux SOME_VAR. Any reason there would be two different values for set and set -U in Vim when that doesn't show running directly in Fish?
Matt Sacks
@mattsacks
It also looks like I can't actually control those variables from inside Vim at all either. :!set -e SOME_VAR and it still shows it's value created before starting up Vim in :!set 😓
Minerva Orlova
@mnrvwl
💛
Matt Sacks
@mattsacks
@faho yep, saw that! It just seems like I can't retrieve the universal version of the variable from Vim even though a global one exists. :!echo $SOME_VAR will give the global version but :!set -U shows the universal one — is it possible to get the value of that one somehow without doing some parsing from the output of set -U?
Matt Sacks
@mattsacks
Ah, I see there's set -S SOME_VAR to show all the scopes of a variable, but no way to query the value from a specific scope…
Matt Sacks
@mattsacks
Figured it out but it's not pretty: set -U | string join "," | string match -r 'SOME_VAR\s(.*?),' | sed -n 2p
Fabian Homborg
@faho
@mattsacks If you want to see the global variables, use set -g?
set -U is specifically listing universal variables
That's what the -U stands for.
Matt Sacks
@mattsacks

@faho Yea sorry, it's kind of a weird situation. In Vim, it seems like universal variables are getting copied into the global scope for the vim session if they're updated in the background. Here's how to repro:

set -Ux TEST "something"
vim .
:!set -S TEST # should only have a universal version set
<Ctrl-z> # send vim to background
set -Ux TEST "new value"
fg
:!set -S TEST # TEST now has a global value of "something"

Ideally, this wouldn't create a global value and would only be the universal one I think?

Fabian Homborg
@faho
Okay, let me clarify the FAQ
When a variable is exported, it is passed to child processes.
When fish imports a variable, it does so as a global variable
Global is a smaller scope than universal, so global variables shadow universal ones.
Matt Sacks
@mattsacks
Oooh gotcha but in this case, it's only importing the variable globally when there's a new universal one exported, right?
Fabian Homborg
@faho
That fish that you start your vim in passes the variable to vim, which then creates a child fish, and passes the variable along.
So if you do want to mess with exported variables in this way, use a global-exported one, not a universal-exported.
Matt Sacks
@mattsacks
Makes sense! But I want this to update other fish sessions as well, not just the current one. Isn't that the use case for universal?
Fabian Homborg
@faho
Then use a non-exported universal variable.
Matt Sacks
@mattsacks
But that wouldn't get updated in a running vim session since it's not exported, right?
Fabian Homborg
@faho
It won't be updated in vim regardless what you do, because vim does not know about universal variables.
It will be updated in the fishes it runs
Matt Sacks
@mattsacks

I'll give that a shot and report back—thank you!

(Also, for the sake of learning, do you have any recommendations on my parsing of scoped variables I posted above with the string match | stuff?)

Fabian Homborg
@faho
I probably wouldn't try parsing sets output like that, and if I did I'd use string replace instead of string match | sed - it has a -f (--filter) option to only pass through lines that matched
Matt Sacks
@mattsacks
Oooh, looks like I missed the -f option. Thanks!
chriz
@chrizworks_twitter
hello 👋 Anyone using vi binding in fish? How do you enable the dot command for repeating and j and k?
John Meow
@johnmeow_gitlab
How do I get $0? Like if I run cmd arg1 arg2, how do I get the cmd parameter?
Fabian Homborg
@faho
@chrizworks_twitter It's not implemented.
@johnmeow_gitlab What do you want? The scripts name?
Most likely status filename, but there's also status current-command, depending on what you're using it for.
Ilan Cosman
@IlanCosman

How can I pipe into a function?

Ex:

function foo
    string replace -a is was
end
printf '%s' is | string replace -a is was
was
❯ printf '%s' is | foo # Errors
Fabian Homborg
@faho
@IlanCosman string won't read from stdin in that case (it'll read arguments from the commandline, not stdin), use read.