From 57744f4962eb0aa6a9edc254df4700306a21213e Mon Sep 17 00:00:00 2001 From: Yigit Date: Sun, 21 Mar 2021 19:37:43 +0300 Subject: [PATCH] Ranger --- .gitmodules | 3 + misc/ranger/colorschemes/__init__.py | 0 .../__pycache__/__init__.cpython-39.opt-1.pyc | Bin 0 -> 142 bytes .../material-ocean.cpython-39.opt-1.pyc | Bin 0 -> 2891 bytes misc/ranger/colorschemes/material-ocean.py | 183 +++++++++++++++++ misc/ranger/commands.py | 189 ++++++++++++++++++ misc/ranger/plugins/.gitignore | 1 + misc/ranger/plugins/__init__.py | 0 misc/ranger/plugins/compress.py | 43 ++++ misc/ranger/plugins/decrypt.py | 33 +++ misc/ranger/plugins/devicons2 | 1 + misc/ranger/plugins/encrypt.py | 55 +++++ misc/ranger/plugins/extract.py | 85 ++++++++ misc/ranger/plugins/zjumper_ranger.py | 29 +++ misc/ranger/rc.conf | 85 ++------ suckless/dwm/keybind.h | 4 +- zsh/aliases | 1 + zsh/antibody/p10k.zsh | 7 +- zsh/profile | 1 + 19 files changed, 643 insertions(+), 77 deletions(-) create mode 100644 misc/ranger/colorschemes/__init__.py create mode 100644 misc/ranger/colorschemes/__pycache__/__init__.cpython-39.opt-1.pyc create mode 100644 misc/ranger/colorschemes/__pycache__/material-ocean.cpython-39.opt-1.pyc create mode 100644 misc/ranger/colorschemes/material-ocean.py create mode 100644 misc/ranger/commands.py create mode 100644 misc/ranger/plugins/.gitignore create mode 100644 misc/ranger/plugins/__init__.py create mode 100644 misc/ranger/plugins/compress.py create mode 100644 misc/ranger/plugins/decrypt.py create mode 160000 misc/ranger/plugins/devicons2 create mode 100644 misc/ranger/plugins/encrypt.py create mode 100644 misc/ranger/plugins/extract.py create mode 100644 misc/ranger/plugins/zjumper_ranger.py diff --git a/.gitmodules b/.gitmodules index 8346ba12..5be3ccd7 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "gtk/Tela-icon-theme"] path = gtk/Tela-icon-theme url = https://github.com/vinceliuice/Tela-icon-theme.git +[submodule "misc/ranger/plugins/devicons2"] + path = misc/ranger/plugins/devicons2 + url = https://github.com/cdump/ranger-devicons2.git diff --git a/misc/ranger/colorschemes/__init__.py b/misc/ranger/colorschemes/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/misc/ranger/colorschemes/__pycache__/__init__.cpython-39.opt-1.pyc b/misc/ranger/colorschemes/__pycache__/__init__.cpython-39.opt-1.pyc new file mode 100644 index 0000000000000000000000000000000000000000..bbf0745fd08955e035e425d24434bd5511fed126 GIT binary patch literal 142 zcmYe~<>g`kg1u(p2_X70h(HF6K#l_t7qb9~6oz01O-8?!3`HPe1o6vQKO;XkRlhPb zJ+nk#FF8LiEi+xeC^0WRwMaiXKPSJaI5{IVH?>$lK0Y%qvm`!Vub}c4hfQvNN@-52 L9mufHK+FID>9HVL literal 0 HcmV?d00001 diff --git a/misc/ranger/colorschemes/__pycache__/material-ocean.cpython-39.opt-1.pyc b/misc/ranger/colorschemes/__pycache__/material-ocean.cpython-39.opt-1.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f04441007362823e9b602717a871221466075c51 GIT binary patch literal 2891 zcmZWr%WoS+7~hxI8{2W*BrT=9p+LIEKoM;v&vBu+?(6DK&p@0+!g0Jdgle&751X7-y+78e^1et*6D z=DXu#j`ItF!@mIFB8IwwN9JU1;cz#0xfgrfkA0VDUJ>wGT(fJx2zfoO^C*t^LcG8m zaf3JGCU3W3`X` z_*fQRbGr3k;oa%_W+~~bvY2Sr%lWvJ+C*8tm8-lIrahLq(7nM#q#C&En&#!QDCMQ94R_dQpxYUi4RmAB{0 zpD_FKln$nW2z1R#gz7A)b$MP#Qy;4Z`I2r-J*=AYZ9H4@ExkDPAm6ssB{_g3@jLRv z-9R6C-I)e@85B>ioN*xeIC!h_D}9t~U@T!A!?wv!o{KaPk! zdom7FpP1K-Ebq%c2`bg+DLbRu6gTkGz!LKr%p2ANofltThxS}%eI`Tn!p7u@a6h)Q zp#BaE;HuyMI+c1KSDT>$#o zBHFv>_X2sH-cm6Dx=0AKzZWQq_#od4pwMo<0Es)THu<>(^vJ%S%RuMsSs_0gK(E+n z$(!p@`n$n^+K_iex@a}s7v(A@Q-1P5 zp$5Cb(uq#`1sZQ6c1$qH2c-#BnQk&I7f2?|*jApR#TU6iyC0TiCL^n?lVOi1aucDn zh~UGN3Da_%BZCkWxlH6HM;O$>CtR4&Dxlx@lPnkTwU~>2#q9=+Znqww;uIR>6CLGA}1AG54rBDqM7G;v*3R)h^5?7N_ zJ?K<-iK%a;$_B82MOt#6YfH-#TvmZ*H?&z8<-<{dp{uYGwYinEZBw%WTIoTK$~CP8 zF(~p>n-;)CXo zL$p2{(Lp|3mlUI1pWU-`#jACWQph|h9xYRrh_&&K@h6JW(Nqu6Np>4v=muWo zhHmHuZp#g@qEX>$9f8sSrQt?@2Y-7$VbZAPN+$w}+z$Sc+qSkM_jo1YLyt6|SN%yF z_B`?%(QubB$lly)!&2ucvT+fYe9=t*YE?y1d6+#bUHd%n5P6~3p$x1a()!=9{LcUA zf%idk_U*BT+Fj{}ChGO*NcVcC(d+Rtn-sKe^?L75lA_{NZ|E76SYD$CZQG&8Rf0$H zpa!7mlM)GemU5+g3z;2E^hCm}r0*T+(}Tp!v1*&whLao{Z$GJMt0jE~na+Qi)jMpv z1- literal 0 HcmV?d00001 diff --git a/misc/ranger/colorschemes/material-ocean.py b/misc/ranger/colorschemes/material-ocean.py new file mode 100644 index 00000000..3d50e2e4 --- /dev/null +++ b/misc/ranger/colorschemes/material-ocean.py @@ -0,0 +1,183 @@ +# This file is part of ranger, the console file manager. +# License: GNU GPL version 3, see the file "AUTHORS" for details. + +from __future__ import (absolute_import, division, print_function) + +from ranger.gui.colorscheme import ColorScheme +from ranger.gui.color import ( + black, blue, cyan, green, magenta, red, white, yellow, default, + normal, bold, reverse, dim, BRIGHT, + default_colors, +) + + +class Default(ColorScheme): + progress_bar_color = blue + + def use(self, context): # pylint: disable=too-many-branches,too-many-statements + fg, bg, attr = default_colors + + if context.reset: + return default_colors + + elif context.in_browser: + if context.selected: + attr = reverse + else: + attr = normal + if context.empty or context.error: + bg = red + if context.border: + fg = default + if context.media: + if context.image: + fg = yellow + else: + fg = magenta + if context.container: + fg = red + if context.directory: + attr |= bold + fg = blue + fg += BRIGHT + elif context.executable and not \ + any((context.media, context.container, + context.fifo, context.socket)): + attr |= bold + fg = green + fg += BRIGHT + if context.socket: + attr |= bold + fg = magenta + fg += BRIGHT + if context.fifo or context.device: + fg = yellow + if context.device: + attr |= bold + fg += BRIGHT + if context.link: + fg = cyan if context.good else magenta + if context.tag_marker and not context.selected: + attr |= bold + if fg in (red, magenta): + fg = white + else: + fg = red + fg += BRIGHT + if not context.selected and (context.cut or context.copied): + attr |= bold + fg = black + fg += BRIGHT + # If the terminal doesn't support bright colors, use dim white + # instead of black. + if BRIGHT == 0: + attr |= dim + fg = white + if context.main_column: + # Doubling up with BRIGHT here causes issues because it's + # additive not idempotent. + if context.selected: + attr |= bold + if context.marked: + attr |= bold + fg = yellow + if context.badinfo: + if attr & reverse: + bg = magenta + else: + fg = magenta + + if context.inactive_pane: + fg = cyan + + elif context.in_titlebar: + if context.hostname: + fg = red if context.bad else green + elif context.directory: + fg = blue + elif context.tab: + if context.good: + bg = green + elif context.link: + fg = cyan + attr |= bold + + elif context.in_statusbar: + if context.permissions: + if context.good: + fg = cyan + elif context.bad: + fg = magenta + if context.marked: + attr |= bold | reverse + fg = yellow + fg += BRIGHT + if context.frozen: + attr |= bold | reverse + fg = cyan + fg += BRIGHT + if context.message: + if context.bad: + attr |= bold + fg = red + fg += BRIGHT + if context.loaded: + bg = self.progress_bar_color + if context.vcsinfo: + fg = blue + attr &= ~bold + if context.vcscommit: + fg = yellow + attr &= ~bold + if context.vcsdate: + fg = cyan + attr &= ~bold + + if context.text: + if context.highlight: + attr |= reverse + + if context.in_taskview: + if context.title: + fg = blue + + if context.selected: + attr |= reverse + + if context.loaded: + if context.selected: + fg = self.progress_bar_color + else: + bg = self.progress_bar_color + + if context.vcsfile and not context.selected: + attr &= ~bold + if context.vcsconflict: + fg = magenta + elif context.vcsuntracked: + fg = cyan + elif context.vcschanged: + fg = red + elif context.vcsunknown: + fg = red + elif context.vcsstaged: + fg = green + elif context.vcssync: + fg = green + elif context.vcsignored: + fg = default + + elif context.vcsremote and not context.selected: + attr &= ~bold + if context.vcssync or context.vcsnone: + fg = green + elif context.vcsbehind: + fg = red + elif context.vcsahead: + fg = blue + elif context.vcsdiverged: + fg = magenta + elif context.vcsunknown: + fg = red + + return fg, bg, attr diff --git a/misc/ranger/commands.py b/misc/ranger/commands.py new file mode 100644 index 00000000..43addbfd --- /dev/null +++ b/misc/ranger/commands.py @@ -0,0 +1,189 @@ +from ranger.api.commands import Command + +class mkcd(Command): + """ + :mkcd + + Creates a directory with the name 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) + +class toggle_flat(Command): + """ + :toggle_flat + + Flattens or unflattens the directory view. + """ + + def execute(self): + if self.fm.thisdir.flat == 0: + self.fm.thisdir.unload() + self.fm.thisdir.flat = -1 + self.fm.thisdir.load_content() + else: + self.fm.thisdir.unload() + self.fm.thisdir.flat = 0 + self.fm.thisdir.load_content() + +class fzf_select(Command): + """ + :fzf_select + Find a file using fzf. + With a prefix argument to select only directories. + + See: https://github.com/junegunn/fzf + """ + + def execute(self): + import subprocess + import os + from ranger.ext.get_executables import get_executables + + if 'fzf' not in get_executables(): + self.fm.notify('Could not find fzf in the PATH.', bad=True) + return + + fd = None + if 'fdfind' in get_executables(): + fd = 'fdfind' + elif 'fd' in get_executables(): + fd = 'fd' + + if fd is not None: + hidden = ('--hidden' if self.fm.settings.show_hidden else '') + exclude = "--no-ignore-vcs --exclude '.git' --exclude '*.py[co]' --exclude '__pycache__'" + only_directories = ('--type directory' if self.quantifier else '') + fzf_default_command = '{} --follow {} {} {} --color=always'.format( + fd, hidden, exclude, only_directories + ) + else: + hidden = ('-false' if self.fm.settings.show_hidden else r"-path '*/\.*' -prune") + exclude = r"\( -name '\.git' -o -iname '\.*py[co]' -o -fstype 'dev' -o -fstype 'proc' \) -prune" + only_directories = ('-type d' if self.quantifier else '') + fzf_default_command = 'find -L . -mindepth 1 {} -o {} -o {} -print | cut -b3-'.format( + hidden, exclude, only_directories + ) + + env = os.environ.copy() + env['FZF_DEFAULT_COMMAND'] = fzf_default_command + env['FZF_DEFAULT_OPTS'] = '--height=40% --layout=reverse --ansi --preview="{}"'.format(''' + ( + batcat --color=always {} || + bat --color=always {} || + cat {} || + tree -ahpCL 3 -I '.git' -I '*.py[co]' -I '__pycache__' {} + ) 2>/dev/null | head -n 100 + ''') + + fzf = self.fm.execute_command('fzf --no-multi', env=env, + universal_newlines=True, stdout=subprocess.PIPE) + stdout, _ = fzf.communicate() + if fzf.returncode == 0: + selected = os.path.abspath(stdout.strip()) + if os.path.isdir(selected): + self.fm.cd(selected) + else: + self.fm.select_file(selected) + +class fzf_rga_documents_search(Command): + """ + :fzf_rga_search_documents + Search in PDFs, E-Books and Office documents in current directory. + Allowed extensions: .epub, .odt, .docx, .fb2, .ipynb, .pdf. + + Usage: fzf_rga_search_documents + """ + def execute(self): + if self.arg(1): + search_string = self.rest(1) + else: + self.fm.notify("Usage: fzf_rga_search_documents ", bad=True) + return + + import subprocess + import os.path + from ranger.container.file import File + command="rga '%s' . --rga-adapters=pandoc,poppler | fzf +m | awk -F':' '{print $1}'" % search_string + 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')) + self.fm.execute_file(File(fzf_file)) + +class tmsu_tag(Command): + """:tmsu_tag + + Tags the current file with tmsu + """ + + def execute(self): + cf = self.fm.thisfile + + self.fm.run("tmsu tag \"{0}\" {1}".format(cf.basename, self.rest(1))) + + +class YankContent(Command): + """ + Copy the content of image file and text file with xclip + """ + + def execute(self): + + import os + import subprocess + from ranger.container.file import File + from ranger.ext.get_executables import get_executables + if 'xclip' not in get_executables(): + self.fm.notify('xclip is not found.', bad=True) + return + + arg = self.rest(1) + if arg: + if not os.path.isfile(arg): + self.fm.notify('{} is not a file.'.format(arg)) + return + file = File(arg) + else: + file = self.fm.thisfile + if not file.is_file: + self.fm.notify('{} is not a file.'.format(file.relative_path)) + return + + relative_path = file.relative_path + cmd = ['xclip', '-selection', 'clipboard'] + if not file.is_binary(): + with open(file.path, 'rb') as fd: + subprocess.check_call(cmd, stdin=fd) + elif file.image: + cmd += ['-t', file.mimetype, file.path] + subprocess.check_call(cmd) + self.fm.notify('Content of {} is copied to x clipboard'.format(relative_path)) + else: + self.fm.notify('{} is not an image file or a text file.'.format(relative_path)) + + def tab(self, tabnum): + return self._tab_directory_content() diff --git a/misc/ranger/plugins/.gitignore b/misc/ranger/plugins/.gitignore new file mode 100644 index 00000000..bee8a64b --- /dev/null +++ b/misc/ranger/plugins/.gitignore @@ -0,0 +1 @@ +__pycache__ diff --git a/misc/ranger/plugins/__init__.py b/misc/ranger/plugins/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/misc/ranger/plugins/compress.py b/misc/ranger/plugins/compress.py new file mode 100644 index 00000000..8286ea8a --- /dev/null +++ b/misc/ranger/plugins/compress.py @@ -0,0 +1,43 @@ +import os +from ranger.api.commands import * +from ranger.core.loader import CommandLoader + +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 + + # Parsing arguments line + parts = self.line.strip().split() + if len(parts) > 1: + au_flags = [' '.join(parts[1:])] + else: + au_flags = [os.path.basename(self.fm.thisdir.path) + '.zip'] + + # Making description line + files_num = len(marked_files) + files_num_str = str(files_num) + ' objects' if files_num > 1 else '1 object' + descr = "Compressing " + files_num_str + " -> " + os.path.basename(au_flags[0]) + + # Creating archive + 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] diff --git a/misc/ranger/plugins/decrypt.py b/misc/ranger/plugins/decrypt.py new file mode 100644 index 00000000..c8870f46 --- /dev/null +++ b/misc/ranger/plugins/decrypt.py @@ -0,0 +1,33 @@ +import os +import tarfile +from gnupg import GPG +from ranger.api.commands import Command + + +class decrypt(Command): + """:decrypts + + Decrypts a file with gpg or a directory by extracting a tar file and decrypting it + + passing true as the false flag will not delete the origin gpg file + """ + + def execute(self): + gpg = GPG(gnupghome=os.path.join(os.path.expanduser('~'), '.gnupg')) + + paths = [os.path.basename(f.path) for f in self.fm.thistab.get_selection()] + + for p in [p for p in paths if p.endswith('gpg')]: + with open(p, 'rb') as enc: + dec_b = gpg.decrypt_file(enc) + + out_fname = os.path.splitext(p)[0] + with open(out_fname, 'wb+') as dec_f: + dec_f.write(dec_b.data) + + if self.arg(1) != 'true': + os.remove(p) + + if tarfile.is_tarfile(out_fname): + tarfile.open(out_fname).extractall(path='.') + os.remove(out_fname) diff --git a/misc/ranger/plugins/devicons2 b/misc/ranger/plugins/devicons2 new file mode 160000 index 00000000..e4c84986 --- /dev/null +++ b/misc/ranger/plugins/devicons2 @@ -0,0 +1 @@ +Subproject commit e4c849867be272a9f4d092ecf45c8f8788bfe4c9 diff --git a/misc/ranger/plugins/encrypt.py b/misc/ranger/plugins/encrypt.py new file mode 100644 index 00000000..c76a02a9 --- /dev/null +++ b/misc/ranger/plugins/encrypt.py @@ -0,0 +1,55 @@ +import os +import tarfile +from gnupg import GPG +from ranger.api.commands import Command +from subprocess import run + + +class encrypt(Command): + """:encrypt + + Encrypts a file or dir (as a tar.gz) with the default gpg key + """ + + def tardir(self, path): + """:tardir + + tars a directory into a dir of the same name appended with .tar.gz + + returns the name of the tarfile + """ + output_path = path + '.tar.gz' + + with tarfile.open(output_path, "w:gz") as tar_handle: + for root, dirs, files in os.walk(path): + for file in files: + tar_handle.add(os.path.join(root, file)) + + return output_path + + def execute(self): + gpg_home = os.path.join(os.path.expanduser('~'), '.gnupg/') + default_recpipient = os.environ['DEFAULT_RECIPIENT'] + + if not default_recpipient: + self.fm.notify('DEFAULT_RECIPIENT environment variable must be set') + return + + gpg = GPG(gpgbinary='/usr/bin/gpg', gnupghome=gpg_home) + + paths = [os.path.basename(f.path) for f in self.fm.thistab.get_selection()] + + for p in paths: + if os.path.isdir(p): + new_p = self.tardir(p) + run(['rm', '-rf', p]) + p = new_p + + with open(p, 'rb') as f: + enc = gpg.encrypt_file(f, default_recpipient) + + with open(p + '.gpg', 'wb+') as out: + out.write(enc.data) + + if os.path.isfile(p): + os.remove(p) diff --git a/misc/ranger/plugins/extract.py b/misc/ranger/plugins/extract.py new file mode 100644 index 00000000..fc86a869 --- /dev/null +++ b/misc/ranger/plugins/extract.py @@ -0,0 +1,85 @@ +import os +from ranger.api.commands import * +from ranger.core.loader import CommandLoader + +class extract(Command): + def execute(self): + """Extract copied files to current directory or directory + specified in a command line + """ + + cwd = self.fm.thisdir + copied_files = cwd.get_selection() + + if not copied_files: + return + + def refresh(_): + cwd = self.fm.get_directory(original_path) + cwd.load_content() + + one_file = copied_files[0] + cwd = self.fm.thisdir + original_path = cwd.path + + line_args = self.line.split()[1:] + if line_args: + extraction_dir = os.path.join(cwd.path, "".join(line_args)) + os.makedirs(extraction_dir, exist_ok=True) + flags = ['-X', extraction_dir] + flags += ['-e'] + else: + flags = ['-X', cwd.path] + flags += ['-e'] + + self.fm.copy_buffer.clear() + self.fm.cut_buffer = False + + if len(copied_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'] + flags \ + + [f.path for f in copied_files], descr=descr, read=True) + + obj.signal_bind('after', refresh) + self.fm.loader.add(obj) + +class extract_to_dirs(Command): + def execute(self): + """ Extract copied files to a subdirectories """ + + cwd = self.fm.thisdir + original_path = cwd.path + copied_files = cwd.get_selection() + + if not copied_files: + return + + def refresh(_): + cwd = self.fm.get_directory(original_path) + cwd.load_content() + + def make_flags(fn): + fn_wo_ext = os.path.basename(os.path.splitext(fn)[0]) + flags = ['-X', fn_wo_ext] + return flags + + one_file = copied_files[0] + self.fm.copy_buffer.clear() + self.fm.cut_buffer = False + + # Making description line + if len(copied_files) == 1: + descr = "Extracting: " + os.path.basename(one_file.path) + else: + descr = "Extracting files from: " + os.path.basename(one_file.dirname) + + # Extracting files + for f in copied_files: + obj = CommandLoader( + args=['aunpack'] + make_flags(f.path) + [f.path], + descr=descr, read=True + ) + obj.signal_bind('after', refresh) + self.fm.loader.add(obj) diff --git a/misc/ranger/plugins/zjumper_ranger.py b/misc/ranger/plugins/zjumper_ranger.py new file mode 100644 index 00000000..200c55a1 --- /dev/null +++ b/misc/ranger/plugins/zjumper_ranger.py @@ -0,0 +1,29 @@ +import ranger.api +from ranger.api.commands import * +from os import getenv +import re + + +class z(Command): + """:z + Uses .z file to set the current directory. + """ + def execute(self): + + # location of .z file + z_loc = getenv("_Z_DATA") or getenv("HOME")+"/.z" + with open(z_loc,"r") as fobj: + flists = fobj.readlines() + + # user given directory + req = re.compile(".*".join(self.args[1:]),re.IGNORECASE) + directories = [] + for i in flists: + if req.search(i): + directories.append(i.split("|")[0]) + + try: + # smallest(length) directory will be the directory required + self.fm.execute_console("cd " + min(directories,key=lambda x: len(x))) + except Exception as e: + raise Exception("Directory not found") diff --git a/misc/ranger/rc.conf b/misc/ranger/rc.conf index 430b48fd..0ea318f3 100644 --- a/misc/ranger/rc.conf +++ b/misc/ranger/rc.conf @@ -1,103 +1,37 @@ -# =================================================================== -# This file contains the default startup commands for ranger. -# To change them, it is recommended to create the file -# ~/.config/ranger/rc.conf and add your custom commands there. -# -# If you copy this whole file there, you may want to set the environment -# variable RANGER_LOAD_DEFAULT_RC to FALSE to avoid loading it twice. -# -# The purpose of this file is mainly to define keybindings and settings. -# For running more complex python code, please create a plugin in "plugins/" or -# a command in "commands.py". -# -# Each line is a command that will be run before the user interface -# is initialized. As a result, you can not use commands which rely -# on the UI such as :delete or :mark. -# =================================================================== - -# =================================================================== -# == Options -# =================================================================== - -# Which viewmode should be used? Possible values are: -# miller: Use miller columns which show multiple levels of the hierarchy -# multipane: Midnight-commander like multipane view showing all tabs next -# to each other set viewmode miller -#set viewmode multipane -# How many columns are there, and what are their relative widths? set column_ratios 2,2,4 -# Which files should be hidden? (regular expression) set hidden_filter ^\.|\.(?:pyc|pyo|bak|swp)$|^lost\+found$|^__(py)?cache__$ - -# Show hidden files? You can toggle this by typing 'zh' set show_hidden false -# Ask for a confirmation when running the "delete" command? -# Valid values are "always", "never", "multiple" (default) -# With "multiple", ranger will ask only if you delete multiple files at once. +# only confirm when deleting multiple files set confirm_on_delete multiple -# Which script is used to generate file previews? -# ranger ships with scope.sh, a script that calls external programs (see -# README.md for dependencies) to preview images, archives, etc. set preview_script ~/.config/ranger/scope.sh - -# Use the external preview script or display simple plain text or image previews? set use_preview_script true -# Automatically count files in the directory, even before entering them? set automatically_count_files true - -# Open all images in this directory when running certain image viewers -# like feh or sxiv? You can still open selected files by marking them. set open_all_images true # Be aware of version control systems and display information. set vcs_aware true -# State of the three backends git, hg, bzr. The possible states are -# disabled, local (only show local info), enabled (show local and remote -# information). set vcs_backend_git enabled set vcs_backend_hg disabled set vcs_backend_bzr disabled # Use one of the supported image preview protocols set preview_images true - -# Set the preview image method. Supported methods: -# -# * w3m (default): -# Preview images in full color with the external command "w3mimgpreview"? -# This requires the console web browser "w3m" and a supported terminal. -# It has been successfully tested with "xterm" and "urxvt" without tmux. -# -# * iterm2: -# Preview images in full color using iTerm2 image previews -# (http://iterm2.com/images.html). This requires using iTerm2 compiled -# with image preview support. -# -# * urxvt: -# Preview images in full color using urxvt image backgrounds. This -# requires using urxvt compiled with pixbuf support. -# -# * urxvt-full: -# The same as urxvt but utilizing not only the preview pane but the -# whole terminal window. set preview_images_method ueberzug # Use a unicode "..." character to mark cut-off filenames? -set unicode_ellipsis false +set unicode_ellipsis true # Show dotfiles in the bookmark preview box? set show_hidden_bookmarks true -# Which colorscheme to use? These colorschemes are available by default: -# default, jungle, snow, solarized -set colorscheme solarized +set colorscheme material-ocean # Preview files on the rightmost column? # And collapse (shrink) the last column if there is nothing to preview? @@ -106,7 +40,7 @@ set preview_directories true set collapse_preview false # Save the console history on exit? -set save_console_history false +set save_console_history true # Draw the status bar on top of the browser window (default: bottom) set status_bar_on_top false @@ -119,7 +53,7 @@ set draw_progress_bar_in_status_bar true set draw_borders true # Display the directory name in tabs? -set dirname_in_tabs false +set dirname_in_tabs true # Enable the mouse support? set mouse_enabled true @@ -135,7 +69,7 @@ set display_tags_in_all_columns true set update_title true # Set the title to "ranger" in the tmux program? -set update_tmux_title false +set update_tmux_title true # Shorten the title if it gets long? The number defines how many # directories are displayed at once, 0 turns off this feature. @@ -162,7 +96,8 @@ set padding_right true # This helps to synchronize bookmarks between multiple ranger # instances but leads to *slight* performance loss. # When false, bookmarks are saved when ranger is exited. -set autosave_bookmarks true +set autosave_bookmarks false +default_linemode devicons2 # You can display the "real" cumulative size of directories by using the # command :get_cumulative_size or typing "dc". The size is expensive to @@ -275,6 +210,7 @@ map cd console cd%space map Mf linemode filename map Mi linemode fileinfo map Mm linemode mtime +map Md linemode devicons2 map Mp linemode permissions map Ms linemode sizemtime map Mt linemode metatitle @@ -404,11 +340,13 @@ map / console search%space map n search_next map N search_next forward=False map ct search_next order=tag +map cz console z%space map cs search_next order=size map ci search_next order=mimetype map cc search_next order=ctime map cm search_next order=mtime map ca search_next order=atime +map cf fzf_select # Tabs map tab_new ~ @@ -460,6 +398,7 @@ map zc set collapse_preview! map zd set sort_directories_first! map zh set show_hidden! map set show_hidden! +map toggle_flat map zI set flushinput! map zi set preview_images! map zm set mouse_enabled! diff --git a/suckless/dwm/keybind.h b/suckless/dwm/keybind.h index 3468e0ff..5cb79218 100644 --- a/suckless/dwm/keybind.h +++ b/suckless/dwm/keybind.h @@ -47,7 +47,8 @@ static const char *online_class[] = {"/home/yigit/.scripts/tedportal",NULL}; static const char *bwmenu[] = {"/home/yigit/.scripts/password_manager", NULL}; -static const char *network_manager[] = {"/home/yigit/.scripts/networkmanager_dmenu"}; +static const char *network_manager[] = {"/home/yigit/.scripts/networkmanager_dmenu", NULL}; +static const char *killall[] = {"/home/yigit/.scripts/dmenu-killall", NULL}; static const char *mconnect[] = {"/home/yigit/.scripts/dmenu-mconnect"}; static const char *genpwd[] = {"sh", "-c","/sbin/bw generate | xclip" }; static const char *trackpad[] = {"/home/yigit/.scripts/toggle_touchpad.sh"}; @@ -111,6 +112,7 @@ static Key keys[] = { { MODKEY|ShiftMask, XK_q, spawn, {.v = outmenu} }, { MODKEY|ShiftMask, XK_t, spawn, {.v = trackpad} }, { MODKEY, XK_x, spawn, {.v = lock } }, + { MODKEY|ShiftMask, XK_x, spawn, {.v = killall } }, { MODKEY, XK_c, spawn, {.v = clipmenu } }, { MODKEY|ShiftMask, XK_p, spawn, {.v = genpwd} }, { MODKEY|ShiftMask, XK_b, spawn, {.v = bluetooth } }, diff --git a/zsh/aliases b/zsh/aliases index f299f8b5..636b996f 100755 --- a/zsh/aliases +++ b/zsh/aliases @@ -1,6 +1,7 @@ #!/usr/bin/zsh alias feh="feh --scale-down --auto-zoom" +alias cclear="$(which clear)" alias clear="clear && neofetch --ascii ~/.config/neofetch/ascii.txt" alias neofetch="neofetch --ascii ~/.config/neofetch/ascii.txt" alias idea="/home/yigit/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-0/201.7223.91/bin/idea.sh" diff --git a/zsh/antibody/p10k.zsh b/zsh/antibody/p10k.zsh index d5431ac3..11710da6 100644 --- a/zsh/antibody/p10k.zsh +++ b/zsh/antibody/p10k.zsh @@ -78,16 +78,17 @@ # in Pure that makes prompt drift down whenever you use the Alt-C binding from fzf or similar. typeset -g POWERLEVEL9K_PROMPT_ADD_NEWLINE=true + if [ -n "$RANGER_LEVEL" ]; then export MODE="[ranger]"; fi # Magenta prompt symbol if the last command succeeded. typeset -g POWERLEVEL9K_PROMPT_CHAR_OK_{VIINS,VICMD,VIVIS}_FOREGROUND=$magenta # Red prompt symbol if the last command failed. typeset -g POWERLEVEL9K_PROMPT_CHAR_ERROR_{VIINS,VICMD,VIVIS}_FOREGROUND=$red # Default prompt symbol. - typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIINS_CONTENT_EXPANSION='λ' + typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIINS_CONTENT_EXPANSION="$MODE λ" # Prompt symbol in command vi mode. - typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VICMD_CONTENT_EXPANSION='❮λ❯' + typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VICMD_CONTENT_EXPANSION="$MODE❮λ❯" # Prompt symbol in visual vi mode is the same as in command mode. - typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIVIS_CONTENT_EXPANSION='❮λ❯' + typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIVIS_CONTENT_EXPANSION="$MODE❮λ❯" # Prompt symbol in overwrite vi mode is the same as in command mode. typeset -g POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE=false diff --git a/zsh/profile b/zsh/profile index f0e88a47..7074385d 100755 --- a/zsh/profile +++ b/zsh/profile @@ -7,6 +7,7 @@ export FLUTTER_HOME=~/flutter export TMUX_PLUGIN_MANAGER_PATH=~/.tmux/plugins export BORG_KEYS_DIR=~/.keys/borg export BROWSER=firefox-developer-edition +export DEFAULT_RECIPIENT="yigitcolakoglu@hotmail.com" export EDITOR=vim # Setup PATH