Skip to content

Instantly share code, notes, and snippets.

@Valexr
Forked from idleberg/fish_shell.md
Created July 18, 2022 17:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Valexr/280183d7f56c042a52ed0ea73b291f68 to your computer and use it in GitHub Desktop.
Save Valexr/280183d7f56c042a52ed0ea73b291f68 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://get.oh-my.fish | fish
sudo bash -c '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..

Shortcut to browse parent directory

function ..
    cd ..
end

And how often did you ever type cd.. instead of cd ..? Let's extend our previous function:

function cd..
    cd ..
end

dropbox

Quickly access your DropBox folder

function db
	set user $HOME
    cd "$HOME/Dropbox"
end

docs

Quickly access your documents folder

function docs    
	switch (uname -s)
    case Darwin Linux FreeBSD NetBSD DragonFly
		set documents $HOME/Documents
	case '*'
		set cygwin (eval uname -o)  
    		if test $cygwin = "Cygwin"
    			set documents (eval cygpath -O)
    		end    
    		return
    	end    
    	cd $documents
    end
end

os

Return platform name

function os
    switch (uname -s)
    case Darwin Linux FreeBSD NetBSD DragonFly
        eval command uname -s
    case "*"
        switch (uname -s)
        case Cygwin
            eval command uname -s
        case "*"
            eval echo "undefined"
        end
    end
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
@Valexr
Copy link
Author

Valexr commented Jul 18, 2022

# This file contains fish universal variable definitions.
# VERSION: 3.0
SETUVAR __fish_initialized:3400
SETUVAR fish_color_autosuggestion:555\x1ebrblack
SETUVAR fish_color_cancel:\x2dr
SETUVAR fish_color_command:005fd7
SETUVAR fish_color_comment:990000
SETUVAR fish_color_cwd:green
SETUVAR fish_color_cwd_root:red
SETUVAR fish_color_end:009900
SETUVAR fish_color_error:ff0000
SETUVAR fish_color_escape:00a6b2
SETUVAR fish_color_history_current:\x2d\x2dbold
SETUVAR fish_color_host:normal
SETUVAR fish_color_host_remote:yellow
SETUVAR fish_color_normal:normal
SETUVAR fish_color_operator:00a6b2
SETUVAR fish_color_param:00afff
SETUVAR fish_color_quote:999900
SETUVAR fish_color_redirection:00afff
SETUVAR fish_color_search_match:bryellow\x1e\x2d\x2dbackground\x3dbrblack
SETUVAR fish_color_selection:white\x1e\x2d\x2dbold\x1e\x2d\x2dbackground\x3dbrblack
SETUVAR fish_color_status:red
SETUVAR fish_color_user:brgreen
SETUVAR fish_color_valid_path:\x2d\x2dunderline
SETUVAR fish_key_bindings:fish_default_key_bindings
SETUVAR fish_pager_color_completion:\x1d
SETUVAR fish_pager_color_description:B3A06D\x1eyellow
SETUVAR fish_pager_color_prefix:normal\x1e\x2d\x2dbold\x1e\x2d\x2dunderline
SETUVAR fish_pager_color_progress:brwhite\x1e\x2d\x2dbackground\x3dcyan
SETUVAR fish_pager_color_selected_background:\x2dr
SETUVAR fish_user_paths:/opt/homebrew/sbin\x1e/opt/homebrew/bin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment