---
title: "Append path to $PATH in fish shell on mac & linux"
author: "kaqi"
date: "2016-11-01T18:11:07Z"
tags: []
categories: ["操作系统"]
slug: "append-path-to-path-in-fish-shell-on-mac-linux"
draft: false
lastmod: "2017-03-08T17:23:36Z"
id: 2334721
url: "https://kaqi.iteye.com/blog/2334721"
---

The best way I have found to **persistently add a path to your `$PATH`**  is

 

```
set-U fish_user_paths $fish_user_paths ~/path/name
```

 

This *prepends* to `$PATH`. And since it's persistent, the path stays in `$PATH` on shell restarts.

It's more efficient than putting a command in your `config.fish` to modify your `$PATH`, because it only runs once compared to running on every shell restart.

The variable [`fish_user_paths` is intended to be set by the user](https://github.com/fish-shell/fish-shell/issues/527#issuecomment-13811988)1, as stated by [ridiculousfish](http://stackoverflow.com/users/1441328/ridiculous-fish), the maintainer of fish.

 

Option 2:

Add the line below to the file ~/.config/fish/config.fish:

```
set PATH $HOME/MAVProxy $PATH
```