Copy config removing sensitive data

This commit is contained in:
Jonathan Hodgson 2017-05-14 10:36:16 +01:00
parent d15767a938
commit 68ffb60404
89 changed files with 12214 additions and 0 deletions

4
config/conky/.themepacks Normal file
View file

@ -0,0 +1,4 @@
default-themes-1.1.cmtp.7z
default-themes-1.2.cmtp.7z
default-themes-2.1.cmtp.7z
default-themes-2.1.cmtp.7z

View file

@ -0,0 +1,54 @@
background yes
update_interval 0.2
double_buffer yes
no_buffers yes
text_buffer_size 2048
gap_x 10
gap_y 10
own_window yes
own_window_type override
own_window_class Conky
own_window_transparent yes
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
own_window_colour 000000
#own_window_argb_visual yes
#own_window_argb_value 128
border_inner_margin 0
border_outer_margin 0
alignment top_left
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no
override_utf8_locale yes
use_xft yes
xftfont caviar dreams:size=10
xftalpha 0.5
uppercase no
# Defining colors
default_color FFFFFF
# Shades of Gray
color1 DDDDDD
color2 AAAAAA
color3 888888
# Blue
color4 2f519a
# Green
color5 77B753
minimum_size 250 500
own_window_argb_value 0
own_window_argb_visual no
TEXT
${font GE Inspira:pixelsize=30}${execpi 60 python ~/.conky/BibleVerse/bibleGateway.py}
${color 2f519a}${execpi 60 python ~/.conky/BibleVerse/reference.py}

View file

@ -0,0 +1,11 @@
__author__ = 'jonathan'
import urllib.request
import json
import html
import textwrap
f = urllib.request.urlopen("http://www.biblegateway.com/votd/get/?format=json&version=ESV")
content = json.loads(f.read().decode("utf-8"))
print(textwrap.fill(html.unescape(content['votd']['text']),30))

View file

@ -0,0 +1,8 @@
__author__ = 'jonathan'
import urllib.request
import json
f = urllib.request.urlopen("http://www.biblegateway.com/votd/get/?format=json&version=ESV")
content = json.loads(f.read().decode("utf-8"))
print(content['votd']['reference'])

View file

@ -0,0 +1,42 @@
use_xft yes
xftfont 123:size=8
xftalpha 0.1
update_interval 0.5
total_run_times 0
own_window yes
own_window_type override
own_window_class Conky
own_window_transparent yes
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
own_window_colour 000000
#own_window_argb_visual yes
#own_window_argb_value 128
background yes
double_buffer yes
maximum_width 500
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no
default_color white
default_shade_color red
default_outline_color green
alignment top_right
gap_x 0
gap_y 10
no_buffers yes
uppercase no
cpu_avg_samples 2
net_avg_samples 1
override_utf8_locale yes
own_window_argb_value 0
own_window_argb_visual no
minimum_size 0 0
TEXT
${color EAEAEA}${font GE Inspira:pixelsize=120}${time %H:%M}${color 2f519a}${time :%S}${font}
${color EAEAEA}${font GE Inspira:pixelsize=58}${time %A}${font GE Inspira:pixelsize=42}${color 2f519a}${time %d}${font GE Inspira:pixelsize=22}${color EAEAEA}${time %B} ${time %Y}

Binary file not shown.

View file

@ -0,0 +1,60 @@
# -- Conky settings -- #
background no
update_interval 2
cpu_avg_samples 2
net_avg_samples 2
override_utf8_locale yes
double_buffer yes
no_buffers yes
text_buffer_size 2048
imlib_cache_size 0
# -- Window specifications -- #
own_window yes
own_window_type override
own_window_class Conky
own_window_transparent yes
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
own_window_colour 000000
#own_window_argb_visual yes
#own_window_argb_value 128
border_inner_margin 0
border_outer_margin 0
minimum_size 7266 748
# -- Graphics settings -- #
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no
# -- Text settings -- #
use_xft yes
xftfont Santana:size=8
xftalpha 0.8
uppercase no
default_color FFFFFF
# -- Lua load -- #
lua_load main.lua
lua_draw_hook_pre main
lua_startup_hook setup
alignment top_left
gap_x 280
gap_y 80
own_window_argb_value 0
own_window_argb_visual yes
own_window_colour 000000
TEXT
#${offset 636}${voffset 223}${font Roboto:size=12}${time %l:%M %P }
${offset 630}${voffset 228}${font Roboto:size=35}Arch

View file

@ -0,0 +1 @@
./face.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,17 @@
# dimenstions
WIDTH = 1366;
HEIGHT = 748;
# network
NETWORK = wlo1;
# cpu
NO_OF_CORES = 8;
# color scheme the values are DARK or WHITE
COLOR = WHITE;
# gmail account
MAIL = '''MAIL''':'''PASSWARD''' https://mail.google.com/mail/feed/atom/unread;

View file

@ -0,0 +1,8 @@
sleep 5s
killall conky
cd "/home/jonathan/.conky/BibleVerse"
conky -c "/home/jonathan/.conky/BibleVerse/bibleGateway" &
cd "/home/jonathan/.conky/MyBlue"
conky -c "/home/jonathan/.conky/MyBlue/MyBlue" &
cd "/home/jonathan/.conky/Octupi_Arch"
conky -c "/home/jonathan/.conky/Octupi_Arch/co_main" &

361
config/i3/config Normal file
View file

@ -0,0 +1,361 @@
# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout some time, delete
# this file and re-run i3-config-wizard(1).
#
# i3 config file (v4)
#
# Please see http://i3wm.org/docs/userguide.html for a complete reference!
set $mod Mod4
set $base00 #101218
set $base01 #1f222d
set $base02 #252936
set $base03 #7780a1
set $base04 #C0C5CE
set $base05 #d1d4e0
set $base06 #C9CCDB
set $base07 #ffffff
set $base08 #ee829f
set $base09 #f99170
set $base0A #ffefcc
set $base0B #a5ffe1
set $base0C #97e0ff
set $base0D #97bbf7
set $base0E #c0b7f9
set $base0F #fcc09e
# Font for window titles. Will also be used by the bar unless a different font
# is used in the bar {} block below.
font pango:monospace 8
# This font is widely installed, provides lots of unicode glyphs, right-to-left
# text rendering and scalability on retina/hidpi displays (thanks to pango).
#font pango:DejaVu Sans Mono 8
# Before i3 v4.8, we used to recommend this one as the default:
# font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
# The font above is very space-efficient, that is, it looks good, sharp and
# clear in small sizes. However, its unicode glyph coverage is limited, the old
# X core fonts rendering does not support right-to-left and this being a bitmap
# font, it doesnt scale on retina/hidpi displays.
# Use Mouse+$mod to drag floating windows to their wanted position
floating_modifier $mod
# start a terminal
# bindsym $mod+Return exec xfce4-terminal
#bindsym $mod+Return exec konsole
bindsym $mod+Return exec termite
# kill focused window
bindsym $mod+q kill
# start dmenu (a program launcher)
# bindsym $mod+d exec dmenu_run
bindsym $mod+d exec albert toggle
#bindsym $mod+z exec xfce4-appfinder
#kill i3
bindsym $mod+Shift+x exec killall i3
for_window [class="xfce4-appfinder"] floating enable
# There also is the (new) i3-dmenu-desktop which only displays applications
# shipping a .desktop file. It is a wrapper around dmenu, so you need that
# installed.
# bindsym $mod+d exec --no-startup-id i3-dmenu-desktop
# change focus
bindsym $mod+j focus down
bindsym $mod+k focus up
bindsym $mod+l focus right
bindsym $mod+h focus left
# alternatively, you can use the cursor keys:
bindsym $mod+Left focus left
bindsym $mod+Down focus down
bindsym $mod+Up focus up
bindsym $mod+Right focus right
# move focused window
bindsym $mod+Shift+j move down
bindsym $mod+Shift+k move up
bindsym $mod+Shift+l move right
bindsym $mod+Shift+h move left
# alternatively, you can use the cursor keys:
bindsym $mod+Shift+Left move left
bindsym $mod+Shift+Down move down
bindsym $mod+Shift+Up move up
bindsym $mod+Shift+Right move right
# split in horizontal orientation
bindsym $mod+g split h
# split in vertical orientation
bindsym $mod+v split v
# enter fullscreen mode for the focused container
bindsym $mod+f fullscreen toggle
# change container layout (stacked, tabbed, toggle split)
bindsym $mod+s layout stacking
bindsym $mod+w layout tabbed
bindsym $mod+e layout toggle split
# toggle tiling / floating
bindsym $mod+Shift+space floating toggle
# change focus between tiling / floating windows
bindsym $mod+space focus mode_toggle
# focus the parent container
bindsym $mod+a focus parent
# move to the parent container
bindsym $mod+Shift+a move parent
# focus the child container
bindsym $mod+z focus child
# move to the child container
bindsym $mod+Shift+z focus child
#set workspace names
set $workspace1 "1: Browser "
set $workspace2 "2: Terminal "
set $workspace3 "3"
set $workspace4 "4"
set $workspace5 "5"
set $workspace6 "6"
set $workspace7 "7"
set $workspace8 "8"
set $workspace9 "9"
set $workspace10 "10: Chat "
# switch to workspace
bindsym $mod+1 workspace $workspace1
bindsym $mod+2 workspace $workspace2
bindsym $mod+3 workspace $workspace3
bindsym $mod+4 workspace $workspace4
bindsym $mod+5 workspace $workspace5
bindsym $mod+6 workspace $workspace6
bindsym $mod+7 workspace $workspace7
bindsym $mod+8 workspace $workspace8
bindsym $mod+9 workspace $workspace9
bindsym $mod+0 workspace $workspace10
# move focused container to workspace
bindsym $mod+Shift+1 move container to workspace $workspace1, workspace $workspace1
bindsym $mod+Shift+2 move container to workspace $workspace2, workspace $workspace2
bindsym $mod+Shift+3 move container to workspace $workspace3, workspace $workspace3
bindsym $mod+Shift+4 move container to workspace $workspace4, workspace $workspace4
bindsym $mod+Shift+5 move container to workspace $workspace5, workspace $workspace5
bindsym $mod+Shift+6 move container to workspace $workspace6, workspace $workspace6
bindsym $mod+Shift+7 move container to workspace $workspace7, workspace $workspace7
bindsym $mod+Shift+8 move container to workspace $workspace8, workspace $workspace8
bindsym $mod+Shift+9 move container to workspace $workspace9, workspace $workspace9
bindsym $mod+Shift+0 move container to workspace $workspace10, workspace $workspace10
#assign programs to workspaces
assign [class="chromium"] $workspace1
assign [instance="crx_knipolnnllmklapflnccelgolnpehhpl"] to $workspace10
for_window [window_role="gimp-toolbox"] floating disable; move left; move left;
for_window [window_role="gimp-dock"] floating disable; move right; move right;
# reload the configuration file
bindsym $mod+Shift+c reload
# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
bindsym $mod+Shift+r restart
# exit i3 (logs you out of your X session)
#bindsym $mod+Shift+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -b 'Yes, exit i3' 'i3-msg exit'"
# resize window (you can also use the mouse for that)
mode "resize" {
# These bindings trigger as soon as you enter the resize mode
# Pressing left will shrink the windows width.
# Pressing right will grow the windows width.
# Pressing up will shrink the windows height.
# Pressing down will grow the windows height.
bindsym h resize shrink width 10 px or 10 ppt
bindsym j resize grow height 10 px or 10 ppt
bindsym k resize shrink height 10 px or 10 ppt
bindsym l resize grow width 10 px or 10 ppt
# same bindings, but for the arrow keys
bindsym Left resize shrink width 10 px or 10 ppt
bindsym Down resize grow height 10 px or 10 ppt
bindsym Up resize shrink height 10 px or 10 ppt
bindsym Right resize grow width 10 px or 10 ppt
# back to normal: Enter or Escape
bindsym Return mode "default"
bindsym Escape mode "default"
}
bindsym $mod+r mode "resize"
# Widow Colours
# border background text indicator
client.focused $base01 $base01 $base07 $base0F
client.focused_inactive $base02 $base02 $base03 $base0F
client.unfocused $base02 $base02 $base03 $base0F
client.urgent $base02 $base08 $base00 $base0F
# Start i3bar to display a workspace bar (plus the system information i3status
# finds out, if available)
bar {
status_command i3status
#tray_output primary
colors {
separator $base03
background $base01
statusline $base05
# border background text
focused_workspace $base01 $base01 $base07
active_workspace $base01 $base02 $base03
inactive_workspace $base01 $base01 $base03
urgent_workspace $base01 $base01 $base08
}
}
#Use xfce4 panel instead of i3's
#exec --no-startup-id xfce4-panel --disable-wm-check
bindsym control+mod1+c exec chromium, workspace $workspace1
bindsym control+mod1+f exec thunar
# Pulse Audio controls
bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume 1 +5% #increase sound volume
bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume 1 -5% #decrease sound volume
bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute 1 toggle # mute sound
# Sreen brightness controls
bindsym XF86MonBrightnessUp exec xbacklight -inc 20 # increase screen brightness
bindsym XF86MonBrightnessDown exec xbacklight -dec 20 # decrease screen brightness
# Touchpad controls
bindsym XF86TouchpadToggle exec /some/path/toggletouchpad.sh # toggle touchpad
# Media player controls
bindsym XF86AudioPlay exec playerctl play
bindsym XF86AudioPause exec playerctl pause
bindsym XF86AudioNext exec playerctl next
bindsym XF86AudioPrev exec playerctl previous
#printscreen
bindsym Print exec xfce4-screenshooter -f
bindsym ctrl+Print exec xfce4-screenshooter -w
bindsym Shift+Print exec xfce4-screenshooter -r
bindsym $mod+x exec --no-startup-id ~/.config/i3/i3exit logout
set $mode_system System (l) lock, (e) logout, (s) suspend, (h) hibernate, (r) reboot, (Shift+s) shutdown
mode "$mode_system" {
bindsym l exec --no-startup-id ~/.config/i3/i3exit lock, mode "default"
bindsym e exec --no-startup-id ~/.config/i3/i3exit logout, mode "default"
bindsym s exec --no-startup-id ~/.config/i3/i3exit suspend, mode "default"
bindsym h exec --no-startup-id ~/.config/i3/i3exit hibernate, mode "default"
bindsym r exec --no-startup-id~/.config/i3/i3exit reboot, mode "default"
bindsym Shift+s exec --no-startup-id ~/.config/i3/i3exit shutdown, mode "default"
# back to normal: Enter or Escape
bindsym Return mode "default"
bindsym Escape mode "default"
}
bindsym ctrl+Shift+l mode "$mode_system"
#bindsym ctrl+l exec "/home/jonathan/.bin/i3exit lock"
##################################################
# #
# i3 Gaps #
# #
##################################################
for_window [class="^.*"] border pixel 0
gaps outer 0
gaps inner 10
smart_gaps on
set $mode_gaps Gaps: (o) outer, (i) inner, (d) default
set $mode_gaps_outer Outer Gaps: +|-|0 (local), Shift + +|-|0 (global)
set $mode_gaps_inner Inner Gaps: +|-|0 (local), Shift + +|-|0 (global)
bindsym $mod+Shift+g mode "$mode_gaps"
mode "$mode_gaps" {
bindsym o mode "$mode_gaps_outer"
bindsym i mode "$mode_gaps_inner"
bindsym d gaps inner current set 10; gaps outer current set 0
bindsym Shift+d gaps inner all set 10; gaps outer all set 0
bindsym Return mode "default"
bindsym Escape mode "default"
}
mode "$mode_gaps_inner" {
bindsym plus gaps inner current plus 5
bindsym minus gaps inner current minus 5
bindsym 0 gaps inner current set 0
bindsym d gaps inner current set 10
bindsym Shift+plus gaps inner all plus 5
bindsym Shift+minus gaps inner all minus 5
bindsym Shift+0 gaps inner all set 0
bindsym Shift+d gaps inner all set 10
bindsym Return mode "default"
bindsym Escape mode "default"
}
mode "$mode_gaps_outer" {
bindsym plus gaps outer current plus 5
bindsym minus gaps outer current minus 5
bindsym 0 gaps outer current set 0
bindsym d gaps outer current set 0
bindsym Shift+plus gaps outer all plus 5
bindsym Shift+minus gaps outer all minus 5
bindsym Shift+0 gaps outer all set 0
bindsym Shift+d gaps outer all set 0
bindsym Return mode "default"
bindsym Escape mode "default"
}
#exec --no-startup-id redshift-gtk
#exec_always feh --bg-fill /home/jonathan/Pictures/Wallpapers/blueConky/dfCXBel.jpg
exec --no-startup-id compton -f -i 0.95
exec --no-startup-id albert
#exec --no-startup-id nm-applet
#exec --no-startup-id blueman-applet
#exec --no-startup-id xfce4-clipman
#exec --no-startup-id xfce4-power-manager
#exec_always --no-startup-id /usr/lib/kdeconnectd
#exec_always --no-startup-id indicator-kdeconnect
#exec_always --no-startup-id killall conky
#exec_always --no-startup-id sleep 1s; killall -9 conky
#exec --no-startup-id sh /home/jonathan/.conky/conky-startup.sh
#exec_always --no-startup-id sleep 2s; conky -c "/home/jonathan/.conky/BibleVerse/bibleGateway"
#exec_always --no-startup-id sleep 2s; conky -c "/home/jonathan/.conky/MyBlue/MyBlue"
#exec_always --no-startup-id cd /home/jonathan/.conky/Octupi_Arch
#exec_always --no-startup-id sleep 2s; conky -c "co_main"
exec setxkbmap gb

363
config/i3/configWork Normal file
View file

@ -0,0 +1,363 @@
# i3 config file (v4)
#
# Please see http://i3wm.org/docs/userguide.html for a complete reference!
set $mod Mod4
set $base00 #101218
set $base01 #1f222d
set $base02 #252936
set $base03 #7780a1
set $base04 #C0C5CE
set $base05 #d1d4e0
set $base06 #C9CCDB
set $base07 #ffffff
set $base08 #ee829f
set $base09 #f99170
set $base0A #ffefcc
set $base0B #a5ffe1
set $base0C #97e0ff
set $base0D #97bbf7
set $base0E #c0b7f9
set $base0F #fcc09e
# Font for window titles. Will also be used by the bar unless a different font
# is used in the bar {} block below.
font pango:monospace 8
# This font is widely installed, provides lots of unicode glyphs, right-to-left
# text rendering and scalability on retina/hidpi displays (thanks to pango).
font pango:DejaVu Sans Mono 8
# Before i3 v4.8, we used to recommend this one as the default:
# font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
# The font above is very space-efficient, that is, it looks good, sharp and
# clear in small sizes. However, its unicode glyph coverage is limited, the old
# X core fonts rendering does not support right-to-left and this being a bitmap
# font, it doesnt scale on retina/hidpi displays.
# Use Mouse+$mod to drag floating windows to their wanted position
floating_modifier $mod
# start a terminal
# bindsym $mod+Return exec xfce4-terminal
# bindsym $mod+Return exec konsole
bindsym $mod+Return exec termite
# kill focused window
bindsym $mod+q kill
# start dmenu (a program launcher)
#bindsym $mod+d exec dmenu_run
bindsym $mod+d exec albert toggle
bindsym XF86Search exec albert toggle
#bindsym $mod+z exec xfce4-appfinder
#kill i3
bindsym $mod+Shift+x exec killall i3
for_window [class="xfce4-appfinder"] floating enable
# There also is the (new) i3-dmenu-desktop which only displays applications
# shipping a .desktop file. It is a wrapper around dmenu, so you need that
# installed.
# bindsym $mod+d exec --no-startup-id i3-dmenu-desktop
# change focus
bindsym $mod+j focus down
bindsym $mod+k focus up
bindsym $mod+l focus right
bindsym $mod+h focus left
# alternatively, you can use the cursor keys:
bindsym $mod+Left focus left
bindsym $mod+Down focus down
bindsym $mod+Up focus up
bindsym $mod+Right focus right
# move focused window
bindsym $mod+Shift+h move left
bindsym $mod+Shift+j move down
bindsym $mod+Shift+k move up
bindsym $mod+Shift+l move right
# alternatively, you can use the cursor keys:
bindsym $mod+Shift+Left move left
bindsym $mod+Shift+Down move down
bindsym $mod+Shift+Up move up
bindsym $mod+Shift+Right move right
# split in horizontal orientation
bindsym $mod+g split h
# split in vertical orientation
bindsym $mod+v split v
# enter fullscreen mode for the focused container
bindsym $mod+f fullscreen toggle
# change container layout (stacked, tabbed, toggle split)
bindsym $mod+s layout stacking
bindsym $mod+w layout tabbed
bindsym $mod+e layout toggle split
# toggle tiling / floating
bindsym $mod+Shift+space floating toggle
# change focus between tiling / floating windows
bindsym $mod+space focus mode_toggle
# focus the parent container
bindsym $mod+a focus parent
# focus the child container
bindsym $mod+Shift+a focus child
#set workspace names
set $workspace1 "1: Browser "
set $workspace2 "2: Terminal "
set $workspace3 "3"
set $workspace4 "4"
set $workspace5 "5"
set $workspace6 "6"
set $workspace7 "7"
set $workspace8 "8"
set $workspace9 "9"
set $workspace10 "10 Chat "
# switch to workspace
bindsym $mod+1 workspace $workspace1
bindsym $mod+2 workspace $workspace2
bindsym $mod+3 workspace $workspace3
bindsym $mod+4 workspace $workspace4
bindsym $mod+5 workspace $workspace5
bindsym $mod+6 workspace $workspace6
bindsym $mod+7 workspace $workspace7
bindsym $mod+8 workspace $workspace8
bindsym $mod+9 workspace $workspace9
bindsym $mod+0 workspace $workspace10
# move focused container to workspace
bindsym $mod+Shift+1 move container to workspace $workspace1, workspace $workspace1
bindsym $mod+Shift+2 move container to workspace $workspace2, workspace $workspace2
bindsym $mod+Shift+3 move container to workspace $workspace3, workspace $workspace3
bindsym $mod+Shift+4 move container to workspace $workspace4, workspace $workspace4
bindsym $mod+Shift+5 move container to workspace $workspace5, workspace $workspace5
bindsym $mod+Shift+6 move container to workspace $workspace6, workspace $workspace6
bindsym $mod+Shift+7 move container to workspace $workspace7, workspace $workspace7
bindsym $mod+Shift+8 move container to workspace $workspace8, workspace $workspace8
bindsym $mod+Shift+9 move container to workspace $workspace9, workspace $workspace9
bindsym $mod+Shift+0 move container to workspace $workspace10, workspace $workspace10
# move workspace to left/right
bindsym $mod+control+Left move workspace to output left
bindsym $mod+control+Right move workspace to output right
bindsym $mod+control+h move workspace to output left
bindsym $mod+control+l move workspace to output right
#assign programs to workspaces
assign [class="chromium"] $workspace1
assign [class="skypeforlinux"] $workspace10
#make applications open in floating mode
for_window [class="Galculator"] floating enable
# reload the configuration file
bindsym $mod+Shift+c reload
# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
bindsym $mod+Shift+r restart
# exit i3 (logs you out of your X session)
bindsym $mod+Shift+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -b 'Yes, exit i3' 'i3-msg exit'"
# resize window (you can also use the mouse for that)
mode "resize" {
# These bindings trigger as soon as you enter the resize mode
# Pressing left will shrink the windows width.
# Pressing right will grow the windows width.
# Pressing up will shrink the windows height.
# Pressing down will grow the windows height.
bindsym h resize shrink width 10 px or 10 ppt
bindsym j resize grow height 10 px or 10 ppt
bindsym k resize shrink height 10 px or 10 ppt
bindsym l resize grow width 10 px or 10 ppt
# same bindings, but for the arrow keys
bindsym Left resize shrink width 10 px or 10 ppt
bindsym Down resize grow height 10 px or 10 ppt
bindsym Up resize shrink height 10 px or 10 ppt
bindsym Right resize grow width 10 px or 10 ppt
# back to normal: Enter or Escape
bindsym Return mode "default"
bindsym Escape mode "default"
}
bindsym $mod+r mode "resize"
# Widow Colours
# border background text indicator
client.focused $base01 $base01 $base07 $base0F
client.focused_inactive $base02 $base02 $base03 $base0F
client.unfocused $base02 $base02 $base03 $base0F
client.urgent $base02 $base08 $base00 $base0F
# Start i3bar to display a workspace bar (plus the system information i3status
# finds out, if available)
bar {
status_command i3status
#tray_output primary
colors {
separator $base03
background $base01
statusline $base05
# border background text
focused_workspace $base01 $base01 $base07
active_workspace $base01 $base02 $base03
inactive_workspace $base01 $base01 $base03
urgent_workspace $base01 $base01 $base08
}
}
#Use xfce4 panel instead of i3's
#exec --no-startup-id xfce4-panel --disable-wm-check
bindsym control+mod1+c exec chromium, workspace $workspace1
bindsym control+mod1+f exec thunar
bindsym XF86Mail exec thunderbird
bindsym $mod+z exec zeal
# Pulse Audio controls
bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume 0 +5% #increase sound volume
bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume 0 -5% #decrease sound volume
bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute 0 toggle # mute sound
# Sreen brightness controls
#bindsym XF86MonBrightnessUp exec xbacklight -inc 20 # increase screen brightness
#bindsym XF86MonBrightnessDown exec xbacklight -dec 20 # decrease screen brightness
# Touchpad controls
#bindsym XF86TouchpadToggle exec /some/path/toggletouchpad.sh # toggle touchpad
# Media player controls
bindsym XF86AudioPlay exec playerctl play-pause
#bindsym XF86AudioPause exec playerctl pause
#bindsym XF86AudioNext exec playerctl next
#bindsym XF86AudioPrev exec playerctl previous
#calculator button
bindsym XF86Calculator exec galculator
#printscreen
bindsym Print exec xfce4-screenshooter -f
bindsym ctrl+Print exec xfce4-screenshooter -w
bindsym Shift+Print exec xfce4-screenshooter -r
bindsym $mod+x exec --no-startup-id ~/.config/i3/i3exit logout
set $mode_system System (l) lock, (e) logout, (s) suspend, (h) hibernate, (r) reboot, (Shift+s) shutdown
mode "$mode_system" {
bindsym l exec --no-startup-id ~/.config/i3/i3exit lock, mode "default"
bindsym e exec --no-startup-id ~/.config/i3/i3exit logout, mode "default"
bindsym s exec --no-startup-id ~/.config/i3/i3exit suspend, mode "default"
bindsym h exec --no-startup-id ~/.config/i3/i3exit hibernate, mode "default"
bindsym r exec --no-startup-id~/.config/i3/i3exit reboot, mode "default"
bindsym Shift+s exec --no-startup-id ~/.config/i3/i3exit shutdown, mode "default"
# back to normal: Enter or Escape
bindsym Return mode "default"
bindsym Escape mode "default"
}
bindsym ctrl+shift+l mode "$mode_system"
#bindsym ctrl+l exec "~/.config/i3/i3exit lock"
##################################################
# #
# i3 Gaps #
# #
##################################################
for_window [class="^.*"] border pixel 0
gaps outer 0
gaps inner 10
smart_gaps on
set $mode_gaps Gaps: (o) outer, (i) inner, (d) default
set $mode_gaps_outer Outer Gaps: +|-|0 (local), Shift + +|-|0 (global)
set $mode_gaps_inner Inner Gaps: +|-|0 (local), Shift + +|-|0 (global)
bindsym $mod+Shift+g mode "$mode_gaps"
mode "$mode_gaps" {
bindsym o mode "$mode_gaps_outer"
bindsym i mode "$mode_gaps_inner"
bindsym d gaps inner current set 10; gaps outer current set 0
bindsym Shift+d gaps inner all set 10; gaps outer all set 0
bindsym Return mode "default"
bindsym Escape mode "default"
}
mode "$mode_gaps_inner" {
bindsym plus gaps inner current plus 5
bindsym minus gaps inner current minus 5
bindsym 0 gaps inner current set 0
bindsym d gaps inner current set 10
bindsym Shift+plus gaps inner all plus 5
bindsym Shift+minus gaps inner all minus 5
bindsym Shift+0 gaps inner all set 0
bindsym Shift+d gaps inner all set 10
bindsym Return mode "default"
bindsym Escape mode "default"
}
mode "$mode_gaps_outer" {
bindsym plus gaps outer current plus 5
bindsym minus gaps outer current minus 5
bindsym 0 gaps outer current set 0
bindsym d gaps outer current set 0
bindsym Shift+plus gaps outer all plus 5
bindsym Shift+minus gaps outer all minus 5
bindsym Shift+0 gaps outer all set 0
bindsym Shift+d gaps outer all set 0
bindsym Return mode "default"
bindsym Escape mode "default"
}
#exec --no-startup-id redshift-gtk
#exec --no-startup-id redshift-gtk
#exec feh --bg-scale /home/jonathan/Pictures/Wallpapers/blueConky/ram_memory_chip-wallpaper-3554x1999.jpg
exec --no-startup-id compton -f -i 0.95
exec_always --no-startup-id /usr/lib/kdeconnectd
exec_always --no-startup-id indicator-kdeconnect
#exec --no-startup-id nm-applet
#exec --no-startup-id blueman-applet
exec --no-startup-id xfce4-clipman
#exec --no-startup-id xfce4-power-manager
#exec_always --no-startup-id killall conky
#exec_always --no-startup-id sleep 1s; killall -9 conky
exec --no-startup-id xrandr --output HDMI-1 --auto --left-of DP-1
exec_always --no-startup-id /usr/lib/xfce4/notifyd/xfce4-notifyd
exec --no-startup-id sh ~/.fehbg
exec_always --no-startup-id sh "/home/jonathan/.config/conky/conky-startup.sh"
#exec --no-startup-id conky -c "/home/jonathan/.config/conky/BibleVerse/bibleGateway"
#exec --no-startup-id conky -c "/home/jonathan/.config/conky/MyBlue/MyBlue"
exec --no-startup-id albert

