Comments (15)
@kevin-stuart I took some time to work out a solution and here's what we have: https://github.com/jarun/nnn#copy-file-paths-when-x-is-missing
This should be fine for all use cases where selected file names are required.
from nnn.
There are reasons we don't support destructive/risky operations like deletion.
clipboard workflow is not very useable in all scenarios such as when using SSH
what's the alternative you propose? There is no clipboard over SSH without X forwarding. And piping to scripts is risky which is why nlay
usage is kept at a minimum.
Also, the tagline says it all - The missing terminal file browser for _X_
.
Maybe you should consider adding a bit of complexity
I think you are ignoring the complexity nnn
already has. Anyway, please raise a PR and we can take a look.
from nnn.
Precisely because clipboard is not really an option for SSH, I proposed that a different approach would need to be taken to support actions such as delete.
I understand the rationale to be careful with desctructive/risky actions, which is why I mentioned that custom scripts would allow confirmations for such actions. However, I think you support rename with C-r, which I accidentally did do; I would consider this also as risky.
Since flat out adding deleting could be dangerous and more limited anyway, I tried to describe an approach which is very close to what you are doing anyway with your scripts directory. Maybe my describtion was too vage and not very good.
I did not say that nnn
is not complex, I merely wanted to express that I think that adding certain things could be very beneficial for making nnn a much more effective tool.
I only created this issue as a feature request, not a pull request. If you do not like the idea at all, you can close this issue. I think the idea is good, because if you reread the discussions in Hacker News comparing nnn
to mc and ncdu, I think a lot of people would really like nnn, because it seems quite light.
I also would not want to create a PR that might get rejected anyway if the idea is not well received. And I while I did like nnn
quite a bit when testing and enough to write this request, I did not like it enough yet when using it with SSH, which is my main usage scenario, to replace mc/ncdu. If I delete files with the command line directly, it is easier to do with fzf for me right now, which can be integrated in many different custom workflows. I also find spawning a new shell a bit expensive just for deletion as opposed to using mc/ncdu for deletion.
from nnn.
Rename and delete are different. You do not lose data with rename.
I do not want to support delete within nnn
and I haven't come around a way to do anything about the SSH scenario without using scripts which is insecure.
Closing the defect.
from nnn.
from nnn.
You don't lose the file contents from renaming, but you loose the filename, which is also information. It can be very long and if you do not know the previous name it is lost. If you have scripts with include/exclude patterns, it can get deleted. And renames can have other disastrous results. It is a modification, just like deletion.
Just to clarify, I did not specifically ask for "file deletion" and a solution just for SSH. I proposed that you could add a line to file to perform custom actions. For example:
tee ~/.config/nnn/keymap << EOF
C-x ~/bin/my_delete.sh
EOF
This could mean that by pressing C-x on a selection, the selection would be send to a script. And in this script, I could provide my own action, for example I could ask for a yes/no confirmation.
This solution is possible to use with SSH. And it is much easier to delete files with it, one could delete files just as in ncdu. And it should not be insecure. Since there is not default delete action in any way, nnn
by default would not delete any files. But this solution requires an external configuration file, which you may not want. But I think the tradeoff may be worth it.
from nnn.
You can absolutely lose data with rename if you rename over an existing file.
Did you try this with nnn
?
from nnn.
This could mean that by pressing C-x on a selection, the selection would be send to a script.
I am adding this to the ToDo list. When I requested you to add a PR that was because I am short on bandwidth myself.
from nnn.
I just tried the rename/overwrite thing, it's nice, nnn
asks for confirmation. Anyway I still think that it is a bit inconsitent because I consider renaming "dangerous", but I am glad that renaming is possible.
I had another idea how one could add custom commmands: You now have a script directory for some parts that can be customized. You could use directories for keys and put scripts there. Then you would not need a config file. For example, you could do ln -s ~/bin/my_delete.sh scripts/ctrl/x
. Then the file is linked to a script and the name defines the keybinding. You would not have to parse a config file.
The only problem would be how to handle default keybindings and if you want to allow users to rebind them. That is something you have to think about. When I read the documentation about the keys, I just thought that I might change or even remove some (like ctrl+r for rename ;-) ). But I do not offer a solution for this.
I also really like the tool as a way to change directories, it is faster than mc for this. If this tool makes its way into distros and can be installed via package managers, it might become quite popular. Ranger is also packaged now, but this tool seems to have a much different use case.
from nnn.
As I mentioned earlier, I would like to see PRs. I am short on bandwidth.
If this tool makes its way into distros and can be installed via package managers, it might become quite popular.
I believe you haven't even read the README. nnn
is available in the repos of major distros already. And nnn
is not ranger.
from nnn.
I missed adding some other aspects for supporting deletion inherently within nnn
:
If there are thousands of files, the operation will block till completion. nnn
doesn't use threads today. If we introduce threads, we will also need a way to visually update the progress to the users which will need changes to the gui.
from nnn.
And the latest release adds vidir integration so you can batch copy, move, delete easily even when there's no X.
from nnn.
There might be one drawback to the current solution: If there is only a single file nnncp, this could cause problems with concurrent usage. For example, if you have two terminals open, use tmux, or if two users are using nnn. A solution could be to allow to supply an environment variable like you do for NNN_TMPFILE
?
I would probably advise to use a default that maps the user as well, maybe the user's $XDG_CACHE_HOME? This would also be safer since only the user may be able to read this file (depending on the setup).
from nnn.
Either that or we can have a tmp file generated per session and remember it. I would prefer tmp in any case. $XDG_CACHE_HOME
is not universal (my system doesn't have it by default) and I don't wanna litter $HOME.
from nnn.
Custom script support in added at commit 2396b94.
from nnn.
Related Issues (20)
- 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
- Sorting bug, different behavior for t and ^T HOT 2
- Misleading typo in the wiki HOT 1
- [plugin] file preview panel get stuck when use plugin preview-tui with tmux and bat HOT 1
- Keybind collision when using the colemak patch HOT 5
- malloc: error pointer being freed was not allocated HOT 9
- The first letter of the file is not correct after change dir HOT 1
- mess with shell colors HOT 1
- [bash] nnn can't return after executing command (] key) if invoked from a `bind -x` keybinding. 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 nnn.