Git Product home page Git Product logo

Comments (3)

tapyu avatar tapyu commented on August 26, 2024 2

Consider another example

# add submodule
git submodule add <is_branch>

$ is_branch: echo "" --- --map "grep -Pq '.+' && echo 'branch=<is_branch>'" --header "are you adding submodule from a specific branch? Type the branch name if yes, or leave empty if no."

I want to create an optional example. If I write something, I must append --branch= to the written argument. Your workaround doesn't work here.

The solution would be

# add submodule
git submodule add <prefix><is_branch>

$ is_branch: echo "" --- --header "are you adding submodule from a specific branch? Type the branch name if yes, or leave empty if no."
$ prefix: [[ -n $(echo <is_branch>) ]] && echo '--branch=' || echo '' --- --fzf-overrides '-1'

Again, a functional but ugly workaround. It would be much better to be able to write former solution.

from navi.

chiva avatar chiva commented on August 26, 2024

You can try a workaround for the same result

% sed

# Print a specific line from a file
sed -n <number>p <file>

$ file: find . -maxdepth 1 -type f | cut -c3-
$ number: aux=$(wc -l <file> | cut -f 1) && echo "This file contains $aux pages" --- --header-lines 1

from navi.

tapyu avatar tapyu commented on August 26, 2024

Small correction, it should be aux=$(wc -l <file> | cut -d ' ' -f 1), we need to define the delimiter.

Anyway, that is a good workaround, but it is a workaround. I would be great to make fzf option aware of both shell-defined variables (e.g., $aux) and navi-defined variables (e.g., <file>), so that one can write something like

% sed

# Print a specific line from a file
sed -n <number>p <file>

$ file: find . -maxdepth 1 -type f | cut -c3-
$ number: export aux=$(wc -l <file> | cut -d ' ' -f 1) --- --header "The file <file> contains $aux pages "

No workarounds, no tricks, no complications.

from navi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.