36
config/i3/fadeLockScreen Executable file
View file

@ -0,0 +1,36 @@
#!/bin/bash
scrot -z /tmp/screen.png
convert /tmp/screen.png -scale 10% -scale 1000% /tmp/screen.png
if [[ -f $HOME/.config/screen-lock.png ]]
then
# placement x/y
PX=0
PY=0
# lockscreen image info
R=$(file ~/.config/screen-lock.png | grep -o '[0-9]* x [0-9]*')
RX=$(echo $R | cut -d' ' -f 1)
RY=$(echo $R | cut -d' ' -f 3)
SR=$(xrandr --query | grep ' connected' | cut -f4 -d' ')
echo $SR
for RES in $SR
do
echo $RES
# monitor position/offset
SRX=$(echo $RES | cut -d'x' -f 1) # x pos
SRY=$(echo $RES | cut -d'x' -f 2 | cut -d'+' -f 1) # y pos
SROX=$(echo $RES | cut -d'x' -f 2 | cut -d'+' -f 2) # x offset
SROY=$(echo $RES | cut -d'x' -f 2 | cut -d'+' -f 3) # y offset
PX=$(($SROX + $SRX/2 - $RX/2))
PY=$(($SROY + $SRY/2 - $RY/2))
convert /tmp/screen.png $HOME/.config/screen-lock.png -geometry +$PX+$PY -composite -matte /tmp/screen.png
echo "done"
done
fi
# dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Stop
# i3lock -I 10 -d -e -u -n -i /tmp/screen.png
i3lock -e -n -i /tmp/screen.png

31
config/i3/i3exit Executable file
View file

