Fish shell 2.1
fishshell.com
fishshell.com
> http://fishshell.com/release_notes.html
> When tab-completing a file, fish will first attempt prefix matches (foo matches foobar), then substring matches (ooba matches foobar), and lastly subsequence matches (fbr matches foobar). For example, in a directory with files foo1.txt, foo2.txt, foo3.txt…, you can type only the numeric part and hit tab to fill in the rest.
This is really brilliant! I always wanted that (without knowing it).
Something like:
Type:
> ssh
press arrow-up:
> ssh larry@google.com
press arrow-up:
> ssh mark@facebook.com
To use it, I use:
bindkey "^[[A" history-beginning-search-backwardEdit: Seems ctrl-up and ctrl-down does the trick.
It emulates the Fish behavior (which is just awesome). I'm not sure if it requires oh-my-zsh, but I think it doesn't.
bind "C-p":history-search-backward
bind "C-n":history-search-forward
Type: ctrl+r
Type: ssh
Bash says:
(reverse-i-search)`ssh': ssh dude@somewhere.com
Type again: ctrl+r
(reverse-i-search)`ssh': ssh someoneelse@elsewhere.com
From the docs: Alt-Up and Alt-Down search the command history for the previous/next token containing the token under the cursor before the search was started. If the commandline was not on a token when the search started, all tokens match. See the history section for more information on history searching. [1]
I know of three history completion modes in fish.
Full command search: start typing a command and press Up. This will search for entire commands matching your query.
Word search: type any letters in a command, then press Alt+Up. This will cycle only the current word based on a substring match of your query. Useful for hostnames, filenames, etc.
Context-sensitive: If fish 'previews' the rest of a line as a lighter color text, press the right arrow key to complete. This is sensitive to the current directory and available files. If you go into a directory, `touch filename`, `cat filename`, and type `cat`, it will preview `cat filename` for you. Pressing the right arrow key will type it. If you `rm filename` or change directory, `cat filename` will no longer appear.
"\e[B": history-search-forward
"\e[A": history-search-backward bind '"\e[A":history-search-backward'
bind '"\e[B":history-search-forward'
It's one of the things I always tell people to use since it makes using bash so much easier."\e[A": history-search-backward
"\e[B": history-search-forward
What do you do when you have to use a computer without your customization? Perfect is the enemy of good, worse is better, join us on the dark side, all that jazz. :)
Is fish really really REALLY worth it?
Uh, by that logic I would only use notepad.exe.
I'm asking, not telling.
For regular shell scripts I tend to still prefer #!/bin/ksh and not bourne shell (no bash is not bourne shell).
I have to admit the line of thinking you're advocating reminds me of the vim/emacs "wars". With the "vim is on ALL THE SERVERS", well yeah but unless i'm at a serial console thats not all that convincing as a TRAMP user. I customized tramp so I could edit files remotely through sudo. What do I care about the version vim installed on the servers?
Even Solaris had zsh in the default install.
Actually, it's still part of the "default" group packages (similar to an installation profile).The default shell for new users (including root) is now bash though.
I don't see any problem with using whatever pleases you (even if those are very obscure tools), if with transition you don't lose ability to use less convenient (but common) tools on occasion. And you usually don't lose that.
Also, fish shares the history between the shells out of the box, unlike zsh... but it chose to do it in a different way (that is, commands are available even if one of the shells hasn't been closed, unlike bash... but they aren't available right away after entering a single new command, like most zsh configurations that I've seen)
Take it for a test: go write a project euler problem (or any small programming task--doesn't have to be math) in your shell of choice. It's painful.
There are weird features of shell languages that will never go away (globs and unquoted strings sharply limit the design space), but even given those limitations, it's possible to design nicer languages.
I don't fault someone for saying "right now, I'd rather use the default shell my box comes with, because the pain points of switching are too high". But yes, we really do need something to replace it. I think both zsh and fish make nice steps, but I don't think either really meets my hopes.
"If you have a strong understanding of other shells, and want to know what fish does differently, search for the magic phrase unlike other shells, which is used to call out important differences."
"stdin and stdout can be redirected via the familiar < and >. Unlike other shells, stderr is redirected with a caret ^"
That's pretty, no argument there. But I already remember to count the std's from 0, so stderr is &2. Not as pretty, fish is nicer, no argument. But its not MUCH nicer, and I'm going to have to use &2 here and there in my life anyway...
So:
- fish has no dedicated syntax for setting variables
- fish does not have an export command
- fish stores the exit status of the last command in $status instead of $?.
- fish does not use backticks ` for command substitutions. Instead, it uses parentheses.. I'm pretty sure good bash form is $() these days, not backticks. So you're spared the dollar sign.
'etc 'etc. I agree we need something to leapfrog what we have but these changes, while nice improvements, seem minor. At least as far as I can see! That's why I asked. Maybe there's some more neat stuff that makes it a significant improvement.
set foo bar # sets foo to bar
set -x foo bar # sets foo to bar and exports it to the environmentI'm asking because i'm using powershell with conmeu for almost 2 years now without a problem. Plus with conmeu i also run vim and farmanager (old school file manager ) in 2 separate tabs.
Really though, it's just the shame that Microsoft hasn't improved their Terminal app in over 16 years at a rough guess, from a functionality standpoint. That's just ... that makes no sense. Not when they're doing so much more to encourage sysadmins to use their command prompts and PowerShell. For a company that can make such great IDEs and OSes, why can't they combine both into a masterful shell window?
Maybe evolution will also go the other way around: Nautilus and other file browsers have rudimentary shell-like use & feel, e.g. when searching for something. Extending that could create some interesting features.
> What do you do when you have to use a computer without your customization?
How are people running into this situation so often? I don't sit down at my coworkers desks and start using their accounts. On production servers, I still have zsh and although some of my custom utilities are missing, it is not like I am somehow crippled by their absence.
This concern is like being opposed to cordless drills and screwdrivers because "what would happen if you found yourself with only a regular screwdriver?" ...well, what of it? If I found myself inexplicably with only a regular screwdriver, I would use it. Not a big dea. It's not like zsh users turn into blithering idiots as soon as they don't have their fancy PS1 set and are missing a few completion options.
I agree with this attitude if indeed this was the case. I don't see how zsh or fish constitute cordless drills and screwdrivers, it feels more like they are the right-y version to the left-y version of the regular screwdriver.
But maybe its because I don't know their killer features, I always try to pay attention to them and play with them occasionally but it never clicked for me why its so much better.
"What do you do when you have to use a computer without your customization? "
I can't answer for other people, but when I am logging into other systems I am very seldom performing the same tasks that I do on my development workstation. I don't need those customizations because I'm not doing the kinds of things that require them.
So when I log into another system, I just use it. I don't try to do the things that I can do on my local system - maintaining awareness of the differences is not a challenging thing.
If by customization you mean setting what happens when you write invalid glob, how much you can store in the history, whether prompt beeps on error, whether integers starting with 0 are octal, what regular expression engine is used, and so on, feel free to use zsh - it's great, really, after you configure everything, that is - fish shell won't let you change that by design. This is not a flaw - author believes that configuration is the root of all evil (and I agree with him).
How much time can I spend on customizing something to be more convenient and still save time in the long run? Can I spend half an hour to speed up a task I do daily by five minutes? Can I spend a month learning Emacs and save time in the long run? Can I spend two weeks learning how to touch-type?
The answers invariably are very much dependent on your personal work. But to me, the far more important question is:
Can I do anything that makes my life more pleasant? To me, personally, fish really improves my enjoyment of terminal usage. Productivity does not even enter this equation, but I suspect that I work faster when I am happy. I in fact do use fish, and Emacs, for the simple reason that I enjoy using them. I might be more productive with other tools, but I would not enjoy my work as much.
So yes, it is a matter of love. Do what you love, not what pays best.
As someone who has used an increasingly customized *nix command-line environment for decades, I'll say that this corner-case occupies a vanishingly small amount of my time. I just doesn't make sense to optimize for it. I currently use zsh, which is frequently not available by default. This implies installing a package, and I don't see how that's any worse for fish. I freely admit that my workflow as a developer vs. (e.g.) a sysadmin provides a greater degree of relative control over my day-to-day working environments.
I do have to work in non-customized environments from time to time. I find this no worse than using Someone Else's Keyboard -- maybe there's some clumsiness at first, but you soon get the hang of it. If you switch environments frequently, the switch becomes unnoticeable.
That said, I've also put continual effort into portability and ease of deployment of my customizations over the years. I can run one command on a networked host and have my rcfiles land there and be ready to use. This is pretty easy to do with a git-managed homedir repo, especially on a provider like GitHub where you can fall back to grabbing tarball if needed. I currently use vcsh[1] & mr[2] to manage my repos -- for that I use a bootstrap script hosted in an orphan branch of the same repo.[2] An efficient setup process of this type also makes it easy to integrate with provisioning tools, e.g. Puppet, Chef, or even just shell scripts.
[1] https://github.com/RichiH/vcsh
On a side note: This is my computer. There are many like it, but this one is mine.
But back in bash-land, _of course_ I alias "ll" to "ls -Flah". And when I'm on a system that doesn't have this alias, then, well, I just type "ls -la".
As others explained, just because I've customized my work environment doesn't mean I've forgotten to use the plain versions.
Edit: I'm running a pre-release of 2.0.0, which I modified to time every command. I was extremely impressed at how simple it was for me to add (not my usual language).
set -x GOPATH $HOME/go
set -x PATH $GOPATH/bin $PATH1. <strike>Fish syntax breaks virtualenv</strike> (Edit: Okay, apparently this isn't actually a problem).
2. Fish does not have the equivalent of 'disown' in bash. This is fine if you exit the parent shell normally, but not if you send SIGKILL, which my window manager (wmii and i3) does.
You might want to try virtualfish [1]
. bin/activate.fish# This file must be used with ". bin/activate.fish" from fish (http://fishshell.org)*
Fish is as the name (Friendly Interactive SHell) suggests an interactive shell. You should just set vim/emacs/whatever to use a bourne-compatible shell. It's one line of vim config: set shell=/bin/sh
bash is configured as my default shell. So every program that runs my default shell and just assumes it can use POSIX syntax, gets what it wants (even though it should really just use /bin/sh).
My terminal on the other hand is configured to ignore my default shell and run fish instead.
I also have a line in my .bash_profile (meaning it only runs for login shells) that checks whether it's running in a virtual terminal and in that case exec's fish in a new tmux (because tmux is a terminal emulator, which means that any bash instances within it won't know they are in a virtual terminal and behave like a normal bash).
https://github.com/fish-shell/fish-shell/issues/825
http://ptspts.blogspot.com/2011/03/how-to-automatically-sync...
"Previously, a single % would pid-expand to either all
backgrounded jobs, or all jobs owned by your user. Now it
expands to the last job backgrounded. If no job is in the
background, it will fail to expand. In particular, fg %
can be used to put the most recent background job in the
foreground."
oh! Can fish background tasks now? I haven't being following very closely, I really should update my shell.There's now a guarantee that `%` expands to either the last process backgrounded or an error.
The thing I appreciate most about fish is the clever suggestions from my shell history - the simplest things can be the biggest time-savers when it comes to entering obscure commands a few weeks apart (I don't have to look them up each time I do it now)
The only problem I had was getting all vim plugins to work with it, but then I discovered that you can set the shell vim shall use in .vimrc (I set it to sh) and now everything works like a charm.
BTW, I'm loving the fuzzy autocompletion, it's truly a "killing feature".
The main thing that I disliked is that all web resources give you scripts and advice for bash/sh; I have routinely launched bash to use them, but every time I felt like I'm going to a handicapped version of console.
function sudo!!
eval sudo $history[1]
end
is pretty close.> http://fishshell.com/docs/current/faq.html#faq-history
> Alt+Up recalls individual arguments, starting from the last argument in the last line executed. ...
I was really missing history substitution in fish, but now I like this even better.
[1]: http://ridiculousfish.com/shell/user_doc/html/design.html#co...
bind: Key with name 'dc' does not have any mapping
bind: Key with name 'ppage' does not have any mapping
bind: Key with name 'npage' does not have any mapping
Does anybody have any idea what causes this / how to fix it?Edit: I can confirm that changing $TERM to "xterm-256color" removes the issue.
http://hackercodex.com/guide/install-fish-shell-mac-ubuntu/
I'll soon have it updated for fish 2.1.0, Mavericks, and the new PPA locations.
[1] http://fishshell.com/files/2.1.0/linux/index.html#dl-ubuntu1...
Upside is I know bash ins and outs :). I'm usually the one-liner wizard of the office.
If you want to be more precise, typing anything in the current argument before pressing the shortcut will do a substring search.
brew update
brew upgrade fish
I'm not sure how it'll work if you initially installed it via a different method. I believe the standalone package installs into /usr/local, just like homebrew, so maybe installing via homebrew will just update it out of the box?