update ranger confi
This commit is contained in:
parent
1453525b2a
commit
7998aaf215
118
conf.d/ranger/command.py
Normal file
118
conf.d/ranger/command.py
Normal file
@ -0,0 +1,118 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
# File : command.py
|
||||
# Author : Jeff LANCE <email@jefflance.me>
|
||||
# Date : 12.05.2021
|
||||
# Last Modified Date: 12.05.2021
|
||||
# Last Modified By : Jeff LANCE <email@jefflance.me>
|
||||
|
||||
import os
|
||||
from ranger.core.loader import CommandLoader
|
||||
from ranger_udisk_menu.mounter import mount
|
||||
|
||||
|
||||
class extract_here(Command):
|
||||
def execute(self):
|
||||
"""extract selected files to current directory."""
|
||||
cwd = self.fm.thisdir
|
||||
marked_files = tuple(cwd.get_selection())
|
||||
|
||||
def refresh(_):
|
||||
cwd = self.fm.get_directory(original_path)
|
||||
cwd.load_content()
|
||||
|
||||
one_file = marked_files[0]
|
||||
cwd = self.fm.thisdir
|
||||
original_path = cwd.path
|
||||
au_flags = ["-x", cwd.path]
|
||||
au_flags += self.line.split()[1:]
|
||||
au_flags += ["-e"]
|
||||
|
||||
self.fm.copy_buffer.clear()
|
||||
self.fm.cut_buffer = False
|
||||
if len(marked_files) == 1:
|
||||
descr = "extracting: " + os.path.basename(one_file.path)
|
||||
else:
|
||||
descr = "extracting files from: " + os.path.basename(one_file.dirname)
|
||||
obj = CommandLoader(
|
||||
args=["aunpack"] + au_flags + [f.path for f in marked_files],
|
||||
descr=descr,
|
||||
read=True,
|
||||
)
|
||||
|
||||
obj.signal_bind("after", refresh)
|
||||
self.fm.loader.add(obj)
|
||||
|
||||
|
||||
class compress(Command):
|
||||
def execute(self):
|
||||
"""Compress marked files to current directory"""
|
||||
cwd = self.fm.thisdir
|
||||
marked_files = cwd.get_selection()
|
||||
|
||||
if not marked_files:
|
||||
return
|
||||
|
||||
def refresh(_):
|
||||
cwd = self.fm.get_directory(original_path)
|
||||
cwd.load_content()
|
||||
|
||||
original_path = cwd.path
|
||||
parts = self.line.split()
|
||||
au_flags = parts[1:]
|
||||
|
||||
descr = "compressing files in: " + os.path.basename(parts[1])
|
||||
obj = CommandLoader(
|
||||
args=["apack"]
|
||||
+ au_flags
|
||||
+ [os.path.relpath(f.path, cwd.path) for f in marked_files],
|
||||
descr=descr,
|
||||
read=True,
|
||||
)
|
||||
|
||||
obj.signal_bind("after", refresh)
|
||||
self.fm.loader.add(obj)
|
||||
|
||||
def tab(self, tabnum):
|
||||
"""Complete with current folder name"""
|
||||
|
||||
extension = [".zip", ".tar.gz", ".rar", ".7z"]
|
||||
return [
|
||||
"compress " + os.path.basename(self.fm.thisdir.path) + ext
|
||||
for ext in extension
|
||||
]
|
||||
|
||||
|
||||
class mkcd(Command):
|
||||
"""
|
||||
:mkcd <dirname>
|
||||
|
||||
Creates a directory with the name <dirname> and enters it.
|
||||
"""
|
||||
|
||||
def execute(self):
|
||||
from os.path import join, expanduser, lexists
|
||||
from os import makedirs
|
||||
import re
|
||||
|
||||
dirname = join(self.fm.thisdir.path, expanduser(self.rest(1)))
|
||||
if not lexists(dirname):
|
||||
makedirs(dirname)
|
||||
|
||||
match = re.search("^/|^~[^/]*/", dirname)
|
||||
if match:
|
||||
self.fm.cd(match.group(0))
|
||||
dirname = dirname[match.end(0) :]
|
||||
|
||||
for m in re.finditer("[^/]+", dirname):
|
||||
s = m.group(0)
|
||||
if s == ".." or (
|
||||
s.startswith(".") and not self.fm.settings["show_hidden"]
|
||||
):
|
||||
self.fm.cd(s)
|
||||
else:
|
||||
## We force ranger to load content before calling `scout`.
|
||||
self.fm.thisdir.load_content(schedule=False)
|
||||
self.fm.execute_console("scout -ae ^{}$".format(s))
|
||||
else:
|
||||
self.fm.notify("file/directory exists!", bad=True)
|
@ -256,6 +256,7 @@ unmap <C-r> <C-l> <C-d> <C-h> <C-m> <C-n> <C-q>
|
||||
unmap <C-a>
|
||||
unmap <C-v> <C-x> <C-c>
|
||||
unmap <C-t> <C-w>
|
||||
unmap ..
|
||||
unmap A a c d G m n o p S s y z
|
||||
unmap gi gl gr ge gh gn go gR gs gT gt gu
|
||||
unmap ud um uq ut uV uv uy
|
||||
@ -302,6 +303,7 @@ map gc cd ~/Cours/
|
||||
map gd cd ~/Documents/
|
||||
map gm cd ~/Musique/
|
||||
map gp cd ~/Projets/
|
||||
map gt cd ~/tmp/
|
||||
map gu eval fm.cd('/run/media/' + os.getenv('USER'))
|
||||
map gv cd ~/Vidéos/
|
||||
# to global dirs
|
||||
@ -312,6 +314,7 @@ map gL cd -r %f
|
||||
map gM cd /mnt
|
||||
map gO cd /opt
|
||||
map gS cd /srv
|
||||
map gT cd /tmp
|
||||
map gU cd /usr
|
||||
map gV cd /var
|
||||
|
||||
@ -342,6 +345,7 @@ map ! console shell%space
|
||||
map ~ set viewmode!
|
||||
map = console chmod%space
|
||||
map ? help
|
||||
map . shell ${HOME}/.config/ranger/scripts/dotify.sh %s
|
||||
|
||||
map Q quit!
|
||||
map W display_log
|
||||
@ -587,3 +591,5 @@ tmap <C-l> redraw_window
|
||||
tmap <ESC> taskview_close
|
||||
copytmap <ESC> q Q w <C-c>
|
||||
|
||||
|
||||
/* vim: set filetype=vim : */
|
||||
|
27
conf.d/ranger/scripts/dotify.sh
Executable file
27
conf.d/ranger/scripts/dotify.sh
Executable file
@ -0,0 +1,27 @@
|
||||
#!/bin/env bash
|
||||
|
||||
# File : conf.d/ranger/scripts/dotify.sh
|
||||
# Author : Jeff Lance <email@jefflance.me>
|
||||
# Date : 01.10.2023 19:06:09
|
||||
# Last Modified Date: 01.10.2023 19:06:09
|
||||
# Last Modified By : Jeff Lance <email@jefflance.me>
|
||||
#
|
||||
# Script that alter visibility of a set of selected files.
|
||||
# It renames files prefixing a dot in the name.
|
||||
|
||||
|
||||
|
||||
for path in "$@"; do
|
||||
file_name="$(basename "$path")"
|
||||
dir_name="$(dirname "$path")"
|
||||
case "$file_name" in .*)
|
||||
mv -v -- "$path" "$dir_name/${file_name#.}"
|
||||
;;
|
||||
*)
|
||||
mv -v -- "$path" "$dir_name/.$file_name"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
printf "Press ENTER to continue"
|
||||
read -r
|
Loading…
Reference in New Issue
Block a user