Comments (4)
function --inherit-variable file
, see the docs.
Have you tried just adding this directory to $PATH instead? (I would then also recommend not using the fish function directory for this)
from fish-shell.
I wanted to use POSIX shell scripts for all of my personal scripts (that I'd previously held in the functions folder) without .sh being part of the name (though I realize that extension is not strictly necessary).
I know this isn't a usual choice, but I'm in an unusual position of wanting to continue using fish as my daily interactive shell and switch to POSIX scripts for everything (because I've had a much better time of it than with fish scripts).
from fish-shell.
I think you were anticipating a response I didn't give.
Let me try to expand on my answer.
Your immediate problem here is that you need to include $file now, when the function is defined. $argv will be filled in when you call it, but when you call it the value of $file will no longer exist (and even if it does, $file was a local variable and so the function would not have access to it anyway).
That's what --inherit-variable does - function $funcname --inherit-variable file
will add a snapshot of $file to the function when it is defined.
This would generally work, but this dance is also just kind of pointless.
The way of least resistance is to just move your scripts to a directory, call them whatever you want, make them executable, add a shebang and then add that directory to $PATH.
E.g. move them to ~/bin and run fish_add_path ~/bin
(once interactively is usually enough). And then simply don't define these as functions at all.
Importantly, these approaches will both share a rather big limitation: These run in dash (or bash, or whatever), and so any changes they make to the environment won't take inside fish.
When you change a variable or cd
in a script like this, that affects the process running it, which won't be fish.
But making them a function doesn't magically change that.
from fish-shell.
Yeah, I was hoping for the second half that; you'd said enough to get across the first part. And yes, I am aware environment things won't affect fish (and I was going to account for that if necessary, but really I usually don't want them to). I was hoping for your response based on why I said I was doing this in case you had insight for me, so thank you.
After thinking on it, I'm probably going to go with my original idea so I can keep my .sh and .fish scripts together (the shell prompt really should be fish).
from fish-shell.
Related Issues (20)
- Add an easy way to retry a command until it succeeds HOT 1
- Undenied permission with brew? HOT 8
- Fish git prompt doesn't show (U)pdated but (U)nmerged changes HOT 2
- No $status even though it's reported it exists HOT 2
- fish_history corrupted with NUL bytes HOT 1
- Oh, I have to pass the argument with quotes, I see. But this one is not working for me HOT 1
- fish_variables has too large size make fish has a significant delays during startup HOT 1
- Different descriptions of Universal variables in the documentation HOT 1
- Transient prompt doesn't work on recent git master builds
- Terminal protocols spew a *lot* of output
- Android install tutorial in README.md HOT 1
- Alias escaping HOT 1
- Feat: In commands such as `edit_command_buffer` set an environment variable to let the editor config setup custom behaviour HOT 3
- Paging command output as if it was written to a terminal HOT 2
- fish became slow because checking two tools HOT 7
- Not able to `ctrl+c` out of `fzf`
- fish hangs in futex() during start in VS Codeβs integrated terminal HOT 8
- Flatpak completions include the author of the application preceded by a bunch of spaces HOT 4
- completions/git: Handle git restore for unmerged file better
- Confusing "highlighting" when path argument contains >1 `**`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fish-shell.