How to reset my PATH after breaking it accidentally? [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 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>

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.

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.

Find and replace text in a 47GB large file [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 2 years ago.
Improve this question
I have to do some find and replace tasks on a rather big file , about 47 GB in size .
Does anybody know how to do this ? I tried using services like TextCrawler , EditpadLite and more but nothing supports this large a file .
I'm assuming this can be done via the commandline .
Do you have an idea how this can be accomplished ?
Sed (stream editor for filtering and transforming text) is your friend.
sed -i 's/old text/new text/g' file
Sed performs text transformations in a single pass.
I use FART - Find And Replace Text by Lionello Lunesu.
It works very well on Windows Seven x64.
You can find and replace the text using this command:
fart -c big_filename.txt "find_this_text" "replace_to_this"
github
On Unix or Mac:
sed 's/oldstring/newstring/g' oldfile.txt > newfile.txt
fast and easy...
I solved the problem usig, before, split to reduce the large file in smalls with 100 MB each.
If you are using a Unix like system then you can use cat | sed to do this
cat hosted_domains.txt | sed s/com/net/g
Example replaces com with net in a list of domain names and then you can pipe the output to a file.
For me none of the tools suggested here work well. Textcrawler ate all my computer's memory, SED didn't work at all, Editpad complained about memory...
The solution is: create your own script in python, perl or even C++.
Or use the tool PowerGrep, this is the easiest and fastest option.
I have't tried fart, it's only command line and maybe not very friendly.
Some hex editor, such as Ultraedit also work well.
I used
sed 's/[nN]//g' oldfile.fasta > newfile.fasta
to replace all the instances of n's in my 7Gb file.
If I omitted the > newfile.fasta aspect it took ages as it scrolled up the screen showing me every line of the file.
With the > newfile it ran it in a matter of seconds on an ubuntu server