Comments (6)
new command added: quit_to_cwd
This will write the current directory to a file specified by the --lastdir
command line option.
Then the function I mentioned above will go to that directory upon quiting joshuto
commit: f8851c7
from joshuto.
This is excellent! The only change I would make (and I don't mean to be nitpicky) would be to change the name from --lastdir
to --last-dir
just to separate the two words and keep a regular naming-convention for flags. Maybe we could add a shorthand version -l
as well, if we want to type less. Thank you again and I appreciate the quick turnaround!
from joshuto.
You can currently do this via an alias:
alias joshut='joshuto --lastdir /tmp/$USER/joshuto-lastdir;
LASTDIR="$(cat /tmp/$USER/joshuto-lastdir)";
[ "$LASTDIR" != "$(pwd)" ] && cd "$LASTDIR"';
This is not optional though; you will always cd to the current directory in Joshuto on exit.
But you can go back with cd -
If you want it to be optional, we can potentially modify the exit code to indicate to our shell that we want to move to the specified directory. ie. exit code 2 means cd to the current directory in Joshuto
from joshuto.
Hmm that sounds sort of hacky, maybe this function from hunter might be helpful in finding a solution:
https://github.com/rabite0/hunter/blob/355d9a3101f6d8dc375807de79e368602f1cb87d/src/file_browser.rs#L931
from joshuto.
Yea, we can implement a command like hunter to QuitToCwd
.
Then have a bash function to facilitate it like hunter. This is what I currently have atm:
function joshuto() {
CWD_FILE="/tmp/$USER/joshuto-cwd"
env joshuto --lastdir "$CWD_FILE" $@
if [ -e "$CWD_FILE" ]; then
JOSHUTO_CWD=$(cat "$CWD_FILE")
rm "$CWD_FILE" && cd "$JOSHUTO_CWD"
fi
}
I will be adding QuitToCwd
shortly.
I don't think I will be adding all the additional options hunter has (at least for now) just because I don't think it will work well with files with spaces or other special characters (without more work).
ie.
HUNTER_CWD=...
F=...
MF=...
We can also move --lastdir
into an option in the config instead of a command line parameter, but that can be for the future
from joshuto.
changed to --last-dir
in dev branch fcf869c.
I've decided to not add -l
just because I think it might be used for a different option in the future and --last-dir
seems like a non-intuitive option to have a shorthand version for.
Also, updated the script so it would take timestamps into account when creating these files to reduce collisions.
function joshuto() {
TIMESTAMP=$(date '+%Y%m%d-%H%M%S')
CWD_FILE="/tmp/$USER/joshuto-cwd-$TIMESTAMP"
env joshuto --last-dir "$CWD_FILE" $@
if [ -e "$CWD_FILE" ]; then
JOSHUTO_CWD=$(cat "$CWD_FILE")
rm "$CWD_FILE" && cd "$JOSHUTO_CWD"
fi
}
from joshuto.
Related Issues (20)
- Add a new command to print default configuration
- No image preview on Alacritty in Void Herbstluft HOT 6
- open command does not respect mimetype.toml HOT 4
- There are some errors when I use Joshuto to preview some .lua files HOT 1
- Latest release doesn't build HOT 1
- v0.9.7 - `Cargo.toml` does not match `Cargo.lock` HOT 2
- feature request: change, simplify joshuto image preview HOT 2
- [BUG] Fatal crash when I return to joshuto from a shell HOT 4
- Use of `--change-directory` command line argument? HOT 1
- Configure ratatui-image preview background/frame color.
- [BUG] Linemode 'sizemtime' unknown. HOT 1
- [FEATURE] More linemodes and sort modes
- linux gnu build error
- Directory chooser HOT 1
- [Help wanted] Creating a custom script to use joshuto to control imv. HOT 1
- Feature request: delete colon to exit command mode
- Feature request: implement scrollable preview area HOT 2
- [Bug] File preview(with bat) does not update after file modification with vim
- Feature request: Add options to pre-select a file on start HOT 2
- Unable to select neovim config with NVIM_APPNAME environment variable
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 joshuto.