diff --git a/.pacman b/.pacman new file mode 100644 index 0000000..61361ae --- /dev/null +++ b/.pacman @@ -0,0 +1,355 @@ +8188eu-aircrack-dkms-git 5.3.9.r145.6146193-1 +acpi 1.7-3 +acpid 2.0.33-1 +adobe-source-han-sans-cn-fonts 2.004-1 +adobe-source-han-sans-jp-fonts 2.004-1 +adobe-source-han-sans-kr-fonts 2.004-1 +alacritty 0.10.0-2 +alsa-firmware 1.2.4-2 +alsa-utils 1.2.6-1 +android-tools 31.0.3-3 +android-udev 20220102-1 +apparmor 3.0.3-3 +appimagelauncher 2.2.0-7 +ark 21.12.2-1 +avahi 0.8+22+gfd482a7-3 +b43-fwcutter 019-3 +bash 5.1.016-2 +bitwarden 1.30.0-1 +bluedevil 1:5.23.5-1 +brave-browser 1.35.100-1 +btrfs-progs 5.16.1-1 +bzip2 1.0.8-4 +cantata 2.4.2-1 +cava 0.7.5-1 +cbonsai 1.3.1-3 +cdparanoia 10.2-8 +cdrdao 1.2.4-2 +coreutils 9.0-2 +cpupower 5.16-1 +crda 4.14-4 +cronie 1.5.7-2 +cryptsetup 2.4.3-2 +cura 4.13.1-1 +device-mapper 2.03.15-1 +dhclient 4.4.2.P1-4 +dhcpcd 9.4.1-1 +dialog 1:1.3_20220117-1 +diffutils 3.8-1 +discord 0.0.17-1 +dmenu 5.0-1 +dmidecode 3.3-1 +dmraid 1.0.0.rc16.3-13 +dnsmasq 2.86-1 +docker 1:20.10.12-1 +dolphin 21.12.2.1-1 +dolphin-plugins 21.12.2-1 +dosfstools 4.2-2 +dvd+rw-tools 7.1-9 +e2fsprogs 1.46.5-2 +ecryptfs-utils 111-5 +efibootmgr 17-2 +emovix 0.9.0-8 +exa 0.10.1-4 +exfat-utils 1.3.0-2 +expressvpn 3.16.0.4_1-1 +f2fs-tools 1.14.0-3 +feh 3.8-1 +ffmpeg 2:4.4.1-1 +ffmpegthumbs 21.12.2-1 +file 5.41-1 +filelight 21.12.2-1 +filesystem 2021.12.07-3 +findutils 4.9.0-1 +firefox 97.0.1-0.1 +fwupd 1.7.5-1 +gawk 5.1.1-1 +gcc-libs 11.1.0-3 +gedit 40.1-3 +gettext 0.21-1 +glibc 2.33-5 +gnome-icon-theme 3.12.0-6 +gnome-layout-switcher 0.8.22-5 +gnome-notes 40.1-1 +gnome-themes-extra 3.28+r6+g45b1d457-1 +gparted 1.3.1-1 +grep 3.7-1 +grub 2.06-4 +grub-theme-manjaro 20.2-12 +gst-libav 1.18.5-1 +gst-plugins-bad 1.18.5-5 +gst-plugins-base 1.18.5-1 +gst-plugins-good 1.18.5-2 +gst-plugins-ugly 1.18.5-2 +gtk3 1:3.24.31-1 +gufw 21.04.0-2 +gvfs 1.48.1-1 +gvfs-afc 1.48.1-1 +gvfs-gphoto2 1.48.1-1 +gvfs-mtp 1.48.1-1 +gvfs-nfs 1.48.1-1 +gvfs-smb 1.48.1-1 +gwenview 21.12.2-1 +gzip 1.11-1 +haveged 1.9.17-1 +htop 3.1.2-1 +i3-gaps 4.20.1-2 +i3lock 2.13-1 +i3status 2.14-1 +illyria-wallpaper 1.4-1 +inetutils 2.2-1 +intel-ucode 20210608-1 +inxi 3.3.13.1-1 +iproute2 5.16.0-1 +iputils 20211215-1 +iwd 1.24-2 +jfsutils 1.1.15-7 +k3b 1:21.12.2-1 +kaccounts-providers 21.12.2-1 +kamera 21.12.2-1 +kate 21.12.2-1 +kcalc 21.12.2-1 +kde-gtk-config 5.23.5-1 +kdeconnect 21.12.2-1 +kdegraphics-thumbnailers 21.12.2-1 +kdenetwork-filesharing 21.12.2-1 +kdeplasma-addons 5.23.5-1 +keditbookmarks 21.12.2-1 +kernel-alive 0.5.1-1 +kfind 21.12.2-1 +kgamma5 5.23.5-1 +kget 21.12.2-1 +khelpcenter 21.12.2-1 +khotkeys 5.23.5-1 +kimageformats 5.90.0-1 +kinfocenter 5.23.5-1 +kio-extras 21.12.2-1 +kmenuedit 5.23.5-1 +konsole 21.12.2-1 +konversation 21.12.2-1 +kscreen 5.23.5-1 +kscreenlocker 5.23.5-1 +ksshaskpass 5.23.5-1 +ksysguard 5.22.0-1 +ksystemlog 21.12.2-1 +kwallet-pam 5.23.5-1 +kwalletmanager 21.12.2-1 +kwayland-integration 5.23.5-1 +kwin 5.23.5-1 +kwrited 5.23.5-1 +less 1:590-1 +lib32-libcanberra 0.30+2+gc0620e4-5 +lib32-libva-intel-driver 2.4.1-1 +lib32-libva-mesa-driver 21.3.5-1 +lib32-libva-vdpau-driver 0.7.4-6 +lib32-mesa-demos 8.4.0-3 +lib32-mesa-vdpau 21.3.5-1 +lib32-nvidia-utils 510.47.03-1 +lib32-vulkan-intel 21.3.5-1 +lib32-vulkan-radeon 21.3.5-1 +libcanberra 0.30+2+gc0620e4-5 +libdvdcss 1.4.3-1 +libktorrent 21.12.2-1 +libreoffice-fresh 7.3.0-4 +libva-intel-driver 2.4.1-1 +libva-mesa-driver 21.3.5-1 +libva-vdpau-driver 0.7.4-5 +libxnvctrl 510.47.03-1 +licenses 20220125-1 +linux419-headers 4.19.227-1 +linux419-nvidia 510.47.03-1 +linux510 5.10.98-1 +linux510-headers 5.10.98-1 +linux510-nvidia 510.47.03-3 +logrotate 3.19.0-1 +lvm2 2.03.15-1 +man-db 2.10.0-1 +man-pages 5.13-1 +manjaro-alsa 20210928-1 +manjaro-application-utility 1.3.3-6 +manjaro-browser-settings 20201114-1 +manjaro-documentation-en 20181009-1 +manjaro-firmware 20160419-1 +manjaro-hello 0.6.7-2 +manjaro-hotfixes 2018.08-6 +manjaro-kde-settings 20220130-1 +manjaro-printer 20200215-2 +manjaro-pulse 20220217-2 +manjaro-release 21.2.3-1 +manjaro-settings-manager-kcm 0.5.7-1 +manjaro-settings-manager-knotifier 0.5.7-1 +manjaro-system 20220202-2 +manjaro-wallpapers-18.0 1.4-3 +manjaro-zsh-config 0.22-2 +mdadm 4.2-1 +memtest86+ 5.31b-1 +mesa-demos 8.4.0-7 +mesa-vdpau 21.3.5-1 +mhwd 0.6.5-2 +mhwd-db 0.6.5-21 +milou 5.23.5-1 +minecraft-launcher 928-1 +mkinitcpio-openswap 0.1.0-3 +mobile-broadband-provider-info 20210805-1 +modemmanager 1.18.4-1 +mpd 0.23.5-1 +mtpfs 1.1-4 +nano 6.0-1 +neofetch 7.1.0-2 +nerdfetch 4.1-1 +netctl 1.27-1 +networkmanager 1.34.0-1 +networkmanager-openconnect 1.2.7dev+65+gca4187c-1 +networkmanager-openvpn 1.8.16-1 +networkmanager-pptp 1.2.9dev+10+gb41b0d0-4 +networkmanager-vpnc 1.2.7dev+20+gdca3aea-2 +nfs-utils 2.6.1-1 +nmap 7.92-1 +nodejs 17.3.0-1 +noto-fonts 20201226-2 +noto-fonts-emoji 20211101-1 +npm 8.4.1-1 +nss-mdns 0.15.1-1 +ntfs-3g 2021.8.22-1 +ntp 4.2.8.p15-1 +numlockx 1.2-5 +nvidia-utils 510.47.03-4 +okular 21.12.2-1 +openbsd-netcat 1.218_2-1 +openresolv 3.12.0-1 +openssh 8.8p1-1 +os-prober 1.79-1 +oxygen 5.23.5-1 +oxygen-icons 1:5.90.0-1 +p7zip 1:17.04-3 +pacman 6.0.1-3 +pamac-cli 10.3.0-5 +pamac-gtk 10.3.0-5 +pamac-tray-icon-plasma 0.1.2-4 +partitionmanager 21.12.2-1 +pciutils 3.7.0-2 +perl 5.34.0-3 +perl-file-mimeinfo 0.30-2 +pfetch-git r395.da06a5c-1 +phonon-qt5-gstreamer 4.10.0-3 +picom 8.2-1 +plasma-desktop 5.23.5-2 +plasma-nm 5.23.5-1 +plasma-pa 5.23.5-1 +plasma-simplemenu 1.0.12-1 +plasma-systemmonitor 5.23.5-1 +plasma-workspace 5.23.5-2 +plasma-workspace-wallpapers 5.23.5-1 +plex-media-server 1.25.3.5409-1 +poppler-data 0.4.11-1 +powerdevil 5.23.5-1 +powertop 2.14-1 +print-manager 21.12.2-1 +procps-ng 3.3.17-1 +psmisc 23.4-1 +pulseaudio-bluetooth 15.0-1 +pulseaudio-ctl 1.70-1 +pulseaudio-zeroconf 15.0-1 +pycharm-community-edition 2021.3.2-1 +python-pillow 9.0.1-1 +python-pip 20.3.4-4 +python-pyqt5 5.15.6-7 +python-pysmbc 1.0.23-3 +python-reportlab 3.6.6-1 +qbittorrent 4.4.0-2 +qemu 6.2.0-2 +qt5-imageformats 5.15.2-2 +qt5-virtualkeyboard 5.15.2+kde+r6-2 +r8152-dkms 2.15.20211119-1 +ranger 1.9.3+428+g0b77fb8a-1 +reiserfsprogs 3.6.27-3 +rofi 1.7.3-1 +rsync 3.2.3-4 +rtl8192cu-fixes-git r115.33a1e27-1 +rtl88x2bu-dkms-git 5.13.1.r153.aea996c-1 +ruby 3.0.3-1 +s-nail 14.9.23-1 +samba 4.15.5-1 +screenfetch 3.9.1-1 +scrot 1.7-1 +sddm 0.19.0-8 +sddm-breath-theme 21.2.0-2 +sddm-kcm 5.23.5-1 +sed 4.8-1 +shadow 4.11.1-1 +skanlite 21.12.2-1 +snapd 2.54.2-2 +snapd-glib 1.59-1 +spectacle 21.12.2-1 +spectre-meltdown-checker 0.44+15+ga485c78-1 +spotify-tui 0.25.0-1 +spotifyd 0.3.3-1 +sshfs 3.7.2-2 +steam-manjaro 1.0.0.74-1 +stow 2.3.1-3 +sudo 1.9.9-2 +sysfsutils 2.1.1-1 +system-config-printer 1.5.15-2 +systemd 250.3-3 +systemd-fsck-silent 239-1 +systemd-kcm 1.2.1-5 +systemd-sysvcompat 250.3-3 +systemsettings 5.23.5-1 +tar 1.34-1 +telegram-desktop 3.5.0-1 +terminator 2.1.1-3 +terminus-font 4.49.1-2 +texinfo 6.8-2 +thunderbird 91.6.1-0.1 +timeshift 21.09.1-3 +tlp 1.5.0-3 +transcode 1.1.7-40 +ttf-dejavu 2.37+18+g9b5d1b2f-3 +ttf-droid 20121017-10 +ttf-inconsolata 1:3.000-3 +ttf-indic-otf 0.2-11 +ttf-liberation 2.1.5-1 +udiskie 2.4.1-1 +udisks2 2.9.4-1 +unarchiver 1.10.7-5 +usb_modeswitch 2.6.1-1 +usbutils 014-2 +util-linux 2.37.3-2 +vcdimager 2.0.1-4 +vde2 2.3.2-19 +vi 1:070224-5 +vim 8.2.4106-1 +virt-manager 3.2.0-4 +virt-viewer 11.0-1 +virtualbox 6.1.32-1 +vlc 3.0.16-7 +vulkan-intel 21.3.5-1 +vulkan-radeon 21.3.5-1 +wallpapers-2018 1.2-1 +wallpapers-juhraya 1.1-2 +wget 1.21.2-1 +which 2.21-5 +wpa_supplicant 2:2.10-1 +xdg-desktop-portal 1.12.1-1 +xdg-desktop-portal-kde 5.23.5-1 +xdg-user-dirs 0.17-3 +xdg-utils 1.1.3+19+g9816ebb-1 +xf86-input-elographics 1.4.2-3 +xf86-input-evdev 2.10.6-3 +xf86-input-libinput 1.2.1-1 +xf86-input-void 1.4.1-6 +xf86-video-amdgpu 21.0.0-2 +xf86-video-ati 1:19.1.0.r9.g5eba006e-2 +xf86-video-intel 1:2.99.917+916+g31486f40-2 +xf86-video-nouveau 1.0.17-2 +xfsprogs 5.14.2-1 +xorg-mkfontscale 1.2.1-2 +xorg-server 21.1.3-2 +xorg-twm 1.0.11-1 +xorg-xinit 1.4.1-3 +xorg-xkill 1.0.5-2 +xscreensaver 6.02-1 +xz 5.2.5-2 +yakuake 21.12.2-1 +yay 11.1.1-1 +zensu 0.3-6 diff --git a/i3/.config/i3/config b/i3/.config/i3/config index ae810f3..8ae4c77 100644 --- a/i3/.config/i3/config +++ b/i3/.config/i3/config @@ -195,7 +195,7 @@ bar { } # set background on startup -exec --no-startup-id feh --bg-fill ~/Pictures/mountains.jpg +exec --no-startup-id feh --bg-fill ~/Pictures/mountains2.jpg # turn picom on on start up exec_always --no-startup-id picom & @@ -211,4 +211,5 @@ set $bd-color #ff004b client.focused $bd-color #111111 #ffffff $ffffff $ffffff # lock screen -bindsym $mod+l exec ~/lock.sh +# bindsym $mod+l exec ~/lock.sh +bindsym $mod+1 exec i3lock diff --git a/ranger/.config/ranger/commands.py b/ranger/.config/ranger/commands.py new file mode 100644 index 0000000..2031756 --- /dev/null +++ b/ranger/.config/ranger/commands.py @@ -0,0 +1,62 @@ +# This is a sample commands.py. You can add your own commands here. +# +# Please refer to commands_full.py for all the default commands and a complete +# documentation. Do NOT add them all here, or you may end up with defunct +# commands when upgrading ranger. + +# A simple command for demonstration purposes follows. +# ----------------------------------------------------------------------------- + +from __future__ import (absolute_import, division, print_function) + +# You can import any python module as needed. +import os + +# You always need to import ranger.api.commands here to get the Command class: +from ranger.api.commands import Command + + +# Any class that is a subclass of "Command" will be integrated into ranger as a +# command. Try typing ":my_edit" in ranger! +class my_edit(Command): + # The so-called doc-string of the class will be visible in the built-in + # help that is accessible by typing "?c" inside ranger. + """:my_edit + + A sample command for demonstration purposes that opens a file in an editor. + """ + + # The execute method is called when you run this command in ranger. + def execute(self): + # self.arg(1) is the first (space-separated) argument to the function. + # This way you can write ":my_edit somefilename". + if self.arg(1): + # self.rest(1) contains self.arg(1) and everything that follows + target_filename = self.rest(1) + else: + # self.fm is a ranger.core.filemanager.FileManager object and gives + # you access to internals of ranger. + # self.fm.thisfile is a ranger.container.file.File object and is a + # reference to the currently selected file. + target_filename = self.fm.thisfile.path + + # This is a generic function to print text in ranger. + self.fm.notify("Let's edit the file " + target_filename + "!") + + # Using bad=True in fm.notify allows you to print error messages: + if not os.path.exists(target_filename): + self.fm.notify("The given file does not exist!", bad=True) + return + + # This executes a function from ranger.core.actions, a module with a + # variety of subroutines that can help you construct commands. + # Check out the source, or run "pydoc ranger.core.actions" for a list. + self.fm.edit_file(target_filename) + + # The tab method is called when you press tab, and should return a list of + # suggestions that the user will tab through. + # tabnum is 1 for and -1 for by default + def tab(self, tabnum): + # This is a generic tab-completion function that iterates through the + # content of the current directory. + return self._tab_directory_content() diff --git a/ranger/.config/ranger/commands_full.py b/ranger/.config/ranger/commands_full.py new file mode 100644 index 0000000..43c4993 --- /dev/null +++ b/ranger/.config/ranger/commands_full.py @@ -0,0 +1,2100 @@ +# -*- coding: utf-8 -*- +# This file is part of ranger, the console file manager. +# This configuration file is licensed under the same terms as ranger. +# =================================================================== +# +# NOTE: If you copied this file to /etc/ranger/commands_full.py or +# ~/.config/ranger/commands_full.py, then it will NOT be loaded by ranger, +# and only serve as a reference. +# +# =================================================================== +# This file contains ranger's commands. +# It's all in python; lines beginning with # are comments. +# +# Note that additional commands are automatically generated from the methods +# of the class ranger.core.actions.Actions. +# +# You can customize commands in the files /etc/ranger/commands.py (system-wide) +# and ~/.config/ranger/commands.py (per user). +# They have the same syntax as this file. In fact, you can just copy this +# file to ~/.config/ranger/commands_full.py with +# `ranger --copy-config=commands_full' and make your modifications, don't +# forget to rename it to commands.py. You can also use +# `ranger --copy-config=commands' to copy a short sample commands.py that +# has everything you need to get started. +# But make sure you update your configs when you update ranger. +# +# =================================================================== +# Every class defined here which is a subclass of `Command' will be used as a +# command in ranger. Several methods are defined to interface with ranger: +# execute(): called when the command is executed. +# cancel(): called when closing the console. +# tab(tabnum): called when is pressed. +# quick(): called after each keypress. +# +# tab() argument tabnum is 1 for and -1 for by default +# +# The return values for tab() can be either: +# None: There is no tab completion +# A string: Change the console to this string +# A list/tuple/generator: cycle through every item in it +# +# The return value for quick() can be: +# False: Nothing happens +# True: Execute the command afterwards +# +# The return value for execute() and cancel() doesn't matter. +# +# =================================================================== +# Commands have certain attributes and methods that facilitate parsing of +# the arguments: +# +# self.line: The whole line that was written in the console. +# self.args: A list of all (space-separated) arguments to the command. +# self.quantifier: If this command was mapped to the key "X" and +# the user pressed 6X, self.quantifier will be 6. +# self.arg(n): The n-th argument, or an empty string if it doesn't exist. +# self.rest(n): The n-th argument plus everything that followed. For example, +# if the command was "search foo bar a b c", rest(2) will be "bar a b c" +# self.start(n): Anything before the n-th argument. For example, if the +# command was "search foo bar a b c", start(2) will be "search foo" +# +# =================================================================== +# And this is a little reference for common ranger functions and objects: +# +# self.fm: A reference to the "fm" object which contains most information +# about ranger. +# self.fm.notify(string): Print the given string on the screen. +# self.fm.notify(string, bad=True): Print the given string in RED. +# self.fm.reload_cwd(): Reload the current working directory. +# self.fm.thisdir: The current working directory. (A File object.) +# self.fm.thisfile: The current file. (A File object too.) +# self.fm.thistab.get_selection(): A list of all selected files. +# self.fm.execute_console(string): Execute the string as a ranger command. +# self.fm.open_console(string): Open the console with the given string +# already typed in for you. +# self.fm.move(direction): Moves the cursor in the given direction, which +# can be something like down=3, up=5, right=1, left=1, to=6, ... +# +# File objects (for example self.fm.thisfile) have these useful attributes and +# methods: +# +# tfile.path: The path to the file. +# tfile.basename: The base name only. +# tfile.load_content(): Force a loading of the directories content (which +# obviously works with directories only) +# tfile.is_directory: True/False depending on whether it's a directory. +# +# For advanced commands it is unavoidable to dive a bit into the source code +# of ranger. +# =================================================================== + +from __future__ import (absolute_import, division, print_function) + +from collections import deque +import os +import re +from io import open + +from ranger import PY3 +from ranger.api.commands import Command + + +class alias(Command): + """:alias + + Copies the oldcommand as newcommand. + """ + + context = 'browser' + resolve_macros = False + + def execute(self): + if not self.arg(1) or not self.arg(2): + self.fm.notify('Syntax: alias ', bad=True) + return + + self.fm.commands.alias(self.arg(1), self.rest(2)) + + +class echo(Command): + """:echo + + Display the text in the statusbar. + """ + + def execute(self): + self.fm.notify(self.rest(1)) + + +class cd(Command): + """:cd [-r] + + The cd command changes the directory. + If the path is a file, selects that file. + The command 'cd -' is equivalent to typing ``. + Using the option "-r" will get you to the real path. + """ + + def execute(self): + if self.arg(1) == '-r': + self.shift() + destination = os.path.realpath(self.rest(1)) + if os.path.isfile(destination): + self.fm.select_file(destination) + return + else: + destination = self.rest(1) + + if not destination: + destination = '~' + + if destination == '-': + self.fm.enter_bookmark('`') + else: + self.fm.cd(destination) + + def _tab_args(self): + # dest must be rest because path could contain spaces + if self.arg(1) == '-r': + start = self.start(2) + dest = self.rest(2) + else: + start = self.start(1) + dest = self.rest(1) + + if dest: + head, tail = os.path.split(os.path.expanduser(dest)) + if head: + dest_exp = os.path.join(os.path.normpath(head), tail) + else: + dest_exp = tail + else: + dest_exp = '' + return (start, dest_exp, os.path.join(self.fm.thisdir.path, dest_exp), + dest.endswith(os.path.sep)) + + @staticmethod + def _tab_paths(dest, dest_abs, ends_with_sep): + if not dest: + try: + return next(os.walk(dest_abs))[1], dest_abs + except (OSError, StopIteration): + return [], '' + + if ends_with_sep: + try: + return [os.path.join(dest, path) for path in next(os.walk(dest_abs))[1]], '' + except (OSError, StopIteration): + return [], '' + + return None, None + + def _tab_match(self, path_user, path_file): + if self.fm.settings.cd_tab_case == 'insensitive': + path_user = path_user.lower() + path_file = path_file.lower() + elif self.fm.settings.cd_tab_case == 'smart' and path_user.islower(): + path_file = path_file.lower() + return path_file.startswith(path_user) + + def _tab_normal(self, dest, dest_abs): + dest_dir = os.path.dirname(dest) + dest_base = os.path.basename(dest) + + try: + dirnames = next(os.walk(os.path.dirname(dest_abs)))[1] + except (OSError, StopIteration): + return [], '' + + return [os.path.join(dest_dir, d) for d in dirnames if self._tab_match(dest_base, d)], '' + + def _tab_fuzzy_match(self, basepath, tokens): + """ Find directories matching tokens recursively """ + if not tokens: + tokens = [''] + paths = [basepath] + while True: + token = tokens.pop() + matches = [] + for path in paths: + try: + directories = next(os.walk(path))[1] + except (OSError, StopIteration): + continue + matches += [os.path.join(path, d) for d in directories + if self._tab_match(token, d)] + if not tokens or not matches: + return matches + paths = matches + + return None + + def _tab_fuzzy(self, dest, dest_abs): + tokens = [] + basepath = dest_abs + while True: + basepath_old = basepath + basepath, token = os.path.split(basepath) + if basepath == basepath_old: + break + if os.path.isdir(basepath_old) and not token.startswith('.'): + basepath = basepath_old + break + tokens.append(token) + + paths = self._tab_fuzzy_match(basepath, tokens) + if not os.path.isabs(dest): + paths_rel = self.fm.thisdir.path + paths = [os.path.relpath(os.path.join(basepath, path), paths_rel) + for path in paths] + else: + paths_rel = '' + return paths, paths_rel + + def tab(self, tabnum): + from os.path import sep + + start, dest, dest_abs, ends_with_sep = self._tab_args() + + paths, paths_rel = self._tab_paths(dest, dest_abs, ends_with_sep) + if paths is None: + if self.fm.settings.cd_tab_fuzzy: + paths, paths_rel = self._tab_fuzzy(dest, dest_abs) + else: + paths, paths_rel = self._tab_normal(dest, dest_abs) + + paths.sort() + + if self.fm.settings.cd_bookmarks: + paths[0:0] = [ + os.path.relpath(v.path, paths_rel) if paths_rel else v.path + for v in self.fm.bookmarks.dct.values() for path in paths + if v.path.startswith(os.path.join(paths_rel, path) + sep) + ] + + if not paths: + return None + if len(paths) == 1: + return start + paths[0] + sep + return [start + dirname + sep for dirname in paths] + + +class chain(Command): + """:chain ; ; ... + + Calls multiple commands at once, separated by semicolons. + """ + resolve_macros = False + + def execute(self): + if not self.rest(1).strip(): + self.fm.notify('Syntax: chain ; ; ...', bad=True) + return + for command in [s.strip() for s in self.rest(1).split(";")]: + self.fm.execute_console(command) + + +class shell(Command): + escape_macros_for_shell = True + + def execute(self): + if self.arg(1) and self.arg(1)[0] == '-': + flags = self.arg(1)[1:] + command = self.rest(2) + else: + flags = '' + command = self.rest(1) + + if command: + self.fm.execute_command(command, flags=flags) + + def tab(self, tabnum): + from ranger.ext.get_executables import get_executables + if self.arg(1) and self.arg(1)[0] == '-': + command = self.rest(2) + else: + command = self.rest(1) + start = self.line[0:len(self.line) - len(command)] + + try: + position_of_last_space = command.rindex(" ") + except ValueError: + return (start + program + ' ' for program + in get_executables() if program.startswith(command)) + if position_of_last_space == len(command) - 1: + selection = self.fm.thistab.get_selection() + if len(selection) == 1: + return self.line + selection[0].shell_escaped_basename + ' ' + return self.line + '%s ' + + before_word, start_of_word = self.line.rsplit(' ', 1) + return (before_word + ' ' + file.shell_escaped_basename + for file in self.fm.thisdir.files or [] + if file.shell_escaped_basename.startswith(start_of_word)) + + +class open_with(Command): + + def execute(self): + app, flags, mode = self._get_app_flags_mode(self.rest(1)) + self.fm.execute_file( + files=self.fm.thistab.get_selection(), + app=app, + flags=flags, + mode=mode) + + def tab(self, tabnum): + return self._tab_through_executables() + + def _get_app_flags_mode(self, string): # pylint: disable=too-many-branches,too-many-statements + """Extracts the application, flags and mode from a string. + + examples: + "mplayer f 1" => ("mplayer", "f", 1) + "atool 4" => ("atool", "", 4) + "p" => ("", "p", 0) + "" => None + """ + + app = '' + flags = '' + mode = 0 + split = string.split() + + if len(split) == 1: + part = split[0] + if self._is_app(part): + app = part + elif self._is_flags(part): + flags = part + elif self._is_mode(part): + mode = part + + elif len(split) == 2: + part0 = split[0] + part1 = split[1] + + if self._is_app(part0): + app = part0 + if self._is_flags(part1): + flags = part1 + elif self._is_mode(part1): + mode = part1 + elif self._is_flags(part0): + flags = part0 + if self._is_mode(part1): + mode = part1 + elif self._is_mode(part0): + mode = part0 + if self._is_flags(part1): + flags = part1 + + elif len(split) >= 3: + part0 = split[0] + part1 = split[1] + part2 = split[2] + + if self._is_app(part0): + app = part0 + if self._is_flags(part1): + flags = part1 + if self._is_mode(part2): + mode = part2 + elif self._is_mode(part1): + mode = part1 + if self._is_flags(part2): + flags = part2 + elif self._is_flags(part0): + flags = part0 + if self._is_mode(part1): + mode = part1 + elif self._is_mode(part0): + mode = part0 + if self._is_flags(part1): + flags = part1 + + return app, flags, int(mode) + + def _is_app(self, arg): + return not self._is_flags(arg) and not arg.isdigit() + + @staticmethod + def _is_flags(arg): + from ranger.core.runner import ALLOWED_FLAGS + return all(x in ALLOWED_FLAGS for x in arg) + + @staticmethod + def _is_mode(arg): + return all(x in '0123456789' for x in arg) + + +class set_(Command): + """:set