Comments (10)
@ivegotasthma Ok so I have checked ranger now. You can use the same mapping as ranger. For that you need to unbind d
key first. Then add dd
for cutting and dD
for deletion. Following should work (not tested):
map d # leave the command name empty like this for unmapping
map dd delete
map dD $IFS=':'; rm -rf $fx
If you don't want to set IFS
variable for each such command as above, you can use the ifs
options to set it for all automatically. Ranger prompts for deleting multiple files. You can achieve something like that by prompting in your custom shell command (again not tested):
map dD ${{
echo 'delete?[y/n]'
read ans
[ $ans = 'y' ] && echo 'deleting files..' || echo 'cancelled.'
}}
You need to replace echo
commands with rm
accordingly. You can also customize this to not prompt when there is only one file selected. Lastly you can create a named command for this and then map dD
to insert the command name to wait for your enter key using the push
command (again not tested):
cmd remove ${{
echo 'delete?[y/n]'
read ans
[ $ans = 'y' ] && echo 'deleting files..' || echo 'cancelled.'
}}
map dD push :remove
Basically, I think everything in ranger
should also be possible in lf
. See the doc and the example configuration file for more examples. If there is anything missing we can improve them.
from lf.
@ivegotasthma delete
command is actually just cutting and it is named after the corresponding vi command and keybinding. By default there are no actual file deletion command is provided. You can use something like $rm $f
interactively or just bind this or maybe $rm -rf $fx
to a key yourself. Alternatively you can use the trash
command from lfrc.example
and/or bind it to a key.
What is that custom mapping you mention?
from lf.
Thanks for clearing up the issue, works great. The mapping I mentioned is: map D $rm -fr "$fx"
. Is it possible to run a command on the marked for cutting files?
from lf.
@ivegotasthma File names are separated with :
so your mapping will not work properly when you have quotes around $fx
(see doc for more detail).
Can you rephrase what you mean by running a command on the marked for cutting files?
from lf.
@gokcehan Thanks for the correction. I notice that with that mapping: map D $rm -fr $fx
I cannot delete a selection of files, marked with the purple flair.
By the files marked for cutting I mean the files that are marked for deletion, with the red indicator before them. I'd like to be able to run a command only on that selection because I find it a bit dangerous to arbitrary delete a file, I'd like to have a small moment of consideration before it. Which selection it for deletion does.
It's the same in ranger, you press the d
key for delete
but it opens a menu for a variety of options where are related to the destruction of the file, one of which is the movement of the file, eg. cutting
it or purging
.
PS. is it possible to remove files selected for deletion with the red flair?
from lf.
@gokcehan I applogize for misartuculating this:
PS. is it possible to remove files selected for deletion with the red flair?
.
I meat to ask if it's possible to unselect files marked for deletion with the red flair or select files that are in a certain selection, so that I could mark files with red and then delete them, ei, having specific flairs for different actions. Red would be dangerous operations for example. It's possible to unselect files marked with purple but not with red.
Here's the command that I ended up with:
# purge the unclean
cmd remove ${{
if [ -z $fs ]; then
rm -fr $f
else
IFS=':'; echo $fs | tr " " "\n"
echo 'delete? [y/n]'
read ans
[ $ans = 'y' ] && (echo 'deleting files...' && rm -fr $fs) || (echo 'cancelled...')
fi
}}
map d
map dd delete
map dD push :remove
from lf.
@ivegotasthma Ahh sorry, now I understand what you mean, at least some of it.
Currently we're missing a command to clear the selection (red/yellow) but you can workaround for this by directly communicating with your socket using netcat if it support unix sockets (e.g. OpenBSD netcat), something along the line:
map c ${{
echo "save move" | nc -U /tmp/lf.${USER}.sock
echo "send sync" | nc -U /tmp/lf.${USER}.sock
}}
First line will save an empty list of files for moving (i.e. red) so it will clear previous selected files. Second line will sync file lists of clients with the server. Note that remote commands and protocol used for communication here are still experimental and undocumented so it will likely break in the future as changes are made. One thing we might add is a command line flag to send arbitrary strings to the socket using lf
so nc
will not be required (e.g. lf -send "save move"
).
Other than that, you seem to have some extra ideas about color codes for file lists. Some of these might be achieved using echo "load" | nc -U /tmp/lf.${USER}.sock
which will return the current file list saved in the server. But there is still only one file list held in the server (i.e. red or yellow). I haven't experimented much with these yet, not sure what things are possible.
from lf.
I second the proposal of @ivegotasthma with regards to unselecting all selections. The idea lf -send "save move"
of @gokcehan seems to be the safest one, so I'm supporting it (in contrast with reliance on pure socket communication which is fragile due to possible changes in lf).
@ivegotasthma could you please rename this topic to something like "Unselect red selections"?
from lf.
@dumblob Just to be clear, lf -send "save move"
is also about using socket communication but using lf
instead of an external command, so it may still break if we change the communication protocol. The good thing is we don't have to pass the socket name so it won't break if we change the socket name at some point.
By the way, I tried to implement a native clear
command for this purpose the other day but there was a race somewhere so I didn't push it. I suspect there is still something wrong with the asynchronous event loop. I will take a look at it when I find some time.
from lf.
I have now added a native clear
command (default c
) and also a -remote
command line flag. Closing this issue now.
from lf.
Related Issues (20)
- Slow reaction when start lf? HOT 2
- lfcd quits shell on exiting LF, when lfcd is defined in another sourced file HOT 5
- enhancement: LF_CONFIG_HOME to ~/.config/lf HOT 6
- Ueberzug previews don't work without python distutils HOT 2
- unset setlocal HOT 2
- Operations performed on sshfs mount no longer reloads HOT 2
- Sort_by function not work very well with hungarian letters HOT 2
- Chafa symbol preview error HOT 9
- lf image preview flickering HOT 5
- Duplicate icon
- Mouse buttons don't work
- Preview window colors HOT 14
- Yank path w/filename, filename, and file (As in Ranger) in Powershell HOT 6
- [QUESTION] Paste with overwrite for multiple files HOT 5
- Main Column Line Numbers Only HOT 4
- Outdated file information for recreated directories HOT 9
- directories have another font type HOT 2
- Feature request: highlighting of cursors when inactive HOT 3
- Feature request: add an lfrc switch to move duplicate copy suffixes at the beginning of filename. HOT 4
- `autoquit` should be enabled by default HOT 6
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 lf.