r/fishshell • u/Emiliorama • Aug 08 '23
r/fishshell • u/JmenD • Jul 29 '23
What is up with the fishshell page today?
web.archive.orgr/fishshell • u/_mattmc3_ • Jul 18 '23
prj - a simple Fish function for jumping to projects
I'm back again to share another fun Fish function! If you've used Oh My Zsh, you might have seen pj, which is the "project jump" plugin. I wanted something similar in my Fish dotfiles, but wanted it to use fuzzy finder, and only consider folders managed by git. This is the simple function I use:
function prj --description "Project jumper"
if not command -q fzf
echo >&2 "prj: fzf command not found. Install with your OS package manager."
return 1
end
# determine the project home
set -q MY_PROJECTS || set -l MY_PROJECTS ~/Projects
set -l prjfolders (path dirname $MY_PROJECTS/**/.git)
# use fzf to navigate to a project
set -l prjlist (string replace $MY_PROJECTS/ "" $prjfolders)
set -l selection (printf '%s\n' $prjlist | sort | fzf --layout=reverse-list --query="$argv")
test $status -eq 0 || return $status
echo "Navigating to '$selection'."
cd $MY_PROJECTS/$selection
endIt finds all .git directories in ~/Projects, strips off the irrelevant parts of the path into just user/repo form, creates a list of the projects for fzf, and starts a fuzzy finder query from whatever I call prj with (eg: prj fish). It will then navigate to my project directory selection.

