From 6f07d96ea0000708202846433605a3c886a271c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Fernando=20S=C3=A1nchez?= Date: Thu, 7 Dec 2017 17:11:32 +0100 Subject: [PATCH] Several changes * Added ranger * Update vim airline * Added udiskie and * Updated i3 status * Updated zsh paths to load even when not in a login session --- i3/.config/i3/config | 20 +- i3/.config/i3/i3blocks.conf | 6 +- i3/.config/i3/status.conf | 77 ++ i3/.config/i3status/conf | 62 + not_dots/50-synaptics.conf | 3 +- not_dots/50-udiskie.rules | 25 + ranger/.config/ranger/bookmarks | 3 + ranger/.config/ranger/commands.py | 61 + ranger/.config/ranger/commands_full.py | 1486 ++++++++++++++++++++++++ ranger/.config/ranger/history | 50 + ranger/.config/ranger/rc.conf | 615 ++++++++++ ranger/.config/ranger/rifle.conf | 211 ++++ ranger/.config/ranger/scope.sh | 121 ++ ranger/.config/ranger/tagged | 0 scripts/.bin/runmenu | 2 +- vim/.vimrc | 1 + zsh/.zprofile | 50 +- zsh/.zshenv | 52 +- 18 files changed, 2783 insertions(+), 62 deletions(-) create mode 100644 i3/.config/i3/status.conf create mode 100644 i3/.config/i3status/conf create mode 100644 not_dots/50-udiskie.rules create mode 100644 ranger/.config/ranger/bookmarks create mode 100644 ranger/.config/ranger/commands.py create mode 100644 ranger/.config/ranger/commands_full.py create mode 100644 ranger/.config/ranger/history create mode 100644 ranger/.config/ranger/rc.conf create mode 100644 ranger/.config/ranger/rifle.conf create mode 100755 ranger/.config/ranger/scope.sh create mode 100644 ranger/.config/ranger/tagged mode change 120000 => 100644 zsh/.zshenv diff --git a/i3/.config/i3/config b/i3/.config/i3/config index f4294d6..2b70249 100644 --- a/i3/.config/i3/config +++ b/i3/.config/i3/config @@ -23,18 +23,22 @@ floating_modifier $mod #bindsym $mod+Return exec --no-startup-id i3-one-tmux bindsym $mod+Return [title="^scratch"] scratchpad show bindsym Control+Mod1+t exec --no-startup-id i3-sensible-terminal +bindsym Control+Mod1+Shift+t exec --no-startup-id i3-sensible-terminal --title=scratch -e 'tmux attach' + +# File manager +bindsym Control+Mod1+f exec --no-startup-id i3-sensible-terminal --title=filemanager -e 'zsh -c ranger' # start lock bindsym Control+Mod1+l exec --no-startup-id i3-exit.sh lock -bindsym Control+Mod1+w exec --no-startup-id chromium || chromium-browser -bindsym Control+Mod1+Shift+w exec --no-startup-id firefox +bindsym Control+Mod1+Shift+w exec --no-startup-id chromium || chromium-browser +bindsym Control+Mod1+w exec --no-startup-id firefox bindsym Control+Mod1+v exec --no-startup-id pavucontrol bindsym Control+Mod1+g exec --no-startup-id gvim bindsym Control+Mod1+e exec --no-startup-id myemacs -c bindsym $mod+Tab exec --no-startup-id winmenu.sh bindsym Mod1+Tab exec --no-startup-id winmenu.sh -bindsym $mod+p [class="Nemo|Thunar|Ranger"] scratchpad show +bindsym $mod+p [title="filemanager"] scratchpad show; [class="Nemo|Thunar"] scratchpad show bindsym $mod+period [instance="emacs" title="^(?!myagenda$)"] scratchpad show bindsym $mod+shift+comma exec --no-startup-id myemacs -nc --eval '(progn (find-file "~/Dropbox/Todo/org/rules.org") (org-agenda-list) (set-frame-name "myagenda"))' bindsym $mod+c exec myemacs -n -e '(make-capture-frame)' @@ -222,7 +226,7 @@ bindsym $mod+n exec i3-input -F 'rename workspace to %s' -P 'New name: ' # Start i3bar to display a workspace bar (plus the system information i3status # finds out, if available) #bar { - #status_command i3status +#status_command i3status #} bar { @@ -230,10 +234,11 @@ bar { position top font pango:DejaVu Sans 10 workspace_buttons yes - status_command ~/.config/i3/status.sh + # status_command ~/.config/i3/status.sh + status_command i3status -c ~/.config/i3status/conf colors { background #101010 - statusline #101010 + statusline #ffffff focused_workspace #101010 #586e75 #fdf6e3 active_workspace #101010 #101010 #cb4b16 inactive_workspace #101010 #101010 #93a1a1 @@ -264,6 +269,7 @@ for_window [class="^lxterminal"] border 1px for_window [class="^xfce4-terminal"] border 1px for_window [title="^scratch"] move to scratchpad for_window [class="^Nemo|Thunar|Ranger"] move to scratchpad; +for_window [title="filemanager"] move to scratchpad; #KDE for_window [class="Plasma-desktop"] border none for_window [class="krunner"] border none @@ -309,7 +315,7 @@ bindsym $mod+Escape exec xfce4-session-logout #exec xautolock -time 10 -corners "----" -locker 'i3lock -t -c 000000 -i ~/Pictures/Wallpapers/Game\ Over\ Hacker.png' & exec --no-startup-id compton -b --config ~/.compton.conf exec --no-startup-id dropbox start -exec --no-startup-id nemo --no-desktop +exec --no-startup-id i3-sensible-terminal --title=filemanager -e 'ranger' exec --no-startup-id nitrogen --restore exec --no-startup-id nm-applet exec --no-startup-id pasystray diff --git a/i3/.config/i3/i3blocks.conf b/i3/.config/i3/i3blocks.conf index ff1c317..8a6ce4f 100644 --- a/i3/.config/i3/i3blocks.conf +++ b/i3/.config/i3/i3blocks.conf @@ -26,7 +26,7 @@ # Each block command defaults to the script name to avoid boilerplate. command=$SCRIPT_DIR/$BLOCK_NAME separator_block_width=15 -markup=none +markup=pango color=#FFFFFF # Volume indicator @@ -140,8 +140,8 @@ interval=5 # OpenVPN support # # Support multiple VPN, with colors. -#[openvpn] -#interval=20 +# [openvpn] +# interval=20 # Key indicators # diff --git a/i3/.config/i3/status.conf b/i3/.config/i3/status.conf new file mode 100644 index 0000000..a384d62 --- /dev/null +++ b/i3/.config/i3/status.conf @@ -0,0 +1,77 @@ +general { + output_format = "dzen2" + colors = true + interval = 5 +} + +order += "ipv6" +order += "disk /" +order += "run_watch DHCP" +order += "run_watch VPNC" +order += "path_exists VPN" +order += "wireless wlan0" +order += "ethernet eth0" +order += "battery 0" +# order += "cpu_temperature 0" +order += "load" +order += "tztime local" +order += "tztime berlin" + +wireless wlan0 { + format_up = "W: (%quality at %essid, %bitrate) %ip" + format_down = "W: down" +} + +ethernet eth0 { + # if you use %speed, i3status requires the cap_net_admin capability + format_up = "E: %ip (%speed) " + format_down = "E: down" +} + +battery 0 { + format = "%status %percentage %remaining %emptytime" + format_down = "No battery" + status_chr = "⚡ CHR" + status_bat = "🔋 BAT" + status_unk = "? UNK" + status_full = "☻ FULL" + path = "/sys/class/power_supply/BAT0/uevent" + low_threshold = 10 +} + +run_watch DHCP { + pidfile = "/var/run/dhclient*.pid" +} + +run_watch VPNC { + # file containing the PID of a vpnc process + pidfile = "/var/run/vpnc/pid" +} + +path_exists VPN { + # path exists when a VPN tunnel launched by nmcli/nm-applet is active + path = "/proc/sys/net/ipv4/conf/tun0" +} + +tztime local { + format = "%Y-%m-%d %H:%M:%S" +} + +tztime berlin { + format = "%Y-%m-%d %H:%M:%S %Z" + timezone = "Europe/Berlin" +} + +load { + format = "%5min" +} + +# cpu_temperature 0 { +# format = "T: %degrees °C" +# path = "/sys/devices/platform/coretemp.0/temp1_input" +# } + +disk "/" { + format = "%free" +} + diff --git a/i3/.config/i3status/conf b/i3/.config/i3status/conf new file mode 100644 index 0000000..722d5ee --- /dev/null +++ b/i3/.config/i3status/conf @@ -0,0 +1,62 @@ +general { + colors = true + interval = 5 +} + +order += "disk /" +order += "disk /home" +order += "path_exists VPN" +order += "wireless wlp2s0" +order += "ethernet eth0" +order += "battery 0" +order += "cpu_temperature 0" +order += "load" +order += "tztime local" + +wireless wlp2s0 { + format_up = "%essid %ip %quality %bitrate" + format_down = "Wireless down" +} + +ethernet eth0 { + # if you use %speed, i3status requires the cap_net_admin capability + format_up = "E: %ip (%speed) " + format_down = "E: down" +} + +battery 0 { + format = "%status %percentage %remaining %emptytime" + format_down = "No battery" + status_chr = "⚡ CHR" + status_bat = "🔋 BAT" + status_unk = "? UNK" + status_chr = "⚡ FULL" + path = "/sys/class/power_supply/BAT%d/uevent" + low_threshold = 10 +} + +path_exists VPN { + # path exists when a VPN tunnel launched by nmcli/nm-applet is active + path = "/proc/sys/net/ipv4/conf/ppp0" +} + +tztime local { + format = "%H:%M %d/%m/%Y" +} + +load { + format = "%5min" +} + +# cpu_temperature 0 { +# format = "T: %degrees °C" +# path = "/sys/devices/platform/coretemp.0/temp1_input" +# } + +disk "/" { + format = "%free / " +} + +disk "/home" { + format = "%free /home " +} diff --git a/not_dots/50-synaptics.conf b/not_dots/50-synaptics.conf index 78d36c7..e5bb43b 100644 --- a/not_dots/50-synaptics.conf +++ b/not_dots/50-synaptics.conf @@ -4,7 +4,8 @@ Section "InputClass" MatchIsTouchpad "on" MatchDevicePath "/dev/input/event*" - Option "TapButton2" "3" Option "TapButton1" "1" + Option "TapButton2" "3" + Option "TapButton3" "2" EndSection diff --git a/not_dots/50-udiskie.rules b/not_dots/50-udiskie.rules new file mode 100644 index 0000000..ab81971 --- /dev/null +++ b/not_dots/50-udiskie.rules @@ -0,0 +1,25 @@ +polkit.addRule(function(action, subject) { + var YES = polkit.Result.YES; + // NOTE: there must be a comma at the end of each line except for the last: + var permission = { + // required for udisks1: + "org.freedesktop.udisks.filesystem-mount": YES, + "org.freedesktop.udisks.luks-unlock": YES, + "org.freedesktop.udisks.drive-eject": YES, + "org.freedesktop.udisks.drive-detach": YES, + // required for udisks2: + "org.freedesktop.udisks2.filesystem-mount": YES, + "org.freedesktop.udisks2.encrypted-unlock": YES, + "org.freedesktop.udisks2.eject-media": YES, + "org.freedesktop.udisks2.power-off-drive": YES, + // required for udisks2 if using udiskie from another seat (e.g. systemd): + "org.freedesktop.udisks2.filesystem-mount-other-seat": YES, + "org.freedesktop.udisks2.filesystem-unmount-others": YES, + "org.freedesktop.udisks2.encrypted-unlock-other-seat": YES, + "org.freedesktop.udisks2.eject-media-other-seat": YES, + "org.freedesktop.udisks2.power-off-drive-other-seat": YES + }; + if (subject.isInGroup("storage")) { + return permission[action.id]; + } +}); diff --git a/ranger/.config/ranger/bookmarks b/ranger/.config/ranger/bookmarks new file mode 100644 index 0000000..1b56ce1 --- /dev/null +++ b/ranger/.config/ranger/bookmarks @@ -0,0 +1,3 @@ +':/home/j +F:/home/j +f:/home/j diff --git a/ranger/.config/ranger/commands.py b/ranger/.config/ranger/commands.py new file mode 100644 index 0000000..1386e84 --- /dev/null +++ b/ranger/.config/ranger/commands.py @@ -0,0 +1,61 @@ +# 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. + +# You always need to import ranger.api.commands here to get the Command class: +from ranger.api.commands import * + +# A simple command for demonstration purposes follows. +# ----------------------------------------------------------------------------- + +# You can import any python module as needed. +import os + +# 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.acitons, 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..a384f42 --- /dev/null +++ b/ranger/.config/ranger/commands_full.py @@ -0,0 +1,1486 @@ +# -*- 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 ~/.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 file ~/.config/ranger/commands.py. +# It has the same syntax as this file. In fact, you can just copy this +# file there with `ranger --copy-config=commands' and make your modifications. +# 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: +# +# cf.path: The path to the file. +# cf.basename: The base name only. +# cf.load_content(): Force a loading of the directories content (which +# obviously works with directories only) +# cf.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 ranger.api.commands import * + + +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) + else: + 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. + The command 'cd -' is equivalent to typing ``. + Using the option "-r" will get you to the real path. + """ + + def execute(self): + import os.path + 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(self, tabnum): + import os + from os.path import dirname, basename, expanduser, join + + cwd = self.fm.thisdir.path + rel_dest = self.rest(1) + + bookmarks = [v.path for v in self.fm.bookmarks.dct.values() + if rel_dest in v.path] + + # expand the tilde into the user directory + if rel_dest.startswith('~'): + rel_dest = expanduser(rel_dest) + + # define some shortcuts + abs_dest = join(cwd, rel_dest) + abs_dirname = dirname(abs_dest) + rel_basename = basename(rel_dest) + rel_dirname = dirname(rel_dest) + + try: + # are we at the end of a directory? + if rel_dest.endswith('/') or rel_dest == '': + _, dirnames, _ = next(os.walk(abs_dest)) + + # are we in the middle of the filename? + else: + _, dirnames, _ = next(os.walk(abs_dirname)) + dirnames = [dn for dn in dirnames + if dn.startswith(rel_basename)] + except (OSError, StopIteration): + # os.walk found nothing + pass + else: + dirnames.sort() + if self.fm.settings.cd_bookmarks: + dirnames = bookmarks + dirnames + + # no results, return None + if len(dirnames) == 0: + return + + # one result. since it must be a directory, append a slash. + if len(dirnames) == 1: + return self.start(1) + join(rel_dirname, dirnames[0]) + '/' + + # more than one result. append no slash, so the user can + # manually type in the slash to advance into that directory + return (self.start(1) + join(rel_dirname, dirname) for dirname in dirnames) + + +class chain(Command): + """:chain ; ; ... + + Calls multiple commands at once, separated by semicolons. + """ + def execute(self): + 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 + ' ' + else: + return self.line + '%s ' + else: + 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=[f for f in 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): + """Extracts the application, flags and mode from a string. + + examples: + "mplayer f 1" => ("mplayer", "f", 1) + "aunpack 4" => ("aunpack", "", 4) + "p" => ("", "p", 0) + "" => None + """ + + app = '' + flags = '' + mode = 0 + split = string.split() + + if len(split) == 0: + pass + + elif 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() + + def _is_flags(self, arg): + from ranger.core.runner import ALLOWED_FLAGS + return all(x in ALLOWED_FLAGS for x in arg) + + def _is_mode(self, arg): + return all(x in '0123456789' for x in arg) + + +class set_(Command): + """:set