markdown 有关如何在Mac OS X上安装Fish shell的说明,包括Oh My Fish!。还包括几个有用的功能。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown 有关如何在Mac OS X上安装Fish shell的说明,包括Oh My Fish!。还包括几个有用的功能。相关的知识,希望对你有一定的参考价值。

# Installation

1. Install [fish](http://fishshell.com/) via [Brew](http://brew.sh/)
2. Optionally install [Oh My Fish!](https://github.com/oh-my-fish/oh-my-fish) 
3. Add fish to known shells
4. Set default shell to fish

```bash
brew install fish  
curl -L https://get.oh-my.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..

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
```

以上是关于markdown 有关如何在Mac OS X上安装Fish shell的说明,包括Oh My Fish!。还包括几个有用的功能。的主要内容,如果未能解决你的问题,请参考以下文章

markdown 在Mac OS X上安装Go

markdown 如何为Mac OS X创建“DMG安装程序”

markdown 在MAC OS X上显示和隐藏文件和文件夹

如何在Mac OS X上安装 Ruby运行环境

如何在Mac OS X上安装 Ruby运行环境

markdown Ruby on Rails的安装环境(Mac OS X 10.9或更高版本)