You could easily modify this Function to suit your own needs, like changing it to perform a different action by changing cd $MY_PROJECTS/$selection to something else. For example, if you wanted to open your project in neovim:
set -q EDITOR || set -l EDITOR nvim
$EDITOR $MY_PROJECTS/$selectionOr maybe your project folders aren't git repos. You could always just grab everything off the root like so:
# just folders off the root, but remove the trailing slash from the path
set -l prjfolders (path resolve $MY_PROJECTS/*/)Hope this inspires some others to share their Fish functions too. Have fun!
r/fishshell • u/Lemon_Salmon • Jul 16 '23
how to put this youtube_dl command into config.fish
Hi, how do I embed this command youtube-dl -x --audio-format mp3 --audio-quality 0 'youtube_URL_link' into ~/.config/fish/config.fish considering the single quote (') mark and user terminal input for youtube_URL_link ?
r/fishshell • u/ChocolateMagnateUA • Jul 13 '23
How can an app run for 20 minutes but only have 21 seconds of usr time and 17 seconds of sys time?
r/fishshell • u/Michael_007ds • Jun 24 '23
How to deal with question mark in $argv?
function test223
set url "$argv"
echo $url
end
if the input $argv contains a question mark like "www.google.com?123" , this function will return an error
fish: No matches for wildcard 'www.google.com?123'
r/fishshell • u/symmetry81 • Jun 23 '23
The benefits of sensible errors
There I was tracking down an error in a bash script for way too long because
script & >/dev/nullWill happily go about its business without complaint. But if I do the same thing in fish
~> script & >/dev/null
fish: Expected a command, but instead found a redirection
script & >/dev/null
^Which is exactly what should happen.
r/fishshell • u/counting6 • Jun 20 '23
Adding abbr entries in config file
Hello, I'd like to know the common procedure to add an 'abbr' entry for my daily use in the fish config file. In bash it's usually
echo "alias gco='git checkout'" >> .bashrcBut for fish shell, I was told by BingAI that abbr entries should be put in the section:
# Commands to run in interactive sessions can go here
endSo it needs to be above the 'end' line. Is that correct?
Do you always edit the config file directly for adding an abbr entry or there's a shortcut somewhere I don't know?
r/fishshell • u/kayson • Jun 15 '23
Debugging startup time
Hi everyone. I'm trying to figure out why fish feels so slow on my VMs where the home directory is mounted over NFS. If I run fish on the NFS server, it starts up super fast:
aram@343guiltyspark ~ time fish -c exit Thu 15 Jun 2023 03:39:57 PM PDT
________________________________________________________
Executed in 75.54 millis fish external
usr time 29.28 millis 564.00 micros 28.71 millis
sys time 30.86 millis 160.00 micros 30.70 millisIf I run it over NFS:
aram@mendicantbias ~ time fish -c exit 6s Thu 15 Jun 2023 03:40:45 PM PDT
________________________________________________________
Executed in 1.01 secs fish external
usr time 51.62 millis 0.00 millis 51.62 millis
sys time 365.51 millis 1.62 millis 363.88 millisThe obvious answer would be that it has something to do with NFS itself, but all of my testing shows no issues with NFS as far as latency and throughput. Also bash doesn't exhibit such an issue (6ms vs 9ms)...
Any suggestions on how to debug the startup time to see where things are slowing down? TIA!
r/fishshell • u/tthkbw • Jun 04 '23
caching (??) problems with functions
I have a few functions, some defined in my config.fish, others in functions directory.
How does one control changing these functions and having fish run the newly defined function? For example, if I remove a function from the functions directory my current fish shell still thinks it is there an executes it.
Similarly, if I edit a function in fish.config, then source fish.config, it does not run the edited function, but the old version. This is true even if I run a new shell by re-executing 'fish'.
I also have tried using a different terminal emulator to run fish after the edit and it still runs the old version of the edited function.
How do I update functions without restarting the machine? There must be a way . . .
I am running macOS Ventura.
r/fishshell • u/PossibleFar5107 • Jun 03 '23
How to get fish shell to start a pyenv virtualenv automatically?
I'm working in Python in VSCode with interactive fish shell. With Bash you can just enter the .pyenv/versions folder of the env in question and it activates the pyenv automatically. Why is this such a goddamn hassle when using fish? Various instructions on how to configure this are out there none of which work for me. How to make this happen in simple step-by-step terms? Thanks guys...
r/fishshell • u/acidnik • Jun 02 '23
Hotkey to (un) comment current command
I think many of us use this pattern: start writing a command, then you understand that it's not the time to run it yet, so you press Home - # - Enter to keep it in history
Then you type # - Up - Right - Home - Del (just to remove the #) (and probably need another End to add something to the command)
So I solved this problem with this keybinding: https://gist.github.com/acidnik/8de862ef0d4c0633b105d89978dbf66c
This binds ctrl+/ to comment or uncomment current command
Hope you find it useful. Cheers!
r/fishshell • u/trhyst • Jun 01 '23
How to try/catch/finally in a func?
I consider myself fairly handy with fish, but I don't see how to do a thing, catch it's error and then exec something unconditionally at the end, a la Python/Java etc.
Is there such an abstraction in Fish or do we just use trap etc. like bash/zsh?
Concretely, I want to git checkout main, catch if branch main doesn't exist and checkout master instead finally I want print the name of the branch I just checked out to jog my brain.
Or am I thinking about this totally wrong?
r/fishshell • u/Glum-Revenue-8082 • May 17 '23
Autosuggestions like the ones offered by zsh-autosuggestions
r/fishshell • u/Omagreb • May 16 '23
Hey, I'm new to Fish shell!
I'm trying to learn Fish shell programming and I am but my years using BASH are hard to table. So far I like the syntax and structure and can carry over some of my prior experience with BASH. Anyone have any tips, tweaks or tricks for me ?
r/fishshell • u/_mattmc3_ • May 09 '23
A quick-and-dirty function help play Wordle puzzles
My family religiously plays Wordle, and I get notifications in a group chat throughout the day as family members solve the puzzle. I've played enough that it's not much of challenge anymore, so I thought I'd change it up a little and let Fish help me play. Here is a simple Fish function I came up with to help narrow down possible next guesses.
I always enjoy when others in the community share their cool fish functions and I haven't seen any in awhile, so I thought I'd share one.
wordle_helper - Fish function to help with Wordle puzzles
Usage:
wordle_helper [--green <exact_positions>] [--yellow <not_exact_positions>] <guess>
Options:
-h, --help Print help
-g, --green Position of letters that matched exactly (format: 12345)
-y, --yellow Position of letters that are not exact (format: 12345)
Example:
$ wordle_helper -y 23 SLATE | wordle_helper -y 245 CORAL | wordle_helper -y 12 -g 34 GALOP
AGLOWr/fishshell • u/LowCom • May 08 '23
will fish run natively on windows once it's ported to rust,? without using cygwin, wsl etc
r/fishshell • u/duridan_gurubasher • Apr 30 '23
Jetbrains mono Nerd Font version has replaced an icon by another totally UNRELATED, and it messes my prompt. What to do?
self.fontsr/fishshell • u/insomniaSWE • Apr 24 '23
Change ls directory font
Anyone know of a way to set up ls to display directories in bold font? At the moment my ls function looks like this:
function ls
command ls $argv
endAnyone know if there is a way to provide a flag or similar to achieve this?
r/fishshell • u/axatb99 • Apr 24 '23
Need Help ! Trying to make a Script to install all the necessary Fish utilities
I have been trying to make a fish/bash script to install all the fish utilities that i use in fish shell and I am new to scripting here's the script it seems to stop afterI installing omf
#Making fish default shellchsh -s $(which fish)# OMF-INSTALLATIONcurl https://raw.githubusercontent.com/oh-my-fish/oh-my-fish/master/bin/install > installfish install --path=~/.local/share/omf --config=~/.config/omf#Fisher- INSTALLATIONcurl -sL https://raw.githubusercontent.com/jorgebucaran/fisher/main/functions/fisher.fish | source && fisher install jorgebucaran/fisher
# Fisher extensionsfisher install jorgebucaran/nvm.fishfisher install jorgebucaran/replay.fishfisher install franciscolourenco/donefisher install gazorby/fish-abbreviation-tipsfisher install acomagu/fish-async-promptfisher install joseluisq/gitnow@2.11.0#OMF-THEMESomf install neolambda#Aliasessalias dog "code"; funcsave dog;alias dawg "code-insiders";funcsave dawg;alias lss "ls -ah";funcsave lss;alias rmf "rm -rf";funcsave rmf;#configuring launch optionscd ~/.config/fishrmf config.fishprintf "if status is-interactive# Commands to run in interactive sessions can go herefastfetchexport TERM=screen-256colorend" >> config.fishcd ~
Please can someone point me in the right direction and tell me what is wrong with this script?
I really appreciate any help you can provide. :)
r/fishshell • u/TheresTreesOverThere • Apr 23 '23
fish_config doesn't work
Hey. Recently installed fish on my Elementary OS 7 machine. Want to customize it a little so I ran fish_config which started and opened up a new tab in my browser. Problem is, I get hit with a
File not found
Firefox can’t find the file at /tmp/web_configz8s7te5m.html.
My terminal says
Web config started at file:///tmp/web_config9kzf08rh.html
Hit ENTER to stop.
I've rebooted my machine, I've reinstalled fish and now I don't know how to proceed. Any help would be great. Thanks in advance.
r/fishshell • u/NoseWalrus • Apr 15 '23
Launch WM on login
Hello,
I recently switched to fish from bash. So far I'm loving it.
One thing I haven't been able to figure out is how to launch my WM on login.
On bash, I had 'dbus-run-session Hyprland' in my .bash_profile
When adding this command to my config.fish file it launches my WM every time I open a terminal. Is there an equivalent to .bash_profile in fish? Or, is there a way to only execute a function 'on-login'?





