fish shell: ctrl-p is not working but ARROW UP is [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 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.

Related

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>

Run fish shell functions via i3 keybinding [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 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

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.

looking for helm-ls-git tutorial (emacs, helm) [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
https://github.com/emacs-helm/helm-ls-git
Found no tutorial for it on google.
That means it doesn't exist in our universe?
I'm looking for a way to find files and grep files within emacs.
Hopefully as easy as in sublime with project directory opened.
(Your search is automatically limited to the directory you specified in sublime)
The functionality you are after is something dired has been doing successfully for years. The file you have linked in your post is a minor enhancement for a convenience feature added on top of the built-in functionality, it doesn't really deal with searching for files outside the context of Git version control system.
Here are some examples of how you could do it with dired:
M-xfind-name-dired, answer the prompts to select the directory where you want to search and possibly refine by providing a regular expression to match file names. You then will be presented with the buffer listing all files you have selected so far. You can further refine from here by % m and providing it with a regexp to filter the file names on, or just hit t selecting all files in the buffer.
Then hit A and write the regexp to search for inside the selected files. The effect of this command will be to open the file, where the match is found. After you close the file, or return to the original buffer, you can press M-, to move to the next match.
If this sounds too elaborate, then you could just do M-xfind-dired to invoke find in the directory you choose with the arguments you can normally provide to find
To just grep and have the matches shown in a dedicated buffer you could do M-xfind-grep - this will invoke find with the output from it piped to grep. You will then need to modify the command used to invoke this to your taste.
M-xfind-grep-dired will do something similar, however it will display the files, where the match was found in a dired buffer, rather then the lines, where the match occurred.
Finally, there may be a bunch more ways to do this, depending on your particular task and what, in the end, you are trying to accomplish. Perhaps, some times, invoking a shell command to place the results directly in the buffer would be the best way to do it. Other times you may want to write your own eLisp function to do something more elaborate with the results. Sky is he limit :)
I saw this question recently and updated the README on the repo page to reflect installation and usage:
https://github.com/emacs-helm/helm-ls-git
Hope it helps!
This might not answer your entire question but I use the following bit of elisp as a shortcut for greping all files with a set list of extensions under a specific folder:
(defun pgrep (regexp)
"rgrep files inside a project folder"
(interactive
(list (grep-read-regexp)))
(grep-compute-defaults)
(rgrep regexp "*rb *erb *js *css *scss" "~/path/to/folder/"))
Then I just run M-x pgrep foo
For anything more complicated I just run rgrep directly - it lets you specify the root folder, search string, and extension.

Syntax Highlighting Pager [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
Improve this question
Right now, I use most as my pager. While it has helpful syntax highlighting for man pages, it lacks colored syntax highlighting for anything else (I'm specifically looking for diff/C++).
Meanwhile, pygments is a wonderful program. I can easily make colorized output with it:
# ./pygmentize -f console256 ${file}
hg diff | ./pygmentize -f console256 -l diff
Now, I would like to be able to page the output, so I just use:
# ./pygmentize -f console256 ${file} | most
hg diff | ./pygmentize -f console256 -l diff | most
At this point, most dumps all the colorizing control characters to my screen like so:
^[[38;5;28;01mclass^[[39;00m ^[[38;5;21;01mheap_allocator^[[39;00m
{
^[[38;5;28;01mpublic^[[39;00m^[[38;5;241m:^[[39m
This is, of course, unreadable. I looked though the man page for most, but I couldn't find any "Hey, show those control characters as colors instead of printing them" options. less has the same garbage behavior as most, but more shows the colors perfectly fine, with the obvious limitations of being more.
Is there a pager that supports syntax highlighting or some crazy combination of parameters and programs I can string together to make this work? Ultimately, I would like to get diffs and logs from Mercurial to be highlighted, so maybe there is a shortcut in there...
Might I suggest vimpager?
First off, recent vim distributions (I believe 6.0 and above) come with a pager-esque-mode script. It's quite simple and functional, and operates similarly to less. Try: vim '+help less' +only.
Even better, however, Rafael Kitover has written a much more robust and powerful script called vimpager. It's available on GitHub (or vimscripts). If you are on OS X and using Homebrew, it's as easy as brew install vimpager.
At that point, you can simply set $PAGER=vimpager, or even alias less=vimpager. It works excellently.
less -R shows ANSI color sequences as-is (instead of expanding to caret notation). That'll make syntax highlighting work!
You can also create an environment variable LESS=-R to make this the default behavior. Similarly for other options; see man less.
Look for bat: A cat(1) clone with wings.
bat supports syntax highlighting for a large number of programming and markup languages.
It is not a pager, but it automatically redirects output to less if needed.
You might try using jed. Yes, it's a text editor, not a pager, but it's quite lightweight and the default install contains excellent colorschemes for a wide variety of file types and languages.
Jed has syntax highlighting modes for different languages, simillar to the emacs ones. For example if you piped a C program to it, you can turn on the highlighting by pressing 'ESC', then 'x', then typing 'c-mode' . If it is a php program - change the last part to 'php-mode' and so on ...