@ -0,0 +1,31 @@
#!/bin/sh
lock() {
~/.config/i3/fadeLockScreen
#i3lock
}
case "$1" in
lock)
lock
;;
logout)
i3-msg exit
;;
suspend)
systemctl suspend && lock
;;
hibernate)
systemctl hibernate && lock
;;
reboot)
systemctl reboot
;;
shutdown)
systemctl poweroff
;;
*)
echo "Usage: $0 {lock|logout|suspend|hibernate|reboot|shutdown}"
exit 2
esac
exit 0

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,86 @@
# Changes
2016-04-16
* Fix issue around unicode function for python 3
2016-04-01
* Refactor of the way the git segment manages data about git's state.
([@b-ryan](https://github.com/milkbikis/powerline-shell/pull/221))
2015-12-26
* Beginnings of unit testing for segments. Included in this change was a
refactor of the way segments are added to powerline. Now, instead of looking
for a global `powerline` object, `powerline` is passed into the function to
add the segment. Segments will also no longer add the segments by calling the
`add` function themselves.
([@b-ryan](https://github.com/milkbikis/powerline-shell/pull/212))
* Python3 fixes for `lib/color_compliment.py`.
([@ceholden](https://github.com/milkbikis/powerline-shell/pull/220))
2015-11-25
* `virtual_env` segment now supports environments made with `conda`
([@ceholden](https://github.com/milkbikis/powerline-shell/pull/198))
2015-11-21
* Fixes for Python 3 compatibility
([@b-ryan](https://github.com/milkbikis/powerline-shell/pull/211))
2015-11-18
* The git segment has gotten a makeover
([@MartinWetterwald](https://github.com/milkbikis/powerline-shell/pull/136))
* Fix git segment when git is not on the standard PATH
([@andrejgl](https://github.com/milkbikis/powerline-shell/pull/153))
* Fix `--cwd-max-depth` showing duplicates when it's <= 2
([@b-ryan](https://github.com/milkbikis/powerline-shell/pull/209))
* Add padding around `exit_code` segment
([@phatblat](https://github.com/milkbikis/powerline-shell/pull/205))
2015-10-02
* New option (`--cwd-max-dir-size`) which allows you to limit each directory
that is displayed to a number of characters. This currently does not apply
if you are using `--cwd-mode plain`.
([@mart-e](https://github.com/milkbikis/powerline-shell/pull/127))
2015-08-26
* New `plain` mode of displaying the current working directory which can be
used by adding `--cwd-only plain` to `powerline-shell.py`.
This deprecates the `--cwd-only` option. `--cwd-mode dironly` can be used
instead. ([@paol](https://github.com/milkbikis/powerline-shell/pull/156))
2015-08-18
* New `time` segment
([@filipebarros](https://github.com/milkbikis/powerline-shell/pull/107))
2015-08-01
* Use `print` function for some python3 compatibility
([@strycore](https://github.com/milkbikis/powerline-shell/pull/195))
2015-07-31
* The current working directory no longer follows symbolic links
* New `exit_code` segment
([@disruptek](https://github.com/milkbikis/powerline-shell/pull/129))
2015-07-30
* Fix ZSH root indicator
([@nkcfan](https://github.com/milkbikis/powerline-shell/pull/150))
* Add uptime segment
([@marcioAlmada](https://github.com/milkbikis/powerline-shell/pull/139))
2015-07-27
* Use `python2` instead of `python` in hashbangs
([@Undeterminant](https://github.com/milkbikis/powerline-shell/pull/100))
* Add `node_version` segment
([@mmilleruva](https://github.com/milkbikis/powerline-shell/pull/189))

View file

@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2014 Shrey Banga and contributors
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View file

@ -0,0 +1,170 @@
A Powerline style prompt for your shell
=======================================
A [Powerline](https://github.com/Lokaltog/vim-powerline) like prompt for Bash, ZSH and Fish:
![MacVim+Solarized+Powerline+CtrlP](https://raw.github.com/milkbikis/dotfiles-mac/master/bash-powerline-screenshot.png)
* Shows some important details about the git/svn/hg/fossil branch (see below)
* Changes color if the last command exited with a failure code
* If you're too deep into a directory tree, shortens the displayed path with an ellipsis
* Shows the current Python [virtualenv](http://www.virtualenv.org/) environment
* It's easy to customize and extend. See below for details.
### Version Control
All of the version control systems supported by powerline shell give you a
quick look into the state of your repo:
* The current branch is displayed and changes background color when the
branch is dirty.
* When the local branch differs from the remote, the difference in number
of commits is shown along with `⇡` or `⇣` indicating whether a git push
or pull is pending
In addition, git has a few extra symbols:
* `✎` -- a file has been modified, but not staged for commit
* `✔` -- a file is staged for commit
* `✼` -- a file has conflicts
FIXME
* A `+` appears when untracked files are present (except for git, which
uses `?` instead)
Each of these will have a number next to it if more than one file matches.
# Setup
This script uses ANSI color codes to display colors in a terminal. These are
notoriously non-portable, so may not work for you out of the box, but try
setting your $TERM to `xterm-256color`, because that works for me.
* Patch the font you use for your terminal: see https://github.com/Lokaltog/powerline-fonts
* If you struggle too much to get working fonts in your terminal, you can use "compatible" mode.
* If you're using old patched fonts, you have to use the older symbols. Basically reverse [this commit](https://github.com/milkbikis/powerline-shell/commit/2a84ecc) in your copy
* Clone this repository somewhere:
git clone https://github.com/milkbikis/powerline-shell
* Copy `config.py.dist` to `config.py` and edit it to configure the segments you want. Then run
./install.py
* This will generate `powerline-shell.py`
* (optional) Create a symlink to this python script in your home:
ln -s <path/to/powerline-shell.py> ~/powerline-shell.py
* If you don't want the symlink, just modify the path in the commands below
* For python2.6 you have to install argparse
pip install argparse
### All Shells:
There are a few optional arguments which can be seen by running `powerline-shell.py --help`.
```
--cwd-mode {fancy,plain,dironly}
How to display the current directory
--cwd-max-depth CWD_MAX_DEPTH
Maximum number of directories to show in path
--cwd-max-dir-size CWD_MAX_DIR_SIZE
Maximum number of letters displayed for each directory
in the path
--colorize-hostname Colorize the hostname based on a hash of itself.
--mode {patched,compatible,flat}
The characters used to make separators between
segments
```
### Bash:
Add the following to your `.bashrc` (or `.profile` on Mac):
```
function _update_ps1() {
PS1="$(~/powerline-shell.py $? 2> /dev/null)"
}
if [ "$TERM" != "linux" ]; then
PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND"
fi
```
### ZSH:
Add the following to your `.zshrc`:
```
function powerline_precmd() {
PS1="$(~/powerline-shell.py $? --shell zsh 2> /dev/null)"
}
function install_powerline_precmd() {
for s in "${precmd_functions[@]}"; do
if [ "$s" = "powerline_precmd" ]; then
return
fi
done
precmd_functions+=(powerline_precmd)
}
if [ "$TERM" != "linux" ]; then
install_powerline_precmd
fi
```
### Fish:
Redefine `fish_prompt` in ~/.config/fish/config.fish:
```
function fish_prompt
~/powerline-shell.py $status --shell bare ^/dev/null
end
```
# Customization
### Adding, Removing and Re-arranging segments
The `config.py` file defines which segments are drawn and in which order. Simply
comment out and rearrange segment names to get your desired arrangement. Every
time you change `config.py`, run `install.py`, which will generate a new
`powerline-shell.py` customized to your configuration. You should see the new
prompt immediately.
### Contributing new types of segments
The `segments` directory contains python scripts which are injected as is into
a single file `powerline_shell_base.py`. Each segment script defines a function
that inserts one or more segments into the prompt. If you want to add a new
segment, simply create a new file in the segments directory and add its name to
the `config.py` file at the appropriate location.
Make sure that your script does not introduce new globals which might conflict
with other scripts. Your script should fail silently and run quickly in any
scenario.
Make sure you introduce new default colors in `themes/default.py` for every new
segment you create. Test your segment with this theme first.
You should add tests for your segment as best you are able. Unit and
integration tests are both welcome. Run your tests with the `nosetests` command
after install the requirements in `dev_requirements.txt`.
### Themes
The `themes` directory stores themes for your prompt, which are basically color
values used by segments. The `default.py` defines a default theme which can be
used standalone, and every other theme falls back to it if they miss colors for
any segments. Create new themes by copying any other existing theme and
changing the values. To use a theme, set the `THEME` variable in `config.py` to
the name of your theme.
A script for testing color combinations is provided at `themes/colortest.py`.
Note that the colors you see may vary depending on your terminal. When designing
a theme, please test your theme on multiple terminals, especially with default
settings.

View file

View file

@ -0,0 +1,5 @@
dependencies:
pre:
- sudo pip install -r dev_requirements.txt
- git config --global user.email "tester@example.com"
- git config --global user.name "Tester McGee"

View file

@ -0,0 +1,57 @@
# This is the configuration file for your powerline-shell prompt
# Every time you make a change to this file, run install.py to apply changes
#
# For instructions on how to use the powerline-shell.py script, see the README
# Add, remove or rearrange these segments to customize what you see on the shell
# prompt. Any segment you add must be present in the segments/ directory
SEGMENTS = [
# Set the terminal window title to user@host:dir
'set_term_title',
# Show current virtual environment (see http://www.virtualenv.org/)
'virtual_env',
# Show the current user's username as in ordinary prompts
'username',
# Show the machine's hostname. Mostly used when ssh-ing into other machines
# 'hostname',
# Show a padlock when ssh-ing from another machine
'ssh',
# Show the current directory. If the path is too long, the middle part is
# replaced with ellipsis ('...')
'cwd',
# Show a padlock if the current user has no write access to the current
# directory
'read_only',
# Show the current git branch and status
'git',
# Show the current mercurial branch and status
'hg',
# Show the current svn branch and status
'svn',
# Show the current fossil branch and status
'fossil',
# Show number of running jobs
'jobs',
# Show the last command's exit code if it was non-zero
# 'exit_code',
# Shows a '#' if the current user is root, '$' otherwise
# Also, changes color if the last command exited with a non-zero error code
'root',
]
# Change the colors used to draw individual segments in your prompt
THEME = 'default'

View file

@ -0,0 +1,57 @@
# This is the configuration file for your powerline-shell prompt
# Every time you make a change to this file, run install.py to apply changes
#
# For instructions on how to use the powerline-shell.py script, see the README
# Add, remove or rearrange these segments to customize what you see on the shell
# prompt. Any segment you add must be present in the segments/ directory
SEGMENTS = [
# Set the terminal window title to user@host:dir
# 'set_term_title',
# Show current virtual environment (see http://www.virtualenv.org/)
'virtual_env',
# Show the current user's username as in ordinary prompts
'username',
# Show the machine's hostname. Mostly used when ssh-ing into other machines
'hostname',
# Show a padlock when ssh-ing from another machine
'ssh',
# Show the current directory. If the path is too long, the middle part is
# replaced with ellipsis ('...')
'cwd',
# Show a padlock if the current user has no write access to the current
# directory
'read_only',
# Show the current git branch and status
'git',
# Show the current mercurial branch and status
'hg',
# Show the current svn branch and status
'svn',
# Show the current fossil branch and status
'fossil',
# Show number of running jobs
'jobs',
# Show the last command's exit code if it was non-zero
# 'exit_code',
# Shows a '#' if the current user is root, '$' otherwise
# Also, changes color if the last command exited with a non-zero error code
'root',
]
# Change the colors used to draw individual segments in your prompt
THEME = 'default'

View file

@ -0,0 +1,3 @@
nose>=1.3.7
mock>=1.3.0
sh>=1.11

View file

@ -0,0 +1,49 @@
#!/usr/bin/env python
from __future__ import print_function
import os
import stat
try:
import config
except ImportError:
print('Created personal config.py for your customizations')
import shutil
shutil.copyfile('config.py.dist', 'config.py')
import config
TEMPLATE_FILE = 'powerline_shell_base.py'
OUTPUT_FILE = 'powerline-shell.py'
SEGMENTS_DIR = 'segments'
THEMES_DIR = 'themes'
def load_source(srcfile):
try:
return ''.join(open(srcfile).readlines()) + '\n\n'
except IOError:
print('Could not open', srcfile)
return ''
if __name__ == "__main__":
source = load_source(TEMPLATE_FILE)
source += load_source(os.path.join(THEMES_DIR, 'default.py'))
if config.THEME != 'default':
source += load_source(os.path.join(THEMES_DIR, config.THEME + '.py'))
for segment in config.SEGMENTS:
source += load_source(os.path.join(SEGMENTS_DIR, segment + '.py'))
# assumes each segment file will have a function called
# add_segment__[segment] that accepts the powerline object
source += 'add_{}_segment(powerline)\n'.format(segment)
source += 'sys.stdout.write(powerline.draw())\n'
try:
open(OUTPUT_FILE, 'w').write(source)
st = os.stat(OUTPUT_FILE)
os.chmod(OUTPUT_FILE, st.st_mode | stat.S_IEXEC)
print(OUTPUT_FILE, 'saved successfully')
except IOError:
print('ERROR: Could not write to powerline-shell.py. Make sure it is writable')
exit(1)

View file

@ -0,0 +1,704 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
import argparse
import os
import sys
py3 = sys.version_info.major == 3
def warn(msg):
print('[powerline-bash] ', msg)
if py3:
def unicode(x):
return x
class Powerline:
symbols = {
'compatible': {
'lock': 'RO',
'network': 'SSH',
'separator': u'\u25B6',
'separator_thin': u'\u276F'
},
'patched': {
'lock': u'\uE0A2',
'network': u'\uE0A2',
'separator': u'\uE0B0',
'separator_thin': u'\uE0B1'
},
'flat': {
'lock': '',
'network': '',
'separator': '',
'separator_thin': ''
},
}
color_templates = {
'bash': '\\[\\e%s\\]',
'zsh': '%%{%s%%}',
'bare': '%s',
}
def __init__(self, args, cwd):
self.args = args
self.cwd = cwd
mode, shell = args.mode, args.shell
self.color_template = self.color_templates[shell]
self.reset = self.color_template % '[0m'
self.lock = Powerline.symbols[mode]['lock']
self.network = Powerline.symbols[mode]['network']
self.separator = Powerline.symbols[mode]['separator']
self.separator_thin = Powerline.symbols[mode]['separator_thin']
self.segments = []
def color(self, prefix, code):
if code is None:
return ''
else:
return self.color_template % ('[%s;5;%sm' % (prefix, code))
def fgcolor(self, code):
return self.color('38', code)
def bgcolor(self, code):
return self.color('48', code)
def append(self, content, fg, bg, separator=None, separator_fg=None):
self.segments.append((content, fg, bg,
separator if separator is not None else self.separator,
separator_fg if separator_fg is not None else bg))
def draw(self):
text = (''.join(self.draw_segment(i) for i in range(len(self.segments)))
+ self.reset) + ' '
if py3:
return text
else:
return text.encode('utf-8')
def draw_segment(self, idx):
segment = self.segments[idx]
next_segment = self.segments[idx + 1] if idx < len(self.segments)-1 else None
return ''.join((
self.fgcolor(segment[1]),
self.bgcolor(segment[2]),
segment[0],
self.bgcolor(next_segment[2]) if next_segment else self.reset,
self.fgcolor(segment[4]),
segment[3]))
class RepoStats:
symbols = {
'detached': u'\u2693',
'ahead': u'\u2B06',
'behind': u'\u2B07',
'staged': u'\u2714',
'not_staged': u'\u270E',
'untracked': u'\u003F',
'conflicted': u'\u273C'
}
def __init__(self):
self.ahead = 0
self.behind = 0
self.untracked = 0
self.not_staged = 0
self.staged = 0
self.conflicted = 0
@property
def dirty(self):
qualifiers = [
self.untracked,
self.not_staged,
self.staged,
self.conflicted,
]
return sum(qualifiers) > 0
def __getitem__(self, _key):
return getattr(self, _key)
def n_or_empty(self, _key):
"""Given a string name of one of the properties of this class, returns
the value of the property as a string when the value is greater than
1. When it is not greater than one, returns an empty string.
As an example, if you want to show an icon for untracked files, but you
only want a number to appear next to the icon when there are more than
one untracked files, you can do:
segment = repo_stats.n_or_empty("untracked") + icon_string
"""
return unicode(self[_key]) if int(self[_key]) > 1 else u''
def add_to_powerline(self, powerline, color):
def add(_key, fg, bg):
if self[_key]:
s = u" {}{} ".format(self.n_or_empty(_key), self.symbols[_key])
powerline.append(s, fg, bg)
add('ahead', color.GIT_AHEAD_FG, color.GIT_AHEAD_BG)
add('behind', color.GIT_BEHIND_FG, color.GIT_BEHIND_BG)
add('staged', color.GIT_STAGED_FG, color.GIT_STAGED_BG)
add('not_staged', color.GIT_NOTSTAGED_FG, color.GIT_NOTSTAGED_BG)
add('untracked', color.GIT_UNTRACKED_FG, color.GIT_UNTRACKED_BG)
add('conflicted', color.GIT_CONFLICTED_FG, color.GIT_CONFLICTED_BG)
def get_valid_cwd():
""" We check if the current working directory is valid or not. Typically
happens when you checkout a different branch on git that doesn't have
this directory.
We return the original cwd because the shell still considers that to be
the working directory, so returning our guess will confuse people
"""
# Prefer the PWD environment variable. Python's os.getcwd function follows
# symbolic links, which is undesirable. But if PWD is not set then fall
# back to this func
try:
cwd = os.getenv('PWD') or os.getcwd()
except:
warn("Your current directory is invalid. If you open a ticket at " +
"https://github.com/milkbikis/powerline-shell/issues/new " +
"we would love to help fix the issue.")
sys.stdout.write("> ")
sys.exit(1)
parts = cwd.split(os.sep)
up = cwd
while parts and not os.path.exists(up):
parts.pop()
up = os.sep.join(parts)
if cwd != up:
warn("Your current directory is invalid. Lowest valid directory: "
+ up)
return cwd
if __name__ == "__main__":
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument('--cwd-mode', action='store',
help='How to display the current directory', default='fancy',
choices=['fancy', 'plain', 'dironly'])
arg_parser.add_argument('--cwd-only', action='store_true',
help='Deprecated. Use --cwd-mode=dironly')
arg_parser.add_argument('--cwd-max-depth', action='store', type=int,
default=5, help='Maximum number of directories to show in path')
arg_parser.add_argument('--cwd-max-dir-size', action='store', type=int,
help='Maximum number of letters displayed for each directory in the path')
arg_parser.add_argument('--colorize-hostname', action='store_true',
help='Colorize the hostname based on a hash of itself.')
arg_parser.add_argument('--mode', action='store', default='patched',
help='The characters used to make separators between segments',
choices=['patched', 'compatible', 'flat'])
arg_parser.add_argument('--shell', action='store', default='bash',
help='Set this to your shell type', choices=['bash', 'zsh', 'bare'])
arg_parser.add_argument('prev_error', nargs='?', type=int, default=0,
help='Error code returned by the last command')
args = arg_parser.parse_args()
powerline = Powerline(args, get_valid_cwd())
class DefaultColor:
"""
This class should have the default colors for every segment.
Please test every new segment with this theme first.
"""
USERNAME_FG = 250
USERNAME_BG = 240
USERNAME_ROOT_BG = 124
HOSTNAME_FG = 250
HOSTNAME_BG = 238
HOME_SPECIAL_DISPLAY = True
HOME_BG = 31 # blueish
HOME_FG = 15 # white
PATH_BG = 237 # dark grey
PATH_FG = 250 # light grey
CWD_FG = 254 # nearly-white grey
SEPARATOR_FG = 244
READONLY_BG = 124
READONLY_FG = 254
SSH_BG = 166 # medium orange
SSH_FG = 254
REPO_CLEAN_BG = 148 # a light green color
REPO_CLEAN_FG = 0 # black
REPO_DIRTY_BG = 161 # pink/red
REPO_DIRTY_FG = 15 # white
JOBS_FG = 39
JOBS_BG = 238
CMD_PASSED_BG = 236
CMD_PASSED_FG = 15
CMD_FAILED_BG = 161
CMD_FAILED_FG = 15
SVN_CHANGES_BG = 148
SVN_CHANGES_FG = 22 # dark green
GIT_AHEAD_BG = 240
GIT_AHEAD_FG = 250
GIT_BEHIND_BG = 240
GIT_BEHIND_FG = 250
GIT_STAGED_BG = 22
GIT_STAGED_FG = 15
GIT_NOTSTAGED_BG = 130
GIT_NOTSTAGED_FG = 15
GIT_UNTRACKED_BG = 52
GIT_UNTRACKED_FG = 15
GIT_CONFLICTED_BG = 9
GIT_CONFLICTED_FG = 15
VIRTUAL_ENV_BG = 35 # a mid-tone green
VIRTUAL_ENV_FG = 00
class Color(DefaultColor):
"""
This subclass is required when the user chooses to use 'default' theme.
Because the segments require a 'Color' class for every theme.
"""
pass
def add_set_term_title_segment(powerline):
term = os.getenv('TERM')
if not (('xterm' in term) or ('rxvt' in term)):
return
if powerline.args.shell == 'bash':
set_title = '\\[\\e]0;\\u@\\h: \\w\\a\\]'
elif powerline.args.shell == 'zsh':
set_title = '\033]0;%n@%m: %~\007'
else:
import socket
set_title = '\033]0;%s@%s: %s\007' % (os.getenv('USER'), socket.gethostname().split('.')[0], powerline.cwd or os.getenv('PWD'))
powerline.append(set_title, None, None, '')
add_set_term_title_segment(powerline)
import os
def add_virtual_env_segment(powerline):
env = os.getenv('VIRTUAL_ENV') or os.getenv('CONDA_ENV_PATH')
if env is None:
return
env_name = os.path.basename(env)
bg = Color.VIRTUAL_ENV_BG
fg = Color.VIRTUAL_ENV_FG
powerline.append(' %s ' % env_name, fg, bg)
add_virtual_env_segment(powerline)
def add_username_segment(powerline):
import os
if powerline.args.shell == 'bash':
user_prompt = ' \\u '
elif powerline.args.shell == 'zsh':
user_prompt = ' %n '
else:
user_prompt = ' %s ' % os.getenv('USER')
if os.getenv('USER') == 'root':
bgcolor = Color.USERNAME_ROOT_BG
else:
bgcolor = Color.USERNAME_BG
powerline.append(user_prompt, Color.USERNAME_FG, bgcolor)
add_username_segment(powerline)
import os
def add_ssh_segment(powerline):
if os.getenv('SSH_CLIENT'):
powerline.append(' %s ' % powerline.network, Color.SSH_FG, Color.SSH_BG)
add_ssh_segment(powerline)
import os
ELLIPSIS = u'\u2026'
def replace_home_dir(cwd):
home = os.getenv('HOME')
if cwd.startswith(home):
return '~' + cwd[len(home):]
return cwd
def split_path_into_names(cwd):
names = cwd.split(os.sep)
if names[0] == '':
names = names[1:]
if not names[0]:
return ['/']
return names
def requires_special_home_display(name):
"""Returns true if the given directory name matches the home indicator and
the chosen theme should use a special home indicator display."""
return (name == '~' and Color.HOME_SPECIAL_DISPLAY)
def maybe_shorten_name(powerline, name):
"""If the user has asked for each directory name to be shortened, will
return the name up to their specified length. Otherwise returns the full
name."""
if powerline.args.cwd_max_dir_size:
return name[:powerline.args.cwd_max_dir_size]
return name
def get_fg_bg(name):
"""Returns the foreground and background color to use for the given name.
"""
if requires_special_home_display(name):
return (Color.HOME_FG, Color.HOME_BG,)
return (Color.PATH_FG, Color.PATH_BG,)
def add_cwd_segment(powerline):
cwd = powerline.cwd or os.getenv('PWD')
if not py3:
cwd = cwd.decode("utf-8")
cwd = replace_home_dir(cwd)
if powerline.args.cwd_mode == 'plain':
powerline.append(' %s ' % (cwd,), Color.CWD_FG, Color.PATH_BG)
return
names = split_path_into_names(cwd)
max_depth = powerline.args.cwd_max_depth
if max_depth <= 0:
warn("Ignoring --cwd-max-depth argument since it's not greater than 0")
elif len(names) > max_depth:
# https://github.com/milkbikis/powerline-shell/issues/148
# n_before is the number is the number of directories to put before the
# ellipsis. So if you are at ~/a/b/c/d/e and max depth is 4, it will
# show `~ a ... d e`.
#
# max_depth must be greater than n_before or else you end up repeating
# parts of the path with the way the splicing is written below.
n_before = 2 if max_depth > 2 else max_depth - 1
names = names[:n_before] + [ELLIPSIS] + names[n_before - max_depth:]
if (powerline.args.cwd_mode == 'dironly' or powerline.args.cwd_only):
# The user has indicated they only want the current directory to be
# displayed, so chop everything else off
names = names[-1:]
for i, name in enumerate(names):
fg, bg = get_fg_bg(name)
separator = powerline.separator_thin
separator_fg = Color.SEPARATOR_FG
is_last_dir = (i == len(names) - 1)
if requires_special_home_display(name) or is_last_dir:
separator = None
separator_fg = None
powerline.append(' %s ' % maybe_shorten_name(powerline, name), fg, bg,
separator, separator_fg)
add_cwd_segment(powerline)
import os
def add_read_only_segment(powerline):
cwd = powerline.cwd or os.getenv('PWD')
if not os.access(cwd, os.W_OK):
powerline.append(' %s ' % powerline.lock, Color.READONLY_FG, Color.READONLY_BG)
add_read_only_segment(powerline)
import re
import subprocess
import os
def get_PATH():
"""Normally gets the PATH from the OS. This function exists to enable
easily mocking the PATH in tests.
"""
return os.getenv("PATH")
def git_subprocess_env():
return {
# LANG is specified to ensure git always uses a language we are expecting.
# Otherwise we may be unable to parse the output.
"LANG": "C",
# https://github.com/milkbikis/powerline-shell/pull/126
"HOME": os.getenv("HOME"),
# https://github.com/milkbikis/powerline-shell/pull/153
"PATH": get_PATH(),
}
def parse_git_branch_info(status):
info = re.search('^## (?P<local>\S+?)''(\.{3}(?P<remote>\S+?)( \[(ahead (?P<ahead>\d+)(, )?)?(behind (?P<behind>\d+))?\])?)?$', status[0])
return info.groupdict() if info else None
def _get_git_detached_branch():
p = subprocess.Popen(['git', 'describe', '--tags', '--always'],
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
env=git_subprocess_env())
detached_ref = p.communicate()[0].decode("utf-8").rstrip('\n')
if p.returncode == 0:
branch = u'{} {}'.format(RepoStats.symbols['detached'], detached_ref)
else:
branch = 'Big Bang'
return branch
def parse_git_stats(status):
stats = RepoStats()
for statusline in status[1:]:
code = statusline[:2]
if code == '??':
stats.untracked += 1
elif code in ('DD', 'AU', 'UD', 'UA', 'DU', 'AA', 'UU'):
stats.conflicted += 1
else:
if code[1] != ' ':
stats.not_staged += 1
if code[0] != ' ':
stats.staged += 1
return stats
def add_git_segment(powerline):
try:
p = subprocess.Popen(['git', 'status', '--porcelain', '-b'],
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
env=git_subprocess_env())
except OSError:
# Popen will throw an OSError if git is not found
return
pdata = p.communicate()
if p.returncode != 0:
return
status = pdata[0].decode("utf-8").splitlines()
stats = parse_git_stats(status)
branch_info = parse_git_branch_info(status)
if branch_info:
stats.ahead = branch_info["ahead"]
stats.behind = branch_info["behind"]
branch = branch_info['local']
else:
branch = _get_git_detached_branch()
bg = Color.REPO_CLEAN_BG
fg = Color.REPO_CLEAN_FG
if stats.dirty:
bg = Color.REPO_DIRTY_BG
fg = Color.REPO_DIRTY_FG
powerline.append(' %s ' % branch, fg, bg)
stats.add_to_powerline(powerline, Color)
add_git_segment(powerline)
import os
import subprocess
def get_hg_status():
has_modified_files = False
has_untracked_files = False
has_missing_files = False
p = subprocess.Popen(['hg', 'status'], stdout=subprocess.PIPE)
output = p.communicate()[0].decode("utf-8")
for line in output.split('\n'):
if line == '':
continue
elif line[0] == '?':
has_untracked_files = True
elif line[0] == '!':
has_missing_files = True
else:
has_modified_files = True
return has_modified_files, has_untracked_files, has_missing_files
def add_hg_segment(powerline):
branch = os.popen('hg branch 2> /dev/null').read().rstrip()
if len(branch) == 0:
return False
bg = Color.REPO_CLEAN_BG
fg = Color.REPO_CLEAN_FG
has_modified_files, has_untracked_files, has_missing_files = get_hg_status()
if has_modified_files or has_untracked_files or has_missing_files:
bg = Color.REPO_DIRTY_BG
fg = Color.REPO_DIRTY_FG
extra = ''
if has_untracked_files:
extra += '+'
if has_missing_files:
extra += '!'
branch += (' ' + extra if extra != '' else '')
return powerline.append(' %s ' % branch, fg, bg)
add_hg_segment(powerline)
import subprocess
def _add_svn_segment(powerline):
is_svn = subprocess.Popen(['svn', 'status'],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
is_svn_output = is_svn.communicate()[1].decode("utf-8").strip()
if len(is_svn_output) != 0:
return
#"svn status | grep -c "^[ACDIMRX\\!\\~]"
p1 = subprocess.Popen(['svn', 'status'], stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
p2 = subprocess.Popen(['grep', '-c', '^[ACDIMR\\!\\~]'],
stdin=p1.stdout, stdout=subprocess.PIPE)
output = p2.communicate()[0].decode("utf-8").strip()
if len(output) > 0 and int(output) > 0:
changes = output.strip()
powerline.append(' %s ' % changes, Color.SVN_CHANGES_FG, Color.SVN_CHANGES_BG)
def add_svn_segment(powerline):
"""Wraps _add_svn_segment in exception handling."""
# FIXME This function was added when introducing a testing framework,
# during which the 'powerline' object was passed into the
# `add_[segment]_segment` functions instead of being a global variable. At
# that time it was unclear whether the below exceptions could actually be
# thrown. It would be preferable to find out whether they ever will. If so,
# write a comment explaining when. Otherwise remove.
try:
_add_svn_segment(powerline)
except OSError:
pass
except subprocess.CalledProcessError:
pass
add_svn_segment(powerline)
import os
import subprocess
def get_fossil_status():
has_modified_files = False
has_untracked_files = False
has_missing_files = False
output = os.popen('fossil changes 2>/dev/null').read().strip()
has_untracked_files = True if os.popen("fossil extras 2>/dev/null").read().strip() else False
has_missing_files = 'MISSING' in output
has_modified_files = 'EDITED' in output
return has_modified_files, has_untracked_files, has_missing_files
def _add_fossil_segment(powerline):
subprocess.Popen(['fossil'], stdout=subprocess.PIPE).communicate()[0]
branch = ''.join([i.replace('*','').strip() for i in os.popen("fossil branch 2> /dev/null").read().strip().split("\n") if i.startswith('*')])
if len(branch) == 0:
return
bg = Color.REPO_CLEAN_BG
fg = Color.REPO_CLEAN_FG
has_modified_files, has_untracked_files, has_missing_files = get_fossil_status()
if has_modified_files or has_untracked_files or has_missing_files:
bg = Color.REPO_DIRTY_BG
fg = Color.REPO_DIRTY_FG
extra = ''
if has_untracked_files:
extra += '+'
if has_missing_files:
extra += '!'
branch += (' ' + extra if extra != '' else '')
powerline.append(' %s ' % branch, fg, bg)
def add_fossil_segment(powerline):
"""Wraps _add_fossil_segment in exception handling."""
# FIXME This function was added when introducing a testing framework,
# during which the 'powerline' object was passed into the
# `add_[segment]_segment` functions instead of being a global variable. At
# that time it was unclear whether the below exceptions could actually be
# thrown. It would be preferable to find out whether they ever will. If so,
# write a comment explaining when. Otherwise remove.
try:
_add_fossil_segment(powerline)
except OSError:
pass
except subprocess.CalledProcessError:
pass
add_fossil_segment(powerline)
import os
import re
import subprocess
def add_jobs_segment(powerline):
pppid_proc = subprocess.Popen(['ps', '-p', str(os.getppid()), '-oppid='],
stdout=subprocess.PIPE)
pppid = pppid_proc.communicate()[0].decode("utf-8").strip()
output_proc = subprocess.Popen(['ps', '-a', '-o', 'ppid'],
stdout=subprocess.PIPE)
output = output_proc.communicate()[0].decode("utf-8")
num_jobs = len(re.findall(str(pppid), output)) - 1
if num_jobs > 0:
powerline.append(' %d ' % num_jobs, Color.JOBS_FG, Color.JOBS_BG)
add_jobs_segment(powerline)
def add_root_segment(powerline):
root_indicators = {
'bash': ' \\$ ',
'zsh': ' %# ',
'bare': ' $ ',
}
bg = Color.CMD_PASSED_BG
fg = Color.CMD_PASSED_FG
if powerline.args.prev_error != 0:
fg = Color.CMD_FAILED_FG
bg = Color.CMD_FAILED_BG
powerline.append(root_indicators[powerline.args.shell], fg, bg)
add_root_segment(powerline)
sys.stdout.write(powerline.draw())

View file

@ -0,0 +1,209 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
import argparse
import os
import sys
py3 = sys.version_info.major == 3
def warn(msg):
print('[powerline-bash] ', msg)
if py3:
def unicode(x):
return x
class Powerline:
symbols = {
'compatible': {
'lock': 'RO',
'network': 'SSH',
'separator': u'\u25B6',
'separator_thin': u'\u276F'
},
'patched': {
'lock': u'\uE0A2',
'network': u'\uE0A2',
'separator': u'\uE0B0',
'separator_thin': u'\uE0B1'
},
'flat': {
'lock': '',
'network': '',
'separator': '',
'separator_thin': ''
},
}
color_templates = {
'bash': '\\[\\e%s\\]',
'zsh': '%%{%s%%}',
'bare': '%s',
}
def __init__(self, args, cwd):
self.args = args
self.cwd = cwd
mode, shell = args.mode, args.shell
self.color_template = self.color_templates[shell]
self.reset = self.color_template % '[0m'
self.lock = Powerline.symbols[mode]['lock']
self.network = Powerline.symbols[mode]['network']
self.separator = Powerline.symbols[mode]['separator']
self.separator_thin = Powerline.symbols[mode]['separator_thin']
self.segments = []
def color(self, prefix, code):
if code is None:
return ''
else:
return self.color_template % ('[%s;5;%sm' % (prefix, code))
def fgcolor(self, code):
return self.color('38', code)
def bgcolor(self, code):
return self.color('48', code)
def append(self, content, fg, bg, separator=None, separator_fg=None):
self.segments.append((content, fg, bg,
separator if separator is not None else self.separator,
separator_fg if separator_fg is not None else bg))
def draw(self):
text = (''.join(self.draw_segment(i) for i in range(len(self.segments)))
+ self.reset) + ' '
if py3:
return text
else:
return text.encode('utf-8')
def draw_segment(self, idx):
segment = self.segments[idx]
next_segment = self.segments[idx + 1] if idx < len(self.segments)-1 else None
return ''.join((
self.fgcolor(segment[1]),
self.bgcolor(segment[2]),
segment[0],
self.bgcolor(next_segment[2]) if next_segment else self.reset,
self.fgcolor(segment[4]),
segment[3]))
class RepoStats:
symbols = {
'detached': u'\u2693',
'ahead': u'\u2B06',
'behind': u'\u2B07',
'staged': u'\u2714',
'not_staged': u'\u270E',
'untracked': u'\u003F',
'conflicted': u'\u273C'
}
def __init__(self):
self.ahead = 0
self.behind = 0
self.untracked = 0
self.not_staged = 0
self.staged = 0
self.conflicted = 0
@property
def dirty(self):
qualifiers = [
self.untracked,
self.not_staged,
self.staged,
self.conflicted,
]
return sum(qualifiers) > 0
def __getitem__(self, _key):
return getattr(self, _key)
def n_or_empty(self, _key):
"""Given a string name of one of the properties of this class, returns
the value of the property as a string when the value is greater than
1. When it is not greater than one, returns an empty string.
As an example, if you want to show an icon for untracked files, but you
only want a number to appear next to the icon when there are more than
one untracked files, you can do:
segment = repo_stats.n_or_empty("untracked") + icon_string
"""
return unicode(self[_key]) if int(self[_key]) > 1 else u''
def add_to_powerline(self, powerline, color):
def add(_key, fg, bg):
if self[_key]:
s = u" {}{} ".format(self.n_or_empty(_key), self.symbols[_key])
powerline.append(s, fg, bg)
add('ahead', color.GIT_AHEAD_FG, color.GIT_AHEAD_BG)
add('behind', color.GIT_BEHIND_FG, color.GIT_BEHIND_BG)
add('staged', color.GIT_STAGED_FG, color.GIT_STAGED_BG)
add('not_staged', color.GIT_NOTSTAGED_FG, color.GIT_NOTSTAGED_BG)
add('untracked', color.GIT_UNTRACKED_FG, color.GIT_UNTRACKED_BG)
add('conflicted', color.GIT_CONFLICTED_FG, color.GIT_CONFLICTED_BG)
def get_valid_cwd():
""" We check if the current working directory is valid or not. Typically
happens when you checkout a different branch on git that doesn't have
this directory.
We return the original cwd because the shell still considers that to be
the working directory, so returning our guess will confuse people
"""
# Prefer the PWD environment variable. Python's os.getcwd function follows
# symbolic links, which is undesirable. But if PWD is not set then fall
# back to this func
try:
cwd = os.getenv('PWD') or os.getcwd()
except:
warn("Your current directory is invalid. If you open a ticket at " +
"https://github.com/milkbikis/powerline-shell/issues/new " +
"we would love to help fix the issue.")
sys.stdout.write("> ")
sys.exit(1)
parts = cwd.split(os.sep)
up = cwd
while parts and not os.path.exists(up):
parts.pop()
up = os.sep.join(parts)
if cwd != up:
warn("Your current directory is invalid. Lowest valid directory: "
+ up)
return cwd
if __name__ == "__main__":
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument('--cwd-mode', action='store',
help='How to display the current directory', default='fancy',
choices=['fancy', 'plain', 'dironly'])
arg_parser.add_argument('--cwd-only', action='store_true',
help='Deprecated. Use --cwd-mode=dironly')
arg_parser.add_argument('--cwd-max-depth', action='store', type=int,
default=5, help='Maximum number of directories to show in path')
arg_parser.add_argument('--cwd-max-dir-size', action='store', type=int,
help='Maximum number of letters displayed for each directory in the path')
arg_parser.add_argument('--colorize-hostname', action='store_true',
help='Colorize the hostname based on a hash of itself.')
arg_parser.add_argument('--mode', action='store', default='patched',
help='The characters used to make separators between segments',
choices=['patched', 'compatible', 'flat'])
arg_parser.add_argument('--shell', action='store', default='bash',
help='Set this to your shell type', choices=['bash', 'zsh', 'bare'])
arg_parser.add_argument('prev_error', nargs='?', type=int, default=0,
help='Error code returned by the last command')
args = arg_parser.parse_args()
powerline = Powerline(args, get_valid_cwd())

3
config/ranger/.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
history
bookmarks
tagged

61
config/ranger/commands.py Normal file
View file

@ -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<ENTER>" 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 <filename>
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<ENTER>".
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 <TAB> and -1 for <S-TAB> 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()

File diff suppressed because it is too large Load diff

618
config/ranger/rc.conf Normal file
View file

@ -0,0 +1,618 @@
# ===================================================================
# 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 1,3,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.
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 w3m
# Use a unicode "..." character to mark cut-off filenames?
set unicode_ellipsis false
# 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 default
# Preview files on the rightmost column?
# And collapse (shrink) the last column if there is nothing to preview?
set preview_files true
set preview_directories true
set collapse_preview true
# Save the console history on exit?
set save_console_history true
# Draw the status bar on top of the browser window (default: bottom)
set status_bar_on_top false
# Draw a progress bar in the status bar which displays the average state of all
# currently running tasks which support progress bars?
set draw_progress_bar_in_status_bar true
# Draw borders around columns?
set draw_borders true
# Display the directory name in tabs?
set dirname_in_tabs false
# Enable the mouse support?
set mouse_enabled true
# Display the file size in the main column or status bar?
set display_size_in_main_column true
set display_size_in_status_bar true
# Display files tags in all columns or only in main column?
set display_tags_in_all_columns true
# Set a title for the window?
set update_title false
# Set the title to "ranger" in the tmux program?
set update_tmux_title false
# Shorten the title if it gets long? The number defines how many
# directories are displayed at once, 0 turns off this feature.
set shorten_title 3
# Abbreviate $HOME with ~ in the titlebar (first line) of ranger?
set tilde_in_titlebar false
# How many directory-changes or console-commands should be kept in history?
set max_history_size 20
set max_console_history_size 50
# Try to keep so much space between the top/bottom border when scrolling:
set scroll_offset 8
# Flush the input after each key hit? (Noticeable when ranger lags)
set flushinput true
# Padding on the right when there's no preview?
# This allows you to click into the space to run the file.
set padding_right true
# Save bookmarks (used with mX and `X) instantly?
# 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
# You can display the "real" cumulative size of directories by using the
# command :get_cumulative_size or typing "dc". The size is expensive to
# calculate and will not be updated automatically. You can choose
# to update it automatically though by turning on this option:
set autoupdate_cumulative_size false
# Turning this on makes sense for screen readers:
set show_cursor false
# One of: size, natural, basename, atime, ctime, mtime, type, random
set sort natural
# Additional sorting options
set sort_reverse false
set sort_case_insensitive true
set sort_directories_first true
set sort_unicode false
# Enable this if key combinations with the Alt Key don't work for you.
# (Especially on xterm)
set xterm_alt_key false
# Whether to include bookmarks in cd command
set cd_bookmarks true
# Avoid previewing files larger than this size, in bytes. Use a value of 0 to
# disable this feature.
set preview_max_size 0
# Add the highlighted file to the path in the titlebar
set show_selection_in_titlebar true
# The delay that ranger idly waits for user input, in milliseconds, with a
# resolution of 100ms. Lower delay reduces lag between directory updates but
# increases CPU load.
set idle_delay 2000
# When the metadata manager module looks for metadata, should it only look for
# a ".metadata.json" file in the current directory, or do a deep search and
# check all directories above the current one as well?
set metadata_deep_search false
# Clear all existing filters when leaving a directory
set clear_filters_on_dir_change false
# Disable displaying line numbers in main column
set line_numbers false
# ===================================================================
# == Local Options
# ===================================================================
# You can set local options that only affect a single directory.
# Examples:
# setlocal path=~/downloads sort mtime
# ===================================================================
# == Command Aliases in the Console
# ===================================================================
alias e edit
alias q quit
alias q! quitall
alias qa quitall
alias qall quitall
alias setl setlocal
alias filter scout -prt
alias find scout -aeit
alias mark scout -mr
alias unmark scout -Mr
alias search scout -rs
alias search_inc scout -rts
alias travel scout -aefiklst
# ===================================================================
# == Define keys for the browser
# ===================================================================
# Basic
map Q quit!
map q quit
copymap q ZZ ZQ
map R reload_cwd
map <C-r> reset
map <C-l> redraw_window
map <C-c> abort
map <esc> change_mode normal
map ~ set viewmode!
map i display_file
map ? help
map W display_log
map w taskview_open
map S shell $SHELL
map : console
map ; console
map ! console shell%space
map @ console -p6 shell %%s
map # console shell -p%space
map s console shell%space
map r chain draw_possible_programs; console open_with%%space
map f console find%space
map cd console cd%space
# Change the line mode
map Mf linemode filename
map Mi linemode fileinfo
map Mm linemode mtime
map Mp linemode permissions
map Ms linemode sizemtime
map Mt linemode metatitle
# Tagging / Marking
map t tag_toggle
map ut tag_remove
map "<any> tag_toggle tag=%any
map <Space> mark_files toggle=True
map v mark_files all=True toggle=True
map uv mark_files all=True val=False
map V toggle_visual_mode
map uV toggle_visual_mode reverse=True
# For the nostalgics: Midnight Commander bindings
map <F1> help
map <F3> display_file
map <F4> edit
map <F5> copy
map <F6> cut
map <F7> console mkdir%space
map <F8> console delete
map <F10> exit
# In case you work on a keyboard with dvorak layout
map <UP> move up=1
map <DOWN> move down=1
map <LEFT> move left=1
map <RIGHT> move right=1
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 <DELETE> console delete
map <INSERT> console touch%space
# VIM-like
copymap <UP> k
copymap <DOWN> j
copymap <LEFT> h
copymap <RIGHT> l
copymap <HOME> gg
copymap <END> G
copymap <PAGEDOWN> <C-F>
copymap <PAGEUP> <C-B>
map J move down=0.5 pages=True
map K move up=0.5 pages=True
copymap J <C-D>
copymap K <C-U>
# Jumping around
map H history_go -1
map L history_go 1
map ] move_parent 1
map [ move_parent -1
map } traverse
map gh cd ~
map ge cd /etc
map gu cd /usr
map gd cd /dev
map gl cd -r .
map gL cd -r %f
map go cd /opt
map gv cd /var
map gm cd /media
map gM cd /mnt
map gs cd /srv
map gr cd /
map gR eval fm.cd(ranger.RANGERDIR)
map g/ cd /
map g? cd /usr/share/doc/ranger
# External Programs
map E edit
map du shell -p du --max-depth=1 -h --apparent-size
map dU shell -p du --max-depth=1 -h --apparent-size | sort -rh
map yp shell -f echo -n %d/%f | xsel -i; xsel -o | xsel -i -b
map yd shell -f echo -n %d | xsel -i; xsel -o | xsel -i -b
map yn shell -f echo -n %f | xsel -i; xsel -o | xsel -i -b
# Filesystem Operations
map = chmod
map cw console rename%space
map a rename_append
map A eval fm.open_console('rename ' + fm.thisfile.relative_path.replace("%", "%%"))
map I eval fm.open_console('rename ' + fm.thisfile.relative_path.replace("%", "%%"), position=7)
map pp paste
map po paste overwrite=True
map pP paste append=True
map pO paste overwrite=True append=True
map pl paste_symlink relative=False
map pL paste_symlink relative=True
map phl paste_hardlink
map pht paste_hardlinked_subtree
map dD console delete
map dd cut
map ud uncut
map da cut mode=add
map dr cut mode=remove
map dt cut mode=toggle
map yy copy
map uy uncut
map ya copy mode=add
map yr copy mode=remove
map yt copy mode=toggle
# Temporary workarounds
map dgg eval fm.cut(dirarg=dict(to=0), narg=quantifier)
map dG eval fm.cut(dirarg=dict(to=-1), narg=quantifier)
map dj eval fm.cut(dirarg=dict(down=1), narg=quantifier)
map dk eval fm.cut(dirarg=dict(up=1), narg=quantifier)
map ygg eval fm.copy(dirarg=dict(to=0), narg=quantifier)
map yG eval fm.copy(dirarg=dict(to=-1), narg=quantifier)
map yj eval fm.copy(dirarg=dict(down=1), narg=quantifier)
map yk eval fm.copy(dirarg=dict(up=1), narg=quantifier)
# Searching
map / console search%space
map n search_next
map N search_next forward=False
map ct search_next order=tag
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
# Tabs
map <C-n> tab_new ~
map <C-w> tab_close
map <TAB> tab_move 1
map <S-TAB> tab_move -1
map <A-Right> tab_move 1
map <A-Left> tab_move -1
map gt tab_move 1
map gT tab_move -1
map gn tab_new ~
map gc tab_close
map uq tab_restore
map <a-1> tab_open 1
map <a-2> tab_open 2
map <a-3> tab_open 3
map <a-4> tab_open 4
map <a-5> tab_open 5
map <a-6> tab_open 6
map <a-7> tab_open 7
map <a-8> tab_open 8
map <a-9> tab_open 9
# Sorting
map or set sort_reverse!
map oz set sort=random
map os chain set sort=size; set sort_reverse=False
map ob chain set sort=basename; set sort_reverse=False
map on chain set sort=natural; set sort_reverse=False
map om chain set sort=mtime; set sort_reverse=False
map oc chain set sort=ctime; set sort_reverse=False
map oa chain set sort=atime; set sort_reverse=False
map ot chain set sort=type; set sort_reverse=False
map oe chain set sort=extension; set sort_reverse=False
map oS chain set sort=size; set sort_reverse=True
map oB chain set sort=basename; set sort_reverse=True
map oN chain set sort=natural; set sort_reverse=True
map oM chain set sort=mtime; set sort_reverse=True
map oC chain set sort=ctime; set sort_reverse=True
map oA chain set sort=atime; set sort_reverse=True
map oT chain set sort=type; set sort_reverse=True
map oE chain set sort=extension; set sort_reverse=True
map dc get_cumulative_size
# Settings
map zc set collapse_preview!
map zd set sort_directories_first!
map zh set show_hidden!
map <C-h> set show_hidden!
map zI set flushinput!
map zi set preview_images!
map zm set mouse_enabled!
map zp set preview_files!
map zP set preview_directories!
map zs set sort_case_insensitive!
map zu set autoupdate_cumulative_size!
map zv set use_preview_script!
map zf console filter%space
# Bookmarks
map `<any> enter_bookmark %any
map '<any> enter_bookmark %any
map m<any> set_bookmark %any
map um<any> unset_bookmark %any
map m<bg> draw_bookmarks
copymap m<bg> um<bg> `<bg> '<bg>
# Generate all the chmod bindings with some python help:
eval for arg in "rwxXst": cmd("map +u{0} shell -f chmod u+{0} %s".format(arg))
eval for arg in "rwxXst": cmd("map +g{0} shell -f chmod g+{0} %s".format(arg))
eval for arg in "rwxXst": cmd("map +o{0} shell -f chmod o+{0} %s".format(arg))
eval for arg in "rwxXst": cmd("map +a{0} shell -f chmod a+{0} %s".format(arg))
eval for arg in "rwxXst": cmd("map +{0} shell -f chmod u+{0} %s".format(arg))
eval for arg in "rwxXst": cmd("map -u{0} shell -f chmod u-{0} %s".format(arg))
eval for arg in "rwxXst": cmd("map -g{0} shell -f chmod g-{0} %s".format(arg))
eval for arg in "rwxXst": cmd("map -o{0} shell -f chmod o-{0} %s".format(arg))
eval for arg in "rwxXst": cmd("map -a{0} shell -f chmod a-{0} %s".format(arg))
eval for arg in "rwxXst": cmd("map -{0} shell -f chmod u-{0} %s".format(arg))
# ===================================================================
# == Define keys for the console
# ===================================================================
# Note: Unmapped keys are passed directly to the console.
# Basic
cmap <tab> eval fm.ui.console.tab()
cmap <s-tab> eval fm.ui.console.tab(-1)
cmap <ESC> eval fm.ui.console.close()
cmap <CR> eval fm.ui.console.execute()
cmap <C-l> redraw_window
copycmap <ESC> <C-c>
copycmap <CR> <C-j>
# Move around
cmap <up> eval fm.ui.console.history_move(-1)
cmap <down> eval fm.ui.console.history_move(1)
cmap <left> eval fm.ui.console.move(left=1)
cmap <right> eval fm.ui.console.move(right=1)
cmap <home> eval fm.ui.console.move(right=0, absolute=True)
cmap <end> eval fm.ui.console.move(right=-1, absolute=True)
cmap <a-left> eval fm.ui.console.move_word(left=1)
cmap <a-right> eval fm.ui.console.move_word(right=1)
# Line Editing
cmap <backspace> eval fm.ui.console.delete(-1)
cmap <delete> eval fm.ui.console.delete(0)
cmap <C-w> eval fm.ui.console.delete_word()
cmap <A-d> eval fm.ui.console.delete_word(backward=False)
cmap <C-k> eval fm.ui.console.delete_rest(1)
cmap <C-u> eval fm.ui.console.delete_rest(-1)
cmap <C-y> eval fm.ui.console.paste()
# And of course the emacs way
copycmap <up> <C-p>
copycmap <down> <C-n>
copycmap <left> <C-b>
copycmap <right> <C-f>
copycmap <home> <C-a>
copycmap <end> <C-e>
copycmap <delete> <C-d>
copycmap <backspace> <C-h>
# Note: There are multiple ways to express backspaces. <backspace> (code 263)
# and <backspace2> (code 127). To be sure, use both.
copycmap <backspace> <backspace2>
# This special expression allows typing in numerals:
cmap <allow_quantifiers> false
# ===================================================================
# == Pager Keybindings
# ===================================================================
# Movement
pmap <down> pager_move down=1
pmap <up> pager_move up=1
pmap <left> pager_move left=4
pmap <right> pager_move right=4
pmap <home> pager_move to=0
pmap <end> pager_move to=-1
pmap <pagedown> pager_move down=1.0 pages=True
pmap <pageup> pager_move up=1.0 pages=True
pmap <C-d> pager_move down=0.5 pages=True
pmap <C-u> pager_move up=0.5 pages=True
copypmap <UP> k <C-p>
copypmap <DOWN> j <C-n> <CR>
copypmap <LEFT> h
copypmap <RIGHT> l
copypmap <HOME> g
copypmap <END> G
copypmap <C-d> d
copypmap <C-u> u
copypmap <PAGEDOWN> n f <C-F> <Space>
copypmap <PAGEUP> p b <C-B>
# Basic
pmap <C-l> redraw_window
pmap <ESC> pager_close
copypmap <ESC> q Q i <F3>
pmap E edit_file
# ===================================================================
# == Taskview Keybindings
# ===================================================================
# Movement
tmap <up> taskview_move up=1
tmap <down> taskview_move down=1
tmap <home> taskview_move to=0
tmap <end> taskview_move to=-1
tmap <pagedown> taskview_move down=1.0 pages=True
tmap <pageup> taskview_move up=1.0 pages=True
tmap <C-d> taskview_move down=0.5 pages=True
tmap <C-u> taskview_move up=0.5 pages=True
copytmap <UP> k <C-p>
copytmap <DOWN> j <C-n> <CR>
copytmap <HOME> g
copytmap <END> G
copytmap <C-u> u
copytmap <PAGEDOWN> n f <C-F> <Space>
copytmap <PAGEUP> p b <C-B>
# Changing priority and deleting tasks
tmap J eval -q fm.ui.taskview.task_move(-1)
tmap K eval -q fm.ui.taskview.task_move(0)
tmap dd eval -q fm.ui.taskview.task_remove()
tmap <pagedown> eval -q fm.ui.taskview.task_move(-1)
tmap <pageup> eval -q fm.ui.taskview.task_move(0)
tmap <delete> eval -q fm.ui.taskview.task_remove()
# Basic
tmap <C-l> redraw_window
tmap <ESC> taskview_close
copytmap <ESC> q Q w <C-c>
# ===================================================================
# == My Additions
# ===================================================================
# Start terminal at location
map S shell bash -c "cd %d ; bash"

211
config/ranger/rifle.conf Normal file
View file

@ -0,0 +1,211 @@
# vim: ft=cfg
#
# This is the configuration file of "rifle", ranger's file executor/opener.
# Each line consists of conditions and a command. For each line the conditions
# are checked and if they are met, the respective command is run.
#
# Syntax:
# <condition1> , <condition2> , ... = command
#
# The command can contain these environment variables:
# $1-$9 | The n-th selected file
# $@ | All selected files
#
# If you use the special command "ask", rifle will ask you what program to run.
#
# Prefixing a condition with "!" will negate its result.
# These conditions are currently supported:
# match <regexp> | The regexp matches $1
# ext <regexp> | The regexp matches the extension of $1
# mime <regexp> | The regexp matches the mime type of $1
# name <regexp> | The regexp matches the basename of $1
# path <regexp> | The regexp matches the absolute path of $1
# has <program> | The program is installed (i.e. located in $PATH)
# env <variable> | The environment variable "variable" is non-empty
# file | $1 is a file
# directory | $1 is a directory
# number <n> | change the number of this command to n
# terminal | stdin, stderr and stdout are connected to a terminal
# X | $DISPLAY is not empty (i.e. Xorg runs)
#
# There are also pseudo-conditions which have a "side effect":
# flag <flags> | Change how the program is run. See below.
# label <label> | Assign a label or name to the command so it can
# | be started with :open_with <label> in ranger
# | or `rifle -p <label>` in the standalone executable.
# else | Always true.
#
# Flags are single characters which slightly transform the command:
# f | Fork the program, make it run in the background.
# | New command = setsid $command >& /dev/null &
# r | Execute the command with root permissions
# | New command = sudo $command
# t | Run the program in a new terminal. If $TERMCMD is not defined,
# | rifle will attempt to extract it from $TERM.
# | New command = $TERMCMD -e $command
# Note: The "New command" serves only as an illustration, the exact
# implementation may differ.
# Note: When using rifle in ranger, there is an additional flag "c" for
# only running the current file even if you have marked multiple files.
#-------------------------------------------
# Websites
#-------------------------------------------
# Rarely installed browsers get higher priority; It is assumed that if you
# install a rare browser, you probably use it. Firefox/konqueror/w3m on the
# other hand are often only installed as fallback browsers.
ext x?html?, has surf, X, flag f = surf -- file://"$1"
ext x?html?, has vimprobable, X, flag f = vimprobable -- "$@"
ext x?html?, has vimprobable2, X, flag f = vimprobable2 -- "$@"
ext x?html?, has qutebrowser, X, flag f = qutebrowser -- "$@"
ext x?html?, has dwb, X, flag f = dwb -- "$@"
ext x?html?, has jumanji, X, flag f = jumanji -- "$@"
ext x?html?, has luakit, X, flag f = luakit -- "$@"
ext x?html?, has uzbl, X, flag f = uzbl -- "$@"
ext x?html?, has uzbl-tabbed, X, flag f = uzbl-tabbed -- "$@"
ext x?html?, has uzbl-browser, X, flag f = uzbl-browser -- "$@"
ext x?html?, has uzbl-core, X, flag f = uzbl-core -- "$@"
ext x?html?, has midori, X, flag f = midori -- "$@"
ext x?html?, has chromium, X, flag f = chromium -- "$@"
ext x?html?, has opera, X, flag f = opera -- "$@"
ext x?html?, has firefox, X, flag f = firefox -- "$@"
ext x?html?, has seamonkey, X, flag f = seamonkey -- "$@"
ext x?html?, has iceweasel, X, flag f = iceweasel -- "$@"
ext x?html?, has epiphany, X, flag f = epiphany -- "$@"
ext x?html?, has konqueror, X, flag f = konqueror -- "$@"
ext x?html?, has elinks, terminal = elinks "$@"
ext x?html?, has links2, terminal = links2 "$@"
ext x?html?, has links, terminal = links "$@"
ext x?html?, has lynx, terminal = lynx -- "$@"
ext x?html?, has w3m, terminal = w3m "$@"
#-------------------------------------------
# Misc
#-------------------------------------------
# Define the "editor" for text files as first action
mime ^text, label editor = $EDITOR -- "$@"
mime ^text, label pager = "$PAGER" -- "$@"
!mime ^text, label editor, ext xml|json|csv|tex|py|pl|rb|js|sh|php = $EDITOR -- "$@"
!mime ^text, label pager, ext xml|json|csv|tex|py|pl|rb|js|sh|php = "$PAGER" -- "$@"
ext 1 = man "$1"
ext s[wmf]c, has zsnes, X = zsnes "$1"
ext s[wmf]c, has snes9x-gtk,X = snes9x-gtk "$1"
ext nes, has fceux, X = fceux "$1"
ext exe = wine "$1"
name ^[mM]akefile$ = make
#--------------------------------------------
# Code
#-------------------------------------------
ext py = python -- "$1"
ext pl = perl -- "$1"
ext rb = ruby -- "$1"
ext js = node -- "$1"
ext sh = sh -- "$1"
ext php = php -- "$1"
#--------------------------------------------
# Audio without X
#-------------------------------------------
mime ^audio|ogg$, terminal, has mpv = mpv -- "$@"
mime ^audio|ogg$, terminal, has mplayer2 = mplayer2 -- "$@"
mime ^audio|ogg$, terminal, has mplayer = mplayer -- "$@"
ext midi?, terminal, has wildmidi = wildmidi -- "$@"
#--------------------------------------------
# Video/Audio with a GUI
#-------------------------------------------
mime ^video|audio, has gmplayer, X, flag f = gmplayer -- "$@"
mime ^video|audio, has smplayer, X, flag f = smplayer "$@"
mime ^video, has mpv, X, flag f = mpv -- "$@"
mime ^video, has mpv, X, flag f = mpv --fs -- "$@"
mime ^video, has mplayer2, X, flag f = mplayer2 -- "$@"
mime ^video, has mplayer2, X, flag f = mplayer2 -fs -- "$@"
mime ^video, has mplayer, X, flag f = mplayer -- "$@"
mime ^video, has mplayer, X, flag f = mplayer -fs -- "$@"
mime ^video|audio, has vlc, X, flag f = vlc -- "$@"
mime ^video|audio, has totem, X, flag f = totem -- "$@"
mime ^video|audio, has totem, X, flag f = totem --fullscreen -- "$@"
#--------------------------------------------
# Video without X:
#-------------------------------------------
mime ^video, terminal, !X, has mpv = mpv -- "$@"
mime ^video, terminal, !X, has mplayer2 = mplayer2 -- "$@"
mime ^video, terminal, !X, has mplayer = mplayer -- "$@"
#-------------------------------------------
# Documents
#-------------------------------------------
ext pdf, has llpp, X, flag f = llpp "$@"
ext pdf, has zathura, X, flag f = zathura -- "$@"
ext pdf, has mupdf, X, flag f = mupdf "$@"
ext pdf, has mupdf-x11,X, flag f = mupdf-x11 "$@"
ext pdf, has apvlv, X, flag f = apvlv -- "$@"
ext pdf, has xpdf, X, flag f = xpdf -- "$@"
ext pdf, has evince, X, flag f = evince -- "$@"
ext pdf, has atril, X, flag f = atril -- "$@"
ext pdf, has okular, X, flag f = okular -- "$@"
ext pdf, has epdfview, X, flag f = epdfview -- "$@"
ext pdf, has qpdfview, X, flag f = qpdfview "$@"
ext docx?, has catdoc, terminal = catdoc -- "$@" | "$PAGER"
ext sxc|xlsx?|xlt|xlw|gnm|gnumeric, has gnumeric, X, flag f = gnumeric -- "$@"
ext sxc|xlsx?|xlt|xlw|gnm|gnumeric, has kspread, X, flag f = kspread -- "$@"
ext pptx?|od[dfgpst]|docx?|sxc|xlsx?|xlt|xlw|gnm|gnumeric, has libreoffice, X, flag f = libreoffice "$@"
ext pptx?|od[dfgpst]|docx?|sxc|xlsx?|xlt|xlw|gnm|gnumeric, has soffice, X, flag f = soffice "$@"
ext pptx?|od[dfgpst]|docx?|sxc|xlsx?|xlt|xlw|gnm|gnumeric, has ooffice, X, flag f = ooffice "$@"
ext djvu, has zathura,X, flag f = zathura -- "$@"
ext djvu, has evince, X, flag f = evince -- "$@"
ext djvu, has atril, X, flag f = atril -- "$@"
#-------------------------------------------
# Image Viewing:
#-------------------------------------------
mime ^image/svg, has inkscape, X, flag f = inkscape -- "$@"
mime ^image/svg, has display, X, flag f = display -- "$@"
mime ^image, has pqiv, X, flag f = pqiv -- "$@"
mime ^image, has sxiv, X, flag f = sxiv -- "$@"
mime ^image, has feh, X, flag f = feh -- "$@"
mime ^image, has mirage, X, flag f = mirage -- "$@"
mime ^image, has ristretto, X, flag f = ristretto "$@"
mime ^image, has eog, X, flag f = eog -- "$@"
mime ^image, has eom, X, flag f = eom -- "$@"
mime ^image, has gimp, X, flag f = gimp -- "$@"
ext xcf, X, flag f = gimp -- "$@"
#-------------------------------------------
# Archives
#-------------------------------------------
# avoid password prompt by providing empty password
ext 7z, has 7z = 7z -p l "$@" | "$PAGER"
# This requires atool
ext ace|ar|arc|bz2?|cab|cpio|cpt|deb|dgc|dmg|gz, has als = als -- "$@" | "$PAGER"
ext iso|jar|msi|pkg|rar|shar|tar|tgz|xar|xpi|xz|zip, has als = als -- "$@" | "$PAGER"
ext 7z|ace|ar|arc|bz2?|cab|cpio|cpt|deb|dgc|dmg|gz, has aunpack = aunpack -- "$@"
ext iso|jar|msi|pkg|rar|shar|tar|tgz|xar|xpi|xz|zip, has aunpack = aunpack -- "$@"
# Fallback:
ext tar|gz, has tar = tar vvtf "$@" | "$PAGER"
ext tar|gz, has tar = tar vvxf "$@"
#-------------------------------------------
# Misc
#-------------------------------------------
label wallpaper, number 11, mime ^image, has feh, X = feh --bg-scale "$1"
label wallpaper, number 12, mime ^image, has feh, X = feh --bg-tile "$1"
label wallpaper, number 13, mime ^image, has feh, X = feh --bg-center "$1"
label wallpaper, number 14, mime ^image, has feh, X = feh --bg-fill "$1"
# Define the editor for non-text files + pager as last action
!mime ^text, !ext xml|json|csv|tex|py|pl|rb|js|sh|php = ask
label editor, !mime ^text, !ext xml|json|csv|tex|py|pl|rb|js|sh|php = $EDITOR -- "$@"
label pager, !mime ^text, !ext xml|json|csv|tex|py|pl|rb|js|sh|php = "$PAGER" -- "$@"
# The very last action, so that it's never triggered accidentally, is to execute a program:
mime application/x-executable = "$1"

128
config/ranger/scope.sh Executable file
View file

@ -0,0 +1,128 @@
#!/usr/bin/env sh
# ranger supports enhanced previews. If the option "use_preview_script"
# is set to True and this file exists, this script will be called and its
# output is displayed in ranger. ANSI color codes are supported.
# NOTES: This script is considered a configuration file. If you upgrade
# ranger, it will be left untouched. (You must update it yourself.)
# Also, ranger disables STDIN here, so interactive scripts won't work properly
# Meanings of exit codes:
# code | meaning | action of ranger
# -----+------------+-------------------------------------------
# 0 | success | success. display stdout as preview
# 1 | no preview | failure. display no preview at all
# 2 | plain text | display the plain content of the file
# 3 | fix width | success. Don't reload when width changes
# 4 | fix height | success. Don't reload when height changes
# 5 | fix both | success. Don't ever reload
# 6 | image | success. display the image $cached points to as an image preview
# 7 | image | success. display the file directly as an image
# Meaningful aliases for arguments:
path="$1" # Full path of the selected file
width="$2" # Width of the preview pane (number of fitting characters)
height="$3" # Height of the preview pane (number of fitting characters)
cached="$4" # Path that should be used to cache image previews
preview_images="$5" # "True" if image previews are enabled, "False" otherwise.
maxln=200 # Stop after $maxln lines. Can be used like ls | head -n $maxln
# Find out something about the file:
mimetype=$(file --mime-type -Lb "$path")
extension=$(/bin/echo "${path##*.}" | awk '{print tolower($0)}')
# Functions:
# runs a command and saves its output into $output. Useful if you need
# the return value AND want to use the output in a pipe
try() { output=$(eval '"$@"'); }
# writes the output of the previously used "try" command
dump() { /bin/echo "$output"; }
# a common post-processing function used after most commands
trim() { head -n "$maxln"; }
# wraps highlight to treat exit code 141 (killed by SIGPIPE) as success
safepipe() { "$@"; test $? = 0 -o $? = 141; }
# Image previews, if enabled in ranger.
if [ "$preview_images" = "True" ]; then
case "$mimetype" in
# Image previews for SVG files, disabled by default.
###image/svg+xml)
### convert "$path" "$cached" && exit 6 || exit 1;;
# Image previews for image files. w3mimgdisplay will be called for all
# image files (unless overriden as above), but might fail for
# unsupported types.
image/svg+xml)
inkscape -e "${cached//.png}" "$path" && exit 6;;
image/*)
exit 7;;
# Image preview for video, disabled by default.:
video/*)
ffmpegthumbnailer -i "$path" -o "$cached" -s 0 && exit 6 || exit 1;;
application/pdf)
pdftoppm -jpeg -singlefile "$path" "${cached//.jpg}" && exit 6;;
esac
fi
case "$extension" in
# Archive extensions:
a|ace|alz|arc|arj|bz|bz2|cab|cpio|deb|gz|jar|lha|lz|lzh|lzma|lzo|\
rpm|rz|t7z|tar|tbz|tbz2|tgz|tlz|txz|tZ|tzo|war|xpi|xz|Z|zip)
try als "$path" && { dump | trim; exit 0; }
try acat "$path" && { dump | trim; exit 3; }
try bsdtar -lf "$path" && { dump | trim; exit 0; }
exit 1;;
rar)
# avoid password prompt by providing empty password
try unrar -p- lt "$path" && { dump | trim; exit 0; } || exit 1;;
7z)
# avoid password prompt by providing empty password
try 7z -p l "$path" && { dump | trim; exit 0; } || exit 1;;
# PDF documents:
pdf)
try pdftotext -l 10 -nopgbrk -q "$path" - && \
{ dump | trim | fmt -s -w $width; exit 0; } || exit 1;;
# BitTorrent Files
torrent)
try transmission-show "$path" && { dump | trim; exit 5; } || exit 1;;
# ODT Files
#odt|ods|odp|sxw)
# try odt2txt "$path" && { dump | trim; exit 5; } || exit 1;;
# Try to get the text out of a document using libreoffice
odt|ods|odp|sxw|doc|docx|xls|xlsx|ppt|pptx)
try libreoffice --cat "$path" && { dump | trim | fmt -s -w $width; exit 0; } || exit 1;;
# HTML Pages:
htm|html|xhtml)
try w3m -dump "$path" && { dump | trim | fmt -s -w $width; exit 4; }
try lynx -dump "$path" && { dump | trim | fmt -s -w $width; exit 4; }
try elinks -dump "$path" && { dump | trim | fmt -s -w $width; exit 4; }
;; # fall back to highlight/cat if the text browsers fail
esac
case "$mimetype" in
# Syntax highlight for text files:
text/* | */xml)
if [ "$(tput colors)" -ge 256 ]; then
pygmentize_format=terminal256
highlight_format=xterm256
else
pygmentize_format=terminal
highlight_format=ansi
fi
try safepipe highlight --out-format=${highlight_format} "$path" && { dump | trim; exit 5; }
try safepipe pygmentize -f ${pygmentize_format} "$path" && { dump | trim; exit 5; }
exit 2;;
# Ascii-previews of images:
image/*)
img2txt --gamma=0.6 --width="$width" "$path" && exit 4 || exit 1;;
# Display information about media files:
video/* | audio/*)
exiftool "$path" && exit 5
# Use sed to remove spaces so the output fits into the narrow window
try mediainfo "$path" && { dump | trim | sed 's/ \+:/: /;'; exit 5; } || exit 1;;
esac
exit 1

81
config/termite/config Normal file
View file

@ -0,0 +1,81 @@
[options]
scroll_on_output = false
scroll_on_keystroke = true
audible_bell = false
mouse_autohide = false
allow_bold = true
dynamic_title = true
urgent_on_bell = true
clickable_url = true
#font = Monospace 12
#font = DejaVu Sans Mono for Powerline 12
font = Ubuntu Mono derivative Powerline 15
font = Roboto Mono for Powerline 12
#font = Ubuntu Mono 15
scrollback_lines = 10000
search_wrap = true
#icon_name = terminal
#geometry = 640x480
# "system", "on" or "off"
cursor_blink = system
# "block", "underline" or "ibeam"
cursor_shape = block
# $BROWSER is used by default if set, with xdg-open as a fallback
#browser = xdg-open
# set size hints for the window
#size_hints = false
# Hide links that are no longer valid in url select overlay mode
filter_unmatched_urls = true
# emit escape sequences for extra modified keys
#modify_other_keys = false
[colors]
#cursor = #dcdccc
#cursor_foreground = #dcdccc
foreground = #dcdccc
foreground_bold = #ffffff
background = #3f3f3f
# 20% background transparency (requires a compositor)
background = rgba(63, 63, 63, 0.95)
# if unset, will reverse foreground and background
highlight = #2f2f2f
# colors from color0 to color254 can be set
#color0 = #3f3f3f
#color1 = #705050
#color2 = #60b48a
#color3 = #dfaf8f
#color4 = #506070
#color5 = #dc8cc3
#color6 = #8cd0d3
#color7 = #dcdccc
#color8 = #709080
#color9 = #dca3a3
#color10 = #c3bf9f
#color11 = #f0dfaf
#This is the blue that ls used by default for folders
color12 = #94bff3
#color13 = #ec93d3
#color14 = #93e0e3
#color15 = #ffffff
[hints]
#font = Monospace 12
#foreground = #dcdccc
#background = #3f3f3f
#active_foreground = #e68080
#active_background = #3f3f3f
#padding = 2
#border = #3f3f3f
#border_width = 0.5
#roundness = 2.0
# vim: ft=dosini cms=#%s