Here Fishy, Fishy...
Friday, Jan 24, 2014
Intro
I'm not a huge vim person... yet. I like IDEs, usually... (I'm looking at you Visual Studio). Therefore I'll only really use a shell for cycript or other random ssh sessions and hax and such.
However, fish is making the shell fun.
What the fish?
So what is fish anyways? While it sounds like the result of preparations of a sushi plate, it's this really awesome shell replacement. Bash, zsh, tcsh (ew), they're all shells that we can use with a terminal to control the operating system or run a bunch of programs without the need for a mouse.
tl;dr: They're what Hollywood uses to make someone look like a "hacker".
Anyways, fish does all that and more. You get ALL the colours with term256 support (it looks nice). You also get auto-completion, which is awesome.
Did I mention it likes emoji? Yeah! Sheep Shell! (or baaaaaaash if you're @stroughtonsmith)!
## git... add? commit? push? --force push? Fish shell does this crazy magical thing, that parses man documents to give you possible auto-completions for whatever you're typing in.
ls -? yep.
ps -? yep.
ssh -? yep.
Look (git):
Simply type in a command and hit tab (as you normally would in most shells to auto-complete directories and such). It also auto-suggests previous commands that you've used in the past so:
history | grep git
// OH RIGHT I REMEMBER
git --force push
becomes:
git --force push <CTRL+F>
It's super simple, and looks great too. To accept a completion, simply hit CTRL+F (which I assume you can change if you really want to, I haven't bothered).
You can add to this as well, such as bpinto's oh my fish (which I highly recommend).
In addition, it auto-completes directories and it tells you if a directory path is valid or not (with colours!):
## script.fish Scripting in fish is actually quite easy. It doesn't like a lot of bash's syntax, but it's super simple to pick-up. Here's a quick primer:
#!/bin/bash
export hey="sup yo"
alias ls="say l s"
whereami () {
echo `pwd`
}
#!/usr/local/bin/fish
set -x hey "sup yo"
alias ls "say l s"
function whereami()
echo (pwd)
end
Basically replace
with ( ) and remove some square brackets. It's well documented too, so be sure to check that out. Also, if you still want to use scripts from other shells, just use a hashbang (#!/bin/sh) and it'll work as expected. You can write scripts and save them as functions to call at your leisure, just write the script and stick it in:
~/.config/fish/functions/
Also, functions are super quick to write and save in the shell:
00:21 adam > function whereami
echo (pwd)
end
00:21 adam > funcsave whereami
00:21 adam > whereami
/Users/Adam
In addition, you can find your equivalent of a .bashrc / .bash_profile in:
~/.config/fish/config.fish
From there you can edit your greeting and prompt or add other environment variables:
#!/usr/local/bin/fish
function fish_greeting
echo The time is currently (date).
end
set -x PATH /usr/local/bin $PATH
function fish_prompt
printf "%s\n%s >" (pwd) (whoami)
end
sushi
Fish is great, and it's fun to change things up!
Do I recommend it? Sure!
Do I not recommend it? Sure!
Only way to know if you'll like it is to try it (if you do launch it from another shell, sometimes it screws up text input). Speaking of trying things, I've also done this (bye nano :( ):
function nano
vim $argv
end