64
votes
How to remove a path from $PATH variable in fish?
The 'fish' way of setting the $PATH variable is to actually use set --universal fish_user_paths $fish_user_paths /new/path/here. Then $fish_user_paths is actually prepended to the $PATH variable when ...
39
votes
Accepted
How to keep terminal window title in sync with tmux window
First thing to point out is that you can do this via tmux completely independent of your shell. Add the following to your ~/.tmux.conf; for example:
set-option -g set-titles on
set-option -g set-...
36
votes
Accepted
Is there a way to "source" a sh script from the fish shell?
For sourcing a general sh script in fish, one option is the bass plugin, which can source a bash script's environment variables into fish.
If you have fisherman, you can install it with fisher install ...
34
votes
re-use '~/.profile` for Fish?
For a much cleaner solution, you can use the foreign env plugin:
fenv source ~/.profile
27
votes
Is there any way to get bash to have syntax highlighting like fish?
There is no simple way to obtain syntax highlighting in GNU Bash (or GNU Readline), but it is in principle possible to implement your own line editor in Bash script by binding all the user inputs to ...
25
votes
How to remove a path from $PATH variable in fish?
As Elijah says, best practice is to modify the fish_user_paths rather than the global PATH. To avoid ever having to Google this again…
Create a couple of functions that only modify fish_user_paths
...
19
votes
Accepted
chain Fish commands via `&&` or `||`
The logical operators you're used to, are supported since fish 3.0.0, released on 2018-12-28.
From the v3 release notes:
fish now supports && (like and), || (like or), and ! (like not), ...
15
votes
What is the equivalent of bash's !$ and !! in the fish shell?
For sudo !!
In fish shell (release 3.1b1 and later) you can use the binding __fish_prepend_sudo, which is Alt+S by default, to prepend the currently present command-line with sudo :
$ make sandwich▎
...
14
votes
Add abbreviations in fish config
Sorry, I'm not sure if I understand what you're asking. But if your question is how to set your abbr definitions on startup (and in a file that you can store in a repository and share between machines)...
12
votes
How do I change EDITOR to be Pico in fish shell?
This FAQ suggests adding set -gx EDITOR pico to ~/.config/fish/config.fish
12
votes
Accepted
Where does fish_config save its settings?
Some settings, such as the color theme, are stored as universal variables. Run set -U to see them.
Note that at the moment universal variables are stored in a file whose name is unique to each host. ...
10
votes
re-use '~/.profile` for Fish?
You can use bass, a plugin to execute bash commands in fish.
Install bass.
$ git clone https://github.com/edc/bass.git
$ cd bass
$ make install
And then, just put this in your config.fish:
bass ...
10
votes
Accepted
Reuse .bash_profile for Fish in Mac
Fish has exactly one user controlled config file which is named $HOME/.config/fish/config.fish by default. Fish also has an export command for compatibility with bash/zsh/sh but it just a thin wrapper ...
10
votes
how to run ssh-agent in fish shell?
There are two parts to your question:
Why do you get an error when attempting eval `ssh-agent -s` ?
How to enable ssh-agent in the Fish shell
For the first, the feature you are looking for is called ...
8
votes
Make bash as close to fish as possible
There are many options for configuring bash. I use the following commands to give easy command history access:-
bind '"\e[A": history-search-backward'
bind '"\e[B": history-search-forward'
These set ...
7
votes
Accepted
How to expand aliases in fish shell?
In fish the alias command just creates a trivial function. For example,
alias cmd 'cd ~/user'
Is simply shorthand for
function cmd
cd ~/user
end
Because it's a function in fish you can't expand ...
7
votes
Accepted
How to set a specific version of Java as JAVA_HOME in Fish in macOS
While I am not deeply familiar with Fish, based on what I am reading it seems like the issue is with the backticks in your command:
/usr/libexec/java_home -v 1.7
You see that is just like this in ...
6
votes
Is there a “reverse incremental search” functionality in Fish similar to Bash’s CTRL+R?
Now in fish shell 3.6.0
https://github.com/fish-shell/fish-shell/releases/tag/3.6.0
By default, Control-R now opens the command history in the pager
(#602). This is fully searchable and syntax-...
6
votes
What is the equivalent of bash's !$ and !! in the fish shell?
I had the same problem as you, and I fixed by using oh-my-fish
(it's a plugin manager for fish shell) https://github.com/oh-my-fish/oh-my-fish. You can install it with this command :
curl -L https:...
6
votes
How can I do string manipulation in fish shell
The fish shell now has a string builtin command.
To use string instead of sed in your case:
set branch (string replace 'ref: refs/heads/' '' <.git/HEAD)
It can operate on given arguments, or on ...
6
votes
Accepted
Difference between set -g and set -x
No, they do not all do the same thing. The -x flag is orthogonal to the -g, -l, and -u flags. The former simply sets the export attribute on the var. The latter three set the scope of the var. You can ...
6
votes
Accepted
How to combine the output of multiple commands in fish?
use a begin...end block
begin; cat a.txt; ls; end | another_command
or with whitespace
begin
cat a.txt
ls
end | another_command
6
votes
Accepted
Fish Shell - can't find where "la" is defined as "ls -la"
The type command is your friend for this type of question:
$ type la
la is a function with definition
# Defined in /usr/local/share/fish/functions/la.fish @ line 4
function la --description 'List ...
6
votes
Execute two or more commands simultaneously in shell script
The most basic approach is with &, this other answer is right. It also advocates nohup but nohup redirects stdin, stdout and stderr, something you may or may not want. Read Difference between ...
6
votes
how to run ssh-agent in fish shell?
I get this solution
run
eval (ssh-agent -c)
reference:https://wiki.archlinux.org/title/Fish#Evaluate_ssh-agent
5
votes
How do you "source" a file in fish?
Use the source command:
source filename.txt
source may not have existed originally but it exists now and the . alias in fish is officially deprecated.
From man . in fish 3.6.1:
. (a single period) ...
5
votes
Is there a “reverse incremental search” functionality in Fish similar to Bash’s CTRL+R?
Far better Ctrl+r reverse searches with FZF and fzf fish plugin, using the Triton fish package manager, configured to use The Silver Searcher.
~/.config/fish/config.fish:
triton jethrokuan/fzf
set -...
5
votes
Reuse .bash_profile for Fish in Mac
You can use this script by overtrue: [gist link]
It basically parses .bash_profile and sets the same environment variables in Fish.
Works great for me!
# Fish shell
egrep "^export " ~/.bash_profile ...
5
votes
Make bash as close to fish as possible
Regarding auto-completion, bash uses GNU Readline to provide tab-completion, and history lookup & completion. Tab completion works for command names, files, and — for any commands which have ...
5
votes
Accepted
What's the easiest way to prepend the current time to the fish prompt?
In ~/.config/fish/functions there is a file named fish_prompt.fish. Replace the line
echo -n (prompt_pwd)
with
echo -n (date +%H:%M) (prompt_pwd)
Result:
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
fish × 190shell × 69
bash × 35
linux × 29
macos × 25
command-line × 18
terminal × 17
iterm2 × 8
prompt × 8
ssh × 7
environment-variables × 7
path × 6
cygwin × 5
shell-script × 5
autocomplete × 5
ubuntu × 4
unix × 4
git × 4
windows-subsystem-for-linux × 4
tmux × 4
terminal.app × 4
keyboard-shortcuts × 3
python × 3
homebrew × 3
mac × 2