Fish

From NixOS Wiki
Revision as of 17:26, 30 June 2017 by imported>Fadenb (Created page with "Fish is the [http://fishshell.com/ Friendly Interactive SHell]. At the moment it’s not possible to use fish as login shell. But you can always start it as default shell of...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Fish is the Friendly Interactive SHell.

At the moment it’s not possible to use fish as login shell. But you can always start it as default shell of your terminal emulator.

Useful scripts

Show that you are in a nix-shell

Add this to fish/fish_prompt.fish:

 set -l nix_shell_info (
   if test "$IN_NIX_SHELL" = "1"
     echo -n "<nix-shell> "
   end
 )

and $nix_shell_info to the echo in that function, e.g.:

echo -n -s "$nix_shell_info ~>"

Now your prompt looks like this

  • outside: ~>
  • inside: <nix-shell> ~>

btw. you can directly start nix-shell in fish with nix-shell --run fish, but (FIXME) the normal build functions are not available there.

Environments

Helper functions that put you in a nix-shell with the given packages installed.

haskellEnv

function haskellEnv
	nix-shell -p "haskellPackages.ghcWithPackages (pkgs: with pkgs; [ $argv ])"
end

# Invocation: haskellEnv package1 packages2 .. packageN

pythonEnv

function pythonEnv --description 'start a nix-shell with the given python packages' --argument pythonVersion
	if set -q argv[2]
    set argv $argv[2..-1]
  end

	for el in $argv
    set ppkgs $ppkgs "python"$pythonVersion"Packages.$el"
  end

	nix-shell -p $ppkgs
end

# Invocation: pythonEnv 3 package1 package2 .. packageN
# or:         pythonEnv 2 ..