Skip to content

Instantly share code, notes, and snippets.

@codemilan
Forked from idleberg/fish_shell.md
Created August 7, 2018 04:42
Show Gist options
  • Select an option

  • Save codemilan/336f50d745f9bb8d1ceae29fa6d84aa1 to your computer and use it in GitHub Desktop.

Select an option

Save codemilan/336f50d745f9bb8d1ceae29fa6d84aa1 to your computer and use it in GitHub Desktop.
Instructions on how to install Fish shell on Mac OS X, including Oh My Fish!. Also includes several useful functions.

Installation

  1. Install fish via Brew
  2. Optionally install Oh My Fish!
  3. Add fish to known shells
  4. Set default shell to fish
brew install fish  
curl -L https://github.com/bpinto/oh-my-fish/raw/master/tools/install.fish | fish
sudo echo /usr/local/bin/fish >> /etc/shells
chsh -s /usr/local/bin/fish

Functions

Add any the following functions to ~/.config/fish/config.fish

sudo bang bang

Repeat previous command with administrator rights

function sudo
    if test "$argv" = !!
        eval command sudo $history[1]
    else
        command sudo $argv
    end
end

cd..

How often did you type cd.. instead of cd ..?

function cd..
    cd ..
end

git tag

Simplify the creation and deletion of Git tags

function tag
	if test $argv[1] = "-d"
		# delete tag if provided
		if test $argv[2]
			eval command git tag -d $argv[2]
			command git push origin :refs/tags/$argv[2]
		end
	else
		# create new tag and push
    	eval command git tag -a $argv[1] -m $argv[1]
    	command git push --tags
    end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment