This part of the FAQ might be useful for you: http://fishshell.com/docs/current/fish_for_bash_users.html#fish-for-bash-users
The most common interactive usage of !! is when doing sudo !!
In Fish, you can use Alt-s
in order to do precisely this. See http://fishshell.com/docs/current/faq.html#why-doesn-t-history-substitution-etc-work
Moving about the command line can be made faster too, if you want to for example replace one of the middle arguments in a previous commands. You can jump back and forwards full words at a time with Ctrl-right
and Ctrl-left
, or if you prefer emacs style shortcuts, Alt-b
and Alt-f
. Ctrl-W
or Alt-backspace
deletes a full word to the left.
With these shortcuts I find myself rarely needing to use !!
at all. In scripts I rarely find it useful and the Alt-s
shortcut makes up for all my sudo-prepending uses.
Edit: If you actually need to use it in a script, you can of course access it through $history[1]
.
See goals 1, 2, and 3 here: http://fishshell.com/docs/current/design.html
Goal 3 is to be POSIX like, but explicitly not at the expense of goals 1 and 2. Read another way: no, fish will not be fully POSIX compliant because that would be against the primary goal of the project.
Forgive me if this is too obvious, but have you tried removing your config.fish file?
A common noob mistake is thinking that you have to have a config.fish file and that you should do PATH surgery in it. This is how you have to do things in bash (or zsh or sh) so it is natural to assume fish would be the same; it isn't. Unfortunately the fish documentation does not well advertise this idea.
The best way to change your PATH from what is inherited from the system is to define fish_user_paths as shown in the tutorial. Your fish_user_path gets prepended to the system PATH so those directories take priority. They also note:
>The advantage is that you don't have to go mucking around in files: just run this once at the command line, and it will affect the current session and all future instances too. (Note: you should NOT add this line to config.fish. If you do, the variable will get longer each time you run fish!)
My config.fish is empty and fish is the interactive shell I use for everything.
In fish you don't have to make all your changes in the config.fish file. Instead many of the customizations that you would put in rc file with zsh or bash, in fish you can instead set them as "universal" variables, which persist across all fish instances even after a reboot. http://fishshell.com/docs/current/tutorial.html#tut_universal You have to change your mental model a bit if you are more used to dot files in bash.
The fish prompt is actually just a function. It is usually stored in ~/.config/fish/functions/fish_prompt.fish and you can edit it there.
You don't need to edit anything in you config.fish file in order to change the prompt, just modify the prompt function.
Thanks for this; you were on the money!
​
Using iTerm2 I had to set the right option key to `Esc+` instead of the default setting of `normal`. Further info here if anyone stumbles across this in the future: How do I make the option/alt key act like Meta or send escape codes?
​
Thanks again and have a great day!
>bind -M insert \ct 'fzf'
No idea what this fzf is, nor of what you want to obtain.
Binding something like this will just execute the program (which may print some text) but will not otherwise affect your shell state. Try typing `ls<enter>` instead of just `<enter>` to understand what's going on.
>alias rd=...
Aliases are just functions. Write a function (that will also make that mess actually readable)
>abbr --add --global rd...
Not sure what's the point of making an alias out of that abomination, however.. loot at set_color.
>urxvtc ...
No idea, I don't use that.
BTW: taskwarrior.org
Not sure. If the [fzf search syntax](https://github.com/junegunn/fzf#search-syntax) doesn't do it for you then you will have to do it through a manual command.
Okay, fish_prompt_mc
is from midnight commander.
That injects this function into fish's stdin and expects it to execute because it ends with a "\n". Do you have "\n" bound to "execute"? bind \n
should tell you.
Also, especially if you are not using mc, do you use any third-party customization? Any plugins, themes, prompts etc from someone else? Some of these also add bindings (even some prompts).
Do you use vi-mode? Does this only occur in normal-mode? Which fish version is this?
What do you mean? I want to have previews without polluting FZF_DEAULT_OPTS, as advised on https://github.com/junegunn/fzf#preview-window. Also separate options for files/directories so I can use different programs for preview (bat vs tree for example).
Good question, I'm glad you asked! Here are some major differences. The out of the box integration: - doesn't autoload it's functions like mine does, which means a slower shell startup - doesn't have configurable keybindings - doesn't have functionality for searching git log - doesn't have functionality for browsing shell variables - is much harder to read and maintain (but of course that is slightly subjective and I'm biased) - history search doesn't show time stamps whereas mine does - find files doesn't support color (e.g. mine shows folders in blue to differentiate it from normal files) - will likely not be as frequently updated
That's off the top of my head and by looking at the implementation. To be fully transparent, I haven't used it in a few years and haven't fully analyzed or tested the code as I wrote this. For reference, you can see the out of the box fish integration code here.
Hope that helps. Let me know if you have more questions!
The other suggestion I have, if you have not done so already, is upgrade your terminal to something like https://www.iterm2.com/
It has some very nice theme support built into it that works regardless of what shell you're using.
Warning, there is a misunderstanding in the use of fish variable ARRAYS!
You used set a (cat agree)
and created an ARRAY containing each line of file agree
This is important for you using fish: echo $a
will print each element of the array with a " " source character as seperator.
Try this instead: set -S a
. (Whatch out: set
takes the variable name a
, not its content $a
)
So, how to output the content of ARRAY a
?
One choice is echo $a\n
which places a newline char after each ARRAY element. But WHY does this even happen?
ARRAYS make fish
easier and - if not understood properly - complicated. It is in the documentation at the section "Variable Expansion", but THIS precisely is in the following section Cartesian Product
Another way to output the content of agree
by looping over the content of a
by for line in $a ; echo $line ; end
The difference to the solution given before is that there the whole content will be in in $a
which is the same as $a[1]
where YOUR initial approach stores every line into $a[1]
to $a[n]
with n
=line count.
What is best for you, I do not know. But I know that it can be hard to understand stuff like echo $a\n
and that you most likely have overlooked it.
Just remember to try set -S <var name without $>
if variables and strings happen to be ... weird.
The line editor in fish is namer "Command line editor" in the docs.
You can add a handler for the fish_command_not_found event, see the --on-event option of the function builtin.
I'm just commenting on the few ones I know: