Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paste with overwrite? #561

Closed
PoSayDone opened this issue Jan 15, 2021 · 4 comments
Closed

Paste with overwrite? #561

PoSayDone opened this issue Jan 15, 2021 · 4 comments
Labels

Comments

@PoSayDone
Copy link

Is there any way to do this in lf by default?

@kmarius
Copy link
Contributor

kmarius commented Jan 15, 2021

I use this command

cmd paste-override &{{
	set -f
	mode=$(head -1 ~/.local/share/lf/files)
	list=$(sed 1d ~/.local/share/lf/files)
	set -- _ $list; shift
	[ $# -gt 0 ] || exit
	case $mode in
		copy)
			rsync -r "$@" ./
			;;
		move)
			rsync -r --remove-source-files "$@" ./
			;;
	esac
	lf -remote 'save\nmove\n'
	lf -remote "send $id load"
	lf -remote "send $id echo \"\033[0;32mpasted $# file(s)\033[0m\""
}}

(note that this does not move files even if on the same file system)

Edit: replaced mv and cp with rsync
Edit2: updated to new load/mode mechanism

@PoSayDone
Copy link
Author

I use this command

cmd paste-override &{{
	set -f
	load=$(lf -remote "load")
	mode=$(echo "$load" | head -1)
	list=$(echo "$load" | sed '1d')
	set -- _ $list; shift
	[ $# -gt 0 ] || exit
	case $mode in
		copy)
			rsync -r "$@" ./
			;;
		move)
			rsync -r --remove-source-files "$@" ./
			;;
	esac
	lf -remote 'save\nmove\n'
	lf -remote "send $id load"
	lf -remote "send $id echo \"\033[0;32mpasted $# file(s)\033[0m\""
}}

Edit: replaced mv and cp with rsync

Hi, thanks, that is working, but I have a small question, Is there any way to execute this command with "po" mapping? I've made normal paste mapping on "pp" but it doesn't working.

@kmarius
Copy link
Contributor

kmarius commented Jan 17, 2021

If something else is mapped to p it needs to be unmapped first, i.e.

map p
map pp paste
map po paste-overwrite

@PoSayDone
Copy link
Author

If something else is mapped to p it needs to be unmapped first, i.e.

map p
map pp paste
map po paste-overwrite

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants