Comments (6)
I'm fairly sure that you don't need to change anything in broot for this. As you might be aware, shell doesn't have a strong distinction between one and multiple args. As far as I can see, broot just passes anything you specify as an arg to the function as a single, un-split string, but there is no rule saying that you can't just split the string yourself, either just using the shell's word-splitting, or by using your own splitting, e.g. by changing the IFS variable.
In your case, that would be
#!/bin/bash
dir="$1"
shift
for var in $*
do
mkdir -p "$dir/$var"
done
Unless I missed or misunderstood something?
from broot.
@SamuelSwartzberg That is exactly what I wanted! Thanks a lot!
from broot.
What do you mean by 'use "'?
Given
[[verbs]]
invocation = "printargs {args}"
external = "echo {args}"
as a simple test verb:
:printargs foo "bar" baz
> foo "bar" baz
So they are preserved. If you mean 'prevent splitting on whitespace', that's true. I'm pretty sure there's a way around this, probably using eval
, but once you're going down that road, you gotta wonder if you shouldn't be doing things differently. So it might be worth trying if you need the solution soon, but else, I also would kinda support an option for verbs that's something like no_quote_args
, where all it does is pass the args down to the command raw, with no shell quoting and escaping. I do think that would be the cleaner solution, relying on shell resplitting is always non-ideal. Shellcheck warns you against it, for example.
from broot.
What would be MakeMulipleDirs
in this case ? An internal
(predefined operation in broot) or an external program ?
from broot.
MakeMultipleDirs would be a custom verb. Something like
{
invocation: MakeMultipleDirs [dirs]
shortcut: mmd
execution: "mkmuldirs {directory} [dirs]"
leave_broot: false
}
here I've used square brakets to indicate a list of arguments compared to 1 argument as an example.
In this case mkmuldirs would be a simple script - something like:
#!/bin/bash
dir="$1"
shift
for var in "$@"
do
mkdir -p "$dir/$var"
done
from broot.
This approach does still have 1 issue though - you are unable to use " for arguments in this case, since broot is automatically managing ".
I guess a better issue would be to ask for a way to toggle this behaviour depending on the verb. @Canop Should I open a new issue for that or can we reuse this one since it is related?
from broot.
Related Issues (20)
- ANSI codes inserted into the prompt after starting broot (causing "No matching verb") HOT 15
- Add features for Trash management HOT 2
- Request: Verb: Toggle descending/following all symlinks HOT 4
- Allow configuring how double click opens files HOT 2
- How do I move around locations? HOT 2
- Slow at /proc HOT 4
- Color scheme produces unexpected output since 1.33.0
- Does not compile on Termux (Android) any more HOT 2
- Wrong light colorscheme in zellij HOT 7
- broot fail to recognize `suid` and `sgid` bits when showing permission HOT 2
- Option to always open editor relative to directory where i start `broot` HOT 6
- Arrow between path and git branch misaligned HOT 2
- Could not edit file in Kakoune by specifying client and server HOT 3
- showing long pathnames on multiple lines
- Is there a way to prevent right arrow from opening file in external editor? HOT 1
- Run shell commands like tar and zip directly through broot terminal UI.
- Put selected path into shell input HOT 3
- Backspace key not working when running in xterm
- Make ``ctrl`` ``p`` append the current verb arguments rather than replace them.
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 broot.