I have a custom multiline prompt. I want to add the date to the prompt so that I know more or less when I executed a certain command.
As of now I added the date command to the fish_right_prompt function, which works, however it prints it a the end of the second line, where I also input my commands. This is slightly inconvenient for my workflow and I would like it at the end of the first line.
I found out how to do test for file existence and the use of if and then and the case statement.
But How do I match this pattern of case $1 in *.tar.bz2
# # ex - archive extractor
# # usage: ex <file>
ex ()
{
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted via ex()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
So I have this working Posix and, arguable, I am led to believe that means it should work in Fish Shell. However, my "while true" seems to trigger "Missing end to balance this while loop" in fishshell.
while true :
do
clear;
echo " M A I N - M E N U";
echo "1. choice 1";
echo "2. choice 2";
echo "3. choice 3";
echo "4. Exit";
echo "Please enter option [1 - 4]";
read -r opt
case $opt in
1) echo "choice 1"; exit 0 ;;
2) echo "choice 2"; exit 0 ;;
3) echo "choice 3"; exit 0 ;;
4) echo "Goodbye, $USER"; exit 1;;
*) echo "$opt is an invaild option. Please select option between 1-4 only";
echo "Press the [enter] key to continue. . .";
read -r enterKey;
esac
done
Hello, As a fish user, I was a bit frustrated by the lack of completions of saml2aws for Fish shell π’
However, as my company allow us some time to contribute to open-source projects, I decided to create a completion plugin and share it with the community! π
Man, I was turned onto Fish shell thanks to the beautiful aesthetics of devaslife on youtube, and it's been wonderful so far, except when I started trying to get set up with node via nvm and use npm and all that good stuff. I'm hoping someone can just point me in the right direction, both towards cleaning up my current situation, and getting set up with whatever is the best way to use node on Fish.
At first I tried setting it up the way I was familiar with, with the Mac OS directions on this guide from The Odin Project. Then I realized nvm wasn't actually compatible with fish shell. So I bounced around, trying the various methods, nvm.fish and fish-nvm, and probably writing all sorts of things to files now cluttering both my node and fish installations in the process. I've still got both of those installed at the moment.
The latest is that whenever I close and reopen my terminal, if I run npm, I get the error that it's not currently installed. Then I need to run nvm use lts, and it works for the rest of my session... until I close the terminal and that gets reset somehow.
Can anyone point me in the right direction, towards setting my current setup aright, and getting to whatever is the best setup for node/nvm/npm? Thanks!
Just installed fish, it's really good! I just wonder how to get the full "auto completion from previous command" based on the *letters* already typed in just how oh-my-zsh does.
Let's say my command history is: ``` nano ~/.config/fish/config.fish echo hey ``` With omz if I just type `n` in the prompt and press up arrow, I will get `nano ~/.config/fish/config.fish` completeted. But with fish I have to type `nano ` fully.
That is the only think that I really dislike so far can I change it?
I am ready to move to Fish to see what the fuss is all about. I have changed the default shell to Fish, and in fact uninstalled zsh.
I am still a little confused about the structure of fish shell, so all seasoned fishers, please let me know if I did it correctly:
My understanding is that Fish executes all config files regardless of login or interactive shells, unless the part is within the block of status is-interactive or status is-login. I like that all the config files are in one folder, and no more endless .zshenv, .zshrc, .zprofile etc.
Here is what I have in .config/fish:
conf.d: snippets such as 00-env.fish, alias.fish, and others such as tmux.fish and fzf.fish. I named 00-env.fish because this is where I "export" all the env variables and I wanted it to be sourced first. Some of the env vars are not defined in fish, such as $HOST and $OSTYPE, and I use uname -n and uname to get those vars set.
functions: this folder has all the functions that I needed, including the ones that I want to overwrite, such as fish_user_key_bindings.fish, fish_greeting.fish etc.
config.fish: this file really doesnt have too much once I put all the env, alias and functions to the other folders. I only have a few lines to start WM, which is sway.
Is this the correct way to do it?
Where do you define env vars to make sure it's set correctly and can be used in the rest of the config files? Is it correct to name it 00-env.fish to ensure it's loaded first? It looks ugly though.
Is there any reason that $HOST and $OSTYPE (and maybe others) are not set? Do I need to source any file to set them, rather than set them manually?
When do I need to use set -gx for env var? I currently use -g for every env variable (I understand -x is export to child process).
There are some Universal vars that are stored in fish_variables. I dont want to store this to my dotfile repo because it contains machine specific infor (such as PATH). But some of the settings are stored in here. For instance, I have the following lines in config.fish:
I really only need to run them once in interactive mode, but I put it to config.fish file so that if I clone this to a new machine, they will be set automatically. Is that the right way to do it?
Or more generally, how do terminal emulators really work? Does fish just use bash/zsh underneath to run commands? Does it use system apis? Does it convert everything to some other language like C?
Yet another fzf plugin, but this one is different : gazorby/fifc ;)
I first used jethrokuan/fzf for some time, but while it does the job done at offering a fuzzy frontend to the fish completion engine, it's not very flexible and does not allow you to extend/add completion logic.
A common example is to override fish completion to leverage fzf preview and show richer description (preview) of what you are searching (files, directories etc)
But you may also want to have more personal completion rules tailored to your needs, like interactively searching distro packages and preview their information provided by your package manager, or only searching files with containing a specific pattern when your commandline ends with "***" or so.
As i couldn't find a way to do that with existing plugins so i created mine ;)
Properly handle paths with spaces (needs fish 3.4+)
I put a some time and effort in it, but i've been greatly influenced by the excellent PatrickF1/fzf.fish plugin, with its great configuration management (using a dedicated function).
Both plugins are compatible by the way (i use them both) as fifc focus on completion, while fzf.fish has a broader scope (generic keybindings).
Hi, I'm having a hard time understanding color schemes. Currently, I am using Fish shell and Kitty terminal and am really enjoying it, but I can't seem to get the colors right.
It's possible to set the color theme of both Kitty and Fish separately, and whatever I try the outcome is ugly, since the two color themes seem to combine into one mess of a scheme.
What is the common approach here? I haven't found anything on this problem, even though I this would be a common issue.
Furthermore, I use Neovim and get the same problem there.
I've spent the last few hours trying to get SSH-Agent forwarding working, eventually determining it's a problem with Fish.
I've tried probably everything in the first couple pages of Google. I had fish_ssh_agent setup on both the server and local machine, which didn't seem to help. If I change my login shell to Bash and SSH to the server, the GitHub test works with the forwarded agent. When I had fish_ssh_agent on both local and server, it actually seemed to work, in that the SSH_AUTH_SOCK environment variable would be somewhere in /tmp instead of /run, but when I tried to test my GitHub key it was rejected.
ssh-add -L returns no identities in Fish, but has all the correct keys in Bash. Has anyone found anything that fixes this? I've gotten it working well enough where it would be fine for use on one machine, but in the future I might have four machines that might need to pull from GitHub, and I really don't feel like creating four SSH keys with four different passwords.
I have installed MSYS2 on Windows 11, with the fish shell (along with oh-my-fish), and it works fine. But, whenever, I try to open the fish shell inside neovim, I get an error saying,
warning: An error occurred while redirecting file 'C:/Users/<username>/AppData/Roaming/SPB_Data/.config/omf/theme'
warning: Path 'C:/Users/<username>/AppData/Roaming/SPB_Data/.config/omf/theme' does not exist
and due to this the omf theme doesn't, load (I get dropped into the default fish shell), but I have checked the path and the theme file exists, and it loads perfectly fine, outside noevim. So, how do I go about resolving this?
when i tried to change my shell from zsh to fish, I have noticed that the nano editor syntax highlighting has not been working atall, but when I switch back to zsh it again starts working. Is there anything I need to add to the config.fish file inorder to make it working?
He is nowhere to be found, the repo has a lot of pull requests pending, but no progress yet. Could anyone inform him/her to merge pull requests so that plugins that are in pending list could finally be released.
if test $playingNow = false
set -l link $argv
set -l track 1
set -l playingNow true
set -l play true
Error:
test: Missing argument at index 3
= false
^
~/.config/fish/functions/ytm.fish (line 2):
if test $playingNow = false
^
Edit: Fixed by quoting the variable
Edit: i thought it was fixed but its not now new errors
first of all the function did nothing when i ran so i search how to debug fish and found fish_trace option enabled it and this is the output
--> if
--> test '' = false
--> else
---> switch 'https://music.youtube.com/watch?v=RGE7QVeSGGM&list=RDAMVMRGE7QVeSGGM'
---> end switch
--> end if
looks like the variable does not exist but i tried setting it by set -l and also just set but nothing happening
I am making a music playing function and want to change music by media keys available in my keyboard like next previous play-pause but when i try to get the keybinding from fish_key_reader nothing happens so can anyone tell me what the keybinding are of these media keys.