Run fish shell functions via i3 keybinding [closed] - fish

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
I wrote a simple fish function which lists out an output of locating command within rofi and the selected option is fed to vim.
function myfunction
vim ( locate ~/str/Dotfiles | rofi -dmenu )
end
and inside i3 config file, I have:
bindsym $mod+c exec myfunction
Well, nothing happens when I press mod+c but the function runs fine inside a terminal. Is it simply impossible to run a user defined fish function outside of a terminal?

Is it simply impossible to run a user defined fish function outside of a terminal?
It's certainly possible.
My best guess is that i3 here is launching a different shell (e.g. /bin/sh or whatever you have set up as your user's default shell via chsh).
Try explicitly specifying fish via:
bindsym $mod+c exec fish -c myfunction

Related

fish shell: ctrl-p is not working but ARROW UP is [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 10 months ago.
Improve this question
I recently installed various fisher plugins and updated to fish 3.4.1 and now "ctrl-p" does not cycle through my commands anymore, but ARROW UP is still working. When I switch to the bash shell, ctrl-p is working. I observe the same behaviour in the gnome terminal and kitty terminal. I have no clue what the problem is and would appreciate a lot if someone could help me, thanks in advance!
It appears one of your plugins rebound ctrl-p.
In general, to find out what a key sequence is bound to, you need to:
Figure out what the key sequence is by starting fish_key_reader and pressing it
Pass that to bind
So, you run fish_key_reader, which tells you:
bind \cP 'do something'
That means ctrl-p sends \cP.
So, we ask what \cP is bound to:
bind \cP
which by default gives us
bind --preset \cp up-or-search
(yes, the case is indeed irrelevant after a \c as \cp and \cP encode the same).
And if you had bound something differently, it might print multiple lines like
bind --preset \cp up-or-search
bind \cp 'echo oops'
What can also happen here is that one of your plugins enabled vi-mode (this can happen even for things you might think are entirely unrelated, for instance there's at least one semi-popular prompt that believes it's entitled to enable it).
In that case, bind \cP will output nothing, and you can also ask bind -M insert \cP to ask what ctrl-p is bound to in insert mode.
To disable vi-mode and go back to the default emacs-inspired bindings (where that binding for ctrl-p originated), run fish_default_key_bindings.

How to reset my PATH after breaking it accidentally? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
The community reviewed whether to reopen this question 1 year ago and left it closed:
Original close reason(s) were not resolved
Improve this question
I think I run something incorrectly trying to add a directory to PATH in fish. Perhaps it was this:
set -g PATH my_foobar_directory "$PATH"
From fish tutorial I now understand that I shouldn't have added the double-quotes.
Better yet, should've used fish_add_path my_foobar_directory.
Lesson learned; however, the change has persisted somewhere, and nothing I try seems to recover the previous state. I also cannot find the previous PATH value — the console logs with it were washed away by copious fish: Unknown command: python etc, from fish_prompt bells & whistles.
Falling back to bash gives me bogus PATH as well — even after set -e PATH.
What do? How do I start over?
So for myself, I solved it like this.
In the process tree, I found a sufficiently long-running process. In my case, cinnamon-session worked — though any not-so-distant fish parent would do.
The idea being that in that process's environment, the previous PATH value could still be intact. It was.
Then basically — let's say the pid was 661 — print environment of pid 661 in fish format:
/bin/tr \0 ' ' < /proc/661/environ
# copy output
Then just pick that output, and feed it into the "universal" variant (fish-specific) of the PATH variable, taking care to erase all other variants:
set -e PATH
set -eg PATH
set -Ux PATH <paste>

ANSI sequence to change terminal name [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
I use a bash script (konsole-name.sh) to change a terminal name, like this:
#!/usr/bin/bash
echo -en "\e]30;$1\a"
and I wanted to use the same method from a perl script that I use to check the GPU temperature, so that it updates periodically the window title.
Yet I didnt find a way.
I tried both this:
$comm='echo -en "\e]30;T=$t\a"';
`$comm`;
and this, using my bash script:
$comm="konsole-name.sh T=$t";
`$comm`;
there is some way to do it?
The console escape sequences work by printing text to the terminal. In your case, the backticks gobble up the output of the script.
Most likely you just want print "\e]30;$1\a"; from within Perl:
my $title = "Fancy terminal title";
print "\e]30;${title}\a";

Double exclamation in fish shell [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
In zsh, I can execute them.
$ sleep 1
$ echo !$ # !$ equals 1
$ echo !! # !! equals sleep 1
But I can't execute them in fish shell.
Could tell me why and where the zsh documentation is?
This is history expansion, which has a lot more to it then those simple examples.
Fish supports none of it (and probably never will). The usual workaround is to use keybindings. By default, alt-up and alt-down should go through the history token-wise, so you can press alt-up once to get what is effectively !$.
If you wish to prepend something to a command from history, recall that command, go to the beginning (e.g. with ctrl-a) and insert what you want.
Other possibilities are functions to bind e.g. !! to something to insert the previous command or to make a command called !!.
This is still discussed in fish issue #288, though concensus seems to be against adding history expansion.

What happens when a file is "run" [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
If I write a function in a .m file and try to run it by pressing the "run" button, will the function just be set in the environment or also run, maybe without arguments?
If the function does not take any arguments, then it will simply be executed. If the function does take arguments, and you try to run it via the GUI, you should be prompted to enter a set of default arguments that should be used. These arguments will be used if you ever run the script in the future.
This is described in Matlab's documentation here.
There are two types of mfiles (files with .m extension) in Matlab:
Scripts and Functions. (See Scripts vs. Functions)
See Calling a function for how to use a function programmatically.