mirror of
https://github.com/theniceboy/.config.git
synced 2026-05-11 00:55:56 +08:00
ranger config update
This commit is contained in:
parent
ffd0c629e8
commit
729fb590de
4 changed files with 36 additions and 16 deletions
3
bin/ranger
Executable file
3
bin/ranger
Executable file
|
|
@ -0,0 +1,3 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
python3 ~/prog/ranger/ranger.py
|
||||
|
|
@ -2,13 +2,19 @@ from ranger.api.commands import Command
|
|||
import os
|
||||
from ranger.core.loader import CommandLoader
|
||||
|
||||
class paste_as_root(Command):
|
||||
def execute(self):
|
||||
if self.fm.do_cut:
|
||||
self.fm.execute_console('shell sudo mv %c .')
|
||||
else:
|
||||
self.fm.execute_console('shell sudo cp -r %c .')
|
||||
|
||||
class paste_as_root(Command):
|
||||
def execute(self):
|
||||
if self.fm.do_cut:
|
||||
self.fm.execute_console('shell sudo mv %c .')
|
||||
else:
|
||||
self.fm.execute_console('shell sudo cp -r %c .')
|
||||
|
||||
|
||||
class toggleVCS(Command):
|
||||
def execute(self):
|
||||
self.fm.execute_console("set vcs_aware!")
|
||||
self.fm.execute_console("reload_cwd")
|
||||
|
||||
|
||||
class mkcd(Command):
|
||||
|
|
@ -17,7 +23,6 @@ class mkcd(Command):
|
|||
|
||||
Creates a directory with the name <dirname> and enters it.
|
||||
"""
|
||||
|
||||
def execute(self):
|
||||
from os.path import join, expanduser, lexists
|
||||
from os import makedirs
|
||||
|
|
@ -34,7 +39,8 @@ class mkcd(Command):
|
|||
|
||||
for m in re.finditer('[^/]+', dirname):
|
||||
s = m.group(0)
|
||||
if s == '..' or (s.startswith('.') and not self.fm.settings['show_hidden']):
|
||||
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`.
|
||||
|
|
@ -43,6 +49,7 @@ class mkcd(Command):
|
|||
else:
|
||||
self.fm.notify("file/directory exists!", bad=True)
|
||||
|
||||
|
||||
class fzf_select(Command):
|
||||
"""
|
||||
:fzf_select
|
||||
|
|
@ -58,13 +65,17 @@ class fzf_select(Command):
|
|||
import os.path
|
||||
if self.quantifier:
|
||||
# match only directories
|
||||
command="find -L . \( -path '*/\.*' -o -fstype 'dev' -o -fstype 'proc' \) -prune \
|
||||
command = "find -L . \( -path '*/\.*' -o -fstype 'dev' -o -fstype 'proc' \) -prune \
|
||||
-o -type d -print 2> /dev/null | sed 1d | cut -b3- | fzf +m"
|
||||
|
||||
else:
|
||||
# match files and directories
|
||||
command="find -L . \( -path '*/\.*' -o -fstype 'dev' -o -fstype 'proc' \) -prune \
|
||||
command = "find -L . \( -path '*/\.*' -o -fstype 'dev' -o -fstype 'proc' \) -prune \
|
||||
-o -print 2> /dev/null | sed 1d | cut -b3- | fzf +m"
|
||||
fzf = self.fm.execute_command(command, universal_newlines=True, stdout=subprocess.PIPE)
|
||||
|
||||
fzf = self.fm.execute_command(command,
|
||||
universal_newlines=True,
|
||||
stdout=subprocess.PIPE)
|
||||
stdout, stderr = fzf.communicate()
|
||||
if fzf.returncode == 0:
|
||||
fzf_file = os.path.abspath(stdout.rstrip('\n'))
|
||||
|
|
@ -74,8 +85,6 @@ class fzf_select(Command):
|
|||
self.fm.select_file(fzf_file)
|
||||
|
||||
|
||||
|
||||
|
||||
class compress(Command):
|
||||
def execute(self):
|
||||
""" Compress marked files to current directory """
|
||||
|
|
@ -104,7 +113,11 @@ class compress(Command):
|
|||
""" 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]
|
||||
return [
|
||||
'compress ' + os.path.basename(self.fm.thisdir.path) + ext
|
||||
for ext in extension
|
||||
]
|
||||
|
||||
|
||||
class extracthere(Command):
|
||||
def execute(self):
|
||||
|
|
@ -130,7 +143,8 @@ class extracthere(Command):
|
|||
if len(copied_files) == 1:
|
||||
descr = "extracting: " + os.path.basename(one_file.path)
|
||||
else:
|
||||
descr = "extracting files from: " + os.path.basename(one_file.dirname)
|
||||
descr = "extracting files from: " + os.path.basename(
|
||||
one_file.dirname)
|
||||
obj = CommandLoader(args=['aunpack'] + au_flags \
|
||||
+ [f.path for f in copied_files], descr=descr, read=True)
|
||||
|
||||
|
|
|
|||
|
|
@ -347,6 +347,7 @@ map ] move_parent 1
|
|||
map [ move_parent -1
|
||||
#map } traverse
|
||||
|
||||
map <CR> toggleVCS
|
||||
|
||||
# Open lazygit
|
||||
map <c-g> shell lazygit
|
||||
|
|
@ -359,6 +360,7 @@ map gD cd ~/Downloads
|
|||
map gfa cd ~/.config/alacritty
|
||||
map gff cd ~/.config
|
||||
map gfr cd ~/.config/ranger
|
||||
map gfb cd ~/.config/bin
|
||||
map gfn cd ~/.config/nvim
|
||||
map gfm cd ~/.config/mutt
|
||||
map gfz cd ~/.config/zsh
|
||||
|
|
@ -394,7 +396,7 @@ map <HOME> move to=0
|
|||
map <END> move to=-1
|
||||
map <PAGEDOWN> move down=1 pages=True
|
||||
map <PAGEUP> move up=1 pages=True
|
||||
map <CR> move right=1
|
||||
#map <CR> move right=1
|
||||
#map <DELETE> console delete
|
||||
map <INSERT> console touch%space
|
||||
|
||||
|
|
|
|||
|
|
@ -14,4 +14,5 @@ zmodule supercrabtree/k
|
|||
zmodule mafredri/zsh-async
|
||||
zmodule hlissner/zsh-autopair
|
||||
zmodule pabloariasal/zfm
|
||||
zmodule agkozak/zsh-z
|
||||
#zmodule cusxio/delta-prompt
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue