Comments (11)
You can use the "-i or --mime" option of file
which return the mime type, which should be easier to parse and not depends on locales
-i, --mime Causes the file command to output mime type strings rather than the more traditional human readable ones. Thus it may say ‘text/plain; charset=us-ascii’ rather than “ASCII text”.
from nnn.
@kaushalmodi @olethanh please test with the fix and confirm everything works as expected. Thanks!
from nnn.
Thanks! I confirm this fix.
from nnn.
Are you on v1.1 (released today)?
Which opener variable did you define? We do detect and attempt to open plaintext files in EDITOR (fallback vi). But that works only if NNN_OPENER is not used. I don't have NNN_OPENER and it's working for me right now.
from nnn.
I have none of the NNN_* env vars defined. I get the same behavior on the v1.1 release too.
> echo $NNN_OPENER
NNN_OPENER: Undefined variable.
> echo $EDITOR
emacsclient
If it matters, I am using tcsh
shell. I can easily get that "No association" message by launching nnn
in this repo root, navigating to the CHANGELOG
file and hitting RET.
To add, if I hit e instead of RET on CHANGELOG
, the file opens fine in my default $EDITOR
.
from nnn.
What's the output of file -b CHANGELOG
?
from nnn.
What's the output of file -b CHANGELOG?
That's it! It outputs ASCII English text
, not ASCII text
. May be you should match for a regular expression like ASCII .*text
?
from nnn.
This is not a good fix, but I tested this out and it works for me:
diff --git a/nnn.c b/nnn.c
index 110495e..e6b8d2b 100644
--- a/nnn.c
+++ b/nnn.c
@@ -1598,7 +1598,7 @@ nochange:
if (get_output(cmd, MAX_CMD_LEN) == NULL)
continue;
- if (strstr(cmd, "ASCII text") != NULL) {
+ if (strstr(cmd, "ASCII English text") != NULL) {
exitcurses();
run = xgetenv("EDITOR", "emacsclient");
spawn(run, newpath, NULL, 0);
from nnn.
Also I found the use of PAGER there more intuitive than EDITOR ( kaushalmodi@05d7641 ). If I wanted to edit the file, I would have hit the e
binding.
from nnn.
I would have to look into the magic numbers and see if I can do anything better than this.
If I wanted to edit the file, I would have hit the
e
binding
I don't think this is too relevant here. The keybind here is Enter
and I don't see a reason to open a text file in read-only mode by default.
from nnn.
@olethanh yes, that'ld be nice! I'll push it in.
from nnn.
Related Issues (20)
- NNN_TRASH_CUSTOM setting not working HOT 4
- preview-tabbed - zathura not focusing HOT 2
- Nerd fonts cause misaligned columns in detail mode with names first HOT 5
- nnn compiled with nerdfonts not displaying correctly in WSL HOT 2
- NNN broken on master HOT 3
- 'size missing' when trying to preview-tui in tmux HOT 7
- NNN does not close Tmux pane on opening a file while preview HOT 5
- Can't batch rename files which names start with dash '-' HOT 6
- mv: unrecognized option '--cp' HOT 2
- Icons does not work when NNN is opened with -C option HOT 5
- preview-tui: mpv HOT 11
- Syntax error with prescribed split-pane script HOT 7
- tabs content colorization is not working (zsh+tmux) HOT 3
- preview-tui does not work with tmux 3.4 HOT 1
- Wrong position of previews in 4K monitor with fractional scaling of 1.5
- Files created with `n`, `f` have incorrect permissions HOT 5
- sort order.... whatever it means.. HOT 2
- preview-tui with wezterm: No FIFO available! ($NNN_FIFO='') HOT 2
- Respect keys regardless of kb language input HOT 4
- Visual Glitch, visual bug, the whole screen breaks, resize does something, redraw does not
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 nnn.