Comments (4)
Can you give a bit more context? I'm still being able to access $?
for the return value in bash
as usual.
from jump.
Yes, that confused me too. I assume PROMPT_COMMAND is executed in a subshell which preserves the value of $?
outside of that. The problem comes inside that PROMPT_COMMAND subshell. If I want to alter my bash prompt in response to the success or failure of the last command, I need to do is store that return value to prevent clobbering it myself:
function my_prompt_func() {
local code=$?
local dir=$(pwd)
if [ $? -eq 0 ]; then
PS1="$dir ✔ $"
else
PS1="$dir ✕ $"
fi
}
PROMPT_COMMAND=my_prompt_func
(Or a real life example)
Of course, when I add eval "$(jump shell bash)
it changes that to PROMPT_COMMAND="__jump_prompt_command;$PROMPT_COMMAND"
, which means that $?
inside of my_prompt_func
is the exit code of __jump_prompt_command
and not the command last executed by the user.
Since it looks like you're just hooking into that to adjust the score, it seems like you could reorder those PROMPT_COMMANDs to put __jump_prompt_command
last, which is what I've done in my workaround. Alternately, you could return the original exit code from _jump_prompt_command
, or preserve the last exit code in an environmental variable, but those both seem unnecessary
from jump.
I get you now! Will reorder it for the next version. Haven't thought that someone may require the return value somewhere in PROMPT_COMMAND
.
Thanks for the detailed report!
from jump.
Hey @greygore, can you try the changes in f124fa4 and see whether they work for you? A lot of tools inject themselves into the beginning of PROMPT_COMMAND
and if I inject myself last I have to be weary of ;;
.
from jump.
Related Issues (20)
- Disable `jump top` from printing scores HOT 2
- Question: listing matches on tab completion not a design goal? HOT 7
- How do you change the directory of the parent process? HOT 1
- RPM refuses to install on Fedora due to OS is specified as darwin HOT 4
- jump has stopped tracking my directories HOT 4
- RangerFM integration HOT 2
- Escaping hyphens and apostrophes and other HOT 8
- Integration documentation outdated? HOT 6
- Add option to use pushd instead of cd in dir motion HOT 1
- [MacOS] brew installs Jump Desktop instead of this tool HOT 2
- `jump import` does not work for non-default Z_DATA location. HOT 2
- brew install jump HOT 1
- jump 0.41.0 debian packages are broken HOT 3
- Release the binary of jump v0.41.0 for macOS HOT 5
- windows builds HOT 6
- Release assets of jump v0.50.0 for Linux HOT 3
- v0.51.0 - release binaries request HOT 2
- ARM version in brew HOT 3
- command not found: jump HOT 2
- Flatpak Install Option HOT 2
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 jump.