diff options
author | Yigit Sever | 2019-03-17 23:09:49 +0300 |
---|---|---|
committer | Yigit Sever | 2019-03-17 23:18:28 +0300 |
commit | ea211500227aa58f5e495777743c5d391cbc3110 (patch) | |
tree | afa2b455f9fea40b45dbf8a742c0d0d498024edb | |
download | dotfiles-ea211500227aa58f5e495777743c5d391cbc3110.tar.gz dotfiles-ea211500227aa58f5e495777743c5d391cbc3110.tar.bz2 dotfiles-ea211500227aa58f5e495777743c5d391cbc3110.zip |
Initial commit
38 files changed, 9636 insertions, 0 deletions
diff --git a/.config/betterlockscreen/betterlockscreenrc b/.config/betterlockscreen/betterlockscreenrc new file mode 100644 index 0000000..2b71c1a --- /dev/null +++ b/.config/betterlockscreen/betterlockscreenrc | |||
@@ -0,0 +1,15 @@ | |||
1 | # configuration file for betterlockscreen | ||
2 | |||
3 | insidecolor=00000000 | ||
4 | ringcolor=ffffffff | ||
5 | keyhlcolor=d23c3dff | ||
6 | bshlcolor=d23c3dff | ||
7 | separatorcolor=00000000 | ||
8 | insidevercolor=00000000 | ||
9 | insidewrongcolor=d23c3dff | ||
10 | ringvercolor=ffffffff | ||
11 | ringwrongcolor=ffffffff | ||
12 | verifcolor=ffffffff | ||
13 | timecolor=ffffffff | ||
14 | datecolor=ffffffff | ||
15 | loginbox=00000066 | ||
diff --git a/.config/compton/compton.conf b/.config/compton/compton.conf new file mode 100644 index 0000000..223411d --- /dev/null +++ b/.config/compton/compton.conf | |||
@@ -0,0 +1,86 @@ | |||
1 | # Shadow | ||
2 | shadow = true; | ||
3 | shadow-radius = 0; | ||
4 | shadow-offset-x = 10; | ||
5 | shadow-offset-y = 5; | ||
6 | log-level = "warn"; | ||
7 | # log-file = "/path/to/your/log/file"; | ||
8 | shadow-opacity = 0.8; | ||
9 | #shadow-red = 0.33; | ||
10 | #shadow-green = 0.33; | ||
11 | #shadow-blue = 0.33; | ||
12 | shadow-exclude = [ | ||
13 | "name = 'Notification'", | ||
14 | "class_g = 'Conky'", | ||
15 | "class_g ?= 'Notify-osd'", | ||
16 | "class_g = 'Cairo-clock'", | ||
17 | "_GTK_FRAME_EXTENTS@:c" | ||
18 | ]; | ||
19 | # shadow-exclude = "n:e:Notification"; | ||
20 | # shadow-exclude-reg = "x10+0+0"; | ||
21 | # xinerama-shadow-crop = true; | ||
22 | |||
23 | # Opacity | ||
24 | inactive-opacity = 0.95; | ||
25 | # active-opacity = 0.8; | ||
26 | frame-opacity = 0.7; | ||
27 | inactive-opacity-override = false; | ||
28 | inactive-dim = 0.0; | ||
29 | # inactive-dim-fixed = true; | ||
30 | #blur-background = true; | ||
31 | # blur-background-frame = true; | ||
32 | blur-kern = "3x3box"; | ||
33 | # blur-kern = "5,5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1"; | ||
34 | # blur-background-fixed = true; | ||
35 | blur-background-exclude = [ | ||
36 | "window_type = 'dock'", | ||
37 | "window_type = 'desktop'", | ||
38 | "_GTK_FRAME_EXTENTS@:c" | ||
39 | ]; | ||
40 | # opacity-rule = [ "80:class_g = 'URxvt'" ]; | ||
41 | |||
42 | # Fading | ||
43 | fading = true; | ||
44 | # fade-delta = 30; | ||
45 | fade-in-step = 0.03; | ||
46 | fade-out-step = 0.03; | ||
47 | # no-fading-openclose = true; | ||
48 | # no-fading-destroyed-argb = true; | ||
49 | fade-exclude = [ ]; | ||
50 | |||
51 | # Other | ||
52 | backend = "xrender"; | ||
53 | mark-wmwin-focused = true; | ||
54 | mark-ovredir-focused = true; | ||
55 | # use-ewmh-active-win = true; | ||
56 | detect-rounded-corners = true; | ||
57 | detect-client-opacity = true; | ||
58 | refresh-rate = 0; | ||
59 | vsync = "none"; | ||
60 | # sw-opti = true; | ||
61 | # unredir-if-possible = true; | ||
62 | # unredir-if-possible-delay = 5000; | ||
63 | # unredir-if-possible-exclude = [ ]; | ||
64 | focus-exclude = [ "class_g = 'Cairo-clock'" ]; | ||
65 | detect-transient = true; | ||
66 | detect-client-leader = true; | ||
67 | invert-color-include = [ ]; | ||
68 | # resize-damage = 1; | ||
69 | |||
70 | # GLX backend | ||
71 | # glx-no-stencil = true; | ||
72 | # glx-no-rebind-pixmap = true; | ||
73 | glx-swap-method = "undefined"; | ||
74 | # glx-use-gpushader4 = true; | ||
75 | # xrender-sync = true; | ||
76 | # xrender-sync-fence = true; | ||
77 | |||
78 | # Window type settings | ||
79 | wintypes: | ||
80 | { | ||
81 | tooltip = { fade = true; shadow = true; opacity = 0.75; focus = true; full-shadow = false; }; | ||
82 | dock = { shadow = false; } | ||
83 | dnd = { shadow = false; } | ||
84 | popup_menu = { fade = true; shadow = true; opacity = 1; focus = true; full-shadow = true; } | ||
85 | dropdown_menu = { opacity = 1; } | ||
86 | }; | ||
diff --git a/.config/conky/conky.conf b/.config/conky/conky.conf new file mode 100644 index 0000000..e968e47 --- /dev/null +++ b/.config/conky/conky.conf | |||
@@ -0,0 +1,101 @@ | |||
1 | conky.config = { | ||
2 | alignment = 'top_right', | ||
3 | background = true, | ||
4 | |||
5 | draw_borders = false, | ||
6 | draw_graph_borders = true, | ||
7 | border_width = 1, | ||
8 | border_outer_margin = 5, | ||
9 | stippled_borders = 6, | ||
10 | |||
11 | cpu_avg_samples = 2, | ||
12 | default_color = 'white', | ||
13 | default_outline_color = '#555', | ||
14 | default_shade_color = 'black', | ||
15 | draw_outline = false, | ||
16 | draw_shades = true, | ||
17 | use_xft = true, | ||
18 | font = 'FuraCode Nerd Font Mono:size=10', | ||
19 | |||
20 | gap_x = 35, | ||
21 | gap_y = 35, | ||
22 | |||
23 | minimum_height = 5, | ||
24 | minimum_width = 5, | ||
25 | net_avg_samples = 2, | ||
26 | no_buffers = true, | ||
27 | out_to_console = false, | ||
28 | out_to_stderr = false, | ||
29 | extra_newline = false, | ||
30 | own_window = true, | ||
31 | own_window_class = 'Conky', | ||
32 | own_window_type = 'override', | ||
33 | own_window_transparent = true, | ||
34 | own_window_hints = 'below,undecorated,skip_taskbar,skip_pager,sticky', | ||
35 | short_units = true, | ||
36 | update_interval = 1.0, | ||
37 | uppercase = false, | ||
38 | use_spacer = 'left', | ||
39 | pad_percents = 2, | ||
40 | show_graph_scale = false, | ||
41 | show_graph_range = false, | ||
42 | double_buffer = true, | ||
43 | |||
44 | lua_load = '~/.config/conky/scripts/conky_lua_scripts.lua', | ||
45 | |||
46 | color0 = '#e74c3c', | ||
47 | color1 = '#bdc3c7', | ||
48 | color3 = '#7a3900', | ||
49 | color4 = '#ff8a00', | ||
50 | color5 = '#ffe3a0', | ||
51 | color6 = '#bdc3c7', | ||
52 | color7 = '#ff8a00', | ||
53 | color8 = '#ffe3a0' | ||
54 | } | ||
55 | |||
56 | conky.text = [[ | ||
57 | ${color}${alignc}$sysname $kernel on $machine | ||
58 | ${color}${alignc}${exec whoami} @ $nodename | ||
59 | ${color0}$hr${color} | ||
60 | ${color0}${alignc} | ||
61 | ${alignc}${color}${time %d %B %A} | ||
62 | ${voffset 1} | ||
63 | ${color0}${offset 40}羽${alignr}${offset -30} | ||
64 | ${color}$uptime${alignr} ${color}${time %k:%M:%S} | ||
65 | ${voffset 1} | ||
66 | ${color0}${alignc} | ||
67 | ${color1}cpu ${color}${platform coretemp.0/hwmon/hwmon1 temp 1}${alignr} ${color1}mobo ${color}${acpitemp} | ||
68 | ${voffset 1} | ||
69 | ${color0}${offset 3}${color} | ||
70 | ${cpubar cpu1 6,45} ${freq_g 1}GHz ${cpu cpu1}% ${alignr}${cpubar cpu2 6,45} ${freq_g 2}GHz${alignr}${cpu cpu2}% | ||
71 | ${cpubar cpu3 6,45} ${freq_g 3}GHz ${cpu cpu3}% ${alignr}${cpubar cpu4 6,45} ${freq_g 4}GHz${alignr}${cpu cpu4}% | ||
72 | ${cpubar cpu5 6,45} ${freq_g 5}GHz ${cpu cpu5}% ${alignr}${cpubar cpu6 6,45} ${freq_g 6}GHz${alignr}${cpu cpu6}% | ||
73 | ${cpubar cpu7 6,45} ${freq_g 7}GHz ${cpu cpu7}% ${alignr}${cpubar cpu8 6,45} ${freq_g 8}GHz${alignr}${cpu cpu8}% | ||
74 | ${voffset 1} | ||
75 | ${color0}${offset 3}${color} | ||
76 | ${color1}cpu${color} ${cpubar cpu0 6, 120}${alignr}${freq_g}GHz ${cpu cpu0}% | ||
77 | ${color1}ram${color} ${membar 6, 120}${alignr}$mem/$memmax $memperc% | ||
78 | ${color1}swp${color} ${swapbar 6,120}${alignr}$swap/$swapmax $swapperc% | ||
79 | ${voffset 1} | ||
80 | ${color0}${offset 3}${color} | ||
81 | ${color1}/ ${color}${fs_bar 6, 130 /}${alignr}${fs_used /} /${fs_size /} ${color} | ||
82 | ${color1}~ ${color}${FS_BAR 6, 130 /home}${alignr}${fs_used /home} /${fs_size /home} ${color} | ||
83 | ${voffset 1} | ||
84 | ${color0}${offset 3}ﯱ${color} | ||
85 | ${color1}down${color} ${downspeed eno1}/s${alignr}${color1}up${color} ${upspeed eno1}/s | ||
86 | ${color}${downspeedgraph eno1 32,150 2980b9 e74c3c}${color} ${upspeedgraph eno1 32,150 2980b9 e74c3c} | ||
87 | ${color1}address${color} ${addr eno1}${alignr}updates ${execi 3600 checkupdates | wc -l} | ||
88 | ${color1}inbound${color} ${tcp_portmon 1 32767 count}${color1} outbound${color} ${tcp_portmon 32768 61000 count}${alignr}${color1}all${color} ${tcp_portmon 1 65535 count} | ||
89 | ${voffset 1} | ||
90 | ${color0}${offset 3}${color} | ||
91 | ${color}${alignc} ${top name 1} ${top pid 1} ${top cpu 1} ${top mem 1} | ||
92 | ${color}${alignc} ${top name 2} ${top pid 2} ${top cpu 2} ${top mem 2} | ||
93 | ${color}${alignc} ${top name 3} ${top pid 3} ${top cpu 3} ${top mem 3} | ||
94 | ${color}${alignc} ${top name 4} ${top pid 4} ${top cpu 4} ${top mem 4} | ||
95 | ${voffset 3} | ||
96 | ${texeci 1800 curl -s wttr.in/ank | sed -n '3,7{s/\d27\[[0-9;]*m//g;s/^..//;s/ *$//;p}'} | ||
97 | ${voffset 1} | ||
98 | ${color0}$stippled_hr${color} | ||
99 | ${voffset 1} | ||
100 | ${execp TODAY=`date +%_d`; cal | tail -n+2 | sed -e '1 s:.*:\${color3}&\${color6}:' -e '1 s:'"$(date +%a |cut -c 1-2)"':\${color4}&\${color5}:' -e '0,/'"$TODAY"'/{s/'"$TODAY"'/\${color7}'"$TODAY"'\${color8}/}' | sed s/^/'${alignc}'/} | ||
101 | ]] | ||
diff --git a/.config/conky/scripts/conky_lua_scripts.lua b/.config/conky/scripts/conky_lua_scripts.lua new file mode 100644 index 0000000..9751a21 --- /dev/null +++ b/.config/conky/scripts/conky_lua_scripts.lua | |||
@@ -0,0 +1,3 @@ | |||
1 | function conky_format( format, number ) | ||
2 | return string.format( format, conky_parse( number ) ) | ||
3 | end | ||
diff --git a/.config/dunst/dunstrc b/.config/dunst/dunstrc new file mode 100755 index 0000000..138a1d7 --- /dev/null +++ b/.config/dunst/dunstrc | |||
@@ -0,0 +1,59 @@ | |||
1 | [global] | ||
2 | monitor = 0 | ||
3 | follow = mouse | ||
4 | geometry = "248x64-32+48" | ||
5 | indicate_hidden = true | ||
6 | shrink = no | ||
7 | transparency = 10 | ||
8 | separator_height = 2 | ||
9 | padding = 16 | ||
10 | horizontal_padding = 16 | ||
11 | frame_width = 2 | ||
12 | sort = no | ||
13 | idle_threshold = 120 | ||
14 | font = Lato 10 | ||
15 | line_height = 4 | ||
16 | markup = full | ||
17 | format = "<b>%s</b> <small>from %a</small>\n%b" | ||
18 | alignment = left | ||
19 | show_age_threshold = 60 | ||
20 | word_wrap = true | ||
21 | ignore_newline = no | ||
22 | stack_duplicates = true | ||
23 | hide_duplicate_count = false | ||
24 | show_indicators = true | ||
25 | icon_position = left | ||
26 | max_icon_size = 64x64 | ||
27 | icon_path = "/usr/share/icons/Papirus-Dark/16x16/status/:/usr/share/icons/Papirus-Dark/16x16/devices/:/usr/share/icons/Papirus-Dark/16x16/actions/:/usr/share/icons/Papirus-Dark/16x16/places/" | ||
28 | sticky_history = yes | ||
29 | dmenu = "/usr/bin/rofi" | ||
30 | history_length = 20 | ||
31 | browser = /usr/bin/firefox | ||
32 | title = Dunst | ||
33 | class = Dunst | ||
34 | |||
35 | [shortcuts] | ||
36 | close = ctrl+space | ||
37 | close_all = ctrl+shift+space | ||
38 | history = ctrl+grave | ||
39 | context = ctrl+shift+period | ||
40 | |||
41 | [urgency_low] | ||
42 | background = "#2f343f" | ||
43 | foreground = "#d8dee8" | ||
44 | timeout = 6 | ||
45 | |||
46 | [urgency_normal] | ||
47 | background = "#2f343f" | ||
48 | foreground = "#d8dee8" | ||
49 | timeout = 6 | ||
50 | |||
51 | [urgency_critical] | ||
52 | background = "#2f343f" | ||
53 | foreground = "#d8dee8" | ||
54 | frame_color = "#bf616a" | ||
55 | timeout = 0 | ||
56 | |||
57 | [Spotify] | ||
58 | appname = Spotify | ||
59 | format = "<b>Now Playing</b>\n%s\n%b" | ||
diff --git a/.config/i3/config b/.config/i3/config new file mode 100644 index 0000000..043eff8 --- /dev/null +++ b/.config/i3/config | |||
@@ -0,0 +1,202 @@ | |||
1 | # i3 config file (v4) | ||
2 | # Please see https://i3wm.org/docs/userguide.html for a complete reference! | ||
3 | |||
4 | # set modifiers | ||
5 | set $mod Mod4 | ||
6 | set $alt Mod1 | ||
7 | |||
8 | #autostart | ||
9 | exec --no-startup-id xsettingsd & | ||
10 | exec --no-startup-id compton -b & | ||
11 | exec --no-startup-id dropbox & | ||
12 | exec --no-startup-id copyq & | ||
13 | exec --no-startup-id redshift-gtk & | ||
14 | exec --no-startup-id nm-applet & | ||
15 | exec --no-startup-id xrandr --output DVI-D-0 --off --output HDMI-0 --mode 1920x1080 --pos 0x0 --rotate left --output DVI-I-1 --primary --mode 1920x1080 --pos 1132x608 --rotate normal --output DVI-I-0 --off --output DP-1 --off --output DP-0 --off & | ||
16 | |||
17 | #launch polybar | ||
18 | exec--no-startup-id $HOME/.config/polybar/launch.sh | ||
19 | |||
20 | # swap caps lock and escape, set keyboard layout | ||
21 | exec --no-startup-id setxkbmap -model pc105 -layout us,tr -option grp:alt_shift_toggle,caps:swapescape | ||
22 | |||
23 | #launch conky windows | ||
24 | exec --no-startup-id conky --daemonize -c ~/.config/conky/conky.conf | ||
25 | exec --no-startup-id conky --daemonize -c ~/.config/conky/task.conf | ||
26 | |||
27 | # set the wallpaper last (hopefully after xrandr) | ||
28 | exec --no-startup-id hsetroot -fill ~/Dropbox/Wallpapers/yousef-espanioly-541259-unsplash.jpg | ||
29 | |||
30 | # lock screen | ||
31 | exec --no-startup-id xidlehook --not-when-fullscreen --not-when-audio --timer normal 300 'i3lock-fancy -f Lato-Light -t "welcome back" -- scrot -z' '' | ||
32 | |||
33 | gaps inner 0 | ||
34 | gaps outer 0 | ||
35 | |||
36 | # Font for window titles | ||
37 | font pango:Lato 11 | ||
38 | |||
39 | # Use Mouse+$mod to drag floating windows to their wanted position | ||
40 | floating_modifier $alt | ||
41 | |||
42 | # bindings | ||
43 | |||
44 | # shoo the mouse | ||
45 | bindsym $mod+o exec --no-startup-id xdotool mousemove 1087 1101 | ||
46 | |||
47 | # i switched back to firefox can you tell | ||
48 | bindsym Ctrl+q exec --no-startup-id true | ||
49 | |||
50 | # bookmark from clipboard | ||
51 | bindsym $mod+u exec --no-startup-id ~/bin/bukuadd_c | ||
52 | |||
53 | # swap caps lock and escape, set keyboard layout | ||
54 | bindsym $mod+p exec --no-startup-id "setxkbmap -model pc105 -layout us,tr -option grp:alt_shift_toggle,caps:swapescape" | ||
55 | |||
56 | # use flameshot with print screen | ||
57 | bindsym Print exec flameshot gui | ||
58 | |||
59 | # media keys | ||
60 | bindsym $mod+m exec "pactl set-sink-mute @DEFAULT_SINK@ toggle" | ||
61 | bindsym $mod+Up exec "pactl set-sink-volume @DEFAULT_SINK@ +5%" | ||
62 | bindsym $mod+Down exec "pactl set-sink-volume @DEFAULT_SINK@ -5%" | ||
63 | bindsym $mod+q exec mpc toggle | ||
64 | #bindsym XF86AudioStop exec mpc stop | ||
65 | bindsym $mod+Left exec /home/yigit/bin/mpvPrev | ||
66 | bindsym $mod+Right exec mpc next | ||
67 | |||
68 | # start a terminal | ||
69 | bindsym $mod+Return exec kitty | ||
70 | |||
71 | # kill focused window | ||
72 | bindsym $mod+Shift+q kill | ||
73 | |||
74 | # start rofi (a program launcher) | ||
75 | bindsym $mod+d exec rofi -show combi | ||
76 | |||
77 | # change focus | ||
78 | bindsym $mod+h focus left | ||
79 | bindsym $mod+j focus down | ||
80 | bindsym $mod+k focus up | ||
81 | bindsym $mod+l focus right | ||
82 | |||
83 | # move focused window | ||
84 | bindsym $mod+Shift+h move left | ||
85 | bindsym $mod+Shift+j move down | ||
86 | bindsym $mod+Shift+k move up | ||
87 | bindsym $mod+Shift+l move right | ||
88 | |||
89 | # split in horizontal orientation | ||
90 | bindsym $mod+b split h | ||
91 | |||
92 | # split in vertical orientation | ||
93 | bindsym $mod+v split v | ||
94 | |||
95 | # enter fullscreen mode for the focused container | ||
96 | bindsym $mod+f fullscreen toggle | ||
97 | |||
98 | # change container layout (stacked, tabbed, toggle split) | ||
99 | bindsym $mod+s layout stacking | ||
100 | bindsym $mod+w layout tabbed | ||
101 | bindsym $mod+e layout toggle split | ||
102 | |||
103 | # toggle tiling / floating | ||
104 | bindsym $mod+Shift+space floating toggle | ||
105 | |||
106 | # change focus between tiling / floating windows | ||
107 | bindsym $mod+space focus mode_toggle | ||
108 | |||
109 | # focus the parent container | ||
110 | bindsym $mod+a focus parent | ||
111 | |||
112 | # Define names for default workspaces for which we configure key bindings later on. | ||
113 | # We use variables to avoid repeating the names in multiple places. | ||
114 | set $ws1 "1" | ||
115 | set $ws2 "2" | ||
116 | set $ws3 "3" | ||
117 | set $ws4 "4" | ||
118 | set $ws5 "5" | ||
119 | set $ws6 "6" | ||
120 | set $ws7 "7" | ||
121 | set $ws8 "8" | ||
122 | set $ws9 "9" | ||
123 | set $ws10 "10" | ||
124 | |||
125 | # switch to workspace | ||
126 | bindsym $mod+1 workspace $ws1 | ||
127 | bindsym $mod+2 workspace $ws2 | ||
128 | bindsym $mod+3 workspace $ws3 | ||
129 | bindsym $mod+4 workspace $ws4 | ||
130 | bindsym $mod+5 workspace $ws5 | ||
131 | bindsym $mod+6 workspace $ws6 | ||
132 | bindsym $mod+7 workspace $ws7 | ||
133 | bindsym $mod+8 workspace $ws8 | ||
134 | bindsym $mod+9 workspace $ws9 | ||
135 | bindsym $mod+0 workspace $ws10 | ||
136 | |||
137 | # move focused container to workspace | ||
138 | bindsym $mod+Shift+1 move container to workspace $ws1 | ||
139 | bindsym $mod+Shift+2 move container to workspace $ws2 | ||
140 | bindsym $mod+Shift+3 move container to workspace $ws3 | ||
141 | bindsym $mod+Shift+4 move container to workspace $ws4 | ||
142 | bindsym $mod+Shift+5 move container to workspace $ws5 | ||
143 | bindsym $mod+Shift+6 move container to workspace $ws6 | ||
144 | bindsym $mod+Shift+7 move container to workspace $ws7 | ||
145 | bindsym $mod+Shift+8 move container to workspace $ws8 | ||
146 | bindsym $mod+Shift+9 move container to workspace $ws9 | ||
147 | bindsym $mod+Shift+0 move container to workspace $ws10 | ||
148 | |||
149 | # reload the configuration file | ||
150 | bindsym $mod+Shift+c reload | ||
151 | # restart i3 inplace (preserves your layout/session, can be used to upgrade i3) | ||
152 | bindsym $mod+Shift+r restart | ||
153 | |||
154 | # resize window (you can also use the mouse for that) | ||
155 | mode "resize" { | ||
156 | # These bindings trigger as soon as you enter the resize mode | ||
157 | |||
158 | # Pressing left will shrink the window’s width. | ||
159 | # Pressing right will grow the window’s width. | ||
160 | # Pressing up will shrink the window’s height. | ||
161 | # Pressing down will grow the window’s height. | ||
162 | bindsym h resize shrink width 10 px or 10 ppt | ||
163 | bindsym j resize grow height 10 px or 10 ppt | ||
164 | bindsym k resize shrink height 10 px or 10 ppt | ||
165 | bindsym l resize grow width 10 px or 10 ppt | ||
166 | |||
167 | # back to normal: Enter or Escape or $mod+r | ||
168 | bindsym Return mode "default" | ||
169 | bindsym Caps_Lock mode "default" | ||
170 | bindsym $mod+r mode "default" | ||
171 | } | ||
172 | |||
173 | # session | ||
174 | mode "(L)ock, (S)ignout, (R)eboot, (P)oweroff" { | ||
175 | bindsym $mod+l exec i3lock-fancy -f Lato-Light -t 'welcome back' -- scrot -z | ||
176 | bindsym $mod+r exec systemctl reboot | ||
177 | bindsym $mod+p exec systemctl poweroff | ||
178 | bindsym $mod+s exit | ||
179 | bindsym Escape mode "default" | ||
180 | } | ||
181 | bindsym $mod+Shift+e mode "(L)ock, (S)ignout, (R)eboot, (P)oweroff" | ||
182 | |||
183 | bindsym $mod+r mode "resize" | ||
184 | |||
185 | for_window [class=".*"] border pixel 4 | ||
186 | |||
187 | assign [class="^Steam$"] 9 | ||
188 | assign [class="^Thunderbird$"] 8 | ||
189 | |||
190 | # class border backgr. text indicator child_border | ||
191 | client.focused #458588 #285577 #ffffff #458588 #285577 | ||
192 | client.focused_inactive #b16286 #5f676a #ffffff #484e50 #5f676a | ||
193 | client.unfocused #927374 #222222 #888888 #292d2e #222222 | ||
194 | client.urgent #2f343a #900000 #ffffff #900000 #900000 | ||
195 | client.placeholder #000000 #0c0c0c #ffffff #000000 #0c0c0c | ||
196 | |||
197 | client.background #ffffff | ||
198 | |||
199 | # config | ||
200 | hide_edge_borders smart | ||
201 | workspace_auto_back_and_forth yes | ||
202 | focus_follows_mouse no | ||
diff --git a/.config/kitty/kitty.conf b/.config/kitty/kitty.conf new file mode 100644 index 0000000..8fb681f --- /dev/null +++ b/.config/kitty/kitty.conf | |||
@@ -0,0 +1,265 @@ | |||
1 | # vim:fileencoding=utf-8:ft=conf:foldmethod=marker | ||
2 | |||
3 | #: Fonts {{{ --> Ligature Support | ||
4 | |||
5 | font_family Fira Code | ||
6 | bold_font Fira Code Bold | ||
7 | italic_font Fira Code Light | ||
8 | bold_italic_font Fira Code Retina | ||
9 | |||
10 | font_size 10.0 | ||
11 | |||
12 | adjust_line_height 0 | ||
13 | adjust_column_width 0 | ||
14 | |||
15 | box_drawing_scale 0.001, 1, 1.5, 2 | ||
16 | |||
17 | #: }}} | ||
18 | |||
19 | #: Cursor customization {{{ | ||
20 | |||
21 | cursor_shape block | ||
22 | cursor #FDE311 | ||
23 | cursor_text_color background | ||
24 | |||
25 | cursor_blink_interval 0 | ||
26 | |||
27 | #: }}} | ||
28 | |||
29 | #: Scrollback {{{ | ||
30 | |||
31 | scrollback_lines 2000 | ||
32 | wheel_scroll_multiplier 5.0 | ||
33 | |||
34 | #: }}} | ||
35 | |||
36 | #: Mouse {{{ | ||
37 | |||
38 | url_color #2aa889 | ||
39 | url_style curly | ||
40 | open_url_modifiers ctrl+shift | ||
41 | open_url_with firefox | ||
42 | |||
43 | #: }}} | ||
44 | |||
45 | #: Terminal bell {{{ | ||
46 | |||
47 | enable_audio_bell no | ||
48 | visual_bell_duration 0.0 | ||
49 | |||
50 | #: }}} | ||
51 | |||
52 | #: Window layout {{{ | ||
53 | |||
54 | remember_window_size no | ||
55 | initial_window_width 80c | ||
56 | initial_window_height 24c | ||
57 | |||
58 | window_padding_width 5.0 | ||
59 | |||
60 | #: }}} | ||
61 | |||
62 | #: Tab bar {{{ | ||
63 | |||
64 | tab_bar_edge bottom | ||
65 | tab_bar_style separator | ||
66 | tab_separator " ┇" | ||
67 | |||
68 | active_tab_foreground #d5c4a1 | ||
69 | active_tab_background #504945 | ||
70 | active_tab_font_style italic | ||
71 | inactive_tab_foreground #a89984 | ||
72 | inactive_tab_background #7c6f64 | ||
73 | inactive_tab_font_style normal | ||
74 | |||
75 | #: }}} | ||
76 | |||
77 | #: Color scheme {{{ | ||
78 | |||
79 | foreground #ebdbb2 | ||
80 | background #282828 | ||
81 | |||
82 | #: The foreground and background for text selected with the mouse | ||
83 | selection_foreground #fbf1c7 | ||
84 | selection_background #d65d0e | ||
85 | |||
86 | #: black | ||
87 | color0 #282828 | ||
88 | color8 #928374 | ||
89 | |||
90 | #: red | ||
91 | color1 #cc241d | ||
92 | color9 #fb4934 | ||
93 | |||
94 | #: green | ||
95 | color2 #97971a | ||
96 | color10 #b8bb26 | ||
97 | |||
98 | #: yellow | ||
99 | color3 #d79921 | ||
100 | color11 #fabd2f | ||
101 | |||
102 | #: blue | ||
103 | color4 #458588 | ||
104 | color12 #83a598 | ||
105 | |||
106 | #: purple | ||
107 | color5 #b16286 | ||
108 | color13 #d3869b | ||
109 | |||
110 | #: cyan | ||
111 | color6 #689d6a | ||
112 | color14 #8ec07c | ||
113 | |||
114 | #: white | ||
115 | color7 #a89984 | ||
116 | color15 #ebdbb2 | ||
117 | |||
118 | #: }}} | ||
119 | |||
120 | #: Advanced {{{ | ||
121 | editor nvim | ||
122 | #: }}} | ||
123 | |||
124 | #: Keyboard shortcuts {{{ | ||
125 | |||
126 | #: Finally, you can use raw system key codes to map keys. To see the | ||
127 | #: system key code for a key, start kitty with the kitty --debug- | ||
128 | #: keyboard option. Then kitty will output some debug text for every | ||
129 | #: key event. In that text look for ``native_code`` the value of that | ||
130 | #: becomes the key name in the shortcut. For example: | ||
131 | |||
132 | #: .. code-block:: none | ||
133 | |||
134 | #: on_key_input: glfw key: 65 native_code: 0x61 action: PRESS mods: 0x0 text: 'a' | ||
135 | |||
136 | #: Here, the key name for the A key is 0x61 and you can use it with:: | ||
137 | |||
138 | #: map ctrl+0x61 something | ||
139 | |||
140 | #: to map ctrl+a to something. | ||
141 | |||
142 | #: You can use the special action no_op to unmap a keyboard shortcut | ||
143 | #: that is assigned in the default configuration. | ||
144 | |||
145 | #: You can combine multiple actions to be triggered by a single | ||
146 | #: shortcut, using the syntax below:: | ||
147 | |||
148 | #: map key combine <separator> action1 <separator> action2 <separator> action3 ... | ||
149 | |||
150 | #: For example:: | ||
151 | |||
152 | #: map kitty_mod+e combine : new_window : next_layout | ||
153 | |||
154 | #: this will create a new window and switch to the next available | ||
155 | #: layout | ||
156 | |||
157 | #: You can use multi-key shortcuts using the syntax shown below:: | ||
158 | |||
159 | #: map key1>key2>key3 action | ||
160 | |||
161 | #: For example:: | ||
162 | |||
163 | #: map ctrl+f>2 set_font_size 20 | ||
164 | |||
165 | kitty_mod ctrl+shift | ||
166 | |||
167 | #: The value of kitty_mod is used as the modifier for all default | ||
168 | #: shortcuts, you can change it in your kitty.conf to change the | ||
169 | #: modifiers for all the default shortcuts. | ||
170 | |||
171 | # clear_all_shortcuts no | ||
172 | |||
173 | #: You can have kitty remove all shortcut definition seen up to this | ||
174 | #: point. Useful, for instance, to remove the default shortcuts. | ||
175 | |||
176 | #: Clipboard {{{ | ||
177 | |||
178 | map kitty_mod+c copy_to_clipboard | ||
179 | map kitty_mod+v paste_from_clipboard | ||
180 | map kitty_mod+s paste_from_selection | ||
181 | map shift+insert paste_from_selection | ||
182 | map kitty_mod+o pass_selection_to_program | ||
183 | |||
184 | #: }}} | ||
185 | |||
186 | #: Scrolling {{{ | ||
187 | |||
188 | map kitty_mod+up scroll_line_up | ||
189 | map kitty_mod+k scroll_line_up | ||
190 | map kitty_mod+down scroll_line_down | ||
191 | map kitty_mod+j scroll_line_down | ||
192 | map kitty_mod+page_up scroll_page_up | ||
193 | map kitty_mod+page_down scroll_page_down | ||
194 | map kitty_mod+home scroll_home | ||
195 | map kitty_mod+end scroll_end | ||
196 | map kitty_mod+h show_scrollback | ||
197 | |||
198 | #: }}} | ||
199 | |||
200 | #: Window management {{{ | ||
201 | |||
202 | # map kitty_mod+enter new_window | ||
203 | # map kitty_mod+n new_os_window | ||
204 | # map kitty_mod+w close_window | ||
205 | # map kitty_mod+] next_window | ||
206 | # map kitty_mod+[ previous_window | ||
207 | # map kitty_mod+f move_window_forward | ||
208 | # map kitty_mod+b move_window_backward | ||
209 | # map kitty_mod+` move_window_to_top | ||
210 | # map kitty_mod+r start_resizing_window | ||
211 | # map kitty_mod+1 first_window | ||
212 | # map kitty_mod+2 second_window | ||
213 | # map kitty_mod+3 third_window | ||
214 | # map kitty_mod+4 fourth_window | ||
215 | # map kitty_mod+5 fifth_window | ||
216 | # map kitty_mod+6 sixth_window | ||
217 | # map kitty_mod+7 seventh_window | ||
218 | # map kitty_mod+8 eighth_window | ||
219 | # map kitty_mod+9 ninth_window | ||
220 | # map kitty_mod+0 tenth_window | ||
221 | #: }}} | ||
222 | |||
223 | #: Tab management {{{ | ||
224 | |||
225 | # map kitty_mod+right next_tab | ||
226 | # map kitty_mod+left previous_tab | ||
227 | # map kitty_mod+t new_tab | ||
228 | # map kitty_mod+q close_tab | ||
229 | # map kitty_mod+. move_tab_forward | ||
230 | # map kitty_mod+, move_tab_backward | ||
231 | # map kitty_mod+alt+t set_tab_title | ||
232 | |||
233 | #: }}} | ||
234 | |||
235 | #: Layout management {{{ | ||
236 | |||
237 | # map kitty_mod+l next_layout | ||
238 | # map ctrl+alt+p last_used_layout | ||
239 | |||
240 | #: }}} | ||
241 | |||
242 | #: Font sizes {{{ | ||
243 | |||
244 | # map kitty_mod+equal change_font_size all +2.0 | ||
245 | # map kitty_mod+minus change_font_size all -2.0 | ||
246 | # map kitty_mod+backspace change_font_size all 0 | ||
247 | |||
248 | #: }}} | ||
249 | |||
250 | #: Miscellaneous {{{ | ||
251 | |||
252 | # map kitty_mod+f11 toggle_fullscreen | ||
253 | # map kitty_mod+u kitten unicode_input | ||
254 | # map kitty_mod+f2 edit_config_file | ||
255 | # map kitty_mod+escape kitty_shell window | ||
256 | |||
257 | # map kitty_mod+a>m set_background_opacity +0.1 | ||
258 | # map kitty_mod+a>l set_background_opacity -0.1 | ||
259 | # map kitty_mod+a>1 set_background_opacity 1 | ||
260 | # map kitty_mod+a>d set_background_opacity default | ||
261 | # map kitty_mod+delete clear_terminal reset active | ||
262 | |||
263 | #: }}} | ||
264 | |||
265 | # }}} | ||
diff --git a/.config/mpv/mpv.conf b/.config/mpv/mpv.conf new file mode 100644 index 0000000..bea2261 --- /dev/null +++ b/.config/mpv/mpv.conf | |||
@@ -0,0 +1,141 @@ | |||
1 | # | ||
2 | # Example mpv configuration file | ||
3 | # | ||
4 | # Warning: | ||
5 | # | ||
6 | # The commented example options usually do _not_ set the default values. Call | ||
7 | # mpv with --list-options to see the default values for most options. There is | ||
8 | # no builtin or example mpv.conf with all the defaults. | ||
9 | # | ||
10 | # | ||
11 | # Configuration files are read system-wide from /usr/local/etc/mpv.conf | ||
12 | # and per-user from ~/.config/mpv/mpv.conf, where per-user settings override | ||
13 | # system-wide settings, all of which are overridden by the command line. | ||
14 | # | ||
15 | # Configuration file settings and the command line options use the same | ||
16 | # underlying mechanisms. Most options can be put into the configuration file | ||
17 | # by dropping the preceding '--'. See the man page for a complete list of | ||
18 | # options. | ||
19 | # | ||
20 | # Lines starting with '#' are comments and are ignored. | ||
21 | # | ||
22 | # See the CONFIGURATION FILES section in the man page | ||
23 | # for a detailed description of the syntax. | ||
24 | # | ||
25 | # Profiles should be placed at the bottom of the configuration file to ensure | ||
26 | # that settings wanted as defaults are not restricted to specific profiles. | ||
27 | |||
28 | term-playing-msg='Title: ${media-title}' | ||
29 | term-status-msg='${time-pos} / ${duration}${?percent-pos: (${percent-pos}%)}${?frame-drop-count:${!frame-drop-count==0: Dropped: ${frame-drop-count}}}\n${?chapter:Chapter: ${chapter}}' | ||
30 | |||
31 | ################## | ||
32 | # video settings # | ||
33 | ################## | ||
34 | |||
35 | # Start in fullscreen mode by default. | ||
36 | #fs=yes | ||
37 | |||
38 | # force starting with centered window | ||
39 | #geometry=50%:50% | ||
40 | |||
41 | # don't allow a new window to have a size larger than 90% of the screen size | ||
42 | #autofit-larger=90%x90% | ||
43 | |||
44 | # Do not close the window on exit. | ||
45 | #keep-open=yes | ||
46 | |||
47 | # Do not wait with showing the video window until it has loaded. (This will | ||
48 | # resize the window once video is loaded. Also always shows a window with | ||
49 | # audio.) | ||
50 | #force-window=immediate | ||
51 | |||
52 | # Disable the On Screen Controller (OSC). | ||
53 | #osc=no | ||
54 | |||
55 | # Keep the player window on top of all other windows. | ||
56 | #ontop=yes | ||
57 | |||
58 | # Specify high quality video rendering preset (for --vo=gpu only) | ||
59 | # Can cause performance problems with some drivers and GPUs. | ||
60 | #profile=gpu-hq | ||
61 | |||
62 | # Force video to lock on the display's refresh rate, and change video and audio | ||
63 | # speed to some degree to ensure synchronous playback - can cause problems | ||
64 | # with some drivers and desktop environments. | ||
65 | #video-sync=display-resample | ||
66 | |||
67 | # Enable hardware decoding if available. Often, this does not work with all | ||
68 | # video outputs, but should work well with default settings on most systems. | ||
69 | # If performance or energy usage is an issue, forcing the vdpau or vaapi VOs | ||
70 | # may or may not help. | ||
71 | #hwdec=auto | ||
72 | |||
73 | ################## | ||
74 | # audio settings # | ||
75 | ################## | ||
76 | |||
77 | # Specify default audio device. You can list devices with: --audio-device=help | ||
78 | # The option takes the device string (the stuff between the '...'). | ||
79 | #audio-device=alsa/default | ||
80 | |||
81 | # Do not filter audio to keep pitch when changing playback speed. | ||
82 | #audio-pitch-correction=no | ||
83 | |||
84 | # Output 5.1 audio natively, and upmix/downmix audio with a different format. | ||
85 | #audio-channels=5.1 | ||
86 | # Disable any automatic remix, _if_ the audio output accepts the audio format. | ||
87 | # of the currently played file. See caveats mentioned in the manpage. | ||
88 | # (The default is "auto-safe", see manpage.) | ||
89 | #audio-channels=auto | ||
90 | |||
91 | ################## | ||
92 | # other settings # | ||
93 | ################## | ||
94 | |||
95 | # Pretend to be a web browser. Might fix playback with some streaming sites, | ||
96 | # but also will break with shoutcast streams. | ||
97 | #user-agent="Mozilla/5.0" | ||
98 | |||
99 | # cache settings | ||
100 | # | ||
101 | # Use 150MB input cache by default. The cache is enabled for network streams only. | ||
102 | #cache-default=153600 | ||
103 | # | ||
104 | # Use 150MB input cache for everything, even local files. | ||
105 | #cache=153600 | ||
106 | # | ||
107 | # Disable the behavior that the player will pause if the cache goes below a | ||
108 | # certain fill size. | ||
109 | #cache-pause=no | ||
110 | # | ||
111 | # Read ahead about 5 seconds of audio and video packets. | ||
112 | #demuxer-readahead-secs=5.0 | ||
113 | # | ||
114 | # Raise readahead from demuxer-readahead-secs to this value if a cache is active. | ||
115 | #cache-secs=50.0 | ||
116 | |||
117 | # Display English subtitles if available. | ||
118 | #slang=en | ||
119 | |||
120 | # Play Finnish audio if available, fall back to English otherwise. | ||
121 | #alang=fi,en | ||
122 | |||
123 | # Change subtitle encoding. For Arabic subtitles use 'cp1256'. | ||
124 | # If the file seems to be valid UTF-8, prefer UTF-8. | ||
125 | # (You can add '+' in front of the codepage to force it.) | ||
126 | #sub-codepage=cp1256 | ||
127 | |||
128 | # You can also include other configuration files. | ||
129 | #include=/path/to/the/file/you/want/to/include | ||
130 | |||
131 | ############ | ||
132 | # Profiles # | ||
133 | ############ | ||
134 | |||
135 | # The options declared as part of profiles override global default settings, | ||
136 | # but only take effect when the profile is active. | ||
137 | |||
138 | # The following profile can be enabled on the command line with: --profile=eye-cancer | ||
139 | |||
140 | #[eye-cancer] | ||
141 | #sharpen=5 | ||
diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim new file mode 100755 index 0000000..af2cedc --- /dev/null +++ b/.config/nvim/init.vim | |||
@@ -0,0 +1,443 @@ | |||
1 | "{{{ | ||
2 | |||
3 | call plug#begin('~/.local/share/nvim/plugged') | ||
4 | |||
5 | "A code-completion engine for Vim | ||
6 | Plug 'Valloric/YouCompleteMe' | ||
7 | "syntax checking | ||
8 | Plug 'w0rp/ale' | ||
9 | "manages tag files | ||
10 | Plug 'ludovicchabant/vim-gutentags' | ||
11 | "language pack | ||
12 | "Plug 'sheerun/vim-polyglot' | ||
13 | |||
14 | "snippet solution | ||
15 | Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets' | ||
16 | "autopair plugin | ||
17 | Plug 'tmsvg/pear-tree' | ||
18 | |||
19 | " Plugin outside ~/.vim/plugged with post-update hook | ||
20 | Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } | ||
21 | |||
22 | "tree explorer | ||
23 | Plug 'scrooloose/nerdtree' | ||
24 | "displays tags ordered by scope | ||
25 | Plug 'majutsushi/tagbar' | ||
26 | "status/tabline | ||
27 | Plug 'bling/vim-airline' | ||
28 | |||
29 | " color theme. | ||
30 | Plug 'morhetz/gruvbox' | ||
31 | |||
32 | "Personal wiki | ||
33 | Plug 'vimwiki/vimwiki' | ||
34 | "distraction-free writing | ||
35 | Plug 'junegunn/goyo.vim' | ||
36 | " latex | ||
37 | Plug 'lervag/vimtex' | ||
38 | |||
39 | "visual display of indent levels | ||
40 | Plug 'nathanaelkane/vim-indent-guides' | ||
41 | "text alignment | ||
42 | Plug 'godlygeek/tabular' | ||
43 | "access cheat.sh sheets | ||
44 | Plug 'dbeniamine/cheat.sh-vim' | ||
45 | "color code highlight | ||
46 | Plug 'chrisbra/Colorizer' | ||
47 | "comment helper | ||
48 | Plug 'scrooloose/nerdcommenter' | ||
49 | "folding ledger files | ||
50 | Plug 'ledger/vim-ledger' | ||
51 | "reporen files at your last edit position | ||
52 | Plug 'farmergreg/vim-lastplace' | ||
53 | "toggle, display and navigate marks | ||
54 | Plug 'kshenoy/vim-signature' | ||
55 | "git diff in the sign column | ||
56 | Plug 'airblade/vim-gitgutter' | ||
57 | |||
58 | Plug 'svermeulen/vim-cutlass' | ||
59 | Plug 'svermeulen/vim-subversive' | ||
60 | Plug 'svermeulen/vim-yoink' | ||
61 | |||
62 | "enable repeating supported plugin maps with '.' | ||
63 | Plug 'tpope/vim-repeat' | ||
64 | "quoting/parenthesizing made simple | ||
65 | Plug 'tpope/vim-surround' | ||
66 | "pairs of handy bracket mappings | ||
67 | Plug 'tpope/vim-unimpaired' | ||
68 | "git wrapper | ||
69 | Plug 'tpope/vim-fugitive' | ||
70 | "increment dates, times & more | ||
71 | Plug 'tpope/vim-speeddating' | ||
72 | "search, substitute and abbreviate | ||
73 | Plug 'tpope/vim-abolish' | ||
74 | "helpers for unix | ||
75 | Plug 'tpope/vim-eunuch' | ||
76 | "unicode character metadata | ||
77 | Plug 'tpope/vim-characterize' | ||
78 | |||
79 | "fancy start screen | ||
80 | Plug 'mhinz/vim-startify' | ||
81 | Plug 'ryanoasis/vim-devicons' " asks to be placed last, sure | ||
82 | |||
83 | call plug#end() " required | ||
84 | |||
85 | "}}} | ||
86 | |||
87 | "{{{Auto Commands | ||
88 | |||
89 | " Automatically cd into the directory that the file is in | ||
90 | autocmd BufEnter * silent! lcd %:p:h | ||
91 | |||
92 | " Remove any trailing whitespace that is in the file | ||
93 | autocmd BufRead,BufWrite * if ! &bin | silent! %s/\s\+$//ge | endif | ||
94 | |||
95 | " Close vim if the only window left open is NERDTree | ||
96 | autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif | ||
97 | |||
98 | "}}} | ||
99 | |||
100 | "{{{Misc Settings | ||
101 | |||
102 | let g:ycm_global_ycm_extra_conf = '~/.ycm_extra_conf.py' | ||
103 | |||
104 | " necesary for lots of cool vim things | ||
105 | set nocompatible | ||
106 | |||
107 | " See below | ||
108 | " https://stackoverflow.com/a/33380495 | ||
109 | if !exists("g:syntax_on") | ||
110 | syntax enable | ||
111 | endif | ||
112 | |||
113 | set grepprg=grep\ -nH\ $* " DONT KNOW WHAT THIS DOES | ||
114 | |||
115 | " Tab stuff | ||
116 | set autoindent | ||
117 | set expandtab " Use appropriate number of spaces to insert a <Tab> | ||
118 | set smarttab | ||
119 | set shiftwidth=4 | ||
120 | set softtabstop=4 | ||
121 | set tabstop=8 | ||
122 | |||
123 | " Visual aid to deter from typing past column 110 | ||
124 | "set colorcolumn=110 | ||
125 | |||
126 | " Use english for spellchecking, but don't spellcheck by default | ||
127 | set spell spelllang=en_us | ||
128 | set nospell | ||
129 | |||
130 | " Cool tab completion stuff | ||
131 | set wildmenu | ||
132 | set wildmode=list:longest,full | ||
133 | set wildignore=*.o,*.obj,*.class | ||
134 | |||
135 | set encoding=utf-8 | ||
136 | set scrolloff=4 " Keep n lines above/below cursor | ||
137 | set mouse=c | ||
138 | set backspace=2 " make backspace work like most other programs | ||
139 | set number " line numbers | ||
140 | set history=1000 " number of lines that are remembered | ||
141 | set showcmd " this shows what you are typing as a command. I love this! | ||
142 | set foldmethod=marker " folding stuffs | ||
143 | set incsearch " search as you type (before <CR>) | ||
144 | set hlsearch " highlight things that we find with the search | ||
145 | set nohidden " when i close a tab, remove the buffer | ||
146 | set title " set terminal title | ||
147 | set showmatch " jump to the matching bracket briefly, REMOVE AFTER TESTING | ||
148 | set linebreak " wrap using 'breakat' character | ||
149 | set splitbelow " new split panes will split to below and right | ||
150 | set splitright | ||
151 | |||
152 | " lower case searches ignore case, upper case searches do not | ||
153 | set ignorecase | ||
154 | set smartcase | ||
155 | |||
156 | " This is totally awesome - remap jj to escape in insert mode. You'll never type jj anyway, so it's great! | ||
157 | inoremap jj <Esc> | ||
158 | nnoremap JJJJ <Nop> | ||
159 | |||
160 | " https://stackoverflow.com/a/3445040/ | ||
161 | " switch case labels | ||
162 | set cinoptions=l1 | ||
163 | |||
164 | " }}} | ||
165 | |||
166 | "{{{Look and Feel | ||
167 | |||
168 | " Color Scheme | ||
169 | " gruvbox_color_column works as expected IF the order is: | ||
170 | " set termguicolors | ||
171 | " colorscheme gruvbox | ||
172 | " ... | ||
173 | " set background=dark | ||
174 | " Investigate later | ||
175 | |||
176 | "let $NVIM_TUI_ENABLE_TRUE_COLOR=1 | ||
177 | set termguicolors | ||
178 | |||
179 | colorscheme gruvbox | ||
180 | |||
181 | let g:gruvbox_bold=1 | ||
182 | let g:gruvbox_color_column='red' | ||
183 | let g:gruvbox_underline=1 | ||
184 | let g:gruvbox_contrast_dark='medium' | ||
185 | let g:gruvbox_contrast_light='hard' | ||
186 | let g:gruvbox_vert_split='aqua' | ||
187 | |||
188 | set background=dark " Setting dark mode | ||
189 | |||
190 | "highlight ColorColumn guibg='DarkRed' | ||
191 | highlight NormalNC guibg='Black' | ||
192 | "highlight NormalNC guifg='Cyan' | ||
193 | |||
194 | |||
195 | " }}} | ||
196 | |||
197 | "{{{ Functions | ||
198 | |||
199 | "{{{ Open URL in browser | ||
200 | |||
201 | function! Browser () | ||
202 | let line = getline (".") | ||
203 | let line = matchstr (line, "http[^ ]*") | ||
204 | exec "!firefox ".line | ||
205 | endfunction | ||
206 | |||
207 | "}}} | ||
208 | |||
209 | "{{{Theme Rotating | ||
210 | "let themeindex=0 | ||
211 | "function! RotateColorTheme() | ||
212 | "let y = -1 | ||
213 | "while y == -1 | ||
214 | "let colorstring = "#gotham#" | ||
215 | "let x = match( colorstring, "#", g:themeindex ) | ||
216 | "let y = match( colorstring, "#", x + 1 ) | ||
217 | "let g:themeindex = x + 1 | ||
218 | "if y == -1 | ||
219 | "let g:themeindex = 0 | ||
220 | "else | ||
221 | "let themestring = strpart(colorstring, x + 1, y - x - 1) | ||
222 | "return ":colorscheme ".themestring | ||
223 | "endif | ||
224 | "endwhile | ||
225 | "endfunction | ||
226 | " }}} | ||
227 | |||
228 | "}}} | ||
229 | |||
230 | "{{{ Mappings | ||
231 | |||
232 | " Open Url on this line with the browser \w | ||
233 | map <Leader>w :call Browser ()<CR> | ||
234 | |||
235 | " Open the TagBar Plugin <F3> | ||
236 | nnoremap <silent> <F3> :TagbarToggle<CR> | ||
237 | |||
238 | " Open NERDTree <F4> | ||
239 | nnoremap <silent> <F4> :NERDTreeToggle<CR> | ||
240 | |||
241 | " Next Tab | ||
242 | nnoremap <silent> <C-Right> :tabnext<CR> | ||
243 | |||
244 | " Previous Tab | ||
245 | nnoremap <silent> <C-Left> :tabprevious<CR> | ||
246 | |||
247 | " New Tab | ||
248 | nnoremap <silent> <C-t> :tabnew<CR> | ||
249 | |||
250 | " Rotate Color Scheme <F8> | ||
251 | "nnoremap <silent> <F8> :execute RotateColorTheme()<CR> | ||
252 | |||
253 | " FixIt from YCM | ||
254 | map <F9> :YcmCompleter FixIt<CR> | ||
255 | |||
256 | " Edit vimrc \ev | ||
257 | nnoremap <silent> <Leader>ev :tabnew<CR>:e ~/.config/nvim/init.vim<CR> | ||
258 | |||
259 | " Up and down are more logical with g.. | ||
260 | nnoremap <silent> k gk | ||
261 | nnoremap <silent> j gj | ||
262 | inoremap <silent> <Up> <Esc>gka | ||
263 | inoremap <silent> <Down> <Esc>gja | ||
264 | |||
265 | " quicker window movement | ||
266 | nnoremap <C-j> <C-w>j | ||
267 | nnoremap <C-k> <C-w>k | ||
268 | nnoremap <C-h> <C-w>h | ||
269 | nnoremap <C-l> <C-w>l | ||
270 | |||
271 | " Disable highlight when <leader><cr> is pressed | ||
272 | map <silent> <leader><cr> :noh<cr> | ||
273 | |||
274 | " Space will toggle folds! | ||
275 | nnoremap <space> za | ||
276 | |||
277 | " Search mappings: These will make it so that going to the next one in a | ||
278 | " search will center on the line it's found in. | ||
279 | map N Nzz | ||
280 | map n nzz | ||
281 | |||
282 | "Insert timestamp | ||
283 | nnoremap <F5> "=strftime("%F %T")<CR>P | ||
284 | inoremap <F5> <C-R>=strftime("%F %T")<CR> | ||
285 | |||
286 | nnoremap <Leader>t "=strftime("%F")<CR>P | ||
287 | |||
288 | "}}} | ||
289 | |||
290 | "{{{Tagbar | ||
291 | |||
292 | let g:tagbar_autofocus = 1 | ||
293 | let g:tagbar_compact = 1 | ||
294 | let g:tagbar_sort = 0 | ||
295 | let g:tagbar_width = 25 | ||
296 | |||
297 | "}}} | ||
298 | |||
299 | "{{{ Airline | ||
300 | |||
301 | let g:airline_powerline_fonts = 1 " fira code | ||
302 | |||
303 | let g:airline#extensions#tabline#formatter = 'unique_tail' | ||
304 | let g:airline#extensions#ycm#enabled = 1 | ||
305 | |||
306 | "}}} | ||
307 | |||
308 | "{{{ NERDTree | ||
309 | |||
310 | let g:NERDTreeWinSize=25 | ||
311 | |||
312 | "}}} | ||
313 | |||
314 | "{{{ Ale | ||
315 | |||
316 | let g:ale_sign_error = '✗' | ||
317 | let g:ale_sign_warning = '⚑' | ||
318 | |||
319 | "}}} | ||
320 | |||
321 | "{{{ YouCompleteMe | ||
322 | |||
323 | let g:ycm_autoclose_preview_window_after_completion = 1 | ||
324 | let g:ycm_always_populate_location_list = 1 | ||
325 | let g:ycm_error_symbol = '✗' | ||
326 | let g:ycm_warning_symbol = '⚑' | ||
327 | |||
328 | map <leader>g :YcmCompleter GoToDefinition<CR> | ||
329 | |||
330 | let g:ycm_filetype_blacklist = { | ||
331 | \ 'tagbar': 1, | ||
332 | \ 'qf': 1, | ||
333 | \ 'notes': 1, | ||
334 | \ 'markdown': 1, | ||
335 | \ 'unite': 1, | ||
336 | \ 'text': 1, | ||
337 | \ 'startify': 1, | ||
338 | \ 'vimwiki': 1, | ||
339 | \ 'pandoc': 1, | ||
340 | \ 'infolog': 1, | ||
341 | \ 'mail': 1 | ||
342 | \} | ||
343 | |||
344 | let g:ycm_filetype_specific_completion_to_disable = { | ||
345 | \ 'gitcommit': 1, | ||
346 | \ 'vim': 1 | ||
347 | \} | ||
348 | |||
349 | "}}} | ||
350 | |||
351 | "{{{ Ledger | ||
352 | |||
353 | let g:ledger_extra_options = '--pedantic --explicit --check-payees' | ||
354 | au FileType ledger noremap { ?^\d<CR> | ||
355 | au FileType ledger noremap } /^\d<CR> | ||
356 | |||
357 | "}}} | ||
358 | |||
359 | "{{{ UltiSnips/YouCompleteMe | ||
360 | set runtimepath+=~/.vim/my-snippets/ | ||
361 | let g:UltiSnipsEditSplit="vertical" | ||
362 | let g:UltiSnipsSnippetsDir=$HOME.'/.vim/my-snippets/UltiSnips' | ||
363 | |||
364 | " these navigate ycm | ||
365 | let g:ycm_key_list_select_completion = ['<TAB>', '<C-j>'] | ||
366 | let g:ycm_key_list_previous_completion = ['<S-TAB>', '<C-k>'] | ||
367 | |||
368 | " ctrl + l expands the snippet, c + j/k navigates placeholders | ||
369 | let g:UltiSnipsExpandTrigger = "<C-l>" | ||
370 | let g:UltiSnipsJumpForwardTrigger = "<C-j>" | ||
371 | let g:UltiSnipsJumpBackwardTrigger = "<C-k>" | ||
372 | let g:UltiSnipsListSnippets = "<C-h>" | ||
373 | "}}} | ||
374 | |||
375 | "{{{ vim-startify | ||
376 | |||
377 | function! StartifyEntryFormat() | ||
378 | return 'WebDevIconsGetFileTypeSymbol(absolute_path) ." ". entry_path' | ||
379 | endfunction | ||
380 | |||
381 | let entry_format = "' ['. index .']'. repeat(' ', (3 - strlen(index)))" | ||
382 | |||
383 | if exists('*WebDevIconsGetFileTypeSymbol') " support for vim-devicons | ||
384 | let entry_format .= ". WebDevIconsGetFileTypeSymbol(entry_path) .' '. entry_path" | ||
385 | else | ||
386 | let entry_format .= '. entry_path' | ||
387 | endif | ||
388 | |||
389 | |||
390 | |||
391 | let g:ascii = [ | ||
392 | \' | ', | ||
393 | \'\ \ \ / -_) | _| _ \ ` \ -_)', | ||
394 | \' \_/\_/\___|_|\__|\___/_|_|_|\___|', | ||
395 | \ '', | ||
396 | \] | ||
397 | |||
398 | let g:startify_custom_header = | ||
399 | \ 'map(g:ascii + startify#fortune#boxed(), "\" \".v:val")' | ||
400 | |||
401 | "}}} | ||
402 | |||
403 | "{{{ vimwiki | ||
404 | let g:vimwiki_list = [{'path': '/home/yigit/Dropbox/personal_wiki', | ||
405 | \ 'path_html': '~/Dropbox/personal_wiki_html', | ||
406 | \ 'css_name': 'tufte.css', | ||
407 | \ 'auto_export': 1}] | ||
408 | let g:vimwiki_global_ext = 0 | ||
409 | map <Leader>b <Plug>VimwikiToggleListItem | ||
410 | "}}} | ||
411 | |||
412 | "{{{ yanks/registers and clips | ||
413 | |||
414 | set clipboard=unnamed,unnamedplus | ||
415 | |||
416 | " s for substitute | ||
417 | nmap s <plug>(SubversiveSubstitute) | ||
418 | nmap ss <plug>(SubversiveSubstituteLine) | ||
419 | nmap S <plug>(SubversiveSubstituteToEndOfLine) | ||
420 | |||
421 | nmap <leader>s <plug>(SubversiveSubstituteRange) | ||
422 | xmap <leader>s <plug>(SubversiveSubstituteRange) | ||
423 | nmap <leader>ss <plug>(SubversiveSubstituteWordRange) | ||
424 | |||
425 | nmap <c-n> <plug>(YoinkPostPasteSwapBack) | ||
426 | nmap <c-p> <plug>(YoinkPostPasteSwapForward) | ||
427 | |||
428 | let g:yoinkIncludeDeleteOperations = 1 | ||
429 | |||
430 | nmap p <plug>(YoinkPaste_p) | ||
431 | nmap P <plug>(YoinkPaste_P) | ||
432 | |||
433 | nnoremap x d | ||
434 | xnoremap x d | ||
435 | |||
436 | nnoremap xx dd | ||
437 | nnoremap X D | ||
438 | "}}} | ||
439 | |||
440 | " {{{ vimtex | ||
441 | let g:vimtex_view_method = 'zathura' | ||
442 | |||
443 | " }}} | ||
diff --git a/.config/polybar/config b/.config/polybar/config new file mode 100644 index 0000000..144597e --- /dev/null +++ b/.config/polybar/config | |||
@@ -0,0 +1,256 @@ | |||
1 | ;========================================================== | ||
2 | ; | ||
3 | ; ██████╗ ██████╗ ██╗ ██╗ ██╗██████╗ █████╗ ██████╗ | ||
4 | ; ██╔══██╗██╔═══██╗██║ ╚██╗ ██╔╝██╔══██╗██╔══██╗██╔══██╗ | ||
5 | ; ██████╔╝██║ ██║██║ ╚████╔╝ ██████╔╝███████║██████╔╝ | ||
6 | ; ██╔═══╝ ██║ ██║██║ ╚██╔╝ ██╔══██╗██╔══██║██╔══██╗ | ||
7 | ; ██║ ╚██████╔╝███████╗██║ ██████╔╝██║ ██║██║ ██║ | ||
8 | ; ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ | ||
9 | ; | ||
10 | ;========================================================== | ||
11 | |||
12 | [colors] | ||
13 | background = #0c1014 | ||
14 | background_alt = #0a3749 | ||
15 | background_modules = #fbf1c7 | ||
16 | foreground = #d3ebe9 | ||
17 | foreground_alt = #99d1ce | ||
18 | foreground_modules = #282828 | ||
19 | red = #9d0006 | ||
20 | green = #427b58 | ||
21 | yellow = #b56714 | ||
22 | blue = #458588 | ||
23 | purple = #8f3f71 | ||
24 | aqua = #689d6a | ||
25 | orange = #d65d0e | ||
26 | primary = #d26937 | ||
27 | secondary = #888ca6 | ||
28 | alert = #c23127 | ||
29 | |||
30 | [bar/top] | ||
31 | monitor = DVI-I-1 | ||
32 | width = 100% | ||
33 | height = 20 | ||
34 | offset-x = 0 | ||
35 | offset-y = 0 | ||
36 | radius = 0 | ||
37 | fixed-center = true | ||
38 | |||
39 | background = ${colors.background} | ||
40 | foreground = ${colors.foreground} | ||
41 | |||
42 | border-top-size = 0 | ||
43 | border-bottom-size = 0 | ||
44 | border-top-color = ${colors.background} | ||
45 | border-bottom-color = ${colors.background} | ||
46 | |||
47 | padding = 2 | ||
48 | module-margin = 1 | ||
49 | |||
50 | font-0 = scientifica:antialias=false;0 | ||
51 | font-1 = Lato:size=10;1 | ||
52 | font-2 = Raleway:size=10;1 | ||
53 | font-3 = FuraCode Nerd Font Mono:size=12;2 | ||
54 | |||
55 | modules-left = i3 pulseaudio mpd | ||
56 | modules-center = xwindow | ||
57 | modules-right = focus download upload date time xkeyboard | ||
58 | |||
59 | tray-position = right | ||
60 | |||
61 | [module/focus] | ||
62 | type = custom/script | ||
63 | exec = ~/.config/polybar/focus | ||
64 | interval = 10 | ||
65 | |||
66 | [module/mpd] | ||
67 | type = internal/mpd | ||
68 | host = 127.0.0.1 | ||
69 | port = 6600 | ||
70 | |||
71 | format-online = <toggle> <label-song> <icon-random> | ||
72 | label-song = %artist% - %title% | ||
73 | icon-pause = | ||
74 | icon-play = | ||
75 | icon-random = 咽 | ||
76 | |||
77 | toggle-on-foreground = ${colors.background_modules} | ||
78 | toggle-off-foreground = ${colors.foreground_modules} | ||
79 | |||
80 | format-offline = <label-offline> | ||
81 | label-offline = mpd is offline | ||
82 | |||
83 | [module/xwindow] | ||
84 | type = internal/xwindow | ||
85 | format = <label> | ||
86 | label = %title:0:70:...% | ||
87 | |||
88 | y-offset = 10 | ||
89 | label-padding = 1 | ||
90 | label-font = 1 | ||
91 | |||
92 | label-empty = ﳓ | ||
93 | label-empty-font = 4 | ||
94 | label-empty-padding = 5 | ||
95 | |||
96 | [module/xkeyboard] | ||
97 | type = internal/xkeyboard | ||
98 | blacklist-0 = num lock | ||
99 | blacklist-1 = scroll lock | ||
100 | |||
101 | format = <label-layout> <label-indicator> | ||
102 | format-spacing = 0 | ||
103 | |||
104 | format-prefix = | ||
105 | format-prefix-padding = 1 | ||
106 | format-prefix-background = ${colors.blue} | ||
107 | format-prefix-foreground = ${colors.foreground} | ||
108 | format-prefix-font = 4 | ||
109 | |||
110 | label-layout = %layout% | ||
111 | label-layout-padding = 1 | ||
112 | label-layout-background = ${colors.background_modules} | ||
113 | label-layout-foreground = ${colors.foreground_modules} | ||
114 | |||
115 | label-indicator-padding = 2 | ||
116 | label-indicator-margin = | ||
117 | label-indicator-background = ${colors.alert} | ||
118 | |||
119 | [module/i3] | ||
120 | type = internal/i3 | ||
121 | format = <label-state> <label-mode> | ||
122 | index-sort = true | ||
123 | wrapping-scroll = false | ||
124 | strip-wsnumbers = true | ||
125 | |||
126 | label-mode-background = ${colors.background_modules} | ||
127 | label-mode-foreground = ${colors.foreground_modules} | ||
128 | label-mode-padding = 2 | ||
129 | |||
130 | label-focused = %name% | ||
131 | label-focused-background = ${colors.red} | ||
132 | label-focused-foreground = ${colors.background_modules} | ||
133 | label-focused-padding = 1 | ||
134 | |||
135 | label-unfocused = %name% | ||
136 | label-unfocused-background = ${colors.background_modules} | ||
137 | label-unfocused-foreground = ${colors.foreground_modules} | ||
138 | label-unfocused-padding = 1 | ||
139 | |||
140 | label-visible = %name% | ||
141 | label-visible-background = ${colors.background_modules} | ||
142 | label-visible-foreground = ${colors.foreground_modules} | ||
143 | label-visible-padding = 1 | ||
144 | |||
145 | label-urgent = %index% | ||
146 | label-urgent-background = ${colors.alert} | ||
147 | label-urgent-foreground = ${colors.background} | ||
148 | label-urgent-padding = 1 | ||
149 | |||
150 | [module/download] | ||
151 | type = internal/network | ||
152 | interface = eno1 | ||
153 | interval = 3.0 | ||
154 | |||
155 | format-connected = <label-connected> | ||
156 | |||
157 | format-connected-prefix = | ||
158 | format-connected-prefix-padding = 1 | ||
159 | format-connected-prefix-background = ${colors.green} | ||
160 | format-connected-prefix-foreground = ${colors.foreground} | ||
161 | |||
162 | label-connected = %downspeed% | ||
163 | label-connected-background = ${colors.background_modules} | ||
164 | label-connected-foreground = ${colors.foreground_modules} | ||
165 | label-connected-padding = 1 | ||
166 | |||
167 | format-disconnected = <label-disconnected> | ||
168 | label-disconnected = %ifname% disconnected | ||
169 | |||
170 | [module/upload] | ||
171 | type = internal/network | ||
172 | interface = eno1 | ||
173 | interval = 3.0 | ||
174 | |||
175 | format-connected = <label-connected> | ||
176 | |||
177 | format-connected-prefix = | ||
178 | format-connected-prefix-padding = 1 | ||
179 | format-connected-prefix-background = ${colors.yellow} | ||
180 | format-connected-prefix-foreground = ${colors.foreground} | ||
181 | |||
182 | label-connected = %upspeed% | ||
183 | label-connected-background = ${colors.background_modules} | ||
184 | label-connected-foreground = ${colors.foreground_modules} | ||
185 | label-connected-padding = 1 | ||
186 | |||
187 | [module/date] | ||
188 | type = internal/date | ||
189 | interval = 1 | ||
190 | |||
191 | date = %Y-%m-%d %A | ||
192 | label = %date% | ||
193 | format = <label> | ||
194 | |||
195 | format-prefix = | ||
196 | format-prefix-background = ${colors.orange} | ||
197 | format-prefix-foreground = ${colors.foreground} | ||
198 | format-prefix-font = 4 | ||
199 | format-prefix-padding = 1 | ||
200 | |||
201 | label-background = ${colors.background_modules} | ||
202 | label-foreground = ${colors.foreground_modules} | ||
203 | label-padding = 1 | ||
204 | |||
205 | [module/time] | ||
206 | type = internal/date | ||
207 | interval = 1 | ||
208 | |||
209 | time = %H:%M | ||
210 | label = %time% | ||
211 | format = <label> | ||
212 | |||
213 | format-prefix = | ||
214 | format-prefix-background = ${colors.secondary} | ||
215 | format-prefix-foreground = ${colors.foreground} | ||
216 | format-prefix-font = 4 | ||
217 | format-prefix-padding = 1 | ||
218 | |||
219 | label-background = ${colors.background_modules} | ||
220 | label-foreground = ${colors.foreground_modules} | ||
221 | label-padding = 1 | ||
222 | |||
223 | [module/pulseaudio] | ||
224 | type = internal/pulseaudio | ||
225 | interval = 5 | ||
226 | |||
227 | format-volume = <label-volume> | ||
228 | |||
229 | format-volume-prefix = ♫ | ||
230 | format-volume-prefix-background = ${colors.purple} | ||
231 | format-volume-prefix-foreground = ${colors.background_modules} | ||
232 | format-volume-prefix-font = 4 | ||
233 | format-volume-prefix-padding = 1 | ||
234 | |||
235 | label-volume = %percentage% | ||
236 | label-volume-background = ${colors.background_modules} | ||
237 | label-volume-foreground = ${colors.foreground_modules} | ||
238 | label-volume-padding = 1 | ||
239 | |||
240 | label-muted = | ||
241 | label-muted-background = ${colors.purple} | ||
242 | label-muted-foreground = ${colors.foreground} | ||
243 | label-muted-padding = 2 | ||
244 | |||
245 | [settings] | ||
246 | screenchange-reload = true | ||
247 | compositing-background = source | ||
248 | compositing-foreground = source | ||
249 | compositing-border = over | ||
250 | pseudo-transparency = false | ||
251 | |||
252 | [global/wm] | ||
253 | margin-top = 5 | ||
254 | margin-bottom = 5 | ||
255 | |||
256 | ; vim:ft=dosini | ||
diff --git a/.config/polybar/focus b/.config/polybar/focus new file mode 100755 index 0000000..0cccea4 --- /dev/null +++ b/.config/polybar/focus | |||
@@ -0,0 +1,42 @@ | |||
1 | #!/usr/bin/env perl | ||
2 | # shows active taskwarrior task on polybar | ||
3 | #Copyright © 2019 yourname | ||
4 | |||
5 | #This program is free software: you can redistribute it and/or modify | ||
6 | #it under the terms of the GNU General Public License as published by | ||
7 | #the Free Software Foundation, either version 3 of the License, or | ||
8 | #(at your option) any later version. | ||
9 | |||
10 | #This program is distributed in the hope that it will be useful, | ||
11 | #but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | #GNU General Public License for more details. | ||
14 | |||
15 | #You should have received a copy of the GNU General Public License | ||
16 | #along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | use strict; | ||
19 | use warnings; | ||
20 | use IO::CaptureOutput qw/capture_exec/; | ||
21 | |||
22 | my ($stdout, $stderr, $success, $exit_code) = capture_exec("task active"); | ||
23 | |||
24 | #print("out: $stdout\nerr: $stderr\nexit_code: $exit_code\n"); | ||
25 | |||
26 | if ($stderr =~ /No matches\./) { | ||
27 | system 'echo "What a beautiful day"'; | ||
28 | exit; | ||
29 | } | ||
30 | my $active_task_maybe = $stdout; | ||
31 | |||
32 | $active_task_maybe =~ s/^\s+|\s+$//g; | ||
33 | |||
34 | my @lines = split /\n/, $active_task_maybe; | ||
35 | |||
36 | my $task = $lines[2]; | ||
37 | $task =~ s/^\s+|\s+$//g; | ||
38 | $task =~ s/\s+/ /g; | ||
39 | |||
40 | if ($task =~ m/.*?next (.*)$/) { | ||
41 | print "$1"; | ||
42 | } | ||
diff --git a/.config/polybar/launch.sh b/.config/polybar/launch.sh new file mode 100755 index 0000000..e6c42ff --- /dev/null +++ b/.config/polybar/launch.sh | |||
@@ -0,0 +1,12 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | # Terminate already running bar instances | ||
4 | killall -q polybar | ||
5 | |||
6 | # Wait until the processes have been shut down | ||
7 | while pgrep -u $UID -x polybar >/dev/null; do sleep 1; done | ||
8 | |||
9 | # Launch bar1 and bar2 | ||
10 | polybar top & | ||
11 | |||
12 | echo "Bars launched..." | ||
diff --git a/.config/ranger/commands.py b/.config/ranger/commands.py new file mode 100644 index 0000000..97b7909 --- /dev/null +++ b/.config/ranger/commands.py | |||
@@ -0,0 +1,62 @@ | |||
1 | # This is a sample commands.py. You can add your own commands here. | ||
2 | # | ||
3 | # Please refer to commands_full.py for all the default commands and a complete | ||
4 | # documentation. Do NOT add them all here, or you may end up with defunct | ||
5 | # commands when upgrading ranger. | ||
6 | |||
7 | # A simple command for demonstration purposes follows. | ||
8 | # ----------------------------------------------------------------------------- | ||
9 | |||
10 | from __future__ import (absolute_import, division, print_function) | ||
11 | |||
12 | # You can import any python module as needed. | ||
13 | import os | ||
14 | |||
15 | # You always need to import ranger.api.commands here to get the Command class: | ||
16 | from ranger.api.commands import Command | ||
17 | |||
18 | |||
19 | # Any class that is a subclass of "Command" will be integrated into ranger as a | ||
20 | # command. Try typing ":my_edit<ENTER>" in ranger! | ||
21 | class my_edit(Command): | ||
22 | # The so-called doc-string of the class will be visible in the built-in | ||
23 | # help that is accessible by typing "?c" inside ranger. | ||
24 | """:my_edit <filename> | ||
25 | |||
26 | A sample command for demonstration purposes that opens a file in an editor. | ||
27 | """ | ||
28 | |||
29 | # The execute method is called when you run this command in ranger. | ||
30 | def execute(self): | ||
31 | # self.arg(1) is the first (space-separated) argument to the function. | ||
32 | # This way you can write ":my_edit somefilename<ENTER>". | ||
33 | if self.arg(1): | ||
34 | # self.rest(1) contains self.arg(1) and everything that follows | ||
35 | target_filename = self.rest(1) | ||
36 | else: | ||
37 | # self.fm is a ranger.core.filemanager.FileManager object and gives | ||
38 | # you access to internals of ranger. | ||
39 | # self.fm.thisfile is a ranger.container.file.File object and is a | ||
40 | # reference to the currently selected file. | ||
41 | target_filename = self.fm.thisfile.path | ||
42 | |||
43 | # This is a generic function to print text in ranger. | ||
44 | self.fm.notify("Let's edit the file " + target_filename + "!") | ||
45 | |||
46 | # Using bad=True in fm.notify allows you to print error messages: | ||
47 | if not os.path.exists(target_filename): | ||
48 | self.fm.notify("The given file does not exist!", bad=True) | ||
49 | return | ||
50 | |||
51 | # This executes a function from ranger.core.acitons, a module with a | ||
52 | # variety of subroutines that can help you construct commands. | ||
53 | # Check out the source, or run "pydoc ranger.core.actions" for a list. | ||
54 | self.fm.edit_file(target_filename) | ||
55 | |||
56 | # The tab method is called when you press tab, and should return a list of | ||
57 | # suggestions that the user will tab through. | ||
58 | # tabnum is 1 for <TAB> and -1 for <S-TAB> by default | ||
59 | def tab(self, tabnum): | ||
60 | # This is a generic tab-completion function that iterates through the | ||
61 | # content of the current directory. | ||
62 | return self._tab_directory_content() | ||
diff --git a/.config/ranger/commands_full.py b/.config/ranger/commands_full.py new file mode 100644 index 0000000..d177203 --- /dev/null +++ b/.config/ranger/commands_full.py | |||
@@ -0,0 +1,1836 @@ | |||
1 | # -*- coding: utf-8 -*- | ||
2 | # This file is part of ranger, the console file manager. | ||
3 | # This configuration file is licensed under the same terms as ranger. | ||
4 | # =================================================================== | ||
5 | # | ||
6 | # NOTE: If you copied this file to /etc/ranger/commands_full.py or | ||
7 | # ~/.config/ranger/commands_full.py, then it will NOT be loaded by ranger, | ||
8 | # and only serve as a reference. | ||
9 | # | ||
10 | # =================================================================== | ||
11 | # This file contains ranger's commands. | ||
12 | # It's all in python; lines beginning with # are comments. | ||
13 | # | ||
14 | # Note that additional commands are automatically generated from the methods | ||
15 | # of the class ranger.core.actions.Actions. | ||
16 | # | ||
17 | # You can customize commands in the files /etc/ranger/commands.py (system-wide) | ||
18 | # and ~/.config/ranger/commands.py (per user). | ||
19 | # They have the same syntax as this file. In fact, you can just copy this | ||
20 | # file to ~/.config/ranger/commands_full.py with | ||
21 | # `ranger --copy-config=commands_full' and make your modifications, don't | ||
22 | # forget to rename it to commands.py. You can also use | ||
23 | # `ranger --copy-config=commands' to copy a short sample commands.py that | ||
24 | # has everything you need to get started. | ||
25 | # But make sure you update your configs when you update ranger. | ||
26 | # | ||
27 | # =================================================================== | ||
28 | # Every class defined here which is a subclass of `Command' will be used as a | ||
29 | # command in ranger. Several methods are defined to interface with ranger: | ||
30 | # execute(): called when the command is executed. | ||
31 | # cancel(): called when closing the console. | ||
32 | # tab(tabnum): called when <TAB> is pressed. | ||
33 | # quick(): called after each keypress. | ||
34 | # | ||
35 | # tab() argument tabnum is 1 for <TAB> and -1 for <S-TAB> by default | ||
36 | # | ||
37 | # The return values for tab() can be either: | ||
38 | # None: There is no tab completion | ||
39 | # A string: Change the console to this string | ||
40 | # A list/tuple/generator: cycle through every item in it | ||
41 | # | ||
42 | # The return value for quick() can be: | ||
43 | # False: Nothing happens | ||
44 | # True: Execute the command afterwards | ||
45 | # | ||
46 | # The return value for execute() and cancel() doesn't matter. | ||
47 | # | ||
48 | # =================================================================== | ||
49 | # Commands have certain attributes and methods that facilitate parsing of | ||
50 | # the arguments: | ||
51 | # | ||
52 | # self.line: The whole line that was written in the console. | ||
53 | # self.args: A list of all (space-separated) arguments to the command. | ||
54 | # self.quantifier: If this command was mapped to the key "X" and | ||
55 | # the user pressed 6X, self.quantifier will be 6. | ||
56 | # self.arg(n): The n-th argument, or an empty string if it doesn't exist. | ||
57 | # self.rest(n): The n-th argument plus everything that followed. For example, | ||
58 | # if the command was "search foo bar a b c", rest(2) will be "bar a b c" | ||
59 | # self.start(n): Anything before the n-th argument. For example, if the | ||
60 | # command was "search foo bar a b c", start(2) will be "search foo" | ||
61 | # | ||
62 | # =================================================================== | ||
63 | # And this is a little reference for common ranger functions and objects: | ||
64 | # | ||
65 | # self.fm: A reference to the "fm" object which contains most information | ||
66 | # about ranger. | ||
67 | # self.fm.notify(string): Print the given string on the screen. | ||
68 | # self.fm.notify(string, bad=True): Print the given string in RED. | ||
69 | # self.fm.reload_cwd(): Reload the current working directory. | ||
70 | # self.fm.thisdir: The current working directory. (A File object.) | ||
71 | # self.fm.thisfile: The current file. (A File object too.) | ||
72 | # self.fm.thistab.get_selection(): A list of all selected files. | ||
73 | # self.fm.execute_console(string): Execute the string as a ranger command. | ||
74 | # self.fm.open_console(string): Open the console with the given string | ||
75 | # already typed in for you. | ||
76 | # self.fm.move(direction): Moves the cursor in the given direction, which | ||
77 | # can be something like down=3, up=5, right=1, left=1, to=6, ... | ||
78 | # | ||
79 | # File objects (for example self.fm.thisfile) have these useful attributes and | ||
80 | # methods: | ||
81 | # | ||
82 | # tfile.path: The path to the file. | ||
83 | # tfile.basename: The base name only. | ||
84 | # tfile.load_content(): Force a loading of the directories content (which | ||
85 | # obviously works with directories only) | ||
86 | # tfile.is_directory: True/False depending on whether it's a directory. | ||
87 | # | ||
88 | # For advanced commands it is unavoidable to dive a bit into the source code | ||
89 | # of ranger. | ||
90 | # =================================================================== | ||
91 | |||
92 | from __future__ import (absolute_import, division, print_function) | ||
93 | |||
94 | from collections import deque | ||
95 | import os | ||
96 | import re | ||
97 | |||
98 | from ranger.api.commands import Command | ||
99 | |||
100 | |||
101 | class alias(Command): | ||
102 | """:alias <newcommand> <oldcommand> | ||
103 | |||
104 | Copies the oldcommand as newcommand. | ||
105 | """ | ||
106 | |||
107 | context = 'browser' | ||
108 | resolve_macros = False | ||
109 | |||
110 | def execute(self): | ||
111 | if not self.arg(1) or not self.arg(2): | ||
112 | self.fm.notify('Syntax: alias <newcommand> <oldcommand>', bad=True) | ||
113 | return | ||
114 | |||
115 | self.fm.commands.alias(self.arg(1), self.rest(2)) | ||
116 | |||
117 | |||
118 | class echo(Command): | ||
119 | """:echo <text> | ||
120 | |||
121 | Display the text in the statusbar. | ||
122 | """ | ||
123 | |||
124 | def execute(self): | ||
125 | self.fm.notify(self.rest(1)) | ||
126 | |||
127 | |||
128 | class cd(Command): | ||
129 | """:cd [-r] <path> | ||
130 | |||
131 | The cd command changes the directory. | ||
132 | If the path is a file, selects that file. | ||
133 | The command 'cd -' is equivalent to typing ``. | ||
134 | Using the option "-r" will get you to the real path. | ||
135 | """ | ||
136 | |||
137 | def execute(self): | ||
138 | if self.arg(1) == '-r': | ||
139 | self.shift() | ||
140 | destination = os.path.realpath(self.rest(1)) | ||
141 | if os.path.isfile(destination): | ||
142 | self.fm.select_file(destination) | ||
143 | return | ||
144 | else: | ||
145 | destination = self.rest(1) | ||
146 | |||
147 | if not destination: | ||
148 | destination = '~' | ||
149 | |||
150 | if destination == '-': | ||
151 | self.fm.enter_bookmark('`') | ||
152 | else: | ||
153 | self.fm.cd(destination) | ||
154 | |||
155 | def _tab_args(self): | ||
156 | # dest must be rest because path could contain spaces | ||
157 | if self.arg(1) == '-r': | ||
158 | start = self.start(2) | ||
159 | dest = self.rest(2) | ||
160 | else: | ||
161 | start = self.start(1) | ||
162 | dest = self.rest(1) | ||
163 | |||
164 | if dest: | ||
165 | head, tail = os.path.split(os.path.expanduser(dest)) | ||
166 | if head: | ||
167 | dest_exp = os.path.join(os.path.normpath(head), tail) | ||
168 | else: | ||
169 | dest_exp = tail | ||
170 | else: | ||
171 | dest_exp = '' | ||
172 | return (start, dest_exp, os.path.join(self.fm.thisdir.path, dest_exp), | ||
173 | dest.endswith(os.path.sep)) | ||
174 | |||
175 | @staticmethod | ||
176 | def _tab_paths(dest, dest_abs, ends_with_sep): | ||
177 | if not dest: | ||
178 | try: | ||
179 | return next(os.walk(dest_abs))[1], dest_abs | ||
180 | except (OSError, StopIteration): | ||
181 | return [], '' | ||
182 | |||
183 | if ends_with_sep: | ||
184 | try: | ||
185 | return [os.path.join(dest, path) for path in next(os.walk(dest_abs))[1]], '' | ||
186 | except (OSError, StopIteration): | ||
187 | return [], '' | ||
188 | |||
189 | return None, None | ||
190 | |||
191 | def _tab_match(self, path_user, path_file): | ||
192 | if self.fm.settings.cd_tab_case == 'insensitive': | ||
193 | path_user = path_user.lower() | ||
194 | path_file = path_file.lower() | ||
195 | elif self.fm.settings.cd_tab_case == 'smart' and path_user.islower(): | ||
196 | path_file = path_file.lower() | ||
197 | return path_file.startswith(path_user) | ||
198 | |||
199 | def _tab_normal(self, dest, dest_abs): | ||
200 | dest_dir = os.path.dirname(dest) | ||
201 | dest_base = os.path.basename(dest) | ||
202 | |||
203 | try: | ||
204 | dirnames = next(os.walk(os.path.dirname(dest_abs)))[1] | ||
205 | except (OSError, StopIteration): | ||
206 | return [], '' | ||
207 | |||
208 | return [os.path.join(dest_dir, d) for d in dirnames if self._tab_match(dest_base, d)], '' | ||
209 | |||
210 | def _tab_fuzzy_match(self, basepath, tokens): | ||
211 | """ Find directories matching tokens recursively """ | ||
212 | if not tokens: | ||
213 | tokens = [''] | ||
214 | paths = [basepath] | ||
215 | while True: | ||
216 | token = tokens.pop() | ||
217 | matches = [] | ||
218 | for path in paths: | ||
219 | try: | ||
220 | directories = next(os.walk(path))[1] | ||
221 | except (OSError, StopIteration): | ||
222 | continue | ||
223 | matches += [os.path.join(path, d) for d in directories | ||
224 | if self._tab_match(token, d)] | ||
225 | if not tokens or not matches: | ||
226 | return matches | ||
227 | paths = matches | ||
228 | |||
229 | return None | ||
230 | |||
231 | def _tab_fuzzy(self, dest, dest_abs): | ||
232 | tokens = [] | ||
233 | basepath = dest_abs | ||
234 | while True: | ||
235 | basepath_old = basepath | ||
236 | basepath, token = os.path.split(basepath) | ||
237 | if basepath == basepath_old: | ||
238 | break | ||
239 | if os.path.isdir(basepath_old) and not token.startswith('.'): | ||
240 | basepath = basepath_old | ||
241 | break | ||
242 | tokens.append(token) | ||
243 | |||
244 | paths = self._tab_fuzzy_match(basepath, tokens) | ||
245 | if not os.path.isabs(dest): | ||
246 | paths_rel = basepath | ||
247 | paths = [os.path.relpath(path, paths_rel) for path in paths] | ||
248 | else: | ||
249 | paths_rel = '' | ||
250 | return paths, paths_rel | ||
251 | |||
252 | def tab(self, tabnum): | ||
253 | from os.path import sep | ||
254 | |||
255 | start, dest, dest_abs, ends_with_sep = self._tab_args() | ||
256 | |||
257 | paths, paths_rel = self._tab_paths(dest, dest_abs, ends_with_sep) | ||
258 | if paths is None: | ||
259 | if self.fm.settings.cd_tab_fuzzy: | ||
260 | paths, paths_rel = self._tab_fuzzy(dest, dest_abs) | ||
261 | else: | ||
262 | paths, paths_rel = self._tab_normal(dest, dest_abs) | ||
263 | |||
264 | paths.sort() | ||
265 | |||
266 | if self.fm.settings.cd_bookmarks: | ||
267 | paths[0:0] = [ | ||
268 | os.path.relpath(v.path, paths_rel) if paths_rel else v.path | ||
269 | for v in self.fm.bookmarks.dct.values() for path in paths | ||
270 | if v.path.startswith(os.path.join(paths_rel, path) + sep) | ||
271 | ] | ||
272 | |||
273 | if not paths: | ||
274 | return None | ||
275 | if len(paths) == 1: | ||
276 | return start + paths[0] + sep | ||
277 | return [start + dirname for dirname in paths] | ||
278 | |||
279 | |||
280 | class chain(Command): | ||
281 | """:chain <command1>; <command2>; ... | ||
282 | |||
283 | Calls multiple commands at once, separated by semicolons. | ||
284 | """ | ||
285 | |||
286 | def execute(self): | ||
287 | if not self.rest(1).strip(): | ||
288 | self.fm.notify('Syntax: chain <command1>; <command2>; ...', bad=True) | ||
289 | return | ||
290 | for command in [s.strip() for s in self.rest(1).split(";")]: | ||
291 | self.fm.execute_console(command) | ||
292 | |||
293 | |||
294 | class shell(Command): | ||
295 | escape_macros_for_shell = True | ||
296 | |||
297 | def execute(self): | ||
298 | if self.arg(1) and self.arg(1)[0] == '-': | ||
299 | flags = self.arg(1)[1:] | ||
300 | command = self.rest(2) | ||
301 | else: | ||
302 | flags = '' | ||
303 | command = self.rest(1) | ||
304 | |||
305 | if command: | ||
306 | self.fm.execute_command(command, flags=flags) | ||
307 | |||
308 | def tab(self, tabnum): | ||
309 | from ranger.ext.get_executables import get_executables | ||
310 | if self.arg(1) and self.arg(1)[0] == '-': | ||
311 | command = self.rest(2) | ||
312 | else: | ||
313 | command = self.rest(1) | ||
314 | start = self.line[0:len(self.line) - len(command)] | ||
315 | |||
316 | try: | ||
317 | position_of_last_space = command.rindex(" ") | ||
318 | except ValueError: | ||
319 | return (start + program + ' ' for program | ||
320 | in get_executables() if program.startswith(command)) | ||
321 | if position_of_last_space == len(command) - 1: | ||
322 | selection = self.fm.thistab.get_selection() | ||
323 | if len(selection) == 1: | ||
324 | return self.line + selection[0].shell_escaped_basename + ' ' | ||
325 | return self.line + '%s ' | ||
326 | |||
327 | before_word, start_of_word = self.line.rsplit(' ', 1) | ||
328 | return (before_word + ' ' + file.shell_escaped_basename | ||
329 | for file in self.fm.thisdir.files or [] | ||
330 | if file.shell_escaped_basename.startswith(start_of_word)) | ||
331 | |||
332 | |||
333 | class open_with(Command): | ||
334 | |||
335 | def execute(self): | ||
336 | app, flags, mode = self._get_app_flags_mode(self.rest(1)) | ||
337 | self.fm.execute_file( | ||
338 | files=[f for f in self.fm.thistab.get_selection()], | ||
339 | app=app, | ||
340 | flags=flags, | ||
341 | mode=mode) | ||
342 | |||
343 | def tab(self, tabnum): | ||
344 | return self._tab_through_executables() | ||
345 | |||
346 | def _get_app_flags_mode(self, string): # pylint: disable=too-many-branches,too-many-statements | ||
347 | """Extracts the application, flags and mode from a string. | ||
348 | |||
349 | examples: | ||
350 | "mplayer f 1" => ("mplayer", "f", 1) | ||
351 | "atool 4" => ("atool", "", 4) | ||
352 | "p" => ("", "p", 0) | ||
353 | "" => None | ||
354 | """ | ||
355 | |||
356 | app = '' | ||
357 | flags = '' | ||
358 | mode = 0 | ||
359 | split = string.split() | ||
360 | |||
361 | if len(split) == 1: | ||
362 | part = split[0] | ||
363 | if self._is_app(part): | ||
364 | app = part | ||
365 | elif self._is_flags(part): | ||
366 | flags = part | ||
367 | elif self._is_mode(part): | ||
368 | mode = part | ||
369 | |||
370 | elif len(split) == 2: | ||
371 | part0 = split[0] | ||
372 | part1 = split[1] | ||
373 | |||
374 | if self._is_app(part0): | ||
375 | app = part0 | ||
376 | if self._is_flags(part1): | ||
377 | flags = part1 | ||
378 | elif self._is_mode(part1): | ||
379 | mode = part1 | ||
380 | elif self._is_flags(part0): | ||
381 | flags = part0 | ||
382 | if self._is_mode(part1): | ||
383 | mode = part1 | ||
384 | elif self._is_mode(part0): | ||
385 | mode = part0 | ||
386 | if self._is_flags(part1): | ||
387 | flags = part1 | ||
388 | |||
389 | elif len(split) >= 3: | ||
390 | part0 = split[0] | ||
391 | part1 = split[1] | ||
392 | part2 = split[2] | ||
393 | |||
394 | if self._is_app(part0): | ||
395 | app = part0 | ||
396 | if self._is_flags(part1): | ||
397 | flags = part1 | ||
398 | if self._is_mode(part2): | ||
399 | mode = part2 | ||
400 | elif self._is_mode(part1): | ||
401 | mode = part1 | ||
402 | if self._is_flags(part2): | ||
403 | flags = part2 | ||
404 | elif self._is_flags(part0): | ||
405 | flags = part0 | ||
406 | if self._is_mode(part1): | ||
407 | mode = part1 | ||
408 | elif self._is_mode(part0): | ||
409 | mode = part0 | ||
410 | if self._is_flags(part1): | ||
411 | flags = part1 | ||
412 | |||
413 | return app, flags, int(mode) | ||
414 | |||
415 | def _is_app(self, arg): | ||
416 | return not self._is_flags(arg) and not arg.isdigit() | ||
417 | |||
418 | @staticmethod | ||
419 | def _is_flags(arg): | ||
420 | from ranger.core.runner import ALLOWED_FLAGS | ||
421 | return all(x in ALLOWED_FLAGS for x in arg) | ||
422 | |||
423 | @staticmethod | ||
424 | def _is_mode(arg): | ||
425 | return all(x in '0123456789' for x in arg) | ||
426 | |||
427 | |||
428 | class set_(Command): | ||
429 | """:set <option name>=<python expression> | ||
430 | |||
431 | Gives an option a new value. | ||
432 | |||
433 | Use `:set <option>!` to toggle or cycle it, e.g. `:set flush_input!` | ||
434 | """ | ||
435 | name = 'set' # don't override the builtin set class | ||
436 | |||
437 | def execute(self): | ||
438 | name = self.arg(1) | ||
439 | name, value, _, toggle = self.parse_setting_line_v2() | ||
440 | if toggle: | ||
441 | self.fm.toggle_option(name) | ||
442 | else: | ||
443 | self.fm.set_option_from_string(name, value) | ||
444 | |||
445 | def tab(self, tabnum): # pylint: disable=too-many-return-statements | ||
446 | from ranger.gui.colorscheme import get_all_colorschemes | ||
447 | name, value, name_done = self.parse_setting_line() | ||
448 | settings = self.fm.settings | ||
449 | if not name: | ||
450 | return sorted(self.firstpart + setting for setting in settings) | ||
451 | if not value and not name_done: | ||
452 | return sorted(self.firstpart + setting for setting in settings | ||
453 | if setting.startswith(name)) | ||
454 | if not value: | ||
455 | value_completers = { | ||
456 | "colorscheme": | ||
457 | # Cycle through colorschemes when name, but no value is specified | ||
458 | lambda: sorted(self.firstpart + colorscheme for colorscheme | ||
459 | in get_all_colorschemes(self.fm)), | ||
460 | |||
461 | "column_ratios": | ||
462 | lambda: self.firstpart + ",".join(map(str, settings[name])), | ||
463 | } | ||
464 | |||
465 | def default_value_completer(): | ||
466 | return self.firstpart + str(settings[name]) | ||
467 | |||
468 | return value_completers.get(name, default_value_completer)() | ||
469 | if bool in settings.types_of(name): | ||
470 | if 'true'.startswith(value.lower()): | ||
471 | return self.firstpart + 'True' | ||
472 | if 'false'.startswith(value.lower()): | ||
473 | return self.firstpart + 'False' | ||
474 | # Tab complete colorscheme values if incomplete value is present | ||
475 | if name == "colorscheme": | ||
476 | return sorted(self.firstpart + colorscheme for colorscheme | ||
477 | in get_all_colorschemes(self.fm) if colorscheme.startswith(value)) | ||
478 | return None | ||
479 | |||
480 | |||
481 | class setlocal(set_): | ||
482 | """:setlocal path=<regular expression> <option name>=<python expression> | ||
483 | |||
484 | Gives an option a new value. | ||
485 | """ | ||
486 | PATH_RE_DQUOTED = re.compile(r'^setlocal\s+path="(.*?)"') | ||
487 | PATH_RE_SQUOTED = re.compile(r"^setlocal\s+path='(.*?)'") | ||
488 | PATH_RE_UNQUOTED = re.compile(r'^path=(.*?)$') | ||
489 | |||
490 | def _re_shift(self, match): | ||
491 | if not match: | ||
492 | return None | ||
493 | path = os.path.expanduser(match.group(1)) | ||
494 | for _ in range(len(path.split())): | ||
495 | self.shift() | ||
496 | return path | ||
497 | |||
498 | def execute(self): | ||
499 | path = self._re_shift(self.PATH_RE_DQUOTED.match(self.line)) | ||
500 | if path is None: | ||
501 | path = self._re_shift(self.PATH_RE_SQUOTED.match(self.line)) | ||
502 | if path is None: | ||
503 | path = self._re_shift(self.PATH_RE_UNQUOTED.match(self.arg(1))) | ||
504 | if path is None and self.fm.thisdir: | ||
505 | path = self.fm.thisdir.path | ||
506 | if not path: | ||
507 | return | ||
508 | |||
509 | name, value, _ = self.parse_setting_line() | ||
510 | self.fm.set_option_from_string(name, value, localpath=path) | ||
511 | |||
512 | |||
513 | class setintag(set_): | ||
514 | """:setintag <tag or tags> <option name>=<option value> | ||
515 | |||
516 | Sets an option for directories that are tagged with a specific tag. | ||
517 | """ | ||
518 | |||
519 | def execute(self): | ||
520 | tags = self.arg(1) | ||
521 | self.shift() | ||
522 | name, value, _ = self.parse_setting_line() | ||
523 | self.fm.set_option_from_string(name, value, tags=tags) | ||
524 | |||
525 | |||
526 | class default_linemode(Command): | ||
527 | |||
528 | def execute(self): | ||
529 | from ranger.container.fsobject import FileSystemObject | ||
530 | |||
531 | if len(self.args) < 2: | ||
532 | self.fm.notify( | ||
533 | "Usage: default_linemode [path=<regexp> | tag=<tag(s)>] <linemode>", bad=True) | ||
534 | |||
535 | # Extract options like "path=..." or "tag=..." from the command line | ||
536 | arg1 = self.arg(1) | ||
537 | method = "always" | ||
538 | argument = None | ||
539 | if arg1.startswith("path="): | ||
540 | method = "path" | ||
541 | argument = re.compile(arg1[5:]) | ||
542 | self.shift() | ||
543 | elif arg1.startswith("tag="): | ||
544 | method = "tag" | ||
545 | argument = arg1[4:] | ||
546 | self.shift() | ||
547 | |||
548 | # Extract and validate the line mode from the command line | ||
549 | lmode = self.rest(1) | ||
550 | if lmode not in FileSystemObject.linemode_dict: | ||
551 | self.fm.notify( | ||
552 | "Invalid linemode: %s; should be %s" % ( | ||
553 | lmode, "/".join(FileSystemObject.linemode_dict)), | ||
554 | bad=True, | ||
555 | ) | ||
556 | |||
557 | # Add the prepared entry to the fm.default_linemodes | ||
558 | entry = [method, argument, lmode] | ||
559 | self.fm.default_linemodes.appendleft(entry) | ||
560 | |||
561 | # Redraw the columns | ||
562 | if self.fm.ui.browser: | ||
563 | for col in self.fm.ui.browser.columns: | ||
564 | col.need_redraw = True | ||
565 | |||
566 | def tab(self, tabnum): | ||
567 | return (self.arg(0) + " " + lmode | ||
568 | for lmode in self.fm.thisfile.linemode_dict.keys() | ||
569 | if lmode.startswith(self.arg(1))) | ||
570 | |||
571 | |||
572 | class quit(Command): # pylint: disable=redefined-builtin | ||
573 | """:quit | ||
574 | |||
575 | Closes the current tab, if there's only one tab. | ||
576 | Otherwise quits if there are no tasks in progress. | ||
577 | """ | ||
578 | def _exit_no_work(self): | ||
579 | if self.fm.loader.has_work(): | ||
580 | self.fm.notify('Not quitting: Tasks in progress: Use `quit!` to force quit') | ||
581 | else: | ||
582 | self.fm.exit() | ||
583 | |||
584 | def execute(self): | ||
585 | if len(self.fm.tabs) >= 2: | ||
586 | self.fm.tab_close() | ||
587 | else: | ||
588 | self._exit_no_work() | ||
589 | |||
590 | |||
591 | class quit_bang(Command): | ||
592 | """:quit! | ||
593 | |||
594 | Closes the current tab, if there's only one tab. | ||
595 | Otherwise force quits immediately. | ||
596 | """ | ||
597 | name = 'quit!' | ||
598 | allow_abbrev = False | ||
599 | |||
600 | def execute(self): | ||
601 | if len(self.fm.tabs) >= 2: | ||
602 | self.fm.tab_close() | ||
603 | else: | ||
604 | self.fm.exit() | ||
605 | |||
606 | |||
607 | class quitall(Command): | ||
608 | """:quitall | ||
609 | |||
610 | Quits if there are no tasks in progress. | ||
611 | """ | ||
612 | def _exit_no_work(self): | ||
613 | if self.fm.loader.has_work(): | ||
614 | self.fm.notify('Not quitting: Tasks in progress: Use `quitall!` to force quit') | ||
615 | else: | ||
616 | self.fm.exit() | ||
617 | |||
618 | def execute(self): | ||
619 | self._exit_no_work() | ||
620 | |||
621 | |||
622 | class quitall_bang(Command): | ||
623 | """:quitall! | ||
624 | |||
625 | Force quits immediately. | ||
626 | """ | ||
627 | name = 'quitall!' | ||
628 | allow_abbrev = False | ||
629 | |||
630 | def execute(self): | ||
631 | self.fm.exit() | ||
632 | |||
633 | |||
634 | class terminal(Command): | ||
635 | """:terminal | ||
636 | |||
637 | Spawns an "x-terminal-emulator" starting in the current directory. | ||
638 | """ | ||
639 | |||
640 | def execute(self): | ||
641 | from ranger.ext.get_executables import get_term | ||
642 | self.fm.run(get_term(), flags='f') | ||
643 | |||
644 | |||
645 | class delete(Command): | ||
646 | """:delete | ||
647 | |||
648 | Tries to delete the selection or the files passed in arguments (if any). | ||
649 | The arguments use a shell-like escaping. | ||
650 | |||
651 | "Selection" is defined as all the "marked files" (by default, you | ||
652 | can mark files with space or v). If there are no marked files, | ||
653 | use the "current file" (where the cursor is) | ||
654 | |||
655 | When attempting to delete non-empty directories or multiple | ||
656 | marked files, it will require a confirmation. | ||
657 | """ | ||
658 | |||
659 | allow_abbrev = False | ||
660 | escape_macros_for_shell = True | ||
661 | |||
662 | def execute(self): | ||
663 | import shlex | ||
664 | from functools import partial | ||
665 | |||
666 | def is_directory_with_files(path): | ||
667 | return os.path.isdir(path) and not os.path.islink(path) and len(os.listdir(path)) > 0 | ||
668 | |||
669 | if self.rest(1): | ||
670 | files = shlex.split(self.rest(1)) | ||
671 | many_files = (len(files) > 1 or is_directory_with_files(files[0])) | ||
672 | else: | ||
673 | cwd = self.fm.thisdir | ||
674 | tfile = self.fm.thisfile | ||
675 | if not cwd or not tfile: | ||
676 | self.fm.notify("Error: no file selected for deletion!", bad=True) | ||
677 | return | ||
678 | |||
679 | # relative_path used for a user-friendly output in the confirmation. | ||
680 | files = [f.relative_path for f in self.fm.thistab.get_selection()] | ||
681 | many_files = (cwd.marked_items or is_directory_with_files(tfile.path)) | ||
682 | |||
683 | confirm = self.fm.settings.confirm_on_delete | ||
684 | if confirm != 'never' and (confirm != 'multiple' or many_files): | ||
685 | self.fm.ui.console.ask( | ||
686 | "Confirm deletion of: %s (y/N)" % ', '.join(files), | ||
687 | partial(self._question_callback, files), | ||
688 | ('n', 'N', 'y', 'Y'), | ||
689 | ) | ||
690 | else: | ||
691 | # no need for a confirmation, just delete | ||
692 | self.fm.delete(files) | ||
693 | |||
694 | def tab(self, tabnum): | ||
695 | return self._tab_directory_content() | ||
696 | |||
697 | def _question_callback(self, files, answer): | ||
698 | if answer == 'y' or answer == 'Y': | ||
699 | self.fm.delete(files) | ||
700 | |||
701 | |||
702 | class jump_non(Command): | ||
703 | """:jump_non [-FLAGS...] | ||
704 | |||
705 | Jumps to first non-directory if highlighted file is a directory and vice versa. | ||
706 | |||
707 | Flags: | ||
708 | -r Jump in reverse order | ||
709 | -w Wrap around if reaching end of filelist | ||
710 | """ | ||
711 | def __init__(self, *args, **kwargs): | ||
712 | super(jump_non, self).__init__(*args, **kwargs) | ||
713 | |||
714 | flags, _ = self.parse_flags() | ||
715 | self._flag_reverse = 'r' in flags | ||
716 | self._flag_wrap = 'w' in flags | ||
717 | |||
718 | @staticmethod | ||
719 | def _non(fobj, is_directory): | ||
720 | return fobj.is_directory if not is_directory else not fobj.is_directory | ||
721 | |||
722 | def execute(self): | ||
723 | tfile = self.fm.thisfile | ||
724 | passed = False | ||
725 | found_before = None | ||
726 | found_after = None | ||
727 | for fobj in self.fm.thisdir.files[::-1] if self._flag_reverse else self.fm.thisdir.files: | ||
728 | if fobj.path == tfile.path: | ||
729 | passed = True | ||
730 | continue | ||
731 | |||
732 | if passed: | ||
733 | if self._non(fobj, tfile.is_directory): | ||
734 | found_after = fobj.path | ||
735 | break | ||
736 | elif not found_before and self._non(fobj, tfile.is_directory): | ||
737 | found_before = fobj.path | ||
738 | |||
739 | if found_after: | ||
740 | self.fm.select_file(found_after) | ||
741 | elif self._flag_wrap and found_before: | ||
742 | self.fm.select_file(found_before) | ||
743 | |||
744 | |||
745 | class mark_tag(Command): | ||
746 | """:mark_tag [<tags>] | ||
747 | |||
748 | Mark all tags that are tagged with either of the given tags. | ||
749 | When leaving out the tag argument, all tagged files are marked. | ||
750 | """ | ||
751 | do_mark = True | ||
752 | |||
753 | def execute(self): | ||
754 | cwd = self.fm.thisdir | ||
755 | tags = self.rest(1).replace(" ", "") | ||
756 | if not self.fm.tags or not cwd.files: | ||
757 | return | ||
758 | for fileobj in cwd.files: | ||
759 | try: | ||
760 | tag = self.fm.tags.tags[fileobj.realpath] | ||
761 | except KeyError: | ||
762 | continue | ||
763 | if not tags or tag in tags: | ||
764 | cwd.mark_item(fileobj, val=self.do_mark) | ||
765 | self.fm.ui.status.need_redraw = True | ||
766 | self.fm.ui.need_redraw = True | ||
767 | |||
768 | |||
769 | class console(Command): | ||
770 | """:console <command> | ||
771 | |||
772 | Open the console with the given command. | ||
773 | """ | ||
774 | |||
775 | def execute(self): | ||
776 | position = None | ||
777 | if self.arg(1)[0:2] == '-p': | ||
778 | try: | ||
779 | position = int(self.arg(1)[2:]) | ||
780 | except ValueError: | ||
781 | pass | ||
782 | else: | ||
783 | self.shift() | ||
784 | self.fm.open_console(self.rest(1), position=position) | ||
785 | |||
786 | |||
787 | class load_copy_buffer(Command): | ||
788 | """:load_copy_buffer | ||
789 | |||
790 | Load the copy buffer from datadir/copy_buffer | ||
791 | """ | ||
792 | copy_buffer_filename = 'copy_buffer' | ||
793 | |||
794 | def execute(self): | ||
795 | import sys | ||
796 | from ranger.container.file import File | ||
797 | from os.path import exists | ||
798 | fname = self.fm.datapath(self.copy_buffer_filename) | ||
799 | unreadable = IOError if sys.version_info[0] < 3 else OSError | ||
800 | try: | ||
801 | fobj = open(fname, 'r') | ||
802 | except unreadable: | ||
803 | return self.fm.notify( | ||
804 | "Cannot open %s" % (fname or self.copy_buffer_filename), bad=True) | ||
805 | |||
806 | self.fm.copy_buffer = set(File(g) | ||
807 | for g in fobj.read().split("\n") if exists(g)) | ||
808 | fobj.close() | ||
809 | self.fm.ui.redraw_main_column() | ||
810 | return None | ||
811 | |||
812 | |||
813 | class save_copy_buffer(Command): | ||
814 | """:save_copy_buffer | ||
815 | |||
816 | Save the copy buffer to datadir/copy_buffer | ||
817 | """ | ||
818 | copy_buffer_filename = 'copy_buffer' | ||
819 | |||
820 | def execute(self): | ||
821 | import sys | ||
822 | fname = None | ||
823 | fname = self.fm.datapath(self.copy_buffer_filename) | ||
824 | unwritable = IOError if sys.version_info[0] < 3 else OSError | ||
825 | try: | ||
826 | fobj = open(fname, 'w') | ||
827 | except unwritable: | ||
828 | return self.fm.notify("Cannot open %s" % | ||
829 | (fname or self.copy_buffer_filename), bad=True) | ||
830 | fobj.write("\n".join(fobj.path for fobj in self.fm.copy_buffer)) | ||
831 | fobj.close() | ||
832 | return None | ||
833 | |||
834 | |||
835 | class unmark_tag(mark_tag): | ||
836 | """:unmark_tag [<tags>] | ||
837 | |||
838 | Unmark all tags that are tagged with either of the given tags. | ||
839 | When leaving out the tag argument, all tagged files are unmarked. | ||
840 | """ | ||
841 | do_mark = False | ||
842 | |||
843 | |||
844 | class mkdir(Command): | ||
845 | """:mkdir <dirname> | ||
846 | |||
847 | Creates a directory with the name <dirname>. | ||
848 | """ | ||
849 | |||
850 | def execute(self): | ||
851 | from os.path import join, expanduser, lexists | ||
852 | from os import makedirs | ||
853 | |||
854 | dirname = join(self.fm.thisdir.path, expanduser(self.rest(1))) | ||
855 | if not lexists(dirname): | ||
856 | makedirs(dirname) | ||
857 | else: | ||
858 | self.fm.notify("file/directory exists!", bad=True) | ||
859 | |||
860 | def tab(self, tabnum): | ||
861 | return self._tab_directory_content() | ||
862 | |||
863 | |||
864 | class touch(Command): | ||
865 | """:touch <fname> | ||
866 | |||
867 | Creates a file with the name <fname>. | ||
868 | """ | ||
869 | |||
870 | def execute(self): | ||
871 | from os.path import join, expanduser, lexists | ||
872 | |||
873 | fname = join(self.fm.thisdir.path, expanduser(self.rest(1))) | ||
874 | if not lexists(fname): | ||
875 | open(fname, 'a').close() | ||
876 | else: | ||
877 | self.fm.notify("file/directory exists!", bad=True) | ||
878 | |||
879 | def tab(self, tabnum): | ||
880 | return self._tab_directory_content() | ||
881 | |||
882 | |||
883 | class edit(Command): | ||
884 | """:edit <filename> | ||
885 | |||
886 | Opens the specified file in vim | ||
887 | """ | ||
888 | |||
889 | def execute(self): | ||
890 | if not self.arg(1): | ||
891 | self.fm.edit_file(self.fm.thisfile.path) | ||
892 | else: | ||
893 | self.fm.edit_file(self.rest(1)) | ||
894 | |||
895 | def tab(self, tabnum): | ||
896 | return self._tab_directory_content() | ||
897 | |||
898 | |||
899 | class eval_(Command): | ||
900 | """:eval [-q] <python code> | ||
901 | |||
902 | Evaluates the python code. | ||
903 | `fm' is a reference to the FM instance. | ||
904 | To display text, use the function `p'. | ||
905 | |||
906 | Examples: | ||
907 | :eval fm | ||
908 | :eval len(fm.directories) | ||
909 | :eval p("Hello World!") | ||
910 | """ | ||
911 | name = 'eval' | ||
912 | resolve_macros = False | ||
913 | |||
914 | def execute(self): | ||
915 | # The import is needed so eval() can access the ranger module | ||
916 | import ranger # NOQA pylint: disable=unused-import,unused-variable | ||
917 | if self.arg(1) == '-q': | ||
918 | code = self.rest(2) | ||
919 | quiet = True | ||
920 | else: | ||
921 | code = self.rest(1) | ||
922 | quiet = False | ||
923 | global cmd, fm, p, quantifier # pylint: disable=invalid-name,global-variable-undefined | ||
924 | fm = self.fm | ||
925 | cmd = self.fm.execute_console | ||
926 | p = fm.notify | ||
927 | quantifier = self.quantifier | ||
928 | try: | ||
929 | try: | ||
930 | result = eval(code) # pylint: disable=eval-used | ||
931 | except SyntaxError: | ||
932 | exec(code) # pylint: disable=exec-used | ||
933 | else: | ||
934 | if result and not quiet: | ||
935 | p(result) | ||
936 | except Exception as err: # pylint: disable=broad-except | ||
937 | fm.notify("The error `%s` was caused by evaluating the " | ||
938 | "following code: `%s`" % (err, code), bad=True) | ||
939 | |||
940 | |||
941 | class rename(Command): | ||
942 | """:rename <newname> | ||
943 | |||
944 | Changes the name of the currently highlighted file to <newname> | ||
945 | """ | ||
946 | |||
947 | def execute(self): | ||
948 | from ranger.container.file import File | ||
949 | from os import access | ||
950 | |||
951 | new_name = self.rest(1) | ||
952 | |||
953 | if not new_name: | ||
954 | return self.fm.notify('Syntax: rename <newname>', bad=True) | ||
955 | |||
956 | if new_name == self.fm.thisfile.relative_path: | ||
957 | return None | ||
958 | |||
959 | if access(new_name, os.F_OK): | ||
960 | return self.fm.notify("Can't rename: file already exists!", bad=True) | ||
961 | |||
962 | if self.fm.rename(self.fm.thisfile, new_name): | ||
963 | file_new = File(new_name) | ||
964 | self.fm.bookmarks.update_path(self.fm.thisfile.path, file_new) | ||
965 | self.fm.tags.update_path(self.fm.thisfile.path, file_new.path) | ||
966 | self.fm.thisdir.pointed_obj = file_new | ||
967 | self.fm.thisfile = file_new | ||
968 | |||
969 | return None | ||
970 | |||
971 | def tab(self, tabnum): | ||
972 | return self._tab_directory_content() | ||
973 | |||
974 | |||
975 | class rename_append(Command): | ||
976 | """:rename_append [-FLAGS...] | ||
977 | |||
978 | Opens the console with ":rename <current file>" with the cursor positioned | ||
979 | before the file extension. | ||
980 | |||
981 | Flags: | ||
982 | -a Position before all extensions | ||
983 | -r Remove everything before extensions | ||
984 | """ | ||
985 | def __init__(self, *args, **kwargs): | ||
986 | super(rename_append, self).__init__(*args, **kwargs) | ||
987 | |||
988 | flags, _ = self.parse_flags() | ||
989 | self._flag_ext_all = 'a' in flags | ||
990 | self._flag_remove = 'r' in flags | ||
991 | |||
992 | def execute(self): | ||
993 | from ranger import MACRO_DELIMITER, MACRO_DELIMITER_ESC | ||
994 | |||
995 | tfile = self.fm.thisfile | ||
996 | relpath = tfile.relative_path.replace(MACRO_DELIMITER, MACRO_DELIMITER_ESC) | ||
997 | basename = tfile.basename.replace(MACRO_DELIMITER, MACRO_DELIMITER_ESC) | ||
998 | |||
999 | if basename.find('.') <= 0: | ||
1000 | self.fm.open_console('rename ' + relpath) | ||
1001 | return | ||
1002 | |||
1003 | if self._flag_ext_all: | ||
1004 | pos_ext = re.search(r'[^.]+', basename).end(0) | ||
1005 | else: | ||
1006 | pos_ext = basename.rindex('.') | ||
1007 | pos = len(relpath) - len(basename) + pos_ext | ||
1008 | |||
1009 | if self._flag_remove: | ||
1010 | relpath = relpath[:-len(basename)] + basename[pos_ext:] | ||
1011 | pos -= pos_ext | ||
1012 | |||
1013 | self.fm.open_console('rename ' + relpath, position=(7 + pos)) | ||
1014 | |||
1015 | |||
1016 | class chmod(Command): | ||
1017 | """:chmod <octal number> | ||
1018 | |||
1019 | Sets the permissions of the selection to the octal number. | ||
1020 | |||
1021 | The octal number is between 0 and 777. The digits specify the | ||
1022 | permissions for the user, the group and others. | ||
1023 | |||
1024 | A 1 permits execution, a 2 permits writing, a 4 permits reading. | ||
1025 | Add those numbers to combine them. So a 7 permits everything. | ||
1026 | """ | ||
1027 | |||
1028 | def execute(self): | ||
1029 | mode_str = self.rest(1) | ||
1030 | if not mode_str: | ||
1031 | if not self.quantifier: | ||
1032 | self.fm.notify("Syntax: chmod <octal number>", bad=True) | ||
1033 | return | ||
1034 | mode_str = str(self.quantifier) | ||
1035 | |||
1036 | try: | ||
1037 | mode = int(mode_str, 8) | ||
1038 | if mode < 0 or mode > 0o777: | ||
1039 | raise ValueError | ||
1040 | except ValueError: | ||
1041 | self.fm.notify("Need an octal number between 0 and 777!", bad=True) | ||
1042 | return | ||
1043 | |||
1044 | for fobj in self.fm.thistab.get_selection(): | ||
1045 | try: | ||
1046 | os.chmod(fobj.path, mode) | ||
1047 | except OSError as ex: | ||
1048 | self.fm.notify(ex) | ||
1049 | |||
1050 | # reloading directory. maybe its better to reload the selected | ||
1051 | # files only. | ||
1052 | self.fm.thisdir.content_outdated = True | ||
1053 | |||
1054 | |||
1055 | class bulkrename(Command): | ||
1056 | """:bulkrename | ||
1057 | |||
1058 | This command opens a list of selected files in an external editor. | ||
1059 | After you edit and save the file, it will generate a shell script | ||
1060 | which does bulk renaming according to the changes you did in the file. | ||
1061 | |||
1062 | This shell script is opened in an editor for you to review. | ||
1063 | After you close it, it will be executed. | ||
1064 | """ | ||
1065 | |||
1066 | def execute(self): # pylint: disable=too-many-locals,too-many-statements | ||
1067 | import sys | ||
1068 | import tempfile | ||
1069 | from ranger.container.file import File | ||
1070 | from ranger.ext.shell_escape import shell_escape as esc | ||
1071 | py3 = sys.version_info[0] >= 3 | ||
1072 | |||
1073 | # Create and edit the file list | ||
1074 | filenames = [f.relative_path for f in self.fm.thistab.get_selection()] | ||
1075 | listfile = tempfile.NamedTemporaryFile(delete=False) | ||
1076 | listpath = listfile.name | ||
1077 | |||
1078 | if py3: | ||
1079 | listfile.write("\n".join(filenames).encode("utf-8")) | ||
1080 | else: | ||
1081 | listfile.write("\n".join(filenames)) | ||
1082 | listfile.close() | ||
1083 | self.fm.execute_file([File(listpath)], app='editor') | ||
1084 | listfile = open(listpath, 'r') | ||
1085 | new_filenames = listfile.read().split("\n") | ||
1086 | listfile.close() | ||
1087 | os.unlink(listpath) | ||
1088 | if all(a == b for a, b in zip(filenames, new_filenames)): | ||
1089 | self.fm.notify("No renaming to be done!") | ||
1090 | return | ||
1091 | |||
1092 | # Generate script | ||
1093 | cmdfile = tempfile.NamedTemporaryFile() | ||
1094 | script_lines = [] | ||
1095 | script_lines.append("# This file will be executed when you close the editor.\n") | ||
1096 | script_lines.append("# Please double-check everything, clear the file to abort.\n") | ||
1097 | script_lines.extend("mv -vi -- %s %s\n" % (esc(old), esc(new)) | ||
1098 | for old, new in zip(filenames, new_filenames) if old != new) | ||
1099 | script_content = "".join(script_lines) | ||
1100 | if py3: | ||
1101 | cmdfile.write(script_content.encode("utf-8")) | ||
1102 | else: | ||
1103 | cmdfile.write(script_content) | ||
1104 | cmdfile.flush() | ||
1105 | |||
1106 | # Open the script and let the user review it, then check if the script | ||
1107 | # was modified by the user | ||
1108 | self.fm.execute_file([File(cmdfile.name)], app='editor') | ||
1109 | cmdfile.seek(0) | ||
1110 | script_was_edited = (script_content != cmdfile.read()) | ||
1111 | |||
1112 | # Do the renaming | ||
1113 | self.fm.run(['/bin/sh', cmdfile.name], flags='w') | ||
1114 | cmdfile.close() | ||
1115 | |||
1116 | # Retag the files, but only if the script wasn't changed during review, | ||
1117 | # because only then we know which are the source and destination files. | ||
1118 | if not script_was_edited: | ||
1119 | tags_changed = False | ||
1120 | for old, new in zip(filenames, new_filenames): | ||
1121 | if old != new: | ||
1122 | oldpath = self.fm.thisdir.path + '/' + old | ||
1123 | newpath = self.fm.thisdir.path + '/' + new | ||
1124 | if oldpath in self.fm.tags: | ||
1125 | old_tag = self.fm.tags.tags[oldpath] | ||
1126 | self.fm.tags.remove(oldpath) | ||
1127 | self.fm.tags.tags[newpath] = old_tag | ||
1128 | tags_changed = True | ||
1129 | if tags_changed: | ||
1130 | self.fm.tags.dump() | ||
1131 | else: | ||
1132 | fm.notify("files have not been retagged") | ||
1133 | |||
1134 | |||
1135 | class relink(Command): | ||
1136 | """:relink <newpath> | ||
1137 | |||
1138 | Changes the linked path of the currently highlighted symlink to <newpath> | ||
1139 | """ | ||
1140 | |||
1141 | def execute(self): | ||
1142 | new_path = self.rest(1) | ||
1143 | tfile = self.fm.thisfile | ||
1144 | |||
1145 | if not new_path: | ||
1146 | return self.fm.notify('Syntax: relink <newpath>', bad=True) | ||
1147 | |||
1148 | if not tfile.is_link: | ||
1149 | return self.fm.notify('%s is not a symlink!' % tfile.relative_path, bad=True) | ||
1150 | |||
1151 | if new_path == os.readlink(tfile.path): | ||
1152 | return None | ||
1153 | |||
1154 | try: | ||
1155 | os.remove(tfile.path) | ||
1156 | os.symlink(new_path, tfile.path) | ||
1157 | except OSError as err: | ||
1158 | self.fm.notify(err) | ||
1159 | |||
1160 | self.fm.reset() | ||
1161 | self.fm.thisdir.pointed_obj = tfile | ||
1162 | self.fm.thisfile = tfile | ||
1163 | |||
1164 | return None | ||
1165 | |||
1166 | def tab(self, tabnum): | ||
1167 | if not self.rest(1): | ||
1168 | return self.line + os.readlink(self.fm.thisfile.path) | ||
1169 | return self._tab_directory_content() | ||
1170 | |||
1171 | |||
1172 | class help_(Command): | ||
1173 | """:help | ||
1174 | |||
1175 | Display ranger's manual page. | ||
1176 | """ | ||
1177 | name = 'help' | ||
1178 | |||
1179 | def execute(self): | ||
1180 | def callback(answer): | ||
1181 | if answer == "q": | ||
1182 | return | ||
1183 | elif answer == "m": | ||
1184 | self.fm.display_help() | ||
1185 | elif answer == "c": | ||
1186 | self.fm.dump_commands() | ||
1187 | elif answer == "k": | ||
1188 | self.fm.dump_keybindings() | ||
1189 | elif answer == "s": | ||
1190 | self.fm.dump_settings() | ||
1191 | |||
1192 | self.fm.ui.console.ask( | ||
1193 | "View [m]an page, [k]ey bindings, [c]ommands or [s]ettings? (press q to abort)", | ||
1194 | callback, | ||
1195 | list("mqkcs") | ||
1196 | ) | ||
1197 | |||
1198 | |||
1199 | class copymap(Command): | ||
1200 | """:copymap <keys> <newkeys1> [<newkeys2>...] | ||
1201 | |||
1202 | Copies a "browser" keybinding from <keys> to <newkeys> | ||
1203 | """ | ||
1204 | context = 'browser' | ||
1205 | |||
1206 | def execute(self): | ||
1207 | if not self.arg(1) or not self.arg(2): | ||
1208 | return self.fm.notify("Not enough arguments", bad=True) | ||
1209 | |||
1210 | for arg in self.args[2:]: | ||
1211 | self.fm.ui.keymaps.copy(self.context, self.arg(1), arg) | ||
1212 | |||
1213 | return None | ||
1214 | |||
1215 | |||
1216 | class copypmap(copymap): | ||
1217 | """:copypmap <keys> <newkeys1> [<newkeys2>...] | ||
1218 | |||
1219 | Copies a "pager" keybinding from <keys> to <newkeys> | ||
1220 | """ | ||
1221 | context = 'pager' | ||
1222 | |||
1223 | |||
1224 | class copycmap(copymap): | ||
1225 | """:copycmap <keys> <newkeys1> [<newkeys2>...] | ||
1226 | |||
1227 | Copies a "console" keybinding from <keys> to <newkeys> | ||
1228 | """ | ||
1229 | context = 'console' | ||
1230 | |||
1231 | |||
1232 | class copytmap(copymap): | ||
1233 | """:copycmap <keys> <newkeys1> [<newkeys2>...] | ||
1234 | |||
1235 | Copies a "taskview" keybinding from <keys> to <newkeys> | ||
1236 | """ | ||
1237 | context = 'taskview' | ||
1238 | |||
1239 | |||
1240 | class unmap(Command): | ||
1241 | """:unmap <keys> [<keys2>, ...] | ||
1242 | |||
1243 | Remove the given "browser" mappings | ||
1244 | """ | ||
1245 | context = 'browser' | ||
1246 | |||
1247 | def execute(self): | ||
1248 | for arg in self.args[1:]: | ||
1249 | self.fm.ui.keymaps.unbind(self.context, arg) | ||
1250 | |||
1251 | |||
1252 | class cunmap(unmap): | ||
1253 | """:cunmap <keys> [<keys2>, ...] | ||
1254 | |||
1255 | Remove the given "console" mappings | ||
1256 | """ | ||
1257 | context = 'browser' | ||
1258 | |||
1259 | |||
1260 | class punmap(unmap): | ||
1261 | """:punmap <keys> [<keys2>, ...] | ||
1262 | |||
1263 | Remove the given "pager" mappings | ||
1264 | """ | ||
1265 | context = 'pager' | ||
1266 | |||
1267 | |||
1268 | class tunmap(unmap): | ||
1269 | """:tunmap <keys> [<keys2>, ...] | ||
1270 | |||
1271 | Remove the given "taskview" mappings | ||
1272 | """ | ||
1273 | context = 'taskview' | ||
1274 | |||
1275 | |||
1276 | class map_(Command): | ||
1277 | """:map <keysequence> <command> | ||
1278 | |||
1279 | Maps a command to a keysequence in the "browser" context. | ||
1280 | |||
1281 | Example: | ||
1282 | map j move down | ||
1283 | map J move down 10 | ||
1284 | """ | ||
1285 | name = 'map' | ||
1286 | context = 'browser' | ||
1287 | resolve_macros = False | ||
1288 | |||
1289 | def execute(self): | ||
1290 | if not self.arg(1) or not self.arg(2): | ||
1291 | self.fm.notify("Syntax: {0} <keysequence> <command>".format(self.get_name()), bad=True) | ||
1292 | return | ||
1293 | |||
1294 | self.fm.ui.keymaps.bind(self.context, self.arg(1), self.rest(2)) | ||
1295 | |||
1296 | |||
1297 | class cmap(map_): | ||
1298 | """:cmap <keysequence> <command> | ||
1299 | |||
1300 | Maps a command to a keysequence in the "console" context. | ||
1301 | |||
1302 | Example: | ||
1303 | cmap <ESC> console_close | ||
1304 | cmap <C-x> console_type test | ||
1305 | """ | ||
1306 | context = 'console' | ||
1307 | |||
1308 | |||
1309 | class tmap(map_): | ||
1310 | """:tmap <keysequence> <command> | ||
1311 | |||
1312 | Maps a command to a keysequence in the "taskview" context. | ||
1313 | """ | ||
1314 | context = 'taskview' | ||
1315 | |||
1316 | |||
1317 | class pmap(map_): | ||
1318 | """:pmap <keysequence> <command> | ||
1319 | |||
1320 | Maps a command to a keysequence in the "pager" context. | ||
1321 | """ | ||
1322 | context = 'pager' | ||
1323 | |||
1324 | |||
1325 | class scout(Command): | ||
1326 | """:scout [-FLAGS...] <pattern> | ||
1327 | |||
1328 | Swiss army knife command for searching, traveling and filtering files. | ||
1329 | |||
1330 | Flags: | ||
1331 | -a Automatically open a file on unambiguous match | ||
1332 | -e Open the selected file when pressing enter | ||
1333 | -f Filter files that match the current search pattern | ||
1334 | -g Interpret pattern as a glob pattern | ||
1335 | -i Ignore the letter case of the files | ||
1336 | -k Keep the console open when changing a directory with the command | ||
1337 | -l Letter skipping; e.g. allow "rdme" to match the file "readme" | ||
1338 | -m Mark the matching files after pressing enter | ||
1339 | -M Unmark the matching files after pressing enter | ||
1340 | -p Permanent filter: hide non-matching files after pressing enter | ||
1341 | -r Interpret pattern as a regular expression pattern | ||
1342 | -s Smart case; like -i unless pattern contains upper case letters | ||
1343 | -t Apply filter and search pattern as you type | ||
1344 | -v Inverts the match | ||
1345 | |||
1346 | Multiple flags can be combined. For example, ":scout -gpt" would create | ||
1347 | a :filter-like command using globbing. | ||
1348 | """ | ||
1349 | # pylint: disable=bad-whitespace | ||
1350 | AUTO_OPEN = 'a' | ||
1351 | OPEN_ON_ENTER = 'e' | ||
1352 | FILTER = 'f' | ||
1353 | SM_GLOB = 'g' | ||
1354 | IGNORE_CASE = 'i' | ||
1355 | KEEP_OPEN = 'k' | ||
1356 | SM_LETTERSKIP = 'l' | ||
1357 | MARK = 'm' | ||
1358 | UNMARK = 'M' | ||
1359 | PERM_FILTER = 'p' | ||
1360 | SM_REGEX = 'r' | ||
1361 | SMART_CASE = 's' | ||
1362 | AS_YOU_TYPE = 't' | ||
1363 | INVERT = 'v' | ||
1364 | # pylint: enable=bad-whitespace | ||
1365 | |||
1366 | def __init__(self, *args, **kwargs): | ||
1367 | super(scout, self).__init__(*args, **kwargs) | ||
1368 | self._regex = None | ||
1369 | self.flags, self.pattern = self.parse_flags() | ||
1370 | |||
1371 | def execute(self): # pylint: disable=too-many-branches | ||
1372 | thisdir = self.fm.thisdir | ||
1373 | flags = self.flags | ||
1374 | pattern = self.pattern | ||
1375 | regex = self._build_regex() | ||
1376 | count = self._count(move=True) | ||
1377 | |||
1378 | self.fm.thistab.last_search = regex | ||
1379 | self.fm.set_search_method(order="search") | ||
1380 | |||
1381 | if (self.MARK in flags or self.UNMARK in flags) and thisdir.files: | ||
1382 | value = flags.find(self.MARK) > flags.find(self.UNMARK) | ||
1383 | if self.FILTER in flags: | ||
1384 | for fobj in thisdir.files: | ||
1385 | thisdir.mark_item(fobj, value) | ||
1386 | else: | ||
1387 | for fobj in thisdir.files: | ||
1388 | if regex.search(fobj.relative_path): | ||
1389 | thisdir.mark_item(fobj, value) | ||
1390 | |||
1391 | if self.PERM_FILTER in flags: | ||
1392 | thisdir.filter = regex if pattern else None | ||
1393 | |||
1394 | # clean up: | ||
1395 | self.cancel() | ||
1396 | |||
1397 | if self.OPEN_ON_ENTER in flags or \ | ||
1398 | (self.AUTO_OPEN in flags and count == 1): | ||
1399 | if pattern == '..': | ||
1400 | self.fm.cd(pattern) | ||
1401 | else: | ||
1402 | self.fm.move(right=1) | ||
1403 | if self.quickly_executed: | ||
1404 | self.fm.block_input(0.5) | ||
1405 | |||
1406 | if self.KEEP_OPEN in flags and thisdir != self.fm.thisdir: | ||
1407 | # reopen the console: | ||
1408 | if not pattern: | ||
1409 | self.fm.open_console(self.line) | ||
1410 | else: | ||
1411 | self.fm.open_console(self.line[0:-len(pattern)]) | ||
1412 | |||
1413 | if self.quickly_executed and thisdir != self.fm.thisdir and pattern != "..": | ||
1414 | self.fm.block_input(0.5) | ||
1415 | |||
1416 | def cancel(self): | ||
1417 | self.fm.thisdir.temporary_filter = None | ||
1418 | self.fm.thisdir.refilter() | ||
1419 | |||
1420 | def quick(self): | ||
1421 | asyoutype = self.AS_YOU_TYPE in self.flags | ||
1422 | if self.FILTER in self.flags: | ||
1423 | self.fm.thisdir.temporary_filter = self._build_regex() | ||
1424 | if self.PERM_FILTER in self.flags and asyoutype: | ||
1425 | self.fm.thisdir.filter = self._build_regex() | ||
1426 | if self.FILTER in self.flags or self.PERM_FILTER in self.flags: | ||
1427 | self.fm.thisdir.refilter() | ||
1428 | if self._count(move=asyoutype) == 1 and self.AUTO_OPEN in self.flags: | ||
1429 | return True | ||
1430 | return False | ||
1431 | |||
1432 | def tab(self, tabnum): | ||
1433 | self._count(move=True, offset=tabnum) | ||
1434 | |||
1435 | def _build_regex(self): | ||
1436 | if self._regex is not None: | ||
1437 | return self._regex | ||
1438 | |||
1439 | frmat = "%s" | ||
1440 | flags = self.flags | ||
1441 | pattern = self.pattern | ||
1442 | |||
1443 | if pattern == ".": | ||
1444 | return re.compile("") | ||
1445 | |||
1446 | # Handle carets at start and dollar signs at end separately | ||
1447 | if pattern.startswith('^'): | ||
1448 | pattern = pattern[1:] | ||
1449 | frmat = "^" + frmat | ||
1450 | if pattern.endswith('$'): | ||
1451 | pattern = pattern[:-1] | ||
1452 | frmat += "$" | ||
1453 | |||
1454 | # Apply one of the search methods | ||
1455 | if self.SM_REGEX in flags: | ||
1456 | regex = pattern | ||
1457 | elif self.SM_GLOB in flags: | ||
1458 | regex = re.escape(pattern).replace("\\*", ".*").replace("\\?", ".") | ||
1459 | elif self.SM_LETTERSKIP in flags: | ||
1460 | regex = ".*".join(re.escape(c) for c in pattern) | ||
1461 | else: | ||
1462 | regex = re.escape(pattern) | ||
1463 | |||
1464 | regex = frmat % regex | ||
1465 | |||
1466 | # Invert regular expression if necessary | ||
1467 | if self.INVERT in flags: | ||
1468 | regex = "^(?:(?!%s).)*$" % regex | ||
1469 | |||
1470 | # Compile Regular Expression | ||
1471 | # pylint: disable=no-member | ||
1472 | options = re.UNICODE | ||
1473 | if self.IGNORE_CASE in flags or self.SMART_CASE in flags and \ | ||
1474 | pattern.islower(): | ||
1475 | options |= re.IGNORECASE | ||
1476 | # pylint: enable=no-member | ||
1477 | try: | ||
1478 | self._regex = re.compile(regex, options) | ||
1479 | except re.error: | ||
1480 | self._regex = re.compile("") | ||
1481 | return self._regex | ||
1482 | |||
1483 | def _count(self, move=False, offset=0): | ||
1484 | count = 0 | ||
1485 | cwd = self.fm.thisdir | ||
1486 | pattern = self.pattern | ||
1487 | |||
1488 | if not pattern or not cwd.files: | ||
1489 | return 0 | ||
1490 | if pattern == '.': | ||
1491 | return 0 | ||
1492 | if pattern == '..': | ||
1493 | return 1 | ||
1494 | |||
1495 | deq = deque(cwd.files) | ||
1496 | deq.rotate(-cwd.pointer - offset) | ||
1497 | i = offset | ||
1498 | regex = self._build_regex() | ||
1499 | for fsobj in deq: | ||
1500 | if regex.search(fsobj.relative_path): | ||
1501 | count += 1 | ||
1502 | if move and count == 1: | ||
1503 | cwd.move(to=(cwd.pointer + i) % len(cwd.files)) | ||
1504 | self.fm.thisfile = cwd.pointed_obj | ||
1505 | if count > 1: | ||
1506 | return count | ||
1507 | i += 1 | ||
1508 | |||
1509 | return count == 1 | ||
1510 | |||
1511 | |||
1512 | class narrow(Command): | ||
1513 | """ | ||
1514 | :narrow | ||
1515 | |||
1516 | Show only the files selected right now. If no files are selected, | ||
1517 | disable narrowing. | ||
1518 | """ | ||
1519 | def execute(self): | ||
1520 | if self.fm.thisdir.marked_items: | ||
1521 | selection = [f.basename for f in self.fm.thistab.get_selection()] | ||
1522 | self.fm.thisdir.narrow_filter = selection | ||
1523 | else: | ||
1524 | self.fm.thisdir.narrow_filter = None | ||
1525 | self.fm.thisdir.refilter() | ||
1526 | |||
1527 | |||
1528 | class filter_inode_type(Command): | ||
1529 | """ | ||
1530 | :filter_inode_type [dfl] | ||
1531 | |||
1532 | Displays only the files of specified inode type. Parameters | ||
1533 | can be combined. | ||
1534 | |||
1535 | d display directories | ||
1536 | f display files | ||
1537 | l display links | ||
1538 | """ | ||
1539 | |||
1540 | def execute(self): | ||
1541 | if not self.arg(1): | ||
1542 | self.fm.thisdir.inode_type_filter = "" | ||
1543 | else: | ||
1544 | self.fm.thisdir.inode_type_filter = self.arg(1) | ||
1545 | self.fm.thisdir.refilter() | ||
1546 | |||
1547 | |||
1548 | class filter_stack(Command): | ||
1549 | """ | ||
1550 | :filter_stack ... | ||
1551 | |||
1552 | Manages the filter stack. | ||
1553 | |||
1554 | filter_stack add FILTER_TYPE ARGS... | ||
1555 | filter_stack pop | ||
1556 | filter_stack decompose | ||
1557 | filter_stack rotate [N=1] | ||
1558 | filter_stack clear | ||
1559 | filter_stack show | ||
1560 | """ | ||
1561 | def execute(self): | ||
1562 | from ranger.core.filter_stack import SIMPLE_FILTERS, FILTER_COMBINATORS | ||
1563 | |||
1564 | subcommand = self.arg(1) | ||
1565 | |||
1566 | if subcommand == "add": | ||
1567 | try: | ||
1568 | self.fm.thisdir.filter_stack.append( | ||
1569 | SIMPLE_FILTERS[self.arg(2)](self.rest(3)) | ||
1570 | ) | ||
1571 | except KeyError: | ||
1572 | FILTER_COMBINATORS[self.arg(2)](self.fm.thisdir.filter_stack) | ||
1573 | elif subcommand == "pop": | ||
1574 | self.fm.thisdir.filter_stack.pop() | ||
1575 | elif subcommand == "decompose": | ||
1576 | inner_filters = self.fm.thisdir.filter_stack.pop().decompose() | ||
1577 | if inner_filters: | ||
1578 | self.fm.thisdir.filter_stack.extend(inner_filters) | ||
1579 | elif subcommand == "clear": | ||
1580 | self.fm.thisdir.filter_stack = [] | ||
1581 | elif subcommand == "rotate": | ||
1582 | rotate_by = int(self.arg(2) or 1) | ||
1583 | self.fm.thisdir.filter_stack = ( | ||
1584 | self.fm.thisdir.filter_stack[-rotate_by:] | ||
1585 | + self.fm.thisdir.filter_stack[:-rotate_by] | ||
1586 | ) | ||
1587 | elif subcommand == "show": | ||
1588 | stack = list(map(str, self.fm.thisdir.filter_stack)) | ||
1589 | pager = self.fm.ui.open_pager() | ||
1590 | pager.set_source(["Filter stack: "] + stack) | ||
1591 | pager.move(to=100, percentage=True) | ||
1592 | return | ||
1593 | else: | ||
1594 | self.fm.notify( | ||
1595 | "Unknown subcommand: {}".format(subcommand), | ||
1596 | bad=True | ||
1597 | ) | ||
1598 | return | ||
1599 | |||
1600 | self.fm.thisdir.refilter() | ||
1601 | |||
1602 | |||
1603 | class grep(Command): | ||
1604 | """:grep <string> | ||
1605 | |||
1606 | Looks for a string in all marked files or directories | ||
1607 | """ | ||
1608 | |||
1609 | def execute(self): | ||
1610 | if self.rest(1): | ||
1611 | action = ['grep', '--line-number'] | ||
1612 | action.extend(['-e', self.rest(1), '-r']) | ||
1613 | action.extend(f.path for f in self.fm.thistab.get_selection()) | ||
1614 | self.fm.execute_command(action, flags='p') | ||
1615 | |||
1616 | |||
1617 | class flat(Command): | ||
1618 | """ | ||
1619 | :flat <level> | ||
1620 | |||
1621 | Flattens the directory view up to the specified level. | ||
1622 | |||
1623 | -1 fully flattened | ||
1624 | 0 remove flattened view | ||
1625 | """ | ||
1626 | |||
1627 | def execute(self): | ||
1628 | try: | ||
1629 | level_str = self.rest(1) | ||
1630 | level = int(level_str) | ||
1631 | except ValueError: | ||
1632 | level = self.quantifier | ||
1633 | if level is None: | ||
1634 | self.fm.notify("Syntax: flat <level>", bad=True) | ||
1635 | return | ||
1636 | if level < -1: | ||
1637 | self.fm.notify("Need an integer number (-1, 0, 1, ...)", bad=True) | ||
1638 | self.fm.thisdir.unload() | ||
1639 | self.fm.thisdir.flat = level | ||
1640 | self.fm.thisdir.load_content() | ||
1641 | |||
1642 | # Version control commands | ||
1643 | # -------------------------------- | ||
1644 | |||
1645 | |||
1646 | class stage(Command): | ||
1647 | """ | ||
1648 | :stage | ||
1649 | |||
1650 | Stage selected files for the corresponding version control system | ||
1651 | """ | ||
1652 | |||
1653 | def execute(self): | ||
1654 | from ranger.ext.vcs import VcsError | ||
1655 | |||
1656 | if self.fm.thisdir.vcs and self.fm.thisdir.vcs.track: | ||
1657 | filelist = [f.path for f in self.fm.thistab.get_selection()] | ||
1658 | try: | ||
1659 | self.fm.thisdir.vcs.action_add(filelist) | ||
1660 | except VcsError as ex: | ||
1661 | self.fm.notify('Unable to stage files: {0}'.format(ex)) | ||
1662 | self.fm.ui.vcsthread.process(self.fm.thisdir) | ||
1663 | else: | ||
1664 | self.fm.notify('Unable to stage files: Not in repository') | ||
1665 | |||
1666 | |||
1667 | class unstage(Command): | ||
1668 | """ | ||
1669 | :unstage | ||
1670 | |||
1671 | Unstage selected files for the corresponding version control system | ||
1672 | """ | ||
1673 | |||
1674 | def execute(self): | ||
1675 | from ranger.ext.vcs import VcsError | ||
1676 | |||
1677 | if self.fm.thisdir.vcs and self.fm.thisdir.vcs.track: | ||
1678 | filelist = [f.path for f in self.fm.thistab.get_selection()] | ||
1679 | try: | ||
1680 | self.fm.thisdir.vcs.action_reset(filelist) | ||
1681 | except VcsError as ex: | ||
1682 | self.fm.notify('Unable to unstage files: {0}'.format(ex)) | ||
1683 | self.fm.ui.vcsthread.process(self.fm.thisdir) | ||
1684 | else: | ||
1685 | self.fm.notify('Unable to unstage files: Not in repository') | ||
1686 | |||
1687 | # Metadata commands | ||
1688 | # -------------------------------- | ||
1689 | |||
1690 | |||
1691 | class prompt_metadata(Command): | ||
1692 | """ | ||
1693 | :prompt_metadata <key1> [<key2> [<key3> ...]] | ||
1694 | |||
1695 | Prompt the user to input metadata for multiple keys in a row. | ||
1696 | """ | ||
1697 | |||
1698 | _command_name = "meta" | ||
1699 | _console_chain = None | ||
1700 | |||
1701 | def execute(self): | ||
1702 | prompt_metadata._console_chain = self.args[1:] | ||
1703 | self._process_command_stack() | ||
1704 | |||
1705 | def _process_command_stack(self): | ||
1706 | if prompt_metadata._console_chain: | ||
1707 | key = prompt_metadata._console_chain.pop() | ||
1708 | self._fill_console(key) | ||
1709 | else: | ||
1710 | for col in self.fm.ui.browser.columns: | ||
1711 | col.need_redraw = True | ||
1712 | |||
1713 | def _fill_console(self, key): | ||
1714 | metadata = self.fm.metadata.get_metadata(self.fm.thisfile.path) | ||
1715 | if key in metadata and metadata[key]: | ||
1716 | existing_value = metadata[key] | ||
1717 | else: | ||
1718 | existing_value = "" | ||
1719 | text = "%s %s %s" % (self._command_name, key, existing_value) | ||
1720 | self.fm.open_console(text, position=len(text)) | ||
1721 | |||
1722 | |||
1723 | class meta(prompt_metadata): | ||
1724 | """ | ||
1725 | :meta <key> [<value>] | ||
1726 | |||
1727 | Change metadata of a file. Deletes the key if value is empty. | ||
1728 | """ | ||
1729 | |||
1730 | def execute(self): | ||
1731 | key = self.arg(1) | ||
1732 | update_dict = dict() | ||
1733 | update_dict[key] = self.rest(2) | ||
1734 | selection = self.fm.thistab.get_selection() | ||
1735 | for fobj in selection: | ||
1736 | self.fm.metadata.set_metadata(fobj.path, update_dict) | ||
1737 | self._process_command_stack() | ||
1738 | |||
1739 | def tab(self, tabnum): | ||
1740 | key = self.arg(1) | ||
1741 | metadata = self.fm.metadata.get_metadata(self.fm.thisfile.path) | ||
1742 | if key in metadata and metadata[key]: | ||
1743 | return [" ".join([self.arg(0), self.arg(1), metadata[key]])] | ||
1744 | return [self.arg(0) + " " + k for k in sorted(metadata) | ||
1745 | if k.startswith(self.arg(1))] | ||
1746 | |||
1747 | |||
1748 | class linemode(default_linemode): | ||
1749 | """ | ||
1750 | :linemode <mode> | ||
1751 | |||
1752 | Change what is displayed as a filename. | ||
1753 | |||
1754 | - "mode" may be any of the defined linemodes (see: ranger.core.linemode). | ||
1755 | "normal" is mapped to "filename". | ||
1756 | """ | ||
1757 | |||
1758 | def execute(self): | ||
1759 | mode = self.arg(1) | ||
1760 | |||
1761 | if mode == "normal": | ||
1762 | from ranger.core.linemode import DEFAULT_LINEMODE | ||
1763 | mode = DEFAULT_LINEMODE | ||
1764 | |||
1765 | if mode not in self.fm.thisfile.linemode_dict: | ||
1766 | self.fm.notify("Unhandled linemode: `%s'" % mode, bad=True) | ||
1767 | return | ||
1768 | |||
1769 | self.fm.thisdir.set_linemode_of_children(mode) | ||
1770 | |||
1771 | # Ask the browsercolumns to redraw | ||
1772 | for col in self.fm.ui.browser.columns: | ||
1773 | col.need_redraw = True | ||
1774 | |||
1775 | |||
1776 | class yank(Command): | ||
1777 | """:yank [name|dir|path] | ||
1778 | |||
1779 | Copies the file's name (default), directory or path into both the primary X | ||
1780 | selection and the clipboard. | ||
1781 | """ | ||
1782 | |||
1783 | modes = { | ||
1784 | '': 'basename', | ||
1785 | 'name_without_extension': 'basename_without_extension', | ||
1786 | 'name': 'basename', | ||
1787 | 'dir': 'dirname', | ||
1788 | 'path': 'path', | ||
1789 | } | ||
1790 | |||
1791 | def execute(self): | ||
1792 | import subprocess | ||
1793 | |||
1794 | def clipboards(): | ||
1795 | from ranger.ext.get_executables import get_executables | ||
1796 | clipboard_managers = { | ||
1797 | 'xclip': [ | ||
1798 | ['xclip'], | ||
1799 | ['xclip', '-selection', 'clipboard'], | ||
1800 | ], | ||
1801 | 'xsel': [ | ||
1802 | ['xsel'], | ||
1803 | ['xsel', '-b'], | ||
1804 | ], | ||
1805 | 'pbcopy': [ | ||
1806 | ['pbcopy'], | ||
1807 | ], | ||
1808 | } | ||
1809 | ordered_managers = ['pbcopy', 'xclip', 'xsel'] | ||
1810 | executables = get_executables() | ||
1811 | for manager in ordered_managers: | ||
1812 | if manager in executables: | ||
1813 | return clipboard_managers[manager] | ||
1814 | return [] | ||
1815 | |||
1816 | clipboard_commands = clipboards() | ||
1817 | |||
1818 | mode = self.modes[self.arg(1)] | ||
1819 | selection = self.get_selection_attr(mode) | ||
1820 | |||
1821 | new_clipboard_contents = "\n".join(selection) | ||
1822 | for command in clipboard_commands: | ||
1823 | process = subprocess.Popen(command, universal_newlines=True, | ||
1824 | stdin=subprocess.PIPE) | ||
1825 | process.communicate(input=new_clipboard_contents) | ||
1826 | |||
1827 | def get_selection_attr(self, attr): | ||
1828 | return [getattr(item, attr) for item in | ||
1829 | self.fm.thistab.get_selection()] | ||
1830 | |||
1831 | def tab(self, tabnum): | ||
1832 | return ( | ||
1833 | self.start(1) + mode for mode | ||
1834 | in sorted(self.modes.keys()) | ||
1835 | if mode | ||
1836 | ) | ||
diff --git a/.config/ranger/ranger_new/commands.py b/.config/ranger/ranger_new/commands.py new file mode 100644 index 0000000..97b7909 --- /dev/null +++ b/.config/ranger/ranger_new/commands.py | |||
@@ -0,0 +1,62 @@ | |||
1 | # This is a sample commands.py. You can add your own commands here. | ||
2 | # | ||
3 | # Please refer to commands_full.py for all the default commands and a complete | ||
4 | # documentation. Do NOT add them all here, or you may end up with defunct | ||
5 | # commands when upgrading ranger. | ||
6 | |||
7 | # A simple command for demonstration purposes follows. | ||
8 | # ----------------------------------------------------------------------------- | ||
9 | |||
10 | from __future__ import (absolute_import, division, print_function) | ||
11 | |||
12 | # You can import any python module as needed. | ||
13 | import os | ||
14 | |||
15 | # You always need to import ranger.api.commands here to get the Command class: | ||
16 | from ranger.api.commands import Command | ||
17 | |||
18 | |||
19 | # Any class that is a subclass of "Command" will be integrated into ranger as a | ||
20 | # command. Try typing ":my_edit<ENTER>" in ranger! | ||
21 | class my_edit(Command): | ||
22 | # The so-called doc-string of the class will be visible in the built-in | ||
23 | # help that is accessible by typing "?c" inside ranger. | ||
24 | """:my_edit <filename> | ||
25 | |||
26 | A sample command for demonstration purposes that opens a file in an editor. | ||
27 | """ | ||
28 | |||
29 | # The execute method is called when you run this command in ranger. | ||
30 | def execute(self): | ||
31 | # self.arg(1) is the first (space-separated) argument to the function. | ||
32 | # This way you can write ":my_edit somefilename<ENTER>". | ||
33 | if self.arg(1): | ||
34 | # self.rest(1) contains self.arg(1) and everything that follows | ||
35 | target_filename = self.rest(1) | ||
36 | else: | ||
37 | # self.fm is a ranger.core.filemanager.FileManager object and gives | ||
38 | # you access to internals of ranger. | ||
39 | # self.fm.thisfile is a ranger.container.file.File object and is a | ||
40 | # reference to the currently selected file. | ||
41 | target_filename = self.fm.thisfile.path | ||
42 | |||
43 | # This is a generic function to print text in ranger. | ||
44 | self.fm.notify("Let's edit the file " + target_filename + "!") | ||
45 | |||
46 | # Using bad=True in fm.notify allows you to print error messages: | ||
47 | if not os.path.exists(target_filename): | ||
48 | self.fm.notify("The given file does not exist!", bad=True) | ||
49 | return | ||
50 | |||
51 | # This executes a function from ranger.core.acitons, a module with a | ||
52 | # variety of subroutines that can help you construct commands. | ||
53 | # Check out the source, or run "pydoc ranger.core.actions" for a list. | ||
54 | self.fm.edit_file(target_filename) | ||
55 | |||
56 | # The tab method is called when you press tab, and should return a list of | ||
57 | # suggestions that the user will tab through. | ||
58 | # tabnum is 1 for <TAB> and -1 for <S-TAB> by default | ||
59 | def tab(self, tabnum): | ||
60 | # This is a generic tab-completion function that iterates through the | ||
61 | # content of the current directory. | ||
62 | return self._tab_directory_content() | ||
diff --git a/.config/ranger/ranger_new/commands_full.py b/.config/ranger/ranger_new/commands_full.py new file mode 100644 index 0000000..d177203 --- /dev/null +++ b/.config/ranger/ranger_new/commands_full.py | |||
@@ -0,0 +1,1836 @@ | |||
1 | # -*- coding: utf-8 -*- | ||
2 | # This file is part of ranger, the console file manager. | ||
3 | # This configuration file is licensed under the same terms as ranger. | ||
4 | # =================================================================== | ||
5 | # | ||
6 | # NOTE: If you copied this file to /etc/ranger/commands_full.py or | ||
7 | # ~/.config/ranger/commands_full.py, then it will NOT be loaded by ranger, | ||
8 | # and only serve as a reference. | ||
9 | # | ||
10 | # =================================================================== | ||
11 | # This file contains ranger's commands. | ||
12 | # It's all in python; lines beginning with # are comments. | ||
13 | # | ||
14 | # Note that additional commands are automatically generated from the methods | ||
15 | # of the class ranger.core.actions.Actions. | ||
16 | # | ||
17 | # You can customize commands in the files /etc/ranger/commands.py (system-wide) | ||
18 | # and ~/.config/ranger/commands.py (per user). | ||
19 | # They have the same syntax as this file. In fact, you can just copy this | ||
20 | # file to ~/.config/ranger/commands_full.py with | ||
21 | # `ranger --copy-config=commands_full' and make your modifications, don't | ||
22 | # forget to rename it to commands.py. You can also use | ||
23 | # `ranger --copy-config=commands' to copy a short sample commands.py that | ||
24 | # has everything you need to get started. | ||
25 | # But make sure you update your configs when you update ranger. | ||
26 | # | ||
27 | # =================================================================== | ||
28 | # Every class defined here which is a subclass of `Command' will be used as a | ||
29 | # command in ranger. Several methods are defined to interface with ranger: | ||
30 | # execute(): called when the command is executed. | ||
31 | # cancel(): called when closing the console. | ||
32 | # tab(tabnum): called when <TAB> is pressed. | ||
33 | # quick(): called after each keypress. | ||
34 | # | ||
35 | # tab() argument tabnum is 1 for <TAB> and -1 for <S-TAB> by default | ||
36 | # | ||
37 | # The return values for tab() can be either: | ||
38 | # None: There is no tab completion | ||
39 | # A string: Change the console to this string | ||
40 | # A list/tuple/generator: cycle through every item in it | ||
41 | # | ||
42 | # The return value for quick() can be: | ||
43 | # False: Nothing happens | ||
44 | # True: Execute the command afterwards | ||
45 | # | ||
46 | # The return value for execute() and cancel() doesn't matter. | ||
47 | # | ||
48 | # =================================================================== | ||
49 | # Commands have certain attributes and methods that facilitate parsing of | ||
50 | # the arguments: | ||
51 | # | ||
52 | # self.line: The whole line that was written in the console. | ||
53 | # self.args: A list of all (space-separated) arguments to the command. | ||
54 | # self.quantifier: If this command was mapped to the key "X" and | ||
55 | # the user pressed 6X, self.quantifier will be 6. | ||
56 | # self.arg(n): The n-th argument, or an empty string if it doesn't exist. | ||
57 | # self.rest(n): The n-th argument plus everything that followed. For example, | ||
58 | # if the command was "search foo bar a b c", rest(2) will be "bar a b c" | ||
59 | # self.start(n): Anything before the n-th argument. For example, if the | ||
60 | # command was "search foo bar a b c", start(2) will be "search foo" | ||
61 | # | ||
62 | # =================================================================== | ||
63 | # And this is a little reference for common ranger functions and objects: | ||
64 | # | ||
65 | # self.fm: A reference to the "fm" object which contains most information | ||
66 | # about ranger. | ||
67 | # self.fm.notify(string): Print the given string on the screen. | ||
68 | # self.fm.notify(string, bad=True): Print the given string in RED. | ||
69 | # self.fm.reload_cwd(): Reload the current working directory. | ||
70 | # self.fm.thisdir: The current working directory. (A File object.) | ||
71 | # self.fm.thisfile: The current file. (A File object too.) | ||
72 | # self.fm.thistab.get_selection(): A list of all selected files. | ||
73 | # self.fm.execute_console(string): Execute the string as a ranger command. | ||
74 | # self.fm.open_console(string): Open the console with the given string | ||
75 | # already typed in for you. | ||
76 | # self.fm.move(direction): Moves the cursor in the given direction, which | ||
77 | # can be something like down=3, up=5, right=1, left=1, to=6, ... | ||
78 | # | ||
79 | # File objects (for example self.fm.thisfile) have these useful attributes and | ||
80 | # methods: | ||
81 | # | ||
82 | # tfile.path: The path to the file. | ||
83 | # tfile.basename: The base name only. | ||
84 | # tfile.load_content(): Force a loading of the directories content (which | ||
85 | # obviously works with directories only) | ||
86 | # tfile.is_directory: True/False depending on whether it's a directory. | ||
87 | # | ||
88 | # For advanced commands it is unavoidable to dive a bit into the source code | ||
89 | # of ranger. | ||
90 | # =================================================================== | ||
91 | |||
92 | from __future__ import (absolute_import, division, print_function) | ||
93 | |||
94 | from collections import deque | ||
95 | import os | ||
96 | import re | ||
97 | |||
98 | from ranger.api.commands import Command | ||
99 | |||
100 | |||
101 | class alias(Command): | ||
102 | """:alias <newcommand> <oldcommand> | ||
103 | |||
104 | Copies the oldcommand as newcommand. | ||
105 | """ | ||
106 | |||
107 | context = 'browser' | ||
108 | resolve_macros = False | ||
109 | |||
110 | def execute(self): | ||
111 | if not self.arg(1) or not self.arg(2): | ||
112 | self.fm.notify('Syntax: alias <newcommand> <oldcommand>', bad=True) | ||
113 | return | ||
114 | |||
115 | self.fm.commands.alias(self.arg(1), self.rest(2)) | ||
116 | |||
117 | |||
118 | class echo(Command): | ||
119 | """:echo <text> | ||
120 | |||
121 | Display the text in the statusbar. | ||
122 | """ | ||
123 | |||
124 | def execute(self): | ||
125 | self.fm.notify(self.rest(1)) | ||
126 | |||
127 | |||
128 | class cd(Command): | ||
129 | """:cd [-r] <path> | ||
130 | |||
131 | The cd command changes the directory. | ||
132 | If the path is a file, selects that file. | ||
133 | The command 'cd -' is equivalent to typing ``. | ||
134 | Using the option "-r" will get you to the real path. | ||
135 | """ | ||
136 | |||
137 | def execute(self): | ||
138 | if self.arg(1) == '-r': | ||
139 | self.shift() | ||
140 | destination = os.path.realpath(self.rest(1)) | ||
141 | if os.path.isfile(destination): | ||
142 | self.fm.select_file(destination) | ||
143 | return | ||
144 | else: | ||
145 | destination = self.rest(1) | ||
146 | |||
147 | if not destination: | ||
148 | destination = '~' | ||
149 | |||
150 | if destination == '-': | ||
151 | self.fm.enter_bookmark('`') | ||
152 | else: | ||
153 | self.fm.cd(destination) | ||
154 | |||
155 | def _tab_args(self): | ||
156 | # dest must be rest because path could contain spaces | ||
157 | if self.arg(1) == '-r': | ||
158 | start = self.start(2) | ||
159 | dest = self.rest(2) | ||
160 | else: | ||
161 | start = self.start(1) | ||
162 | dest = self.rest(1) | ||
163 | |||
164 | if dest: | ||
165 | head, tail = os.path.split(os.path.expanduser(dest)) | ||
166 | if head: | ||
167 | dest_exp = os.path.join(os.path.normpath(head), tail) | ||
168 | else: | ||
169 | dest_exp = tail | ||
170 | else: | ||
171 | dest_exp = '' | ||
172 | return (start, dest_exp, os.path.join(self.fm.thisdir.path, dest_exp), | ||
173 | dest.endswith(os.path.sep)) | ||
174 | |||
175 | @staticmethod | ||
176 | def _tab_paths(dest, dest_abs, ends_with_sep): | ||
177 | if not dest: | ||
178 | try: | ||
179 | return next(os.walk(dest_abs))[1], dest_abs | ||
180 | except (OSError, StopIteration): | ||
181 | return [], '' | ||
182 | |||
183 | if ends_with_sep: | ||
184 | try: | ||
185 | return [os.path.join(dest, path) for path in next(os.walk(dest_abs))[1]], '' | ||
186 | except (OSError, StopIteration): | ||
187 | return [], '' | ||
188 | |||
189 | return None, None | ||
190 | |||
191 | def _tab_match(self, path_user, path_file): | ||
192 | if self.fm.settings.cd_tab_case == 'insensitive': | ||
193 | path_user = path_user.lower() | ||
194 | path_file = path_file.lower() | ||
195 | elif self.fm.settings.cd_tab_case == 'smart' and path_user.islower(): | ||
196 | path_file = path_file.lower() | ||
197 | return path_file.startswith(path_user) | ||
198 | |||
199 | def _tab_normal(self, dest, dest_abs): | ||
200 | dest_dir = os.path.dirname(dest) | ||
201 | dest_base = os.path.basename(dest) | ||
202 | |||
203 | try: | ||
204 | dirnames = next(os.walk(os.path.dirname(dest_abs)))[1] | ||
205 | except (OSError, StopIteration): | ||
206 | return [], '' | ||
207 | |||
208 | return [os.path.join(dest_dir, d) for d in dirnames if self._tab_match(dest_base, d)], '' | ||
209 | |||
210 | def _tab_fuzzy_match(self, basepath, tokens): | ||
211 | """ Find directories matching tokens recursively """ | ||
212 | if not tokens: | ||
213 | tokens = [''] | ||
214 | paths = [basepath] | ||
215 | while True: | ||
216 | token = tokens.pop() | ||
217 | matches = [] | ||
218 | for path in paths: | ||
219 | try: | ||
220 | directories = next(os.walk(path))[1] | ||
221 | except (OSError, StopIteration): | ||
222 | continue | ||
223 | matches += [os.path.join(path, d) for d in directories | ||
224 | if self._tab_match(token, d)] | ||
225 | if not tokens or not matches: | ||
226 | return matches | ||
227 | paths = matches | ||
228 | |||
229 | return None | ||
230 | |||
231 | def _tab_fuzzy(self, dest, dest_abs): | ||
232 | tokens = [] | ||
233 | basepath = dest_abs | ||
234 | while True: | ||
235 | basepath_old = basepath | ||
236 | basepath, token = os.path.split(basepath) | ||
237 | if basepath == basepath_old: | ||
238 | break | ||
239 | if os.path.isdir(basepath_old) and not token.startswith('.'): | ||
240 | basepath = basepath_old | ||
241 | break | ||
242 | tokens.append(token) | ||
243 | |||
244 | paths = self._tab_fuzzy_match(basepath, tokens) | ||
245 | if not os.path.isabs(dest): | ||
246 | paths_rel = basepath | ||
247 | paths = [os.path.relpath(path, paths_rel) for path in paths] | ||
248 | else: | ||
249 | paths_rel = '' | ||
250 | return paths, paths_rel | ||
251 | |||
252 | def tab(self, tabnum): | ||
253 | from os.path import sep | ||
254 | |||
255 | start, dest, dest_abs, ends_with_sep = self._tab_args() | ||
256 | |||
257 | paths, paths_rel = self._tab_paths(dest, dest_abs, ends_with_sep) | ||
258 | if paths is None: | ||
259 | if self.fm.settings.cd_tab_fuzzy: | ||
260 | paths, paths_rel = self._tab_fuzzy(dest, dest_abs) | ||
261 | else: | ||
262 | paths, paths_rel = self._tab_normal(dest, dest_abs) | ||
263 | |||
264 | paths.sort() | ||
265 | |||
266 | if self.fm.settings.cd_bookmarks: | ||
267 | paths[0:0] = [ | ||
268 | os.path.relpath(v.path, paths_rel) if paths_rel else v.path | ||
269 | for v in self.fm.bookmarks.dct.values() for path in paths | ||
270 | if v.path.startswith(os.path.join(paths_rel, path) + sep) | ||
271 | ] | ||
272 | |||
273 | if not paths: | ||
274 | return None | ||
275 | if len(paths) == 1: | ||
276 | return start + paths[0] + sep | ||
277 | return [start + dirname for dirname in paths] | ||
278 | |||
279 | |||
280 | class chain(Command): | ||
281 | """:chain <command1>; <command2>; ... | ||
282 | |||
283 | Calls multiple commands at once, separated by semicolons. | ||
284 | """ | ||
285 | |||
286 | def execute(self): | ||
287 | if not self.rest(1).strip(): | ||
288 | self.fm.notify('Syntax: chain <command1>; <command2>; ...', bad=True) | ||
289 | return | ||
290 | for command in [s.strip() for s in self.rest(1).split(";")]: | ||
291 | self.fm.execute_console(command) | ||
292 | |||
293 | |||
294 | class shell(Command): | ||
295 | escape_macros_for_shell = True | ||
296 | |||
297 | def execute(self): | ||
298 | if self.arg(1) and self.arg(1)[0] == '-': | ||
299 | flags = self.arg(1)[1:] | ||
300 | command = self.rest(2) | ||
301 | else: | ||
302 | flags = '' | ||
303 | command = self.rest(1) | ||
304 | |||
305 | if command: | ||
306 | self.fm.execute_command(command, flags=flags) | ||
307 | |||
308 | def tab(self, tabnum): | ||
309 | from ranger.ext.get_executables import get_executables | ||
310 | if self.arg(1) and self.arg(1)[0] == '-': | ||
311 | command = self.rest(2) | ||
312 | else: | ||
313 | command = self.rest(1) | ||
314 | start = self.line[0:len(self.line) - len(command)] | ||
315 | |||
316 | try: | ||
317 | position_of_last_space = command.rindex(" ") | ||
318 | except ValueError: | ||
319 | return (start + program + ' ' for program | ||
320 | in get_executables() if program.startswith(command)) | ||
321 | if position_of_last_space == len(command) - 1: | ||
322 | selection = self.fm.thistab.get_selection() | ||
323 | if len(selection) == 1: | ||
324 | return self.line + selection[0].shell_escaped_basename + ' ' | ||
325 | return self.line + '%s ' | ||
326 | |||
327 | before_word, start_of_word = self.line.rsplit(' ', 1) | ||
328 | return (before_word + ' ' + file.shell_escaped_basename | ||
329 | for file in self.fm.thisdir.files or [] | ||
330 | if file.shell_escaped_basename.startswith(start_of_word)) | ||
331 | |||
332 | |||
333 | class open_with(Command): | ||
334 | |||
335 | def execute(self): | ||
336 | app, flags, mode = self._get_app_flags_mode(self.rest(1)) | ||
337 | self.fm.execute_file( | ||
338 | files=[f for f in self.fm.thistab.get_selection()], | ||
339 | app=app, | ||
340 | flags=flags, | ||
341 | mode=mode) | ||
342 | |||
343 | def tab(self, tabnum): | ||
344 | return self._tab_through_executables() | ||
345 | |||
346 | def _get_app_flags_mode(self, string): # pylint: disable=too-many-branches,too-many-statements | ||
347 | """Extracts the application, flags and mode from a string. | ||
348 | |||
349 | examples: | ||
350 | "mplayer f 1" => ("mplayer", "f", 1) | ||
351 | "atool 4" => ("atool", "", 4) | ||
352 | "p" => ("", "p", 0) | ||
353 | "" => None | ||
354 | """ | ||
355 | |||
356 | app = '' | ||
357 | flags = '' | ||
358 | mode = 0 | ||
359 | split = string.split() | ||
360 | |||
361 | if len(split) == 1: | ||
362 | part = split[0] | ||
363 | if self._is_app(part): | ||
364 | app = part | ||
365 | elif self._is_flags(part): | ||
366 | flags = part | ||
367 | elif self._is_mode(part): | ||
368 | mode = part | ||
369 | |||
370 | elif len(split) == 2: | ||
371 | part0 = split[0] | ||
372 | part1 = split[1] | ||
373 | |||
374 | if self._is_app(part0): | ||
375 | app = part0 | ||
376 | if self._is_flags(part1): | ||
377 | flags = part1 | ||
378 | elif self._is_mode(part1): | ||
379 | mode = part1 | ||
380 | elif self._is_flags(part0): | ||
381 | flags = part0 | ||
382 | if self._is_mode(part1): | ||
383 | mode = part1 | ||
384 | elif self._is_mode(part0): | ||
385 | mode = part0 | ||
386 | if self._is_flags(part1): | ||
387 | flags = part1 | ||
388 | |||
389 | elif len(split) >= 3: | ||
390 | part0 = split[0] | ||
391 | part1 = split[1] | ||
392 | part2 = split[2] | ||
393 | |||
394 | if self._is_app(part0): | ||
395 | app = part0 | ||
396 | if self._is_flags(part1): | ||
397 | flags = part1 | ||
398 | if self._is_mode(part2): | ||
399 | mode = part2 | ||
400 | elif self._is_mode(part1): | ||
401 | mode = part1 | ||
402 | if self._is_flags(part2): | ||
403 | flags = part2 | ||
404 | elif self._is_flags(part0): | ||
405 | flags = part0 | ||
406 | if self._is_mode(part1): | ||
407 | mode = part1 | ||
408 | elif self._is_mode(part0): | ||
409 | mode = part0 | ||
410 | if self._is_flags(part1): | ||
411 | flags = part1 | ||
412 | |||
413 | return app, flags, int(mode) | ||
414 | |||
415 | def _is_app(self, arg): | ||
416 | return not self._is_flags(arg) and not arg.isdigit() | ||
417 | |||
418 | @staticmethod | ||
419 | def _is_flags(arg): | ||
420 | from ranger.core.runner import ALLOWED_FLAGS | ||
421 | return all(x in ALLOWED_FLAGS for x in arg) | ||
422 | |||
423 | @staticmethod | ||
424 | def _is_mode(arg): | ||
425 | return all(x in '0123456789' for x in arg) | ||
426 | |||
427 | |||
428 | class set_(Command): | ||
429 | """:set <option name>=<python expression> | ||
430 | |||
431 | Gives an option a new value. | ||
432 | |||
433 | Use `:set <option>!` to toggle or cycle it, e.g. `:set flush_input!` | ||
434 | """ | ||
435 | name = 'set' # don't override the builtin set class | ||
436 | |||
437 | def execute(self): | ||
438 | name = self.arg(1) | ||
439 | name, value, _, toggle = self.parse_setting_line_v2() | ||
440 | if toggle: | ||
441 | self.fm.toggle_option(name) | ||
442 | else: | ||
443 | self.fm.set_option_from_string(name, value) | ||
444 | |||
445 | def tab(self, tabnum): # pylint: disable=too-many-return-statements | ||
446 | from ranger.gui.colorscheme import get_all_colorschemes | ||
447 | name, value, name_done = self.parse_setting_line() | ||
448 | settings = self.fm.settings | ||
449 | if not name: | ||
450 | return sorted(self.firstpart + setting for setting in settings) | ||
451 | if not value and not name_done: | ||
452 | return sorted(self.firstpart + setting for setting in settings | ||
453 | if setting.startswith(name)) | ||
454 | if not value: | ||
455 | value_completers = { | ||
456 | "colorscheme": | ||
457 | # Cycle through colorschemes when name, but no value is specified | ||
458 | lambda: sorted(self.firstpart + colorscheme for colorscheme | ||
459 | in get_all_colorschemes(self.fm)), | ||
460 | |||
461 | "column_ratios": | ||
462 | lambda: self.firstpart + ",".join(map(str, settings[name])), | ||
463 | } | ||
464 | |||
465 | def default_value_completer(): | ||
466 | return self.firstpart + str(settings[name]) | ||
467 | |||
468 | return value_completers.get(name, default_value_completer)() | ||
469 | if bool in settings.types_of(name): | ||
470 | if 'true'.startswith(value.lower()): | ||
471 | return self.firstpart + 'True' | ||
472 | if 'false'.startswith(value.lower()): | ||
473 | return self.firstpart + 'False' | ||
474 | # Tab complete colorscheme values if incomplete value is present | ||
475 | if name == "colorscheme": | ||
476 | return sorted(self.firstpart + colorscheme for colorscheme | ||
477 | in get_all_colorschemes(self.fm) if colorscheme.startswith(value)) | ||
478 | return None | ||
479 | |||
480 | |||
481 | class setlocal(set_): | ||
482 | """:setlocal path=<regular expression> <option name>=<python expression> | ||
483 | |||
484 | Gives an option a new value. | ||
485 | """ | ||
486 | PATH_RE_DQUOTED = re.compile(r'^setlocal\s+path="(.*?)"') | ||
487 | PATH_RE_SQUOTED = re.compile(r"^setlocal\s+path='(.*?)'") | ||
488 | PATH_RE_UNQUOTED = re.compile(r'^path=(.*?)$') | ||
489 | |||
490 | def _re_shift(self, match): | ||
491 | if not match: | ||
492 | return None | ||
493 | path = os.path.expanduser(match.group(1)) | ||
494 | for _ in range(len(path.split())): | ||
495 | self.shift() | ||
496 | return path | ||
497 | |||
498 | def execute(self): | ||
499 | path = self._re_shift(self.PATH_RE_DQUOTED.match(self.line)) | ||
500 | if path is None: | ||
501 | path = self._re_shift(self.PATH_RE_SQUOTED.match(self.line)) | ||
502 | if path is None: | ||
503 | path = self._re_shift(self.PATH_RE_UNQUOTED.match(self.arg(1))) | ||
504 | if path is None and self.fm.thisdir: | ||
505 | path = self.fm.thisdir.path | ||
506 | if not path: | ||
507 | return | ||
508 | |||
509 | name, value, _ = self.parse_setting_line() | ||
510 | self.fm.set_option_from_string(name, value, localpath=path) | ||
511 | |||
512 | |||
513 | class setintag(set_): | ||
514 | """:setintag <tag or tags> <option name>=<option value> | ||
515 | |||
516 | Sets an option for directories that are tagged with a specific tag. | ||
517 | """ | ||
518 | |||
519 | def execute(self): | ||
520 | tags = self.arg(1) | ||
521 | self.shift() | ||
522 | name, value, _ = self.parse_setting_line() | ||
523 | self.fm.set_option_from_string(name, value, tags=tags) | ||
524 | |||
525 | |||
526 | class default_linemode(Command): | ||
527 | |||
528 | def execute(self): | ||
529 | from ranger.container.fsobject import FileSystemObject | ||
530 | |||
531 | if len(self.args) < 2: | ||
532 | self.fm.notify( | ||
533 | "Usage: default_linemode [path=<regexp> | tag=<tag(s)>] <linemode>", bad=True) | ||
534 | |||
535 | # Extract options like "path=..." or "tag=..." from the command line | ||
536 | arg1 = self.arg(1) | ||
537 | method = "always" | ||
538 | argument = None | ||
539 | if arg1.startswith("path="): | ||
540 | method = "path" | ||
541 | argument = re.compile(arg1[5:]) | ||
542 | self.shift() | ||
543 | elif arg1.startswith("tag="): | ||
544 | method = "tag" | ||
545 | argument = arg1[4:] | ||
546 | self.shift() | ||
547 | |||
548 | # Extract and validate the line mode from the command line | ||
549 | lmode = self.rest(1) | ||
550 | if lmode not in FileSystemObject.linemode_dict: | ||
551 | self.fm.notify( | ||
552 | "Invalid linemode: %s; should be %s" % ( | ||
553 | lmode, "/".join(FileSystemObject.linemode_dict)), | ||
554 | bad=True, | ||
555 | ) | ||
556 | |||
557 | # Add the prepared entry to the fm.default_linemodes | ||
558 | entry = [method, argument, lmode] | ||
559 | self.fm.default_linemodes.appendleft(entry) | ||
560 | |||
561 | # Redraw the columns | ||
562 | if self.fm.ui.browser: | ||
563 | for col in self.fm.ui.browser.columns: | ||
564 | col.need_redraw = True | ||
565 | |||
566 | def tab(self, tabnum): | ||
567 | return (self.arg(0) + " " + lmode | ||
568 | for lmode in self.fm.thisfile.linemode_dict.keys() | ||
569 | if lmode.startswith(self.arg(1))) | ||
570 | |||
571 | |||
572 | class quit(Command): # pylint: disable=redefined-builtin | ||
573 | """:quit | ||
574 | |||
575 | Closes the current tab, if there's only one tab. | ||
576 | Otherwise quits if there are no tasks in progress. | ||
577 | """ | ||
578 | def _exit_no_work(self): | ||
579 | if self.fm.loader.has_work(): | ||
580 | self.fm.notify('Not quitting: Tasks in progress: Use `quit!` to force quit') | ||
581 | else: | ||
582 | self.fm.exit() | ||
583 | |||
584 | def execute(self): | ||
585 | if len(self.fm.tabs) >= 2: | ||
586 | self.fm.tab_close() | ||
587 | else: | ||
588 | self._exit_no_work() | ||
589 | |||
590 | |||
591 | class quit_bang(Command): | ||
592 | """:quit! | ||
593 | |||
594 | Closes the current tab, if there's only one tab. | ||
595 | Otherwise force quits immediately. | ||
596 | """ | ||
597 | name = 'quit!' | ||
598 | allow_abbrev = False | ||
599 | |||
600 | def execute(self): | ||
601 | if len(self.fm.tabs) >= 2: | ||
602 | self.fm.tab_close() | ||
603 | else: | ||
604 | self.fm.exit() | ||
605 | |||
606 | |||
607 | class quitall(Command): | ||
608 | """:quitall | ||
609 | |||
610 | Quits if there are no tasks in progress. | ||
611 | """ | ||
612 | def _exit_no_work(self): | ||
613 | if self.fm.loader.has_work(): | ||
614 | self.fm.notify('Not quitting: Tasks in progress: Use `quitall!` to force quit') | ||
615 | else: | ||
616 | self.fm.exit() | ||
617 | |||
618 | def execute(self): | ||
619 | self._exit_no_work() | ||
620 | |||
621 | |||
622 | class quitall_bang(Command): | ||
623 | """:quitall! | ||
624 | |||
625 | Force quits immediately. | ||
626 | """ | ||
627 | name = 'quitall!' | ||
628 | allow_abbrev = False | ||
629 | |||
630 | def execute(self): | ||
631 | self.fm.exit() | ||
632 | |||
633 | |||
634 | class terminal(Command): | ||
635 | """:terminal | ||
636 | |||
637 | Spawns an "x-terminal-emulator" starting in the current directory. | ||
638 | """ | ||
639 | |||
640 | def execute(self): | ||
641 | from ranger.ext.get_executables import get_term | ||
642 | self.fm.run(get_term(), flags='f') | ||
643 | |||
644 | |||
645 | class delete(Command): | ||
646 | """:delete | ||
647 | |||
648 | Tries to delete the selection or the files passed in arguments (if any). | ||
649 | The arguments use a shell-like escaping. | ||
650 | |||
651 | "Selection" is defined as all the "marked files" (by default, you | ||
652 | can mark files with space or v). If there are no marked files, | ||
653 | use the "current file" (where the cursor is) | ||
654 | |||
655 | When attempting to delete non-empty directories or multiple | ||
656 | marked files, it will require a confirmation. | ||
657 | """ | ||
658 | |||
659 | allow_abbrev = False | ||
660 | escape_macros_for_shell = True | ||
661 | |||
662 | def execute(self): | ||
663 | import shlex | ||
664 | from functools import partial | ||
665 | |||
666 | def is_directory_with_files(path): | ||
667 | return os.path.isdir(path) and not os.path.islink(path) and len(os.listdir(path)) > 0 | ||
668 | |||
669 | if self.rest(1): | ||
670 | files = shlex.split(self.rest(1)) | ||
671 | many_files = (len(files) > 1 or is_directory_with_files(files[0])) | ||
672 | else: | ||
673 | cwd = self.fm.thisdir | ||
674 | tfile = self.fm.thisfile | ||
675 | if not cwd or not tfile: | ||
676 | self.fm.notify("Error: no file selected for deletion!", bad=True) | ||
677 | return | ||
678 | |||
679 | # relative_path used for a user-friendly output in the confirmation. | ||
680 | files = [f.relative_path for f in self.fm.thistab.get_selection()] | ||
681 | many_files = (cwd.marked_items or is_directory_with_files(tfile.path)) | ||
682 | |||
683 | confirm = self.fm.settings.confirm_on_delete | ||
684 | if confirm != 'never' and (confirm != 'multiple' or many_files): | ||
685 | self.fm.ui.console.ask( | ||
686 | "Confirm deletion of: %s (y/N)" % ', '.join(files), | ||
687 | partial(self._question_callback, files), | ||
688 | ('n', 'N', 'y', 'Y'), | ||
689 | ) | ||
690 | else: | ||
691 | # no need for a confirmation, just delete | ||
692 | self.fm.delete(files) | ||
693 | |||
694 | def tab(self, tabnum): | ||
695 | return self._tab_directory_content() | ||
696 | |||
697 | def _question_callback(self, files, answer): | ||
698 | if answer == 'y' or answer == 'Y': | ||
699 | self.fm.delete(files) | ||
700 | |||
701 | |||
702 | class jump_non(Command): | ||
703 | """:jump_non [-FLAGS...] | ||
704 | |||
705 | Jumps to first non-directory if highlighted file is a directory and vice versa. | ||
706 | |||
707 | Flags: | ||
708 | -r Jump in reverse order | ||
709 | -w Wrap around if reaching end of filelist | ||
710 | """ | ||
711 | def __init__(self, *args, **kwargs): | ||
712 | super(jump_non, self).__init__(*args, **kwargs) | ||
713 | |||
714 | flags, _ = self.parse_flags() | ||
715 | self._flag_reverse = 'r' in flags | ||
716 | self._flag_wrap = 'w' in flags | ||
717 | |||
718 | @staticmethod | ||
719 | def _non(fobj, is_directory): | ||
720 | return fobj.is_directory if not is_directory else not fobj.is_directory | ||
721 | |||
722 | def execute(self): | ||
723 | tfile = self.fm.thisfile | ||
724 | passed = False | ||
725 | found_before = None | ||
726 | found_after = None | ||
727 | for fobj in self.fm.thisdir.files[::-1] if self._flag_reverse else self.fm.thisdir.files: | ||
728 | if fobj.path == tfile.path: | ||
729 | passed = True | ||
730 | continue | ||
731 | |||
732 | if passed: | ||
733 | if self._non(fobj, tfile.is_directory): | ||
734 | found_after = fobj.path | ||
735 | break | ||
736 | elif not found_before and self._non(fobj, tfile.is_directory): | ||
737 | found_before = fobj.path | ||
738 | |||
739 | if found_after: | ||
740 | self.fm.select_file(found_after) | ||
741 | elif self._flag_wrap and found_before: | ||
742 | self.fm.select_file(found_before) | ||
743 | |||
744 | |||
745 | class mark_tag(Command): | ||
746 | """:mark_tag [<tags>] | ||
747 | |||
748 | Mark all tags that are tagged with either of the given tags. | ||
749 | When leaving out the tag argument, all tagged files are marked. | ||
750 | """ | ||
751 | do_mark = True | ||
752 | |||
753 | def execute(self): | ||
754 | cwd = self.fm.thisdir | ||
755 | tags = self.rest(1).replace(" ", "") | ||
756 | if not self.fm.tags or not cwd.files: | ||
757 | return | ||
758 | for fileobj in cwd.files: | ||
759 | try: | ||
760 | tag = self.fm.tags.tags[fileobj.realpath] | ||
761 | except KeyError: | ||
762 | continue | ||
763 | if not tags or tag in tags: | ||
764 | cwd.mark_item(fileobj, val=self.do_mark) | ||
765 | self.fm.ui.status.need_redraw = True | ||
766 | self.fm.ui.need_redraw = True | ||
767 | |||
768 | |||
769 | class console(Command): | ||
770 | """:console <command> | ||
771 | |||
772 | Open the console with the given command. | ||
773 | """ | ||
774 | |||
775 | def execute(self): | ||
776 | position = None | ||
777 | if self.arg(1)[0:2] == '-p': | ||
778 | try: | ||
779 | position = int(self.arg(1)[2:]) | ||
780 | except ValueError: | ||
781 | pass | ||
782 | else: | ||
783 | self.shift() | ||
784 | self.fm.open_console(self.rest(1), position=position) | ||
785 | |||
786 | |||
787 | class load_copy_buffer(Command): | ||
788 | """:load_copy_buffer | ||
789 | |||
790 | Load the copy buffer from datadir/copy_buffer | ||
791 | """ | ||
792 | copy_buffer_filename = 'copy_buffer' | ||
793 | |||
794 | def execute(self): | ||
795 | import sys | ||
796 | from ranger.container.file import File | ||
797 | from os.path import exists | ||
798 | fname = self.fm.datapath(self.copy_buffer_filename) | ||
799 | unreadable = IOError if sys.version_info[0] < 3 else OSError | ||
800 | try: | ||
801 | fobj = open(fname, 'r') | ||
802 | except unreadable: | ||
803 | return self.fm.notify( | ||
804 | "Cannot open %s" % (fname or self.copy_buffer_filename), bad=True) | ||
805 | |||
806 | self.fm.copy_buffer = set(File(g) | ||
807 | for g in fobj.read().split("\n") if exists(g)) | ||
808 | fobj.close() | ||
809 | self.fm.ui.redraw_main_column() | ||
810 | return None | ||
811 | |||
812 | |||
813 | class save_copy_buffer(Command): | ||
814 | """:save_copy_buffer | ||
815 | |||
816 | Save the copy buffer to datadir/copy_buffer | ||
817 | """ | ||
818 | copy_buffer_filename = 'copy_buffer' | ||
819 | |||
820 | def execute(self): | ||
821 | import sys | ||
822 | fname = None | ||
823 | fname = self.fm.datapath(self.copy_buffer_filename) | ||
824 | unwritable = IOError if sys.version_info[0] < 3 else OSError | ||
825 | try: | ||
826 | fobj = open(fname, 'w') | ||
827 | except unwritable: | ||
828 | return self.fm.notify("Cannot open %s" % | ||
829 | (fname or self.copy_buffer_filename), bad=True) | ||
830 | fobj.write("\n".join(fobj.path for fobj in self.fm.copy_buffer)) | ||
831 | fobj.close() | ||
832 | return None | ||
833 | |||
834 | |||
835 | class unmark_tag(mark_tag): | ||
836 | """:unmark_tag [<tags>] | ||
837 | |||
838 | Unmark all tags that are tagged with either of the given tags. | ||
839 | When leaving out the tag argument, all tagged files are unmarked. | ||
840 | """ | ||
841 | do_mark = False | ||
842 | |||
843 | |||
844 | class mkdir(Command): | ||
845 | """:mkdir <dirname> | ||
846 | |||
847 | Creates a directory with the name <dirname>. | ||
848 | """ | ||
849 | |||
850 | def execute(self): | ||
851 | from os.path import join, expanduser, lexists | ||
852 | from os import makedirs | ||
853 | |||
854 | dirname = join(self.fm.thisdir.path, expanduser(self.rest(1))) | ||
855 | if not lexists(dirname): | ||
856 | makedirs(dirname) | ||
857 | else: | ||
858 | self.fm.notify("file/directory exists!", bad=True) | ||
859 | |||
860 | def tab(self, tabnum): | ||
861 | return self._tab_directory_content() | ||
862 | |||
863 | |||
864 | class touch(Command): | ||
865 | """:touch <fname> | ||
866 | |||
867 | Creates a file with the name <fname>. | ||
868 | """ | ||
869 | |||
870 | def execute(self): | ||
871 | from os.path import join, expanduser, lexists | ||
872 | |||
873 | fname = join(self.fm.thisdir.path, expanduser(self.rest(1))) | ||
874 | if not lexists(fname): | ||
875 | open(fname, 'a').close() | ||
876 | else: | ||
877 | self.fm.notify("file/directory exists!", bad=True) | ||
878 | |||
879 | def tab(self, tabnum): | ||
880 | return self._tab_directory_content() | ||
881 | |||
882 | |||
883 | class edit(Command): | ||
884 | """:edit <filename> | ||
885 | |||
886 | Opens the specified file in vim | ||
887 | """ | ||
888 | |||
889 | def execute(self): | ||
890 | if not self.arg(1): | ||
891 | self.fm.edit_file(self.fm.thisfile.path) | ||
892 | else: | ||
893 | self.fm.edit_file(self.rest(1)) | ||
894 | |||
895 | def tab(self, tabnum): | ||
896 | return self._tab_directory_content() | ||
897 | |||
898 | |||
899 | class eval_(Command): | ||
900 | """:eval [-q] <python code> | ||
901 | |||
902 | Evaluates the python code. | ||
903 | `fm' is a reference to the FM instance. | ||
904 | To display text, use the function `p'. | ||
905 | |||
906 | Examples: | ||
907 | :eval fm | ||
908 | :eval len(fm.directories) | ||
909 | :eval p("Hello World!") | ||
910 | """ | ||
911 | name = 'eval' | ||
912 | resolve_macros = False | ||
913 | |||
914 | def execute(self): | ||
915 | # The import is needed so eval() can access the ranger module | ||
916 | import ranger # NOQA pylint: disable=unused-import,unused-variable | ||
917 | if self.arg(1) == '-q': | ||
918 | code = self.rest(2) | ||
919 | quiet = True | ||
920 | else: | ||
921 | code = self.rest(1) | ||
922 | quiet = False | ||
923 | global cmd, fm, p, quantifier # pylint: disable=invalid-name,global-variable-undefined | ||
924 | fm = self.fm | ||
925 | cmd = self.fm.execute_console | ||
926 | p = fm.notify | ||
927 | quantifier = self.quantifier | ||
928 | try: | ||
929 | try: | ||
930 | result = eval(code) # pylint: disable=eval-used | ||
931 | except SyntaxError: | ||
932 | exec(code) # pylint: disable=exec-used | ||
933 | else: | ||
934 | if result and not quiet: | ||
935 | p(result) | ||
936 | except Exception as err: # pylint: disable=broad-except | ||
937 | fm.notify("The error `%s` was caused by evaluating the " | ||
938 | "following code: `%s`" % (err, code), bad=True) | ||
939 | |||
940 | |||
941 | class rename(Command): | ||
942 | """:rename <newname> | ||
943 | |||
944 | Changes the name of the currently highlighted file to <newname> | ||
945 | """ | ||
946 | |||
947 | def execute(self): | ||
948 | from ranger.container.file import File | ||
949 | from os import access | ||
950 | |||
951 | new_name = self.rest(1) | ||
952 | |||
953 | if not new_name: | ||
954 | return self.fm.notify('Syntax: rename <newname>', bad=True) | ||
955 | |||
956 | if new_name == self.fm.thisfile.relative_path: | ||
957 | return None | ||
958 | |||
959 | if access(new_name, os.F_OK): | ||
960 | return self.fm.notify("Can't rename: file already exists!", bad=True) | ||
961 | |||
962 | if self.fm.rename(self.fm.thisfile, new_name): | ||
963 | file_new = File(new_name) | ||
964 | self.fm.bookmarks.update_path(self.fm.thisfile.path, file_new) | ||
965 | self.fm.tags.update_path(self.fm.thisfile.path, file_new.path) | ||
966 | self.fm.thisdir.pointed_obj = file_new | ||
967 | self.fm.thisfile = file_new | ||
968 | |||
969 | return None | ||
970 | |||
971 | def tab(self, tabnum): | ||
972 | return self._tab_directory_content() | ||
973 | |||
974 | |||
975 | class rename_append(Command): | ||
976 | """:rename_append [-FLAGS...] | ||
977 | |||
978 | Opens the console with ":rename <current file>" with the cursor positioned | ||
979 | before the file extension. | ||
980 | |||
981 | Flags: | ||
982 | -a Position before all extensions | ||
983 | -r Remove everything before extensions | ||
984 | """ | ||
985 | def __init__(self, *args, **kwargs): | ||
986 | super(rename_append, self).__init__(*args, **kwargs) | ||
987 | |||
988 | flags, _ = self.parse_flags() | ||
989 | self._flag_ext_all = 'a' in flags | ||
990 | self._flag_remove = 'r' in flags | ||
991 | |||
992 | def execute(self): | ||
993 | from ranger import MACRO_DELIMITER, MACRO_DELIMITER_ESC | ||
994 | |||
995 | tfile = self.fm.thisfile | ||
996 | relpath = tfile.relative_path.replace(MACRO_DELIMITER, MACRO_DELIMITER_ESC) | ||
997 | basename = tfile.basename.replace(MACRO_DELIMITER, MACRO_DELIMITER_ESC) | ||
998 | |||
999 | if basename.find('.') <= 0: | ||
1000 | self.fm.open_console('rename ' + relpath) | ||
1001 | return | ||
1002 | |||
1003 | if self._flag_ext_all: | ||
1004 | pos_ext = re.search(r'[^.]+', basename).end(0) | ||
1005 | else: | ||
1006 | pos_ext = basename.rindex('.') | ||
1007 | pos = len(relpath) - len(basename) + pos_ext | ||
1008 | |||
1009 | if self._flag_remove: | ||
1010 | relpath = relpath[:-len(basename)] + basename[pos_ext:] | ||
1011 | pos -= pos_ext | ||
1012 | |||
1013 | self.fm.open_console('rename ' + relpath, position=(7 + pos)) | ||
1014 | |||
1015 | |||
1016 | class chmod(Command): | ||
1017 | """:chmod <octal number> | ||
1018 | |||
1019 | Sets the permissions of the selection to the octal number. | ||
1020 | |||
1021 | The octal number is between 0 and 777. The digits specify the | ||
1022 | permissions for the user, the group and others. | ||
1023 | |||
1024 | A 1 permits execution, a 2 permits writing, a 4 permits reading. | ||
1025 | Add those numbers to combine them. So a 7 permits everything. | ||
1026 | """ | ||
1027 | |||
1028 | def execute(self): | ||
1029 | mode_str = self.rest(1) | ||
1030 | if not mode_str: | ||
1031 | if not self.quantifier: | ||
1032 | self.fm.notify("Syntax: chmod <octal number>", bad=True) | ||
1033 | return | ||
1034 | mode_str = str(self.quantifier) | ||
1035 | |||
1036 | try: | ||
1037 | mode = int(mode_str, 8) | ||
1038 | if mode < 0 or mode > 0o777: | ||
1039 | raise ValueError | ||
1040 | except ValueError: | ||
1041 | self.fm.notify("Need an octal number between 0 and 777!", bad=True) | ||
1042 | return | ||
1043 | |||
1044 | for fobj in self.fm.thistab.get_selection(): | ||
1045 | try: | ||
1046 | os.chmod(fobj.path, mode) | ||
1047 | except OSError as ex: | ||
1048 | self.fm.notify(ex) | ||
1049 | |||
1050 | # reloading directory. maybe its better to reload the selected | ||
1051 | # files only. | ||
1052 | self.fm.thisdir.content_outdated = True | ||
1053 | |||
1054 | |||
1055 | class bulkrename(Command): | ||
1056 | """:bulkrename | ||
1057 | |||
1058 | This command opens a list of selected files in an external editor. | ||
1059 | After you edit and save the file, it will generate a shell script | ||
1060 | which does bulk renaming according to the changes you did in the file. | ||
1061 | |||
1062 | This shell script is opened in an editor for you to review. | ||
1063 | After you close it, it will be executed. | ||
1064 | """ | ||
1065 | |||
1066 | def execute(self): # pylint: disable=too-many-locals,too-many-statements | ||
1067 | import sys | ||
1068 | import tempfile | ||
1069 | from ranger.container.file import File | ||
1070 | from ranger.ext.shell_escape import shell_escape as esc | ||
1071 | py3 = sys.version_info[0] >= 3 | ||
1072 | |||
1073 | # Create and edit the file list | ||
1074 | filenames = [f.relative_path for f in self.fm.thistab.get_selection()] | ||
1075 | listfile = tempfile.NamedTemporaryFile(delete=False) | ||
1076 | listpath = listfile.name | ||
1077 | |||
1078 | if py3: | ||
1079 | listfile.write("\n".join(filenames).encode("utf-8")) | ||
1080 | else: | ||
1081 | listfile.write("\n".join(filenames)) | ||
1082 | listfile.close() | ||
1083 | self.fm.execute_file([File(listpath)], app='editor') | ||
1084 | listfile = open(listpath, 'r') | ||
1085 | new_filenames = listfile.read().split("\n") | ||
1086 | listfile.close() | ||
1087 | os.unlink(listpath) | ||
1088 | if all(a == b for a, b in zip(filenames, new_filenames)): | ||
1089 | self.fm.notify("No renaming to be done!") | ||
1090 | return | ||
1091 | |||
1092 | # Generate script | ||
1093 | cmdfile = tempfile.NamedTemporaryFile() | ||
1094 | script_lines = [] | ||
1095 | script_lines.append("# This file will be executed when you close the editor.\n") | ||
1096 | script_lines.append("# Please double-check everything, clear the file to abort.\n") | ||
1097 | script_lines.extend("mv -vi -- %s %s\n" % (esc(old), esc(new)) | ||
1098 | for old, new in zip(filenames, new_filenames) if old != new) | ||
1099 | script_content = "".join(script_lines) | ||
1100 | if py3: | ||
1101 | cmdfile.write(script_content.encode("utf-8")) | ||
1102 | else: | ||
1103 | cmdfile.write(script_content) | ||
1104 | cmdfile.flush() | ||
1105 | |||
1106 | # Open the script and let the user review it, then check if the script | ||
1107 | # was modified by the user | ||
1108 | self.fm.execute_file([File(cmdfile.name)], app='editor') | ||
1109 | cmdfile.seek(0) | ||
1110 | script_was_edited = (script_content != cmdfile.read()) | ||
1111 | |||
1112 | # Do the renaming | ||
1113 | self.fm.run(['/bin/sh', cmdfile.name], flags='w') | ||
1114 | cmdfile.close() | ||
1115 | |||
1116 | # Retag the files, but only if the script wasn't changed during review, | ||
1117 | # because only then we know which are the source and destination files. | ||
1118 | if not script_was_edited: | ||
1119 | tags_changed = False | ||
1120 | for old, new in zip(filenames, new_filenames): | ||
1121 | if old != new: | ||
1122 | oldpath = self.fm.thisdir.path + '/' + old | ||
1123 | newpath = self.fm.thisdir.path + '/' + new | ||
1124 | if oldpath in self.fm.tags: | ||
1125 | old_tag = self.fm.tags.tags[oldpath] | ||
1126 | self.fm.tags.remove(oldpath) | ||
1127 | self.fm.tags.tags[newpath] = old_tag | ||
1128 | tags_changed = True | ||
1129 | if tags_changed: | ||
1130 | self.fm.tags.dump() | ||
1131 | else: | ||
1132 | fm.notify("files have not been retagged") | ||
1133 | |||
1134 | |||
1135 | class relink(Command): | ||
1136 | """:relink <newpath> | ||
1137 | |||
1138 | Changes the linked path of the currently highlighted symlink to <newpath> | ||
1139 | """ | ||
1140 | |||
1141 | def execute(self): | ||
1142 | new_path = self.rest(1) | ||
1143 | tfile = self.fm.thisfile | ||
1144 | |||
1145 | if not new_path: | ||
1146 | return self.fm.notify('Syntax: relink <newpath>', bad=True) | ||
1147 | |||
1148 | if not tfile.is_link: | ||
1149 | return self.fm.notify('%s is not a symlink!' % tfile.relative_path, bad=True) | ||
1150 | |||
1151 | if new_path == os.readlink(tfile.path): | ||
1152 | return None | ||
1153 | |||
1154 | try: | ||
1155 | os.remove(tfile.path) | ||
1156 | os.symlink(new_path, tfile.path) | ||
1157 | except OSError as err: | ||
1158 | self.fm.notify(err) | ||
1159 | |||
1160 | self.fm.reset() | ||
1161 | self.fm.thisdir.pointed_obj = tfile | ||
1162 | self.fm.thisfile = tfile | ||
1163 | |||
1164 | return None | ||
1165 | |||
1166 | def tab(self, tabnum): | ||
1167 | if not self.rest(1): | ||
1168 | return self.line + os.readlink(self.fm.thisfile.path) | ||
1169 | return self._tab_directory_content() | ||
1170 | |||
1171 | |||
1172 | class help_(Command): | ||
1173 | """:help | ||
1174 | |||
1175 | Display ranger's manual page. | ||
1176 | """ | ||
1177 | name = 'help' | ||
1178 | |||
1179 | def execute(self): | ||
1180 | def callback(answer): | ||
1181 | if answer == "q": | ||
1182 | return | ||
1183 | elif answer == "m": | ||
1184 | self.fm.display_help() | ||
1185 | elif answer == "c": | ||
1186 | self.fm.dump_commands() | ||
1187 | elif answer == "k": | ||
1188 | self.fm.dump_keybindings() | ||
1189 | elif answer == "s": | ||
1190 | self.fm.dump_settings() | ||
1191 | |||
1192 | self.fm.ui.console.ask( | ||
1193 | "View [m]an page, [k]ey bindings, [c]ommands or [s]ettings? (press q to abort)", | ||
1194 | callback, | ||
1195 | list("mqkcs") | ||
1196 | ) | ||
1197 | |||
1198 | |||
1199 | class copymap(Command): | ||
1200 | """:copymap <keys> <newkeys1> [<newkeys2>...] | ||
1201 | |||
1202 | Copies a "browser" keybinding from <keys> to <newkeys> | ||
1203 | """ | ||
1204 | context = 'browser' | ||
1205 | |||
1206 | def execute(self): | ||
1207 | if not self.arg(1) or not self.arg(2): | ||
1208 | return self.fm.notify("Not enough arguments", bad=True) | ||
1209 | |||
1210 | for arg in self.args[2:]: | ||
1211 | self.fm.ui.keymaps.copy(self.context, self.arg(1), arg) | ||
1212 | |||
1213 | return None | ||
1214 | |||
1215 | |||
1216 | class copypmap(copymap): | ||
1217 | """:copypmap <keys> <newkeys1> [<newkeys2>...] | ||
1218 | |||
1219 | Copies a "pager" keybinding from <keys> to <newkeys> | ||
1220 | """ | ||
1221 | context = 'pager' | ||
1222 | |||
1223 | |||
1224 | class copycmap(copymap): | ||
1225 | """:copycmap <keys> <newkeys1> [<newkeys2>...] | ||
1226 | |||
1227 | Copies a "console" keybinding from <keys> to <newkeys> | ||
1228 | """ | ||
1229 | context = 'console' | ||
1230 | |||
1231 | |||
1232 | class copytmap(copymap): | ||
1233 | """:copycmap <keys> <newkeys1> [<newkeys2>...] | ||
1234 | |||
1235 | Copies a "taskview" keybinding from <keys> to <newkeys> | ||
1236 | """ | ||
1237 | context = 'taskview' | ||
1238 | |||
1239 | |||
1240 | class unmap(Command): | ||
1241 | """:unmap <keys> [<keys2>, ...] | ||
1242 | |||
1243 | Remove the given "browser" mappings | ||
1244 | """ | ||
1245 | context = 'browser' | ||
1246 | |||
1247 | def execute(self): | ||
1248 | for arg in self.args[1:]: | ||
1249 | self.fm.ui.keymaps.unbind(self.context, arg) | ||
1250 | |||
1251 | |||
1252 | class cunmap(unmap): | ||
1253 | """:cunmap <keys> [<keys2>, ...] | ||
1254 | |||
1255 | Remove the given "console" mappings | ||
1256 | """ | ||
1257 | context = 'browser' | ||
1258 | |||
1259 | |||
1260 | class punmap(unmap): | ||
1261 | """:punmap <keys> [<keys2>, ...] | ||
1262 | |||
1263 | Remove the given "pager" mappings | ||
1264 | """ | ||
1265 | context = 'pager' | ||
1266 | |||
1267 | |||
1268 | class tunmap(unmap): | ||
1269 | """:tunmap <keys> [<keys2>, ...] | ||
1270 | |||
1271 | Remove the given "taskview" mappings | ||
1272 | """ | ||
1273 | context = 'taskview' | ||
1274 | |||
1275 | |||
1276 | class map_(Command): | ||
1277 | """:map <keysequence> <command> | ||
1278 | |||
1279 | Maps a command to a keysequence in the "browser" context. | ||
1280 | |||
1281 | Example: | ||
1282 | map j move down | ||
1283 | map J move down 10 | ||
1284 | """ | ||
1285 | name = 'map' | ||
1286 | context = 'browser' | ||
1287 | resolve_macros = False | ||
1288 | |||
1289 | def execute(self): | ||
1290 | if not self.arg(1) or not self.arg(2): | ||
1291 | self.fm.notify("Syntax: {0} <keysequence> <command>".format(self.get_name()), bad=True) | ||
1292 | return | ||
1293 | |||
1294 | self.fm.ui.keymaps.bind(self.context, self.arg(1), self.rest(2)) | ||
1295 | |||
1296 | |||
1297 | class cmap(map_): | ||
1298 | """:cmap <keysequence> <command> | ||
1299 | |||
1300 | Maps a command to a keysequence in the "console" context. | ||
1301 | |||
1302 | Example: | ||
1303 | cmap <ESC> console_close | ||
1304 | cmap <C-x> console_type test | ||
1305 | """ | ||
1306 | context = 'console' | ||
1307 | |||
1308 | |||
1309 | class tmap(map_): | ||
1310 | """:tmap <keysequence> <command> | ||
1311 | |||
1312 | Maps a command to a keysequence in the "taskview" context. | ||
1313 | """ | ||
1314 | context = 'taskview' | ||
1315 | |||
1316 | |||
1317 | class pmap(map_): | ||
1318 | """:pmap <keysequence> <command> | ||
1319 | |||
1320 | Maps a command to a keysequence in the "pager" context. | ||
1321 | """ | ||
1322 | context = 'pager' | ||
1323 | |||
1324 | |||
1325 | class scout(Command): | ||
1326 | """:scout [-FLAGS...] <pattern> | ||
1327 | |||
1328 | Swiss army knife command for searching, traveling and filtering files. | ||
1329 | |||
1330 | Flags: | ||
1331 | -a Automatically open a file on unambiguous match | ||
1332 | -e Open the selected file when pressing enter | ||
1333 | -f Filter files that match the current search pattern | ||
1334 | -g Interpret pattern as a glob pattern | ||
1335 | -i Ignore the letter case of the files | ||
1336 | -k Keep the console open when changing a directory with the command | ||
1337 | -l Letter skipping; e.g. allow "rdme" to match the file "readme" | ||
1338 | -m Mark the matching files after pressing enter | ||
1339 | -M Unmark the matching files after pressing enter | ||
1340 | -p Permanent filter: hide non-matching files after pressing enter | ||
1341 | -r Interpret pattern as a regular expression pattern | ||
1342 | -s Smart case; like -i unless pattern contains upper case letters | ||
1343 | -t Apply filter and search pattern as you type | ||
1344 | -v Inverts the match | ||
1345 | |||
1346 | Multiple flags can be combined. For example, ":scout -gpt" would create | ||
1347 | a :filter-like command using globbing. | ||
1348 | """ | ||
1349 | # pylint: disable=bad-whitespace | ||
1350 | AUTO_OPEN = 'a' | ||
1351 | OPEN_ON_ENTER = 'e' | ||
1352 | FILTER = 'f' | ||
1353 | SM_GLOB = 'g' | ||
1354 | IGNORE_CASE = 'i' | ||
1355 | KEEP_OPEN = 'k' | ||
1356 | SM_LETTERSKIP = 'l' | ||
1357 | MARK = 'm' | ||
1358 | UNMARK = 'M' | ||
1359 | PERM_FILTER = 'p' | ||
1360 | SM_REGEX = 'r' | ||
1361 | SMART_CASE = 's' | ||
1362 | AS_YOU_TYPE = 't' | ||
1363 | INVERT = 'v' | ||
1364 | # pylint: enable=bad-whitespace | ||
1365 | |||
1366 | def __init__(self, *args, **kwargs): | ||
1367 | super(scout, self).__init__(*args, **kwargs) | ||
1368 | self._regex = None | ||
1369 | self.flags, self.pattern = self.parse_flags() | ||
1370 | |||
1371 | def execute(self): # pylint: disable=too-many-branches | ||
1372 | thisdir = self.fm.thisdir | ||
1373 | flags = self.flags | ||
1374 | pattern = self.pattern | ||
1375 | regex = self._build_regex() | ||
1376 | count = self._count(move=True) | ||
1377 | |||
1378 | self.fm.thistab.last_search = regex | ||
1379 | self.fm.set_search_method(order="search") | ||
1380 | |||
1381 | if (self.MARK in flags or self.UNMARK in flags) and thisdir.files: | ||
1382 | value = flags.find(self.MARK) > flags.find(self.UNMARK) | ||
1383 | if self.FILTER in flags: | ||
1384 | for fobj in thisdir.files: | ||
1385 | thisdir.mark_item(fobj, value) | ||
1386 | else: | ||
1387 | for fobj in thisdir.files: | ||
1388 | if regex.search(fobj.relative_path): | ||
1389 | thisdir.mark_item(fobj, value) | ||
1390 | |||
1391 | if self.PERM_FILTER in flags: | ||
1392 | thisdir.filter = regex if pattern else None | ||
1393 | |||
1394 | # clean up: | ||
1395 | self.cancel() | ||
1396 | |||
1397 | if self.OPEN_ON_ENTER in flags or \ | ||
1398 | (self.AUTO_OPEN in flags and count == 1): | ||
1399 | if pattern == '..': | ||
1400 | self.fm.cd(pattern) | ||
1401 | else: | ||
1402 | self.fm.move(right=1) | ||
1403 | if self.quickly_executed: | ||
1404 | self.fm.block_input(0.5) | ||
1405 | |||
1406 | if self.KEEP_OPEN in flags and thisdir != self.fm.thisdir: | ||
1407 | # reopen the console: | ||
1408 | if not pattern: | ||
1409 | self.fm.open_console(self.line) | ||
1410 | else: | ||
1411 | self.fm.open_console(self.line[0:-len(pattern)]) | ||
1412 | |||
1413 | if self.quickly_executed and thisdir != self.fm.thisdir and pattern != "..": | ||
1414 | self.fm.block_input(0.5) | ||
1415 | |||
1416 | def cancel(self): | ||
1417 | self.fm.thisdir.temporary_filter = None | ||
1418 | self.fm.thisdir.refilter() | ||
1419 | |||
1420 | def quick(self): | ||
1421 | asyoutype = self.AS_YOU_TYPE in self.flags | ||
1422 | if self.FILTER in self.flags: | ||
1423 | self.fm.thisdir.temporary_filter = self._build_regex() | ||
1424 | if self.PERM_FILTER in self.flags and asyoutype: | ||
1425 | self.fm.thisdir.filter = self._build_regex() | ||
1426 | if self.FILTER in self.flags or self.PERM_FILTER in self.flags: | ||
1427 | self.fm.thisdir.refilter() | ||
1428 | if self._count(move=asyoutype) == 1 and self.AUTO_OPEN in self.flags: | ||
1429 | return True | ||
1430 | return False | ||
1431 | |||
1432 | def tab(self, tabnum): | ||
1433 | self._count(move=True, offset=tabnum) | ||
1434 | |||
1435 | def _build_regex(self): | ||
1436 | if self._regex is not None: | ||
1437 | return self._regex | ||
1438 | |||
1439 | frmat = "%s" | ||
1440 | flags = self.flags | ||
1441 | pattern = self.pattern | ||
1442 | |||
1443 | if pattern == ".": | ||
1444 | return re.compile("") | ||
1445 | |||
1446 | # Handle carets at start and dollar signs at end separately | ||
1447 | if pattern.startswith('^'): | ||
1448 | pattern = pattern[1:] | ||
1449 | frmat = "^" + frmat | ||
1450 | if pattern.endswith('$'): | ||
1451 | pattern = pattern[:-1] | ||
1452 | frmat += "$" | ||
1453 | |||
1454 | # Apply one of the search methods | ||
1455 | if self.SM_REGEX in flags: | ||
1456 | regex = pattern | ||
1457 | elif self.SM_GLOB in flags: | ||
1458 | regex = re.escape(pattern).replace("\\*", ".*").replace("\\?", ".") | ||
1459 | elif self.SM_LETTERSKIP in flags: | ||
1460 | regex = ".*".join(re.escape(c) for c in pattern) | ||
1461 | else: | ||
1462 | regex = re.escape(pattern) | ||
1463 | |||
1464 | regex = frmat % regex | ||
1465 | |||
1466 | # Invert regular expression if necessary | ||
1467 | if self.INVERT in flags: | ||
1468 | regex = "^(?:(?!%s).)*$" % regex | ||
1469 | |||
1470 | # Compile Regular Expression | ||
1471 | # pylint: disable=no-member | ||
1472 | options = re.UNICODE | ||
1473 | if self.IGNORE_CASE in flags or self.SMART_CASE in flags and \ | ||
1474 | pattern.islower(): | ||
1475 | options |= re.IGNORECASE | ||
1476 | # pylint: enable=no-member | ||
1477 | try: | ||
1478 | self._regex = re.compile(regex, options) | ||
1479 | except re.error: | ||
1480 | self._regex = re.compile("") | ||
1481 | return self._regex | ||
1482 | |||
1483 | def _count(self, move=False, offset=0): | ||
1484 | count = 0 | ||
1485 | cwd = self.fm.thisdir | ||
1486 | pattern = self.pattern | ||
1487 | |||
1488 | if not pattern or not cwd.files: | ||
1489 | return 0 | ||
1490 | if pattern == '.': | ||
1491 | return 0 | ||
1492 | if pattern == '..': | ||
1493 | return 1 | ||
1494 | |||
1495 | deq = deque(cwd.files) | ||
1496 | deq.rotate(-cwd.pointer - offset) | ||
1497 | i = offset | ||
1498 | regex = self._build_regex() | ||
1499 | for fsobj in deq: | ||
1500 | if regex.search(fsobj.relative_path): | ||
1501 | count += 1 | ||
1502 | if move and count == 1: | ||
1503 | cwd.move(to=(cwd.pointer + i) % len(cwd.files)) | ||
1504 | self.fm.thisfile = cwd.pointed_obj | ||
1505 | if count > 1: | ||
1506 | return count | ||
1507 | i += 1 | ||
1508 | |||
1509 | return count == 1 | ||
1510 | |||
1511 | |||
1512 | class narrow(Command): | ||
1513 | """ | ||
1514 | :narrow | ||
1515 | |||
1516 | Show only the files selected right now. If no files are selected, | ||
1517 | disable narrowing. | ||
1518 | """ | ||
1519 | def execute(self): | ||
1520 | if self.fm.thisdir.marked_items: | ||
1521 | selection = [f.basename for f in self.fm.thistab.get_selection()] | ||
1522 | self.fm.thisdir.narrow_filter = selection | ||
1523 | else: | ||
1524 | self.fm.thisdir.narrow_filter = None | ||
1525 | self.fm.thisdir.refilter() | ||
1526 | |||
1527 | |||
1528 | class filter_inode_type(Command): | ||
1529 | """ | ||
1530 | :filter_inode_type [dfl] | ||
1531 | |||
1532 | Displays only the files of specified inode type. Parameters | ||
1533 | can be combined. | ||
1534 | |||
1535 | d display directories | ||
1536 | f display files | ||
1537 | l display links | ||
1538 | """ | ||
1539 | |||
1540 | def execute(self): | ||
1541 | if not self.arg(1): | ||
1542 | self.fm.thisdir.inode_type_filter = "" | ||
1543 | else: | ||
1544 | self.fm.thisdir.inode_type_filter = self.arg(1) | ||
1545 | self.fm.thisdir.refilter() | ||
1546 | |||
1547 | |||
1548 | class filter_stack(Command): | ||
1549 | """ | ||
1550 | :filter_stack ... | ||
1551 | |||
1552 | Manages the filter stack. | ||
1553 | |||
1554 | filter_stack add FILTER_TYPE ARGS... | ||
1555 | filter_stack pop | ||
1556 | filter_stack decompose | ||
1557 | filter_stack rotate [N=1] | ||
1558 | filter_stack clear | ||
1559 | filter_stack show | ||
1560 | """ | ||
1561 | def execute(self): | ||
1562 | from ranger.core.filter_stack import SIMPLE_FILTERS, FILTER_COMBINATORS | ||
1563 | |||
1564 | subcommand = self.arg(1) | ||
1565 | |||
1566 | if subcommand == "add": | ||
1567 | try: | ||
1568 | self.fm.thisdir.filter_stack.append( | ||
1569 | SIMPLE_FILTERS[self.arg(2)](self.rest(3)) | ||
1570 | ) | ||
1571 | except KeyError: | ||
1572 | FILTER_COMBINATORS[self.arg(2)](self.fm.thisdir.filter_stack) | ||
1573 | elif subcommand == "pop": | ||
1574 | self.fm.thisdir.filter_stack.pop() | ||
1575 | elif subcommand == "decompose": | ||
1576 | inner_filters = self.fm.thisdir.filter_stack.pop().decompose() | ||
1577 | if inner_filters: | ||
1578 | self.fm.thisdir.filter_stack.extend(inner_filters) | ||
1579 | elif subcommand == "clear": | ||
1580 | self.fm.thisdir.filter_stack = [] | ||
1581 | elif subcommand == "rotate": | ||
1582 | rotate_by = int(self.arg(2) or 1) | ||
1583 | self.fm.thisdir.filter_stack = ( | ||
1584 | self.fm.thisdir.filter_stack[-rotate_by:] | ||
1585 | + self.fm.thisdir.filter_stack[:-rotate_by] | ||
1586 | ) | ||
1587 | elif subcommand == "show": | ||
1588 | stack = list(map(str, self.fm.thisdir.filter_stack)) | ||
1589 | pager = self.fm.ui.open_pager() | ||
1590 | pager.set_source(["Filter stack: "] + stack) | ||
1591 | pager.move(to=100, percentage=True) | ||
1592 | return | ||
1593 | else: | ||
1594 | self.fm.notify( | ||
1595 | "Unknown subcommand: {}".format(subcommand), | ||
1596 | bad=True | ||
1597 | ) | ||
1598 | return | ||
1599 | |||
1600 | self.fm.thisdir.refilter() | ||
1601 | |||
1602 | |||
1603 | class grep(Command): | ||
1604 | """:grep <string> | ||
1605 | |||
1606 | Looks for a string in all marked files or directories | ||
1607 | """ | ||
1608 | |||
1609 | def execute(self): | ||
1610 | if self.rest(1): | ||
1611 | action = ['grep', '--line-number'] | ||
1612 | action.extend(['-e', self.rest(1), '-r']) | ||
1613 | action.extend(f.path for f in self.fm.thistab.get_selection()) | ||
1614 | self.fm.execute_command(action, flags='p') | ||
1615 | |||
1616 | |||
1617 | class flat(Command): | ||
1618 | """ | ||
1619 | :flat <level> | ||
1620 | |||
1621 | Flattens the directory view up to the specified level. | ||
1622 | |||
1623 | -1 fully flattened | ||
1624 | 0 remove flattened view | ||
1625 | """ | ||
1626 | |||
1627 | def execute(self): | ||
1628 | try: | ||
1629 | level_str = self.rest(1) | ||
1630 | level = int(level_str) | ||
1631 | except ValueError: | ||
1632 | level = self.quantifier | ||
1633 | if level is None: | ||
1634 | self.fm.notify("Syntax: flat <level>", bad=True) | ||
1635 | return | ||
1636 | if level < -1: | ||
1637 | self.fm.notify("Need an integer number (-1, 0, 1, ...)", bad=True) | ||
1638 | self.fm.thisdir.unload() | ||
1639 | self.fm.thisdir.flat = level | ||
1640 | self.fm.thisdir.load_content() | ||
1641 | |||
1642 | # Version control commands | ||
1643 | # -------------------------------- | ||
1644 | |||
1645 | |||
1646 | class stage(Command): | ||
1647 | """ | ||
1648 | :stage | ||
1649 | |||
1650 | Stage selected files for the corresponding version control system | ||
1651 | """ | ||
1652 | |||
1653 | def execute(self): | ||
1654 | from ranger.ext.vcs import VcsError | ||
1655 | |||
1656 | if self.fm.thisdir.vcs and self.fm.thisdir.vcs.track: | ||
1657 | filelist = [f.path for f in self.fm.thistab.get_selection()] | ||
1658 | try: | ||
1659 | self.fm.thisdir.vcs.action_add(filelist) | ||
1660 | except VcsError as ex: | ||
1661 | self.fm.notify('Unable to stage files: {0}'.format(ex)) | ||
1662 | self.fm.ui.vcsthread.process(self.fm.thisdir) | ||
1663 | else: | ||
1664 | self.fm.notify('Unable to stage files: Not in repository') | ||
1665 | |||
1666 | |||
1667 | class unstage(Command): | ||
1668 | """ | ||
1669 | :unstage | ||
1670 | |||
1671 | Unstage selected files for the corresponding version control system | ||
1672 | """ | ||
1673 | |||
1674 | def execute(self): | ||
1675 | from ranger.ext.vcs import VcsError | ||
1676 | |||
1677 | if self.fm.thisdir.vcs and self.fm.thisdir.vcs.track: | ||
1678 | filelist = [f.path for f in self.fm.thistab.get_selection()] | ||
1679 | try: | ||
1680 | self.fm.thisdir.vcs.action_reset(filelist) | ||
1681 | except VcsError as ex: | ||
1682 | self.fm.notify('Unable to unstage files: {0}'.format(ex)) | ||
1683 | self.fm.ui.vcsthread.process(self.fm.thisdir) | ||
1684 | else: | ||
1685 | self.fm.notify('Unable to unstage files: Not in repository') | ||
1686 | |||
1687 | # Metadata commands | ||
1688 | # -------------------------------- | ||
1689 | |||
1690 | |||
1691 | class prompt_metadata(Command): | ||
1692 | """ | ||
1693 | :prompt_metadata <key1> [<key2> [<key3> ...]] | ||
1694 | |||
1695 | Prompt the user to input metadata for multiple keys in a row. | ||
1696 | """ | ||
1697 | |||
1698 | _command_name = "meta" | ||
1699 | _console_chain = None | ||
1700 | |||
1701 | def execute(self): | ||
1702 | prompt_metadata._console_chain = self.args[1:] | ||
1703 | self._process_command_stack() | ||
1704 | |||
1705 | def _process_command_stack(self): | ||
1706 | if prompt_metadata._console_chain: | ||
1707 | key = prompt_metadata._console_chain.pop() | ||
1708 | self._fill_console(key) | ||
1709 | else: | ||
1710 | for col in self.fm.ui.browser.columns: | ||
1711 | col.need_redraw = True | ||
1712 | |||
1713 | def _fill_console(self, key): | ||
1714 | metadata = self.fm.metadata.get_metadata(self.fm.thisfile.path) | ||
1715 | if key in metadata and metadata[key]: | ||
1716 | existing_value = metadata[key] | ||
1717 | else: | ||
1718 | existing_value = "" | ||
1719 | text = "%s %s %s" % (self._command_name, key, existing_value) | ||
1720 | self.fm.open_console(text, position=len(text)) | ||
1721 | |||
1722 | |||
1723 | class meta(prompt_metadata): | ||
1724 | """ | ||
1725 | :meta <key> [<value>] | ||
1726 | |||
1727 | Change metadata of a file. Deletes the key if value is empty. | ||
1728 | """ | ||
1729 | |||
1730 | def execute(self): | ||
1731 | key = self.arg(1) | ||
1732 | update_dict = dict() | ||
1733 | update_dict[key] = self.rest(2) | ||
1734 | selection = self.fm.thistab.get_selection() | ||
1735 | for fobj in selection: | ||
1736 | self.fm.metadata.set_metadata(fobj.path, update_dict) | ||
1737 | self._process_command_stack() | ||
1738 | |||
1739 | def tab(self, tabnum): | ||
1740 | key = self.arg(1) | ||
1741 | metadata = self.fm.metadata.get_metadata(self.fm.thisfile.path) | ||
1742 | if key in metadata and metadata[key]: | ||
1743 | return [" ".join([self.arg(0), self.arg(1), metadata[key]])] | ||
1744 | return [self.arg(0) + " " + k for k in sorted(metadata) | ||
1745 | if k.startswith(self.arg(1))] | ||
1746 | |||
1747 | |||
1748 | class linemode(default_linemode): | ||
1749 | """ | ||
1750 | :linemode <mode> | ||
1751 | |||
1752 | Change what is displayed as a filename. | ||
1753 | |||
1754 | - "mode" may be any of the defined linemodes (see: ranger.core.linemode). | ||
1755 | "normal" is mapped to "filename". | ||
1756 | """ | ||
1757 | |||
1758 | def execute(self): | ||
1759 | mode = self.arg(1) | ||
1760 | |||
1761 | if mode == "normal": | ||
1762 | from ranger.core.linemode import DEFAULT_LINEMODE | ||
1763 | mode = DEFAULT_LINEMODE | ||
1764 | |||
1765 | if mode not in self.fm.thisfile.linemode_dict: | ||
1766 | self.fm.notify("Unhandled linemode: `%s'" % mode, bad=True) | ||
1767 | return | ||
1768 | |||
1769 | self.fm.thisdir.set_linemode_of_children(mode) | ||
1770 | |||
1771 | # Ask the browsercolumns to redraw | ||
1772 | for col in self.fm.ui.browser.columns: | ||
1773 | col.need_redraw = True | ||
1774 | |||
1775 | |||
1776 | class yank(Command): | ||
1777 | """:yank [name|dir|path] | ||
1778 | |||
1779 | Copies the file's name (default), directory or path into both the primary X | ||
1780 | selection and the clipboard. | ||
1781 | """ | ||
1782 | |||
1783 | modes = { | ||
1784 | '': 'basename', | ||
1785 | 'name_without_extension': 'basename_without_extension', | ||
1786 | 'name': 'basename', | ||
1787 | 'dir': 'dirname', | ||
1788 | 'path': 'path', | ||
1789 | } | ||
1790 | |||
1791 | def execute(self): | ||
1792 | import subprocess | ||
1793 | |||
1794 | def clipboards(): | ||
1795 | from ranger.ext.get_executables import get_executables | ||
1796 | clipboard_managers = { | ||
1797 | 'xclip': [ | ||
1798 | ['xclip'], | ||
1799 | ['xclip', '-selection', 'clipboard'], | ||
1800 | ], | ||
1801 | 'xsel': [ | ||
1802 | ['xsel'], | ||
1803 | ['xsel', '-b'], | ||
1804 | ], | ||
1805 | 'pbcopy': [ | ||
1806 | ['pbcopy'], | ||
1807 | ], | ||
1808 | } | ||
1809 | ordered_managers = ['pbcopy', 'xclip', 'xsel'] | ||
1810 | executables = get_executables() | ||
1811 | for manager in ordered_managers: | ||
1812 | if manager in executables: | ||
1813 | return clipboard_managers[manager] | ||
1814 | return [] | ||
1815 | |||
1816 | clipboard_commands = clipboards() | ||
1817 | |||
1818 | mode = self.modes[self.arg(1)] | ||
1819 | selection = self.get_selection_attr(mode) | ||
1820 | |||
1821 | new_clipboard_contents = "\n".join(selection) | ||
1822 | for command in clipboard_commands: | ||
1823 | process = subprocess.Popen(command, universal_newlines=True, | ||
1824 | stdin=subprocess.PIPE) | ||
1825 | process.communicate(input=new_clipboard_contents) | ||
1826 | |||
1827 | def get_selection_attr(self, attr): | ||
1828 | return [getattr(item, attr) for item in | ||
1829 | self.fm.thistab.get_selection()] | ||
1830 | |||
1831 | def tab(self, tabnum): | ||
1832 | return ( | ||
1833 | self.start(1) + mode for mode | ||
1834 | in sorted(self.modes.keys()) | ||
1835 | if mode | ||
1836 | ) | ||
diff --git a/.config/ranger/ranger_new/rc.conf b/.config/ranger/ranger_new/rc.conf new file mode 100644 index 0000000..4c4a5b9 --- /dev/null +++ b/.config/ranger/ranger_new/rc.conf | |||
@@ -0,0 +1,725 @@ | |||
1 | # =================================================================== | ||
2 | # This file contains the default startup commands for ranger. | ||
3 | # To change them, it is recommended to create either /etc/ranger/rc.conf | ||
4 | # (system-wide) or ~/.config/ranger/rc.conf (per user) and add your custom | ||
5 | # commands there. | ||
6 | # | ||
7 | # If you copy this whole file there, you may want to set the environment | ||
8 | # variable RANGER_LOAD_DEFAULT_RC to FALSE to avoid loading it twice. | ||
9 | # | ||
10 | # The purpose of this file is mainly to define keybindings and settings. | ||
11 | # For running more complex python code, please create a plugin in "plugins/" or | ||
12 | # a command in "commands.py". | ||
13 | # | ||
14 | # Each line is a command that will be run before the user interface | ||
15 | # is initialized. As a result, you can not use commands which rely | ||
16 | # on the UI such as :delete or :mark. | ||
17 | # =================================================================== | ||
18 | |||
19 | # =================================================================== | ||
20 | # == Options | ||
21 | # =================================================================== | ||
22 | |||
23 | # Which viewmode should be used? Possible values are: | ||
24 | # miller: Use miller columns which show multiple levels of the hierarchy | ||
25 | # multipane: Midnight-commander like multipane view showing all tabs next | ||
26 | # to each other | ||
27 | set viewmode miller | ||
28 | #set viewmode multipane | ||
29 | |||
30 | # How many columns are there, and what are their relative widths? | ||
31 | set column_ratios 1,3,4 | ||
32 | |||
33 | # Which files should be hidden? (regular expression) | ||
34 | set hidden_filter ^\.|\.(?:pyc|pyo|bak|swp)$|^lost\+found$|^__(py)?cache__$ | ||
35 | |||
36 | # Show hidden files? You can toggle this by typing 'zh' | ||
37 | set show_hidden false | ||
38 | |||
39 | # Ask for a confirmation when running the "delete" command? | ||
40 | # Valid values are "always", "never", "multiple" (default) | ||
41 | # With "multiple", ranger will ask only if you delete multiple files at once. | ||
42 | set confirm_on_delete multiple | ||
43 | |||
44 | # Use non-default path for file preview script? | ||
45 | # ranger ships with scope.sh, a script that calls external programs (see | ||
46 | # README.md for dependencies) to preview images, archives, etc. | ||
47 | set preview_script ~/.config/ranger/scope.sh | ||
48 | |||
49 | # Use the external preview script or display simple plain text or image previews? | ||
50 | set use_preview_script true | ||
51 | |||
52 | # Automatically count files in the directory, even before entering them? | ||
53 | set automatically_count_files true | ||
54 | |||
55 | # Open all images in this directory when running certain image viewers | ||
56 | # like feh or sxiv? You can still open selected files by marking them. | ||
57 | set open_all_images true | ||
58 | |||
59 | # Be aware of version control systems and display information. | ||
60 | set vcs_aware true | ||
61 | |||
62 | # State of the four backends git, hg, bzr, svn. The possible states are | ||
63 | # disabled, local (only show local info), enabled (show local and remote | ||
64 | # information). | ||
65 | set vcs_backend_git enabled | ||
66 | set vcs_backend_hg disabled | ||
67 | set vcs_backend_bzr disabled | ||
68 | set vcs_backend_svn disabled | ||
69 | |||
70 | # Use one of the supported image preview protocols | ||
71 | set preview_images true | ||
72 | |||
73 | # Set the preview image method. Supported methods: | ||
74 | # | ||
75 | # * w3m (default): | ||
76 | # Preview images in full color with the external command "w3mimgpreview"? | ||
77 | # This requires the console web browser "w3m" and a supported terminal. | ||
78 | # It has been successfully tested with "xterm" and "urxvt" without tmux. | ||
79 | # | ||
80 | # * iterm2: | ||
81 | # Preview images in full color using iTerm2 image previews | ||
82 | # (http://iterm2.com/images.html). This requires using iTerm2 compiled | ||
83 | # with image preview support. | ||
84 | # | ||
85 | # This feature relies on the dimensions of the terminal's font. By default, a | ||
86 | # width of 8 and height of 11 are used. To use other values, set the options | ||
87 | # iterm2_font_width and iterm2_font_height to the desired values. | ||
88 | # | ||
89 | # * terminology: | ||
90 | # Previews images in full color in the terminology terminal emulator. | ||
91 | # Supports a wide variety of formats, even vector graphics like svg. | ||
92 | # | ||
93 | # * urxvt: | ||
94 | # Preview images in full color using urxvt image backgrounds. This | ||
95 | # requires using urxvt compiled with pixbuf support. | ||
96 | # | ||
97 | # * urxvt-full: | ||
98 | # The same as urxvt but utilizing not only the preview pane but the | ||
99 | # whole terminal window. | ||
100 | # | ||
101 | # * kitty: | ||
102 | # Preview images in full color using kitty image protocol. | ||
103 | # Requires python PIL or pillow library. | ||
104 | # If ranger does not share the local filesystem with kitty | ||
105 | # the transfer method is changed to encode the whole image; | ||
106 | # while slower, this allows remote previews, | ||
107 | # for example during an ssh session. | ||
108 | # Tmux is unsupported. | ||
109 | set preview_images_method w3m | ||
110 | |||
111 | # Delay in seconds before displaying an image with the w3m method. | ||
112 | # Increase it in case of experiencing display corruption. | ||
113 | set w3m_delay 0.02 | ||
114 | |||
115 | # Default iTerm2 font size (see: preview_images_method: iterm2) | ||
116 | set iterm2_font_width 8 | ||
117 | set iterm2_font_height 11 | ||
118 | |||
119 | # Use a unicode "..." character to mark cut-off filenames? | ||
120 | set unicode_ellipsis false | ||
121 | |||
122 | # BIDI support - try to properly display file names in RTL languages (Hebrew, Arabic). | ||
123 | # Requires the python-bidi pip package | ||
124 | set bidi_support false | ||
125 | |||
126 | # Show dotfiles in the bookmark preview box? | ||
127 | set show_hidden_bookmarks true | ||
128 | |||
129 | # Which colorscheme to use? These colorschemes are available by default: | ||
130 | # default, jungle, snow, solarized | ||
131 | set colorscheme default | ||
132 | |||
133 | # Preview files on the rightmost column? | ||
134 | # And collapse (shrink) the last column if there is nothing to preview? | ||
135 | set preview_files true | ||
136 | set preview_directories true | ||
137 | set collapse_preview true | ||
138 | |||
139 | # Save the console history on exit? | ||
140 | set save_console_history true | ||
141 | |||
142 | # Draw the status bar on top of the browser window (default: bottom) | ||
143 | set status_bar_on_top false | ||
144 | |||
145 | # Draw a progress bar in the status bar which displays the average state of all | ||
146 | # currently running tasks which support progress bars? | ||
147 | set draw_progress_bar_in_status_bar true | ||
148 | |||
149 | # Draw borders around columns? (separators, outline, both, or none) | ||
150 | # Separators are vertical lines between columns. | ||
151 | # Outline draws a box around all the columns. | ||
152 | # Both combines the two. | ||
153 | set draw_borders both | ||
154 | |||
155 | # Display the directory name in tabs? | ||
156 | set dirname_in_tabs true | ||
157 | |||
158 | # Enable the mouse support? | ||
159 | set mouse_enabled true | ||
160 | |||
161 | # Display the file size in the main column or status bar? | ||
162 | set display_size_in_main_column true | ||
163 | set display_size_in_status_bar true | ||
164 | |||
165 | # Display the free disk space in the status bar? | ||
166 | set display_free_space_in_status_bar true | ||
167 | |||
168 | # Display files tags in all columns or only in main column? | ||
169 | set display_tags_in_all_columns true | ||
170 | |||
171 | # Set a title for the window? | ||
172 | set update_title false | ||
173 | |||
174 | # Set the title to "ranger" in the tmux program? | ||
175 | set update_tmux_title true | ||
176 | |||
177 | # Shorten the title if it gets long? The number defines how many | ||
178 | # directories are displayed at once, 0 turns off this feature. | ||
179 | set shorten_title 3 | ||
180 | |||
181 | # Show hostname in titlebar? | ||
182 | set hostname_in_titlebar true | ||
183 | |||
184 | # Abbreviate $HOME with ~ in the titlebar (first line) of ranger? | ||
185 | set tilde_in_titlebar false | ||
186 | |||
187 | # How many directory-changes or console-commands should be kept in history? | ||
188 | set max_history_size 20 | ||
189 | set max_console_history_size 50 | ||
190 | |||
191 | # Try to keep so much space between the top/bottom border when scrolling: | ||
192 | set scroll_offset 8 | ||
193 | |||
194 | # Flush the input after each key hit? (Noticeable when ranger lags) | ||
195 | set flushinput true | ||
196 | |||
197 | # Padding on the right when there's no preview? | ||
198 | # This allows you to click into the space to run the file. | ||
199 | set padding_right true | ||
200 | |||
201 | # Save bookmarks (used with mX and `X) instantly? | ||
202 | # This helps to synchronize bookmarks between multiple ranger | ||
203 | # instances but leads to *slight* performance loss. | ||
204 | # When false, bookmarks are saved when ranger is exited. | ||
205 | set autosave_bookmarks true | ||
206 | |||
207 | # Save the "`" bookmark to disk. This can be used to switch to the last | ||
208 | # directory by typing "``". | ||
209 | set save_backtick_bookmark true | ||
210 | |||
211 | # You can display the "real" cumulative size of directories by using the | ||
212 | # command :get_cumulative_size or typing "dc". The size is expensive to | ||
213 | # calculate and will not be updated automatically. You can choose | ||
214 | # to update it automatically though by turning on this option: | ||
215 | set autoupdate_cumulative_size false | ||
216 | |||
217 | # Turning this on makes sense for screen readers: | ||
218 | set show_cursor false | ||
219 | |||
220 | # One of: size, natural, basename, atime, ctime, mtime, type, random | ||
221 | set sort natural | ||
222 | |||
223 | # Additional sorting options | ||
224 | set sort_reverse false | ||
225 | set sort_case_insensitive true | ||
226 | set sort_directories_first true | ||
227 | set sort_unicode false | ||
228 | |||
229 | # Enable this if key combinations with the Alt Key don't work for you. | ||
230 | # (Especially on xterm) | ||
231 | set xterm_alt_key false | ||
232 | |||
233 | # Whether to include bookmarks in cd command | ||
234 | set cd_bookmarks true | ||
235 | |||
236 | # Changes case sensitivity for the cd command tab completion | ||
237 | set cd_tab_case sensitive | ||
238 | |||
239 | # Use fuzzy tab completion with the "cd" command. For example, | ||
240 | # ":cd /u/lo/b<tab>" expands to ":cd /usr/local/bin". | ||
241 | set cd_tab_fuzzy false | ||
242 | |||
243 | # Avoid previewing files larger than this size, in bytes. Use a value of 0 to | ||
244 | # disable this feature. | ||
245 | set preview_max_size 0 | ||
246 | |||
247 | # The key hint lists up to this size have their sublists expanded. | ||
248 | # Otherwise the submaps are replaced with "...". | ||
249 | set hint_collapse_threshold 10 | ||
250 | |||
251 | # Add the highlighted file to the path in the titlebar | ||
252 | set show_selection_in_titlebar true | ||
253 | |||
254 | # The delay that ranger idly waits for user input, in milliseconds, with a | ||
255 | # resolution of 100ms. Lower delay reduces lag between directory updates but | ||
256 | # increases CPU load. | ||
257 | set idle_delay 2000 | ||
258 | |||
259 | # When the metadata manager module looks for metadata, should it only look for | ||
260 | # a ".metadata.json" file in the current directory, or do a deep search and | ||
261 | # check all directories above the current one as well? | ||
262 | set metadata_deep_search false | ||
263 | |||
264 | # Clear all existing filters when leaving a directory | ||
265 | set clear_filters_on_dir_change false | ||
266 | |||
267 | # Disable displaying line numbers in main column. | ||
268 | # Possible values: false, absolute, relative. | ||
269 | set line_numbers false | ||
270 | |||
271 | # When line_numbers=relative show the absolute line number in the | ||
272 | # current line. | ||
273 | set relative_current_zero false | ||
274 | |||
275 | # Start line numbers from 1 instead of 0 | ||
276 | set one_indexed false | ||
277 | |||
278 | # Save tabs on exit | ||
279 | set save_tabs_on_exit false | ||
280 | |||
281 | # Enable scroll wrapping - moving down while on the last item will wrap around to | ||
282 | # the top and vice versa. | ||
283 | set wrap_scroll false | ||
284 | |||
285 | # Set the global_inode_type_filter to nothing. Possible options: d, f and l for | ||
286 | # directories, files and symlinks respectively. | ||
287 | set global_inode_type_filter | ||
288 | |||
289 | # This setting allows to freeze the list of files to save I/O bandwidth. It | ||
290 | # should be 'false' during start-up, but you can toggle it by pressing F. | ||
291 | set freeze_files false | ||
292 | |||
293 | # =================================================================== | ||
294 | # == Local Options | ||
295 | # =================================================================== | ||
296 | # You can set local options that only affect a single directory. | ||
297 | |||
298 | # Examples: | ||
299 | # setlocal path=~/downloads sort mtime | ||
300 | |||
301 | # =================================================================== | ||
302 | # == Command Aliases in the Console | ||
303 | # =================================================================== | ||
304 | |||
305 | alias e edit | ||
306 | alias q quit | ||
307 | alias q! quit! | ||
308 | alias qa quitall | ||
309 | alias qa! quitall! | ||
310 | alias qall quitall | ||
311 | alias qall! quitall! | ||
312 | alias setl setlocal | ||
313 | |||
314 | alias filter scout -prts | ||
315 | alias find scout -aets | ||
316 | alias mark scout -mr | ||
317 | alias unmark scout -Mr | ||
318 | alias search scout -rs | ||
319 | alias search_inc scout -rts | ||
320 | alias travel scout -aefklst | ||
321 | |||
322 | # =================================================================== | ||
323 | # == Define keys for the browser | ||
324 | # =================================================================== | ||
325 | |||
326 | # Basic | ||
327 | map Q quitall | ||
328 | map q quit | ||
329 | copymap q ZZ ZQ | ||
330 | |||
331 | map R reload_cwd | ||
332 | map F set freeze_files! | ||
333 | map <C-r> reset | ||
334 | map <C-l> redraw_window | ||
335 | map <C-c> abort | ||
336 | map <esc> change_mode normal | ||
337 | map ~ set viewmode! | ||
338 | |||
339 | map i display_file | ||
340 | map ? help | ||
341 | map W display_log | ||
342 | map w taskview_open | ||
343 | map S shell $SHELL | ||
344 | |||
345 | map : console | ||
346 | map ; console | ||
347 | map ! console shell%space | ||
348 | map @ console -p6 shell %%s | ||
349 | map # console shell -p%space | ||
350 | map s console shell%space | ||
351 | map r chain draw_possible_programs; console open_with%%space | ||
352 | map f console find%space | ||
353 | map cd console cd%space | ||
354 | |||
355 | map <C-p> chain console; eval fm.ui.console.history_move(-1) | ||
356 | |||
357 | # Change the line mode | ||
358 | map Mf linemode filename | ||
359 | map Mi linemode fileinfo | ||
360 | map Mm linemode mtime | ||
361 | map Mp linemode permissions | ||
362 | map Ms linemode sizemtime | ||
363 | map Mt linemode metatitle | ||
364 | |||
365 | # Tagging / Marking | ||
366 | map t tag_toggle | ||
367 | map ut tag_remove | ||
368 | map "<any> tag_toggle tag=%any | ||
369 | map <Space> mark_files toggle=True | ||
370 | map v mark_files all=True toggle=True | ||
371 | map uv mark_files all=True val=False | ||
372 | map V toggle_visual_mode | ||
373 | map uV toggle_visual_mode reverse=True | ||
374 | |||
375 | # For the nostalgics: Midnight Commander bindings | ||
376 | map <F1> help | ||
377 | map <F2> rename_append | ||
378 | map <F3> display_file | ||
379 | map <F4> edit | ||
380 | map <F5> copy | ||
381 | map <F6> cut | ||
382 | map <F7> console mkdir%space | ||
383 | map <F8> console delete | ||
384 | map <F10> exit | ||
385 | |||
386 | # In case you work on a keyboard with dvorak layout | ||
387 | map <UP> move up=1 | ||
388 | map <DOWN> move down=1 | ||
389 | map <LEFT> move left=1 | ||
390 | map <RIGHT> move right=1 | ||
391 | map <HOME> move to=0 | ||
392 | map <END> move to=-1 | ||
393 | map <PAGEDOWN> move down=1 pages=True | ||
394 | map <PAGEUP> move up=1 pages=True | ||
395 | map <CR> move right=1 | ||
396 | #map <DELETE> console delete | ||
397 | map <INSERT> console touch%space | ||
398 | |||
399 | # VIM-like | ||
400 | copymap <UP> k | ||
401 | copymap <DOWN> j | ||
402 | copymap <LEFT> h | ||
403 | copymap <RIGHT> l | ||
404 | copymap <HOME> gg | ||
405 | copymap <END> G | ||
406 | copymap <PAGEDOWN> <C-F> | ||
407 | copymap <PAGEUP> <C-B> | ||
408 | |||
409 | map J move down=0.5 pages=True | ||
410 | map K move up=0.5 pages=True | ||
411 | copymap J <C-D> | ||
412 | copymap K <C-U> | ||
413 | |||
414 | # Jumping around | ||
415 | map H history_go -1 | ||
416 | map L history_go 1 | ||
417 | map ] move_parent 1 | ||
418 | map [ move_parent -1 | ||
419 | map } traverse | ||
420 | map { traverse_backwards | ||
421 | map ) jump_non | ||
422 | |||
423 | map gh cd ~ | ||
424 | map ge cd /etc | ||
425 | map gu cd /usr | ||
426 | map gd cd /dev | ||
427 | map gl cd -r . | ||
428 | map gL cd -r %f | ||
429 | map go cd /opt | ||
430 | map gv cd /var | ||
431 | map gm cd /media | ||
432 | map gi eval fm.cd('/run/media/' + os.getenv('USER')) | ||
433 | map gM cd /mnt | ||
434 | map gs cd /srv | ||
435 | map gp cd /tmp | ||
436 | map gr cd / | ||
437 | map gR eval fm.cd(ranger.RANGERDIR) | ||
438 | map g/ cd / | ||
439 | map g? cd /usr/share/doc/ranger | ||
440 | |||
441 | # External Programs | ||
442 | map E edit | ||
443 | map du shell -p du --max-depth=1 -h --apparent-size | ||
444 | map dU shell -p du --max-depth=1 -h --apparent-size | sort -rh | ||
445 | map yp yank path | ||
446 | map yd yank dir | ||
447 | map yn yank name | ||
448 | map y. yank name_without_extension | ||
449 | |||
450 | # Filesystem Operations | ||
451 | map = chmod | ||
452 | |||
453 | map cw console rename%space | ||
454 | map a rename_append | ||
455 | map A eval fm.open_console('rename ' + fm.thisfile.relative_path.replace("%", "%%")) | ||
456 | map I eval fm.open_console('rename ' + fm.thisfile.relative_path.replace("%", "%%"), position=7) | ||
457 | |||
458 | map pp paste | ||
459 | map po paste overwrite=True | ||
460 | map pP paste append=True | ||
461 | map pO paste overwrite=True append=True | ||
462 | map pl paste_symlink relative=False | ||
463 | map pL paste_symlink relative=True | ||
464 | map phl paste_hardlink | ||
465 | map pht paste_hardlinked_subtree | ||
466 | |||
467 | map dD console delete | ||
468 | |||
469 | map dd cut | ||
470 | map ud uncut | ||
471 | map da cut mode=add | ||
472 | map dr cut mode=remove | ||
473 | map dt cut mode=toggle | ||
474 | |||
475 | map yy copy | ||
476 | map uy uncut | ||
477 | map ya copy mode=add | ||
478 | map yr copy mode=remove | ||
479 | map yt copy mode=toggle | ||
480 | |||
481 | # Temporary workarounds | ||
482 | map dgg eval fm.cut(dirarg=dict(to=0), narg=quantifier) | ||
483 | map dG eval fm.cut(dirarg=dict(to=-1), narg=quantifier) | ||
484 | map dj eval fm.cut(dirarg=dict(down=1), narg=quantifier) | ||
485 | map dk eval fm.cut(dirarg=dict(up=1), narg=quantifier) | ||
486 | map ygg eval fm.copy(dirarg=dict(to=0), narg=quantifier) | ||
487 | map yG eval fm.copy(dirarg=dict(to=-1), narg=quantifier) | ||
488 | map yj eval fm.copy(dirarg=dict(down=1), narg=quantifier) | ||
489 | map yk eval fm.copy(dirarg=dict(up=1), narg=quantifier) | ||
490 | |||
491 | # Searching | ||
492 | map / console search%space | ||
493 | map n search_next | ||
494 | map N search_next forward=False | ||
495 | map ct search_next order=tag | ||
496 | map cs search_next order=size | ||
497 | map ci search_next order=mimetype | ||
498 | map cc search_next order=ctime | ||
499 | map cm search_next order=mtime | ||
500 | map ca search_next order=atime | ||
501 | |||
502 | # Tabs | ||
503 | map <C-n> tab_new | ||
504 | map <C-w> tab_close | ||
505 | map <TAB> tab_move 1 | ||
506 | map <S-TAB> tab_move -1 | ||
507 | map <A-Right> tab_move 1 | ||
508 | map <A-Left> tab_move -1 | ||
509 | map gt tab_move 1 | ||
510 | map gT tab_move -1 | ||
511 | map gn tab_new | ||
512 | map gc tab_close | ||
513 | map uq tab_restore | ||
514 | map <a-1> tab_open 1 | ||
515 | map <a-2> tab_open 2 | ||
516 | map <a-3> tab_open 3 | ||
517 | map <a-4> tab_open 4 | ||
518 | map <a-5> tab_open 5 | ||
519 | map <a-6> tab_open 6 | ||
520 | map <a-7> tab_open 7 | ||
521 | map <a-8> tab_open 8 | ||
522 | map <a-9> tab_open 9 | ||
523 | map <a-r> tab_shift 1 | ||
524 | map <a-l> tab_shift -1 | ||
525 | |||
526 | # Sorting | ||
527 | map or set sort_reverse! | ||
528 | map oz set sort=random | ||
529 | map os chain set sort=size; set sort_reverse=False | ||
530 | map ob chain set sort=basename; set sort_reverse=False | ||
531 | map on chain set sort=natural; set sort_reverse=False | ||
532 | map om chain set sort=mtime; set sort_reverse=False | ||
533 | map oc chain set sort=ctime; set sort_reverse=False | ||
534 | map oa chain set sort=atime; set sort_reverse=False | ||
535 | map ot chain set sort=type; set sort_reverse=False | ||
536 | map oe chain set sort=extension; set sort_reverse=False | ||
537 | |||
538 | map oS chain set sort=size; set sort_reverse=True | ||
539 | map oB chain set sort=basename; set sort_reverse=True | ||
540 | map oN chain set sort=natural; set sort_reverse=True | ||
541 | map oM chain set sort=mtime; set sort_reverse=True | ||
542 | map oC chain set sort=ctime; set sort_reverse=True | ||
543 | map oA chain set sort=atime; set sort_reverse=True | ||
544 | map oT chain set sort=type; set sort_reverse=True | ||
545 | map oE chain set sort=extension; set sort_reverse=True | ||
546 | |||
547 | map dc get_cumulative_size | ||
548 | |||
549 | # Settings | ||
550 | map zc set collapse_preview! | ||
551 | map zd set sort_directories_first! | ||
552 | map zh set show_hidden! | ||
553 | map <C-h> set show_hidden! | ||
554 | copymap <C-h> <backspace> | ||
555 | copymap <backspace> <backspace2> | ||
556 | map zI set flushinput! | ||
557 | map zi set preview_images! | ||
558 | map zm set mouse_enabled! | ||
559 | map zp set preview_files! | ||
560 | map zP set preview_directories! | ||
561 | map zs set sort_case_insensitive! | ||
562 | map zu set autoupdate_cumulative_size! | ||
563 | map zv set use_preview_script! | ||
564 | map zf console filter%space | ||
565 | copymap zf zz | ||
566 | |||
567 | # Filter stack | ||
568 | map .n console filter_stack add name%space | ||
569 | map .m console filter_stack add mime%space | ||
570 | map .d filter_stack add type d | ||
571 | map .f filter_stack add type f | ||
572 | map .l filter_stack add type l | ||
573 | map .| filter_stack add or | ||
574 | map .& filter_stack add and | ||
575 | map .! filter_stack add not | ||
576 | map .r console filter_stack rotate | ||
577 | map .c filter_stack clear | ||
578 | map .* filter_stack decompose | ||
579 | map .p filter_stack pop | ||
580 | map .. filter_stack show | ||
581 | |||
582 | # Bookmarks | ||
583 | map `<any> enter_bookmark %any | ||
584 | map '<any> enter_bookmark %any | ||
585 | map m<any> set_bookmark %any | ||
586 | map um<any> unset_bookmark %any | ||
587 | |||
588 | map m<bg> draw_bookmarks | ||
589 | copymap m<bg> um<bg> `<bg> '<bg> | ||
590 | |||
591 | # Generate all the chmod bindings with some python help: | ||
592 | eval for arg in "rwxXst": cmd("map +u{0} shell -f chmod u+{0} %s".format(arg)) | ||
593 | eval for arg in "rwxXst": cmd("map +g{0} shell -f chmod g+{0} %s".format(arg)) | ||
594 | eval for arg in "rwxXst": cmd("map +o{0} shell -f chmod o+{0} %s".format(arg)) | ||
595 | eval for arg in "rwxXst": cmd("map +a{0} shell -f chmod a+{0} %s".format(arg)) | ||
596 | eval for arg in "rwxXst": cmd("map +{0} shell -f chmod u+{0} %s".format(arg)) | ||
597 | |||
598 | eval for arg in "rwxXst": cmd("map -u{0} shell -f chmod u-{0} %s".format(arg)) | ||
599 | eval for arg in "rwxXst": cmd("map -g{0} shell -f chmod g-{0} %s".format(arg)) | ||
600 | eval for arg in "rwxXst": cmd("map -o{0} shell -f chmod o-{0} %s".format(arg)) | ||
601 | eval for arg in "rwxXst": cmd("map -a{0} shell -f chmod a-{0} %s".format(arg)) | ||
602 | eval for arg in "rwxXst": cmd("map -{0} shell -f chmod u-{0} %s".format(arg)) | ||
603 | |||
604 | # =================================================================== | ||
605 | # == Define keys for the console | ||
606 | # =================================================================== | ||
607 | # Note: Unmapped keys are passed directly to the console. | ||
608 | |||
609 | # Basic | ||
610 | cmap <tab> eval fm.ui.console.tab() | ||
611 | cmap <s-tab> eval fm.ui.console.tab(-1) | ||
612 | cmap <ESC> eval fm.ui.console.close() | ||
613 | cmap <CR> eval fm.ui.console.execute() | ||
614 | cmap <C-l> redraw_window | ||
615 | |||
616 | copycmap <ESC> <C-c> | ||
617 | copycmap <CR> <C-j> | ||
618 | |||
619 | # Move around | ||
620 | cmap <up> eval fm.ui.console.history_move(-1) | ||
621 | cmap <down> eval fm.ui.console.history_move(1) | ||
622 | cmap <left> eval fm.ui.console.move(left=1) | ||
623 | cmap <right> eval fm.ui.console.move(right=1) | ||
624 | cmap <home> eval fm.ui.console.move(right=0, absolute=True) | ||
625 | cmap <end> eval fm.ui.console.move(right=-1, absolute=True) | ||
626 | cmap <a-b> eval fm.ui.console.move_word(left=1) | ||
627 | cmap <a-f> eval fm.ui.console.move_word(right=1) | ||
628 | |||
629 | copycmap <a-b> <a-left> | ||
630 | copycmap <a-f> <a-right> | ||
631 | |||
632 | # Line Editing | ||
633 | cmap <backspace> eval fm.ui.console.delete(-1) | ||
634 | cmap <delete> eval fm.ui.console.delete(0) | ||
635 | cmap <C-w> eval fm.ui.console.delete_word() | ||
636 | cmap <A-d> eval fm.ui.console.delete_word(backward=False) | ||
637 | cmap <C-k> eval fm.ui.console.delete_rest(1) | ||
638 | cmap <C-u> eval fm.ui.console.delete_rest(-1) | ||
639 | cmap <C-y> eval fm.ui.console.paste() | ||
640 | |||
641 | # And of course the emacs way | ||
642 | copycmap <ESC> <C-g> | ||
643 | copycmap <up> <C-p> | ||
644 | copycmap <down> <C-n> | ||
645 | copycmap <left> <C-b> | ||
646 | copycmap <right> <C-f> | ||
647 | copycmap <home> <C-a> | ||
648 | copycmap <end> <C-e> | ||
649 | copycmap <delete> <C-d> | ||
650 | copycmap <backspace> <C-h> | ||
651 | |||
652 | # Note: There are multiple ways to express backspaces. <backspace> (code 263) | ||
653 | # and <backspace2> (code 127). To be sure, use both. | ||
654 | copycmap <backspace> <backspace2> | ||
655 | |||
656 | # This special expression allows typing in numerals: | ||
657 | cmap <allow_quantifiers> false | ||
658 | |||
659 | # =================================================================== | ||
660 | # == Pager Keybindings | ||
661 | # =================================================================== | ||
662 | |||
663 | # Movement | ||
664 | pmap <down> pager_move down=1 | ||
665 | pmap <up> pager_move up=1 | ||
666 | pmap <left> pager_move left=4 | ||
667 | pmap <right> pager_move right=4 | ||
668 | pmap <home> pager_move to=0 | ||
669 | pmap <end> pager_move to=-1 | ||
670 | pmap <pagedown> pager_move down=1.0 pages=True | ||
671 | pmap <pageup> pager_move up=1.0 pages=True | ||
672 | pmap <C-d> pager_move down=0.5 pages=True | ||
673 | pmap <C-u> pager_move up=0.5 pages=True | ||
674 | |||
675 | copypmap <UP> k <C-p> | ||
676 | copypmap <DOWN> j <C-n> <CR> | ||
677 | copypmap <LEFT> h | ||
678 | copypmap <RIGHT> l | ||
679 | copypmap <HOME> g | ||
680 | copypmap <END> G | ||
681 | copypmap <C-d> d | ||
682 | copypmap <C-u> u | ||
683 | copypmap <PAGEDOWN> n f <C-F> <Space> | ||
684 | copypmap <PAGEUP> p b <C-B> | ||
685 | |||
686 | # Basic | ||
687 | pmap <C-l> redraw_window | ||
688 | pmap <ESC> pager_close | ||
689 | copypmap <ESC> q Q i <F3> | ||
690 | pmap E edit_file | ||
691 | |||
692 | # =================================================================== | ||
693 | # == Taskview Keybindings | ||
694 | # =================================================================== | ||
695 | |||
696 | # Movement | ||
697 | tmap <up> taskview_move up=1 | ||
698 | tmap <down> taskview_move down=1 | ||
699 | tmap <home> taskview_move to=0 | ||
700 | tmap <end> taskview_move to=-1 | ||
701 | tmap <pagedown> taskview_move down=1.0 pages=True | ||
702 | tmap <pageup> taskview_move up=1.0 pages=True | ||
703 | tmap <C-d> taskview_move down=0.5 pages=True | ||
704 | tmap <C-u> taskview_move up=0.5 pages=True | ||
705 | |||
706 | copytmap <UP> k <C-p> | ||
707 | copytmap <DOWN> j <C-n> <CR> | ||
708 | copytmap <HOME> g | ||
709 | copytmap <END> G | ||
710 | copytmap <C-u> u | ||
711 | copytmap <PAGEDOWN> n f <C-F> <Space> | ||
712 | copytmap <PAGEUP> p b <C-B> | ||
713 | |||
714 | # Changing priority and deleting tasks | ||
715 | tmap J eval -q fm.ui.taskview.task_move(-1) | ||
716 | tmap K eval -q fm.ui.taskview.task_move(0) | ||
717 | tmap dd eval -q fm.ui.taskview.task_remove() | ||
718 | tmap <pagedown> eval -q fm.ui.taskview.task_move(-1) | ||
719 | tmap <pageup> eval -q fm.ui.taskview.task_move(0) | ||
720 | tmap <delete> eval -q fm.ui.taskview.task_remove() | ||
721 | |||
722 | # Basic | ||
723 | tmap <C-l> redraw_window | ||
724 | tmap <ESC> taskview_close | ||
725 | copytmap <ESC> q Q w <C-c> | ||
diff --git a/.config/ranger/ranger_new/rifle.conf b/.config/ranger/ranger_new/rifle.conf new file mode 100644 index 0000000..babdcda --- /dev/null +++ b/.config/ranger/ranger_new/rifle.conf | |||
@@ -0,0 +1,256 @@ | |||
1 | # vim: ft=cfg | ||
2 | # | ||
3 | # This is the configuration file of "rifle", ranger's file executor/opener. | ||
4 | # Each line consists of conditions and a command. For each line the conditions | ||
5 | # are checked and if they are met, the respective command is run. | ||
6 | # | ||
7 | # Syntax: | ||
8 | # <condition1> , <condition2> , ... = command | ||
9 | # | ||
10 | # The command can contain these environment variables: | ||
11 | # $1-$9 | The n-th selected file | ||
12 | # $@ | All selected files | ||
13 | # | ||
14 | # If you use the special command "ask", rifle will ask you what program to run. | ||
15 | # | ||
16 | # Prefixing a condition with "!" will negate its result. | ||
17 | # These conditions are currently supported: | ||
18 | # match <regexp> | The regexp matches $1 | ||
19 | # ext <regexp> | The regexp matches the extension of $1 | ||
20 | # mime <regexp> | The regexp matches the mime type of $1 | ||
21 | # name <regexp> | The regexp matches the basename of $1 | ||
22 | # path <regexp> | The regexp matches the absolute path of $1 | ||
23 | # has <program> | The program is installed (i.e. located in $PATH) | ||
24 | # env <variable> | The environment variable "variable" is non-empty | ||
25 | # file | $1 is a file | ||
26 | # directory | $1 is a directory | ||
27 | # number <n> | change the number of this command to n | ||
28 | # terminal | stdin, stderr and stdout are connected to a terminal | ||
29 | # X | $DISPLAY is not empty (i.e. Xorg runs) | ||
30 | # | ||
31 | # There are also pseudo-conditions which have a "side effect": | ||
32 | # flag <flags> | Change how the program is run. See below. | ||
33 | # label <label> | Assign a label or name to the command so it can | ||
34 | # | be started with :open_with <label> in ranger | ||
35 | # | or `rifle -p <label>` in the standalone executable. | ||
36 | # else | Always true. | ||
37 | # | ||
38 | # Flags are single characters which slightly transform the command: | ||
39 | # f | Fork the program, make it run in the background. | ||
40 | # | New command = setsid $command >& /dev/null & | ||
41 | # r | Execute the command with root permissions | ||
42 | # | New command = sudo $command | ||
43 | # t | Run the program in a new terminal. If $TERMCMD is not defined, | ||
44 | # | rifle will attempt to extract it from $TERM. | ||
45 | # | New command = $TERMCMD -e $command | ||
46 | # Note: The "New command" serves only as an illustration, the exact | ||
47 | # implementation may differ. | ||
48 | # Note: When using rifle in ranger, there is an additional flag "c" for | ||
49 | # only running the current file even if you have marked multiple files. | ||
50 | |||
51 | #------------------------------------------- | ||
52 | # Websites | ||
53 | #------------------------------------------- | ||
54 | # Rarely installed browsers get higher priority; It is assumed that if you | ||
55 | # install a rare browser, you probably use it. Firefox/konqueror/w3m on the | ||
56 | # other hand are often only installed as fallback browsers. | ||
57 | ext x?html?, has surf, X, flag f = surf -- file://"$1" | ||
58 | ext x?html?, has vimprobable, X, flag f = vimprobable -- "$@" | ||
59 | ext x?html?, has vimprobable2, X, flag f = vimprobable2 -- "$@" | ||
60 | ext x?html?, has qutebrowser, X, flag f = qutebrowser -- "$@" | ||
61 | ext x?html?, has dwb, X, flag f = dwb -- "$@" | ||
62 | ext x?html?, has jumanji, X, flag f = jumanji -- "$@" | ||
63 | ext x?html?, has luakit, X, flag f = luakit -- "$@" | ||
64 | ext x?html?, has uzbl, X, flag f = uzbl -- "$@" | ||
65 | ext x?html?, has uzbl-tabbed, X, flag f = uzbl-tabbed -- "$@" | ||
66 | ext x?html?, has uzbl-browser, X, flag f = uzbl-browser -- "$@" | ||
67 | ext x?html?, has uzbl-core, X, flag f = uzbl-core -- "$@" | ||
68 | ext x?html?, has midori, X, flag f = midori -- "$@" | ||
69 | ext x?html?, has chromium-browser, X, flag f = chromium-browser -- "$@" | ||
70 | ext x?html?, has chromium, X, flag f = chromium -- "$@" | ||
71 | ext x?html?, has google-chrome, X, flag f = google-chrome -- "$@" | ||
72 | ext x?html?, has opera, X, flag f = opera -- "$@" | ||
73 | ext x?html?, has firefox, X, flag f = firefox -- "$@" | ||
74 | ext x?html?, has seamonkey, X, flag f = seamonkey -- "$@" | ||
75 | ext x?html?, has iceweasel, X, flag f = iceweasel -- "$@" | ||
76 | ext x?html?, has epiphany, X, flag f = epiphany -- "$@" | ||
77 | ext x?html?, has konqueror, X, flag f = konqueror -- "$@" | ||
78 | ext x?html?, has elinks, terminal = elinks "$@" | ||
79 | ext x?html?, has links2, terminal = links2 "$@" | ||
80 | ext x?html?, has links, terminal = links "$@" | ||
81 | ext x?html?, has lynx, terminal = lynx -- "$@" | ||
82 | ext x?html?, has w3m, terminal = w3m "$@" | ||
83 | |||
84 | #------------------------------------------- | ||
85 | # Misc | ||
86 | #------------------------------------------- | ||
87 | # Define the "editor" for text files as first action | ||
88 | mime ^text, label editor = ${VISUAL:-$EDITOR} -- "$@" | ||
89 | mime ^text, label pager = "$PAGER" -- "$@" | ||
90 | !mime ^text, label editor, ext xml|json|csv|tex|py|pl|rb|js|sh|php = ${VISUAL:-$EDITOR} -- "$@" | ||
91 | !mime ^text, label pager, ext xml|json|csv|tex|py|pl|rb|js|sh|php = "$PAGER" -- "$@" | ||
92 | |||
93 | ext 1 = man "$1" | ||
94 | ext s[wmf]c, has zsnes, X = zsnes "$1" | ||
95 | ext s[wmf]c, has snes9x-gtk,X = snes9x-gtk "$1" | ||
96 | ext nes, has fceux, X = fceux "$1" | ||
97 | ext exe = wine "$1" | ||
98 | name ^[mM]akefile$ = make | ||
99 | |||
100 | #-------------------------------------------- | ||
101 | # Code | ||
102 | #------------------------------------------- | ||
103 | ext py = python -- "$1" | ||
104 | ext pl = perl -- "$1" | ||
105 | ext rb = ruby -- "$1" | ||
106 | ext js = node -- "$1" | ||
107 | ext sh = sh -- "$1" | ||
108 | ext php = php -- "$1" | ||
109 | |||
110 | #-------------------------------------------- | ||
111 | # Audio without X | ||
112 | #------------------------------------------- | ||
113 | mime ^audio|ogg$, terminal, has mpv = mpv -- "$@" | ||
114 | mime ^audio|ogg$, terminal, has mplayer2 = mplayer2 -- "$@" | ||
115 | mime ^audio|ogg$, terminal, has mplayer = mplayer -- "$@" | ||
116 | ext midi?, terminal, has wildmidi = wildmidi -- "$@" | ||
117 | |||
118 | #-------------------------------------------- | ||
119 | # Video/Audio with a GUI | ||
120 | #------------------------------------------- | ||
121 | mime ^video|audio, has gmplayer, X, flag f = gmplayer -- "$@" | ||
122 | mime ^video|audio, has smplayer, X, flag f = smplayer "$@" | ||
123 | mime ^video, has mpv, X, flag f = mpv -- "$@" | ||
124 | mime ^video, has mpv, X, flag f = mpv --fs -- "$@" | ||
125 | mime ^video, has mplayer2, X, flag f = mplayer2 -- "$@" | ||
126 | mime ^video, has mplayer2, X, flag f = mplayer2 -fs -- "$@" | ||
127 | mime ^video, has mplayer, X, flag f = mplayer -- "$@" | ||
128 | mime ^video, has mplayer, X, flag f = mplayer -fs -- "$@" | ||
129 | mime ^video|audio, has vlc, X, flag f = vlc -- "$@" | ||
130 | mime ^video|audio, has totem, X, flag f = totem -- "$@" | ||
131 | mime ^video|audio, has totem, X, flag f = totem --fullscreen -- "$@" | ||
132 | |||
133 | #-------------------------------------------- | ||
134 | # Video without X: | ||
135 | #------------------------------------------- | ||
136 | mime ^video, terminal, !X, has mpv = mpv -- "$@" | ||
137 | mime ^video, terminal, !X, has mplayer2 = mplayer2 -- "$@" | ||
138 | mime ^video, terminal, !X, has mplayer = mplayer -- "$@" | ||
139 | |||
140 | #------------------------------------------- | ||
141 | # Documents | ||
142 | #------------------------------------------- | ||
143 | ext pdf, has llpp, X, flag f = llpp "$@" | ||
144 | ext pdf, has zathura, X, flag f = zathura -- "$@" | ||
145 | ext pdf, has mupdf, X, flag f = mupdf "$@" | ||
146 | ext pdf, has mupdf-x11,X, flag f = mupdf-x11 "$@" | ||
147 | ext pdf, has apvlv, X, flag f = apvlv -- "$@" | ||
148 | ext pdf, has xpdf, X, flag f = xpdf -- "$@" | ||
149 | ext pdf, has evince, X, flag f = evince -- "$@" | ||
150 | ext pdf, has atril, X, flag f = atril -- "$@" | ||
151 | ext pdf, has okular, X, flag f = okular -- "$@" | ||
152 | ext pdf, has epdfview, X, flag f = epdfview -- "$@" | ||
153 | ext pdf, has qpdfview, X, flag f = qpdfview "$@" | ||
154 | ext pdf, has open, X, flag f = open "$@" | ||
155 | |||
156 | ext docx?, has catdoc, terminal = catdoc -- "$@" | "$PAGER" | ||
157 | |||
158 | ext sxc|xlsx?|xlt|xlw|gnm|gnumeric, has gnumeric, X, flag f = gnumeric -- "$@" | ||
159 | ext sxc|xlsx?|xlt|xlw|gnm|gnumeric, has kspread, X, flag f = kspread -- "$@" | ||
160 | ext pptx?|od[dfgpst]|docx?|sxc|xlsx?|xlt|xlw|gnm|gnumeric, has libreoffice, X, flag f = libreoffice "$@" | ||
161 | ext pptx?|od[dfgpst]|docx?|sxc|xlsx?|xlt|xlw|gnm|gnumeric, has soffice, X, flag f = soffice "$@" | ||
162 | ext pptx?|od[dfgpst]|docx?|sxc|xlsx?|xlt|xlw|gnm|gnumeric, has ooffice, X, flag f = ooffice "$@" | ||
163 | |||
164 | ext djvu, has zathura,X, flag f = zathura -- "$@" | ||
165 | ext djvu, has evince, X, flag f = evince -- "$@" | ||
166 | ext djvu, has atril, X, flag f = atril -- "$@" | ||
167 | ext djvu, has djview, X, flag f = djview -- "$@" | ||
168 | |||
169 | ext epub, has ebook-viewer, X, flag f = ebook-viewer -- "$@" | ||
170 | ext mobi, has ebook-viewer, X, flag f = ebook-viewer -- "$@" | ||
171 | |||
172 | #------------------------------------------- | ||
173 | # Image Viewing: | ||
174 | #------------------------------------------- | ||
175 | mime ^image/svg, has inkscape, X, flag f = inkscape -- "$@" | ||
176 | mime ^image/svg, has display, X, flag f = display -- "$@" | ||
177 | |||
178 | mime ^image, has pqiv, X, flag f = pqiv -- "$@" | ||
179 | mime ^image, has sxiv, X, flag f = sxiv -- "$@" | ||
180 | mime ^image, has feh, X, flag f = feh -- "$@" | ||
181 | mime ^image, has mirage, X, flag f = mirage -- "$@" | ||
182 | mime ^image, has ristretto, X, flag f = ristretto "$@" | ||
183 | mime ^image, has eog, X, flag f = eog -- "$@" | ||
184 | mime ^image, has eom, X, flag f = eom -- "$@" | ||
185 | mime ^image, has nomacs, X, flag f = nomacs -- "$@" | ||
186 | mime ^image, has geeqie, X, flag f = geeqie -- "$@" | ||
187 | mime ^image, has gwenview, X, flag f = gwenview -- "$@" | ||
188 | mime ^image, has gimp, X, flag f = gimp -- "$@" | ||
189 | ext xcf, X, flag f = gimp -- "$@" | ||
190 | |||
191 | #------------------------------------------- | ||
192 | # Archives | ||
193 | #------------------------------------------- | ||
194 | |||
195 | # avoid password prompt by providing empty password | ||
196 | ext 7z, has 7z = 7z -p l "$@" | "$PAGER" | ||
197 | # This requires atool | ||
198 | ext ace|ar|arc|bz2?|cab|cpio|cpt|deb|dgc|dmg|gz, has atool = atool --list --each -- "$@" | "$PAGER" | ||
199 | ext iso|jar|msi|pkg|rar|shar|tar|tgz|xar|xpi|xz|zip, has atool = atool --list --each -- "$@" | "$PAGER" | ||
200 | ext 7z|ace|ar|arc|bz2?|cab|cpio|cpt|deb|dgc|dmg|gz, has atool = atool --extract --each -- "$@" | ||
201 | ext iso|jar|msi|pkg|rar|shar|tar|tgz|xar|xpi|xz|zip, has atool = atool --extract --each -- "$@" | ||
202 | |||
203 | # Listing and extracting archives without atool: | ||
204 | ext tar|gz|bz2|xz, has tar = tar vvtf "$1" | "$PAGER" | ||
205 | ext tar|gz|bz2|xz, has tar = for file in "$@"; do tar vvxf "$file"; done | ||
206 | ext bz2, has bzip2 = for file in "$@"; do bzip2 -dk "$file"; done | ||
207 | ext zip, has unzip = unzip -l "$1" | less | ||
208 | ext zip, has unzip = for file in "$@"; do unzip -d "${file%.*}" "$file"; done | ||
209 | ext ace, has unace = unace l "$1" | less | ||
210 | ext ace, has unace = for file in "$@"; do unace e "$file"; done | ||
211 | ext rar, has unrar = unrar l "$1" | less | ||
212 | ext rar, has unrar = for file in "$@"; do unrar x "$file"; done | ||
213 | |||
214 | #------------------------------------------- | ||
215 | # Flag t fallback terminals | ||
216 | #------------------------------------------- | ||
217 | # Rarely installed terminal emulators get higher priority; It is assumed that | ||
218 | # if you install a rare terminal emulator, you probably use it. | ||
219 | # gnome-terminal/konsole/xterm on the other hand are often installed as part of | ||
220 | # a desktop environment or as fallback terminal emulators. | ||
221 | mime ^ranger/x-terminal-emulator, has terminology = terminology -e "$@" | ||
222 | mime ^ranger/x-terminal-emulator, has kitty = kitty -- "$@" | ||
223 | mime ^ranger/x-terminal-emulator, has alacritty = alacritty -e "$@" | ||
224 | mime ^ranger/x-terminal-emulator, has sakura = sakura -e "$@" | ||
225 | mime ^ranger/x-terminal-emulator, has lilyterm = lilyterm -e "$@" | ||
226 | #mime ^ranger/x-terminal-emulator, has cool-retro-term = cool-retro-term -e "$@" | ||
227 | mime ^ranger/x-terminal-emulator, has termite = termite -x '"$@"' | ||
228 | #mime ^ranger/x-terminal-emulator, has yakuake = yakuake -e "$@" | ||
229 | mime ^ranger/x-terminal-emulator, has guake = guake -ne "$@" | ||
230 | mime ^ranger/x-terminal-emulator, has tilda = tilda -c "$@" | ||
231 | mime ^ranger/x-terminal-emulator, has st = st -e "$@" | ||
232 | mime ^ranger/x-terminal-emulator, has terminator = terminator -x "$@" | ||
233 | mime ^ranger/x-terminal-emulator, has urxvt = urxvt -e "$@" | ||
234 | mime ^ranger/x-terminal-emulator, has pantheon-terminal = pantheon-terminal -e "$@" | ||
235 | mime ^ranger/x-terminal-emulator, has lxterminal = lxterminal -e "$@" | ||
236 | mime ^ranger/x-terminal-emulator, has mate-terminal = mate-terminal -x "$@" | ||
237 | mime ^ranger/x-terminal-emulator, has xfce4-terminal = xfce4-terminal -x "$@" | ||
238 | mime ^ranger/x-terminal-emulator, has konsole = konsole -e "$@" | ||
239 | mime ^ranger/x-terminal-emulator, has gnome-terminal = gnome-terminal -- "$@" | ||
240 | mime ^ranger/x-terminal-emulator, has xterm = xterm -e "$@" | ||
241 | |||
242 | #------------------------------------------- | ||
243 | # Misc | ||
244 | #------------------------------------------- | ||
245 | label wallpaper, number 11, mime ^image, has feh, X = feh --bg-scale "$1" | ||
246 | label wallpaper, number 12, mime ^image, has feh, X = feh --bg-tile "$1" | ||
247 | label wallpaper, number 13, mime ^image, has feh, X = feh --bg-center "$1" | ||
248 | label wallpaper, number 14, mime ^image, has feh, X = feh --bg-fill "$1" | ||
249 | |||
250 | # Define the editor for non-text files + pager as last action | ||
251 | !mime ^text, !ext xml|json|csv|tex|py|pl|rb|js|sh|php = ask | ||
252 | label editor, !mime ^text, !ext xml|json|csv|tex|py|pl|rb|js|sh|php = ${VISUAL:-$EDITOR} -- "$@" | ||
253 | label pager, !mime ^text, !ext xml|json|csv|tex|py|pl|rb|js|sh|php = "$PAGER" -- "$@" | ||
254 | |||
255 | # The very last action, so that it's never triggered accidentally, is to execute a program: | ||
256 | mime application/x-executable = "$1" | ||
diff --git a/.config/ranger/ranger_new/scope.sh b/.config/ranger/ranger_new/scope.sh new file mode 100755 index 0000000..13a25b4 --- /dev/null +++ b/.config/ranger/ranger_new/scope.sh | |||
@@ -0,0 +1,216 @@ | |||
1 | #!/usr/bin/env bash | ||
2 | |||
3 | set -o noclobber -o noglob -o nounset -o pipefail | ||
4 | IFS=$'\n' | ||
5 | |||
6 | # If the option `use_preview_script` is set to `true`, | ||
7 | # then this script will be called and its output will be displayed in ranger. | ||
8 | # ANSI color codes are supported. | ||
9 | # STDIN is disabled, so interactive scripts won't work properly | ||
10 | |||
11 | # This script is considered a configuration file and must be updated manually. | ||
12 | # It will be left untouched if you upgrade ranger. | ||
13 | |||
14 | # Meanings of exit codes: | ||
15 | # code | meaning | action of ranger | ||
16 | # -----+------------+------------------------------------------- | ||
17 | # 0 | success | Display stdout as preview | ||
18 | # 1 | no preview | Display no preview at all | ||
19 | # 2 | plain text | Display the plain content of the file | ||
20 | # 3 | fix width | Don't reload when width changes | ||
21 | # 4 | fix height | Don't reload when height changes | ||
22 | # 5 | fix both | Don't ever reload | ||
23 | # 6 | image | Display the image `$IMAGE_CACHE_PATH` points to as an image preview | ||
24 | # 7 | image | Display the file directly as an image | ||
25 | |||
26 | # Script arguments | ||
27 | FILE_PATH="${1}" # Full path of the highlighted file | ||
28 | PV_WIDTH="${2}" # Width of the preview pane (number of fitting characters) | ||
29 | PV_HEIGHT="${3}" # Height of the preview pane (number of fitting characters) | ||
30 | IMAGE_CACHE_PATH="${4}" # Full path that should be used to cache image preview | ||
31 | PV_IMAGE_ENABLED="${5}" # 'True' if image previews are enabled, 'False' otherwise. | ||
32 | |||
33 | FILE_EXTENSION="${FILE_PATH##*.}" | ||
34 | FILE_EXTENSION_LOWER=$(echo ${FILE_EXTENSION} | tr '[:upper:]' '[:lower:]') | ||
35 | |||
36 | # Settings | ||
37 | HIGHLIGHT_SIZE_MAX=262143 # 256KiB | ||
38 | HIGHLIGHT_TABWIDTH=8 | ||
39 | HIGHLIGHT_STYLE='pablo' | ||
40 | PYGMENTIZE_STYLE='autumn' | ||
41 | |||
42 | |||
43 | handle_extension() { | ||
44 | case "${FILE_EXTENSION_LOWER}" in | ||
45 | # Archive | ||
46 | a|ace|alz|arc|arj|bz|bz2|cab|cpio|deb|gz|jar|lha|lz|lzh|lzma|lzo|\ | ||
47 | rpm|rz|t7z|tar|tbz|tbz2|tgz|tlz|txz|tZ|tzo|war|xpi|xz|Z|zip) | ||
48 | atool --list -- "${FILE_PATH}" && exit 5 | ||
49 | bsdtar --list --file "${FILE_PATH}" && exit 5 | ||
50 | exit 1;; | ||
51 | rar) | ||
52 | # Avoid password prompt by providing empty password | ||
53 | unrar lt -p- -- "${FILE_PATH}" && exit 5 | ||
54 | exit 1;; | ||
55 | 7z) | ||
56 | # Avoid password prompt by providing empty password | ||
57 | 7z l -p -- "${FILE_PATH}" && exit 5 | ||
58 | exit 1;; | ||
59 | |||
60 | |||
61 | pdf) | ||
62 | # Preview as text conversion | ||
63 | pdftotext -l 10 -nopgbrk -q -- "${FILE_PATH}" - | fmt -w ${PV_WIDTH} && exit 5 | ||
64 | mutool draw -F txt -i -- "${FILE_PATH}" 1-10 | fmt -w ${PV_WIDTH} && exit 5 | ||
65 | exiftool "${FILE_PATH}" && exit 5 | ||
66 | exit 1;; | ||
67 | |||
68 | # BitTorrent | ||
69 | torrent) | ||
70 | transmission-show -- "${FILE_PATH}" && exit 5 | ||
71 | exit 1;; | ||
72 | |||
73 | # OpenDocument | ||
74 | odt|ods|odp|sxw) | ||
75 | # Preview as text conversion | ||
76 | odt2txt "${FILE_PATH}" && exit 5 | ||
77 | exit 1;; | ||
78 | |||
79 | # HTML | ||
80 | htm|html|xhtml) | ||
81 | # Preview as text conversion | ||
82 | w3m -dump "${FILE_PATH}" && exit 5 | ||
83 | lynx -dump -- "${FILE_PATH}" && exit 5 | ||
84 | elinks -dump "${FILE_PATH}" && exit 5 | ||
85 | ;; # Continue with next handler on failure | ||
86 | esac | ||
87 | } | ||
88 | |||
89 | handle_image() { | ||
90 | local mimetype="${1}" | ||
91 | case "${mimetype}" in | ||
92 | # SVG | ||
93 | # image/svg+xml) | ||
94 | # convert "${FILE_PATH}" "${IMAGE_CACHE_PATH}" && exit 6 | ||
95 | # exit 1;; | ||
96 | |||
97 | # Image | ||
98 | image/*) | ||
99 | local orientation | ||
100 | orientation="$( identify -format '%[EXIF:Orientation]\n' -- "${FILE_PATH}" )" | ||
101 | # If orientation data is present and the image actually | ||
102 | # needs rotating ("1" means no rotation)... | ||
103 | if [[ -n "$orientation" && "$orientation" != 1 ]]; then | ||
104 | # ...auto-rotate the image according to the EXIF data. | ||
105 | convert -- "${FILE_PATH}" -auto-orient "${IMAGE_CACHE_PATH}" && exit 6 | ||
106 | fi | ||
107 | |||
108 | # `w3mimgdisplay` will be called for all images (unless overriden as above), | ||
109 | # but might fail for unsupported types. | ||
110 | exit 7;; | ||
111 | |||
112 | # Video | ||
113 | # video/*) | ||
114 | # # Thumbnail | ||
115 | # ffmpegthumbnailer -i "${FILE_PATH}" -o "${IMAGE_CACHE_PATH}" -s 0 && exit 6 | ||
116 | # exit 1;; | ||
117 | |||
118 | # application/pdf) | ||
119 | # pdftoppm -f 1 -l 1 \ | ||
120 | # -scale-to-x 1920 \ | ||
121 | # -scale-to-y -1 \ | ||
122 | # -singlefile \ | ||
123 | # -jpeg -tiffcompression jpeg \ | ||
124 | # -- "${FILE_PATH}" "${IMAGE_CACHE_PATH%.*}" \ | ||
125 | # && exit 6 || exit 1;; | ||
126 | |||
127 | # Preview archives using the first image inside. | ||
128 | # (Very useful for comic book collections for example.) | ||
129 | # application/zip|application/x-rar|application/x-7z-compressed|\ | ||
130 | # application/x-xz|application/x-bzip2|application/x-gzip|application/x-tar) | ||
131 | # local fn=""; local fe="" | ||
132 | # local zip=""; local rar=""; local tar=""; local bsd="" | ||
133 | # case "${mimetype}" in | ||
134 | # application/zip) zip=1 ;; | ||
135 | # application/x-rar) rar=1 ;; | ||
136 | # application/x-7z-compressed) ;; | ||
137 | # *) tar=1 ;; | ||
138 | # esac | ||
139 | # { [ "$tar" ] && fn=$(tar --list --file "${FILE_PATH}"); } || \ | ||
140 | # { fn=$(bsdtar --list --file "${FILE_PATH}") && bsd=1 && tar=""; } || \ | ||
141 | # { [ "$rar" ] && fn=$(unrar lb -p- -- "${FILE_PATH}"); } || \ | ||
142 | # { [ "$zip" ] && fn=$(zipinfo -1 -- "${FILE_PATH}"); } || return | ||
143 | # | ||
144 | # fn=$(echo "$fn" | python -c "import sys; import mimetypes as m; \ | ||
145 | # [ print(l, end='') for l in sys.stdin if \ | ||
146 | # (m.guess_type(l[:-1])[0] or '').startswith('image/') ]" |\ | ||
147 | # sort -V | head -n 1) | ||
148 | # [ "$fn" = "" ] && return | ||
149 | # [ "$bsd" ] && fn=$(printf '%b' "$fn") | ||
150 | # | ||
151 | # [ "$tar" ] && tar --extract --to-stdout \ | ||
152 | # --file "${FILE_PATH}" -- "$fn" > "${IMAGE_CACHE_PATH}" && exit 6 | ||
153 | # fe=$(echo -n "$fn" | sed 's/[][*?\]/\\\0/g') | ||
154 | # [ "$bsd" ] && bsdtar --extract --to-stdout \ | ||
155 | # --file "${FILE_PATH}" -- "$fe" > "${IMAGE_CACHE_PATH}" && exit 6 | ||
156 | # [ "$bsd" ] || [ "$tar" ] && rm -- "${IMAGE_CACHE_PATH}" | ||
157 | # [ "$rar" ] && unrar p -p- -inul -- "${FILE_PATH}" "$fn" > \ | ||
158 | # "${IMAGE_CACHE_PATH}" && exit 6 | ||
159 | # [ "$zip" ] && unzip -pP "" -- "${FILE_PATH}" "$fe" > \ | ||
160 | # "${IMAGE_CACHE_PATH}" && exit 6 | ||
161 | # [ "$rar" ] || [ "$zip" ] && rm -- "${IMAGE_CACHE_PATH}" | ||
162 | # ;; | ||
163 | esac | ||
164 | } | ||
165 | |||
166 | handle_mime() { | ||
167 | local mimetype="${1}" | ||
168 | case "${mimetype}" in | ||
169 | # Text | ||
170 | text/* | */xml) | ||
171 | # Syntax highlight | ||
172 | if [[ "$( stat --printf='%s' -- "${FILE_PATH}" )" -gt "${HIGHLIGHT_SIZE_MAX}" ]]; then | ||
173 | exit 2 | ||
174 | fi | ||
175 | if [[ "$( tput colors )" -ge 256 ]]; then | ||
176 | local pygmentize_format='terminal256' | ||
177 | local highlight_format='xterm256' | ||
178 | else | ||
179 | local pygmentize_format='terminal' | ||
180 | local highlight_format='ansi' | ||
181 | fi | ||
182 | highlight --replace-tabs="${HIGHLIGHT_TABWIDTH}" --out-format="${highlight_format}" \ | ||
183 | --style="${HIGHLIGHT_STYLE}" --force -- "${FILE_PATH}" && exit 5 | ||
184 | # pygmentize -f "${pygmentize_format}" -O "style=${PYGMENTIZE_STYLE}" -- "${FILE_PATH}" && exit 5 | ||
185 | exit 2;; | ||
186 | |||
187 | # Image | ||
188 | image/*) | ||
189 | # Preview as text conversion | ||
190 | # img2txt --gamma=0.6 --width="${PV_WIDTH}" -- "${FILE_PATH}" && exit 4 | ||
191 | exiftool "${FILE_PATH}" && exit 5 | ||
192 | exit 1;; | ||
193 | |||
194 | # Video and audio | ||
195 | video/* | audio/*) | ||
196 | mediainfo "${FILE_PATH}" && exit 5 | ||
197 | exiftool "${FILE_PATH}" && exit 5 | ||
198 | exit 1;; | ||
199 | esac | ||
200 | } | ||
201 | |||
202 | handle_fallback() { | ||
203 | echo '----- File Type Classification -----' && file --dereference --brief -- "${FILE_PATH}" && exit 5 | ||
204 | exit 1 | ||
205 | } | ||
206 | |||
207 | |||
208 | MIMETYPE="$( file --dereference --brief --mime-type -- "${FILE_PATH}" )" | ||
209 | if [[ "${PV_IMAGE_ENABLED}" == 'True' ]]; then | ||
210 | handle_image "${MIMETYPE}" | ||
211 | fi | ||
212 | handle_extension | ||
213 | handle_mime "${MIMETYPE}" | ||
214 | handle_fallback | ||
215 | |||
216 | exit 1 | ||
diff --git a/.config/ranger/rc.conf b/.config/ranger/rc.conf new file mode 100644 index 0000000..4c4a5b9 --- /dev/null +++ b/.config/ranger/rc.conf | |||
@@ -0,0 +1,725 @@ | |||
1 | # =================================================================== | ||
2 | # This file contains the default startup commands for ranger. | ||
3 | # To change them, it is recommended to create either /etc/ranger/rc.conf | ||
4 | # (system-wide) or ~/.config/ranger/rc.conf (per user) and add your custom | ||
5 | # commands there. | ||
6 | # | ||
7 | # If you copy this whole file there, you may want to set the environment | ||
8 | # variable RANGER_LOAD_DEFAULT_RC to FALSE to avoid loading it twice. | ||
9 | # | ||
10 | # The purpose of this file is mainly to define keybindings and settings. | ||
11 | # For running more complex python code, please create a plugin in "plugins/" or | ||
12 | # a command in "commands.py". | ||
13 | # | ||
14 | # Each line is a command that will be run before the user interface | ||
15 | # is initialized. As a result, you can not use commands which rely | ||
16 | # on the UI such as :delete or :mark. | ||
17 | # =================================================================== | ||
18 | |||
19 | # =================================================================== | ||
20 | # == Options | ||
21 | # =================================================================== | ||
22 | |||
23 | # Which viewmode should be used? Possible values are: | ||
24 | # miller: Use miller columns which show multiple levels of the hierarchy | ||
25 | # multipane: Midnight-commander like multipane view showing all tabs next | ||
26 | # to each other | ||
27 | set viewmode miller | ||
28 | #set viewmode multipane | ||
29 | |||
30 | # How many columns are there, and what are their relative widths? | ||
31 | set column_ratios 1,3,4 | ||
32 | |||
33 | # Which files should be hidden? (regular expression) | ||
34 | set hidden_filter ^\.|\.(?:pyc|pyo|bak|swp)$|^lost\+found$|^__(py)?cache__$ | ||
35 | |||
36 | # Show hidden files? You can toggle this by typing 'zh' | ||
37 | set show_hidden false | ||
38 | |||
39 | # Ask for a confirmation when running the "delete" command? | ||
40 | # Valid values are "always", "never", "multiple" (default) | ||
41 | # With "multiple", ranger will ask only if you delete multiple files at once. | ||
42 | set confirm_on_delete multiple | ||
43 | |||
44 | # Use non-default path for file preview script? | ||
45 | # ranger ships with scope.sh, a script that calls external programs (see | ||
46 | # README.md for dependencies) to preview images, archives, etc. | ||
47 | set preview_script ~/.config/ranger/scope.sh | ||
48 | |||
49 | # Use the external preview script or display simple plain text or image previews? | ||
50 | set use_preview_script true | ||
51 | |||
52 | # Automatically count files in the directory, even before entering them? | ||
53 | set automatically_count_files true | ||
54 | |||
55 | # Open all images in this directory when running certain image viewers | ||
56 | # like feh or sxiv? You can still open selected files by marking them. | ||
57 | set open_all_images true | ||
58 | |||
59 | # Be aware of version control systems and display information. | ||
60 | set vcs_aware true | ||
61 | |||
62 | # State of the four backends git, hg, bzr, svn. The possible states are | ||
63 | # disabled, local (only show local info), enabled (show local and remote | ||
64 | # information). | ||
65 | set vcs_backend_git enabled | ||
66 | set vcs_backend_hg disabled | ||
67 | set vcs_backend_bzr disabled | ||
68 | set vcs_backend_svn disabled | ||
69 | |||
70 | # Use one of the supported image preview protocols | ||
71 | set preview_images true | ||
72 | |||
73 | # Set the preview image method. Supported methods: | ||
74 | # | ||
75 | # * w3m (default): | ||
76 | # Preview images in full color with the external command "w3mimgpreview"? | ||
77 | # This requires the console web browser "w3m" and a supported terminal. | ||
78 | # It has been successfully tested with "xterm" and "urxvt" without tmux. | ||
79 | # | ||
80 | # * iterm2: | ||
81 | # Preview images in full color using iTerm2 image previews | ||
82 | # (http://iterm2.com/images.html). This requires using iTerm2 compiled | ||
83 | # with image preview support. | ||
84 | # | ||
85 | # This feature relies on the dimensions of the terminal's font. By default, a | ||
86 | # width of 8 and height of 11 are used. To use other values, set the options | ||
87 | # iterm2_font_width and iterm2_font_height to the desired values. | ||
88 | # | ||
89 | # * terminology: | ||
90 | # Previews images in full color in the terminology terminal emulator. | ||
91 | # Supports a wide variety of formats, even vector graphics like svg. | ||
92 | # | ||
93 | # * urxvt: | ||
94 | # Preview images in full color using urxvt image backgrounds. This | ||
95 | # requires using urxvt compiled with pixbuf support. | ||
96 | # | ||
97 | # * urxvt-full: | ||
98 | # The same as urxvt but utilizing not only the preview pane but the | ||
99 | # whole terminal window. | ||
100 | # | ||
101 | # * kitty: | ||
102 | # Preview images in full color using kitty image protocol. | ||
103 | # Requires python PIL or pillow library. | ||
104 | # If ranger does not share the local filesystem with kitty | ||
105 | # the transfer method is changed to encode the whole image; | ||
106 | # while slower, this allows remote previews, | ||
107 | # for example during an ssh session. | ||
108 | # Tmux is unsupported. | ||
109 | set preview_images_method w3m | ||
110 | |||
111 | # Delay in seconds before displaying an image with the w3m method. | ||
112 | # Increase it in case of experiencing display corruption. | ||
113 | set w3m_delay 0.02 | ||
114 | |||
115 | # Default iTerm2 font size (see: preview_images_method: iterm2) | ||
116 | set iterm2_font_width 8 | ||
117 | set iterm2_font_height 11 | ||
118 | |||
119 | # Use a unicode "..." character to mark cut-off filenames? | ||
120 | set unicode_ellipsis false | ||
121 | |||
122 | # BIDI support - try to properly display file names in RTL languages (Hebrew, Arabic). | ||
123 | # Requires the python-bidi pip package | ||
124 | set bidi_support false | ||
125 | |||
126 | # Show dotfiles in the bookmark preview box? | ||
127 | set show_hidden_bookmarks true | ||
128 | |||
129 | # Which colorscheme to use? These colorschemes are available by default: | ||
130 | # default, jungle, snow, solarized | ||
131 | set colorscheme default | ||
132 | |||
133 | # Preview files on the rightmost column? | ||
134 | # And collapse (shrink) the last column if there is nothing to preview? | ||
135 | set preview_files true | ||
136 | set preview_directories true | ||
137 | set collapse_preview true | ||
138 | |||
139 | # Save the console history on exit? | ||
140 | set save_console_history true | ||
141 | |||
142 | # Draw the status bar on top of the browser window (default: bottom) | ||
143 | set status_bar_on_top false | ||
144 | |||
145 | # Draw a progress bar in the status bar which displays the average state of all | ||
146 | # currently running tasks which support progress bars? | ||
147 | set draw_progress_bar_in_status_bar true | ||
148 | |||
149 | # Draw borders around columns? (separators, outline, both, or none) | ||
150 | # Separators are vertical lines between columns. | ||
151 | # Outline draws a box around all the columns. | ||
152 | # Both combines the two. | ||
153 | set draw_borders both | ||
154 | |||
155 | # Display the directory name in tabs? | ||
156 | set dirname_in_tabs true | ||
157 | |||
158 | # Enable the mouse support? | ||
159 | set mouse_enabled true | ||
160 | |||
161 | # Display the file size in the main column or status bar? | ||
162 | set display_size_in_main_column true | ||
163 | set display_size_in_status_bar true | ||
164 | |||
165 | # Display the free disk space in the status bar? | ||
166 | set display_free_space_in_status_bar true | ||
167 | |||
168 | # Display files tags in all columns or only in main column? | ||
169 | set display_tags_in_all_columns true | ||
170 | |||
171 | # Set a title for the window? | ||
172 | set update_title false | ||
173 | |||
174 | # Set the title to "ranger" in the tmux program? | ||
175 | set update_tmux_title true | ||
176 | |||
177 | # Shorten the title if it gets long? The number defines how many | ||
178 | # directories are displayed at once, 0 turns off this feature. | ||
179 | set shorten_title 3 | ||
180 | |||
181 | # Show hostname in titlebar? | ||
182 | set hostname_in_titlebar true | ||
183 | |||
184 | # Abbreviate $HOME with ~ in the titlebar (first line) of ranger? | ||
185 | set tilde_in_titlebar false | ||
186 | |||
187 | # How many directory-changes or console-commands should be kept in history? | ||
188 | set max_history_size 20 | ||
189 | set max_console_history_size 50 | ||
190 | |||
191 | # Try to keep so much space between the top/bottom border when scrolling: | ||
192 | set scroll_offset 8 | ||
193 | |||
194 | # Flush the input after each key hit? (Noticeable when ranger lags) | ||
195 | set flushinput true | ||
196 | |||
197 | # Padding on the right when there's no preview? | ||
198 | # This allows you to click into the space to run the file. | ||
199 | set padding_right true | ||
200 | |||
201 | # Save bookmarks (used with mX and `X) instantly? | ||
202 | # This helps to synchronize bookmarks between multiple ranger | ||
203 | # instances but leads to *slight* performance loss. | ||
204 | # When false, bookmarks are saved when ranger is exited. | ||
205 | set autosave_bookmarks true | ||
206 | |||
207 | # Save the "`" bookmark to disk. This can be used to switch to the last | ||
208 | # directory by typing "``". | ||
209 | set save_backtick_bookmark true | ||
210 | |||
211 | # You can display the "real" cumulative size of directories by using the | ||
212 | # command :get_cumulative_size or typing "dc". The size is expensive to | ||
213 | # calculate and will not be updated automatically. You can choose | ||
214 | # to update it automatically though by turning on this option: | ||
215 | set autoupdate_cumulative_size false | ||
216 | |||
217 | # Turning this on makes sense for screen readers: | ||
218 | set show_cursor false | ||
219 | |||
220 | # One of: size, natural, basename, atime, ctime, mtime, type, random | ||
221 | set sort natural | ||
222 | |||
223 | # Additional sorting options | ||
224 | set sort_reverse false | ||
225 | set sort_case_insensitive true | ||
226 | set sort_directories_first true | ||
227 | set sort_unicode false | ||
228 | |||
229 | # Enable this if key combinations with the Alt Key don't work for you. | ||
230 | # (Especially on xterm) | ||
231 | set xterm_alt_key false | ||
232 | |||
233 | # Whether to include bookmarks in cd command | ||
234 | set cd_bookmarks true | ||
235 | |||
236 | # Changes case sensitivity for the cd command tab completion | ||
237 | set cd_tab_case sensitive | ||
238 | |||
239 | # Use fuzzy tab completion with the "cd" command. For example, | ||
240 | # ":cd /u/lo/b<tab>" expands to ":cd /usr/local/bin". | ||
241 | set cd_tab_fuzzy false | ||
242 | |||
243 | # Avoid previewing files larger than this size, in bytes. Use a value of 0 to | ||
244 | # disable this feature. | ||
245 | set preview_max_size 0 | ||
246 | |||
247 | # The key hint lists up to this size have their sublists expanded. | ||
248 | # Otherwise the submaps are replaced with "...". | ||
249 | set hint_collapse_threshold 10 | ||
250 | |||
251 | # Add the highlighted file to the path in the titlebar | ||
252 | set show_selection_in_titlebar true | ||
253 | |||
254 | # The delay that ranger idly waits for user input, in milliseconds, with a | ||
255 | # resolution of 100ms. Lower delay reduces lag between directory updates but | ||
256 | # increases CPU load. | ||
257 | set idle_delay 2000 | ||
258 | |||
259 | # When the metadata manager module looks for metadata, should it only look for | ||
260 | # a ".metadata.json" file in the current directory, or do a deep search and | ||
261 | # check all directories above the current one as well? | ||
262 | set metadata_deep_search false | ||
263 | |||
264 | # Clear all existing filters when leaving a directory | ||
265 | set clear_filters_on_dir_change false | ||
266 | |||
267 | # Disable displaying line numbers in main column. | ||
268 | # Possible values: false, absolute, relative. | ||
269 | set line_numbers false | ||
270 | |||
271 | # When line_numbers=relative show the absolute line number in the | ||
272 | # current line. | ||
273 | set relative_current_zero false | ||
274 | |||
275 | # Start line numbers from 1 instead of 0 | ||
276 | set one_indexed false | ||
277 | |||
278 | # Save tabs on exit | ||
279 | set save_tabs_on_exit false | ||
280 | |||
281 | # Enable scroll wrapping - moving down while on the last item will wrap around to | ||
282 | # the top and vice versa. | ||
283 | set wrap_scroll false | ||
284 | |||
285 | # Set the global_inode_type_filter to nothing. Possible options: d, f and l for | ||
286 | # directories, files and symlinks respectively. | ||
287 | set global_inode_type_filter | ||
288 | |||
289 | # This setting allows to freeze the list of files to save I/O bandwidth. It | ||
290 | # should be 'false' during start-up, but you can toggle it by pressing F. | ||
291 | set freeze_files false | ||
292 | |||
293 | # =================================================================== | ||
294 | # == Local Options | ||
295 | # =================================================================== | ||
296 | # You can set local options that only affect a single directory. | ||
297 | |||
298 | # Examples: | ||
299 | # setlocal path=~/downloads sort mtime | ||
300 | |||
301 | # =================================================================== | ||
302 | # == Command Aliases in the Console | ||
303 | # =================================================================== | ||
304 | |||
305 | alias e edit | ||
306 | alias q quit | ||
307 | alias q! quit! | ||
308 | alias qa quitall | ||
309 | alias qa! quitall! | ||
310 | alias qall quitall | ||
311 | alias qall! quitall! | ||
312 | alias setl setlocal | ||
313 | |||
314 | alias filter scout -prts | ||
315 | alias find scout -aets | ||
316 | alias mark scout -mr | ||
317 | alias unmark scout -Mr | ||
318 | alias search scout -rs | ||
319 | alias search_inc scout -rts | ||
320 | alias travel scout -aefklst | ||
321 | |||
322 | # =================================================================== | ||
323 | # == Define keys for the browser | ||
324 | # =================================================================== | ||
325 | |||
326 | # Basic | ||
327 | map Q quitall | ||
328 | map q quit | ||
329 | copymap q ZZ ZQ | ||
330 | |||
331 | map R reload_cwd | ||
332 | map F set freeze_files! | ||
333 | map <C-r> reset | ||
334 | map <C-l> redraw_window | ||
335 | map <C-c> abort | ||
336 | map <esc> change_mode normal | ||
337 | map ~ set viewmode! | ||
338 | |||
339 | map i display_file | ||
340 | map ? help | ||
341 | map W display_log | ||
342 | map w taskview_open | ||
343 | map S shell $SHELL | ||
344 | |||
345 | map : console | ||
346 | map ; console | ||
347 | map ! console shell%space | ||
348 | map @ console -p6 shell %%s | ||
349 | map # console shell -p%space | ||
350 | map s console shell%space | ||
351 | map r chain draw_possible_programs; console open_with%%space | ||
352 | map f console find%space | ||
353 | map cd console cd%space | ||
354 | |||
355 | map <C-p> chain console; eval fm.ui.console.history_move(-1) | ||
356 | |||
357 | # Change the line mode | ||
358 | map Mf linemode filename | ||
359 | map Mi linemode fileinfo | ||
360 | map Mm linemode mtime | ||
361 | map Mp linemode permissions | ||
362 | map Ms linemode sizemtime | ||
363 | map Mt linemode metatitle | ||
364 | |||
365 | # Tagging / Marking | ||
366 | map t tag_toggle | ||
367 | map ut tag_remove | ||
368 | map "<any> tag_toggle tag=%any | ||
369 | map <Space> mark_files toggle=True | ||
370 | map v mark_files all=True toggle=True | ||
371 | map uv mark_files all=True val=False | ||
372 | map V toggle_visual_mode | ||
373 | map uV toggle_visual_mode reverse=True | ||
374 | |||
375 | # For the nostalgics: Midnight Commander bindings | ||
376 | map <F1> help | ||
377 | map <F2> rename_append | ||
378 | map <F3> display_file | ||
379 | map <F4> edit | ||
380 | map <F5> copy | ||
381 | map <F6> cut | ||
382 | map <F7> console mkdir%space | ||
383 | map <F8> console delete | ||
384 | map <F10> exit | ||
385 | |||
386 | # In case you work on a keyboard with dvorak layout | ||
387 | map <UP> move up=1 | ||
388 | map <DOWN> move down=1 | ||
389 | map <LEFT> move left=1 | ||
390 | map <RIGHT> move right=1 | ||
391 | map <HOME> move to=0 | ||
392 | map <END> move to=-1 | ||
393 | map <PAGEDOWN> move down=1 pages=True | ||
394 | map <PAGEUP> move up=1 pages=True | ||
395 | map <CR> move right=1 | ||
396 | #map <DELETE> console delete | ||
397 | map <INSERT> console touch%space | ||
398 | |||
399 | # VIM-like | ||
400 | copymap <UP> k | ||
401 | copymap <DOWN> j | ||
402 | copymap <LEFT> h | ||
403 | copymap <RIGHT> l | ||
404 | copymap <HOME> gg | ||
405 | copymap <END> G | ||
406 | copymap <PAGEDOWN> <C-F> | ||
407 | copymap <PAGEUP> <C-B> | ||
408 | |||
409 | map J move down=0.5 pages=True | ||
410 | map K move up=0.5 pages=True | ||
411 | copymap J <C-D> | ||
412 | copymap K <C-U> | ||
413 | |||
414 | # Jumping around | ||
415 | map H history_go -1 | ||
416 | map L history_go 1 | ||
417 | map ] move_parent 1 | ||
418 | map [ move_parent -1 | ||
419 | map } traverse | ||
420 | map { traverse_backwards | ||
421 | map ) jump_non | ||
422 | |||
423 | map gh cd ~ | ||
424 | map ge cd /etc | ||
425 | map gu cd /usr | ||
426 | map gd cd /dev | ||
427 | map gl cd -r . | ||
428 | map gL cd -r %f | ||
429 | map go cd /opt | ||
430 | map gv cd /var | ||
431 | map gm cd /media | ||
432 | map gi eval fm.cd('/run/media/' + os.getenv('USER')) | ||
433 | map gM cd /mnt | ||
434 | map gs cd /srv | ||
435 | map gp cd /tmp | ||
436 | map gr cd / | ||
437 | map gR eval fm.cd(ranger.RANGERDIR) | ||
438 | map g/ cd / | ||
439 | map g? cd /usr/share/doc/ranger | ||
440 | |||
441 | # External Programs | ||
442 | map E edit | ||
443 | map du shell -p du --max-depth=1 -h --apparent-size | ||
444 | map dU shell -p du --max-depth=1 -h --apparent-size | sort -rh | ||
445 | map yp yank path | ||
446 | map yd yank dir | ||
447 | map yn yank name | ||
448 | map y. yank name_without_extension | ||
449 | |||
450 | # Filesystem Operations | ||
451 | map = chmod | ||
452 | |||
453 | map cw console rename%space | ||
454 | map a rename_append | ||
455 | map A eval fm.open_console('rename ' + fm.thisfile.relative_path.replace("%", "%%")) | ||
456 | map I eval fm.open_console('rename ' + fm.thisfile.relative_path.replace("%", "%%"), position=7) | ||
457 | |||
458 | map pp paste | ||
459 | map po paste overwrite=True | ||
460 | map pP paste append=True | ||
461 | map pO paste overwrite=True append=True | ||
462 | map pl paste_symlink relative=False | ||
463 | map pL paste_symlink relative=True | ||
464 | map phl paste_hardlink | ||
465 | map pht paste_hardlinked_subtree | ||
466 | |||
467 | map dD console delete | ||
468 | |||
469 | map dd cut | ||
470 | map ud uncut | ||
471 | map da cut mode=add | ||
472 | map dr cut mode=remove | ||
473 | map dt cut mode=toggle | ||
474 | |||
475 | map yy copy | ||
476 | map uy uncut | ||
477 | map ya copy mode=add | ||
478 | map yr copy mode=remove | ||
479 | map yt copy mode=toggle | ||
480 | |||
481 | # Temporary workarounds | ||
482 | map dgg eval fm.cut(dirarg=dict(to=0), narg=quantifier) | ||
483 | map dG eval fm.cut(dirarg=dict(to=-1), narg=quantifier) | ||
484 | map dj eval fm.cut(dirarg=dict(down=1), narg=quantifier) | ||
485 | map dk eval fm.cut(dirarg=dict(up=1), narg=quantifier) | ||
486 | map ygg eval fm.copy(dirarg=dict(to=0), narg=quantifier) | ||
487 | map yG eval fm.copy(dirarg=dict(to=-1), narg=quantifier) | ||
488 | map yj eval fm.copy(dirarg=dict(down=1), narg=quantifier) | ||
489 | map yk eval fm.copy(dirarg=dict(up=1), narg=quantifier) | ||
490 | |||
491 | # Searching | ||
492 | map / console search%space | ||
493 | map n search_next | ||
494 | map N search_next forward=False | ||
495 | map ct search_next order=tag | ||
496 | map cs search_next order=size | ||
497 | map ci search_next order=mimetype | ||
498 | map cc search_next order=ctime | ||
499 | map cm search_next order=mtime | ||
500 | map ca search_next order=atime | ||
501 | |||
502 | # Tabs | ||
503 | map <C-n> tab_new | ||
504 | map <C-w> tab_close | ||
505 | map <TAB> tab_move 1 | ||
506 | map <S-TAB> tab_move -1 | ||
507 | map <A-Right> tab_move 1 | ||
508 | map <A-Left> tab_move -1 | ||
509 | map gt tab_move 1 | ||
510 | map gT tab_move -1 | ||
511 | map gn tab_new | ||
512 | map gc tab_close | ||
513 | map uq tab_restore | ||
514 | map <a-1> tab_open 1 | ||
515 | map <a-2> tab_open 2 | ||
516 | map <a-3> tab_open 3 | ||
517 | map <a-4> tab_open 4 | ||
518 | map <a-5> tab_open 5 | ||
519 | map <a-6> tab_open 6 | ||
520 | map <a-7> tab_open 7 | ||
521 | map <a-8> tab_open 8 | ||
522 | map <a-9> tab_open 9 | ||
523 | map <a-r> tab_shift 1 | ||
524 | map <a-l> tab_shift -1 | ||
525 | |||
526 | # Sorting | ||
527 | map or set sort_reverse! | ||
528 | map oz set sort=random | ||
529 | map os chain set sort=size; set sort_reverse=False | ||
530 | map ob chain set sort=basename; set sort_reverse=False | ||
531 | map on chain set sort=natural; set sort_reverse=False | ||
532 | map om chain set sort=mtime; set sort_reverse=False | ||
533 | map oc chain set sort=ctime; set sort_reverse=False | ||
534 | map oa chain set sort=atime; set sort_reverse=False | ||
535 | map ot chain set sort=type; set sort_reverse=False | ||
536 | map oe chain set sort=extension; set sort_reverse=False | ||
537 | |||
538 | map oS chain set sort=size; set sort_reverse=True | ||
539 | map oB chain set sort=basename; set sort_reverse=True | ||
540 | map oN chain set sort=natural; set sort_reverse=True | ||
541 | map oM chain set sort=mtime; set sort_reverse=True | ||
542 | map oC chain set sort=ctime; set sort_reverse=True | ||
543 | map oA chain set sort=atime; set sort_reverse=True | ||
544 | map oT chain set sort=type; set sort_reverse=True | ||
545 | map oE chain set sort=extension; set sort_reverse=True | ||
546 | |||
547 | map dc get_cumulative_size | ||
548 | |||
549 | # Settings | ||
550 | map zc set collapse_preview! | ||
551 | map zd set sort_directories_first! | ||
552 | map zh set show_hidden! | ||
553 | map <C-h> set show_hidden! | ||
554 | copymap <C-h> <backspace> | ||
555 | copymap <backspace> <backspace2> | ||
556 | map zI set flushinput! | ||
557 | map zi set preview_images! | ||
558 | map zm set mouse_enabled! | ||
559 | map zp set preview_files! | ||
560 | map zP set preview_directories! | ||
561 | map zs set sort_case_insensitive! | ||
562 | map zu set autoupdate_cumulative_size! | ||
563 | map zv set use_preview_script! | ||
564 | map zf console filter%space | ||
565 | copymap zf zz | ||
566 | |||
567 | # Filter stack | ||
568 | map .n console filter_stack add name%space | ||
569 | map .m console filter_stack add mime%space | ||
570 | map .d filter_stack add type d | ||
571 | map .f filter_stack add type f | ||
572 | map .l filter_stack add type l | ||
573 | map .| filter_stack add or | ||
574 | map .& filter_stack add and | ||
575 | map .! filter_stack add not | ||
576 | map .r console filter_stack rotate | ||
577 | map .c filter_stack clear | ||
578 | map .* filter_stack decompose | ||
579 | map .p filter_stack pop | ||
580 | map .. filter_stack show | ||
581 | |||
582 | # Bookmarks | ||
583 | map `<any> enter_bookmark %any | ||
584 | map '<any> enter_bookmark %any | ||
585 | map m<any> set_bookmark %any | ||
586 | map um<any> unset_bookmark %any | ||
587 | |||
588 | map m<bg> draw_bookmarks | ||
589 | copymap m<bg> um<bg> `<bg> '<bg> | ||
590 | |||
591 | # Generate all the chmod bindings with some python help: | ||
592 | eval for arg in "rwxXst": cmd("map +u{0} shell -f chmod u+{0} %s".format(arg)) | ||
593 | eval for arg in "rwxXst": cmd("map +g{0} shell -f chmod g+{0} %s".format(arg)) | ||
594 | eval for arg in "rwxXst": cmd("map +o{0} shell -f chmod o+{0} %s".format(arg)) | ||
595 | eval for arg in "rwxXst": cmd("map +a{0} shell -f chmod a+{0} %s".format(arg)) | ||
596 | eval for arg in "rwxXst": cmd("map +{0} shell -f chmod u+{0} %s".format(arg)) | ||
597 | |||
598 | eval for arg in "rwxXst": cmd("map -u{0} shell -f chmod u-{0} %s".format(arg)) | ||
599 | eval for arg in "rwxXst": cmd("map -g{0} shell -f chmod g-{0} %s".format(arg)) | ||
600 | eval for arg in "rwxXst": cmd("map -o{0} shell -f chmod o-{0} %s".format(arg)) | ||
601 | eval for arg in "rwxXst": cmd("map -a{0} shell -f chmod a-{0} %s".format(arg)) | ||
602 | eval for arg in "rwxXst": cmd("map -{0} shell -f chmod u-{0} %s".format(arg)) | ||
603 | |||
604 | # =================================================================== | ||
605 | # == Define keys for the console | ||
606 | # =================================================================== | ||
607 | # Note: Unmapped keys are passed directly to the console. | ||
608 | |||
609 | # Basic | ||
610 | cmap <tab> eval fm.ui.console.tab() | ||
611 | cmap <s-tab> eval fm.ui.console.tab(-1) | ||
612 | cmap <ESC> eval fm.ui.console.close() | ||
613 | cmap <CR> eval fm.ui.console.execute() | ||
614 | cmap <C-l> redraw_window | ||
615 | |||
616 | copycmap <ESC> <C-c> | ||
617 | copycmap <CR> <C-j> | ||
618 | |||
619 | # Move around | ||
620 | cmap <up> eval fm.ui.console.history_move(-1) | ||
621 | cmap <down> eval fm.ui.console.history_move(1) | ||
622 | cmap <left> eval fm.ui.console.move(left=1) | ||
623 | cmap <right> eval fm.ui.console.move(right=1) | ||
624 | cmap <home> eval fm.ui.console.move(right=0, absolute=True) | ||
625 | cmap <end> eval fm.ui.console.move(right=-1, absolute=True) | ||
626 | cmap <a-b> eval fm.ui.console.move_word(left=1) | ||
627 | cmap <a-f> eval fm.ui.console.move_word(right=1) | ||
628 | |||
629 | copycmap <a-b> <a-left> | ||
630 | copycmap <a-f> <a-right> | ||
631 | |||
632 | # Line Editing | ||
633 | cmap <backspace> eval fm.ui.console.delete(-1) | ||
634 | cmap <delete> eval fm.ui.console.delete(0) | ||
635 | cmap <C-w> eval fm.ui.console.delete_word() | ||
636 | cmap <A-d> eval fm.ui.console.delete_word(backward=False) | ||
637 | cmap <C-k> eval fm.ui.console.delete_rest(1) | ||
638 | cmap <C-u> eval fm.ui.console.delete_rest(-1) | ||
639 | cmap <C-y> eval fm.ui.console.paste() | ||
640 | |||
641 | # And of course the emacs way | ||
642 | copycmap <ESC> <C-g> | ||
643 | copycmap <up> <C-p> | ||
644 | copycmap <down> <C-n> | ||
645 | copycmap <left> <C-b> | ||
646 | copycmap <right> <C-f> | ||
647 | copycmap <home> <C-a> | ||
648 | copycmap <end> <C-e> | ||
649 | copycmap <delete> <C-d> | ||
650 | copycmap <backspace> <C-h> | ||
651 | |||
652 | # Note: There are multiple ways to express backspaces. <backspace> (code 263) | ||
653 | # and <backspace2> (code 127). To be sure, use both. | ||
654 | copycmap <backspace> <backspace2> | ||
655 | |||
656 | # This special expression allows typing in numerals: | ||
657 | cmap <allow_quantifiers> false | ||
658 | |||
659 | # =================================================================== | ||
660 | # == Pager Keybindings | ||
661 | # =================================================================== | ||
662 | |||
663 | # Movement | ||
664 | pmap <down> pager_move down=1 | ||
665 | pmap <up> pager_move up=1 | ||
666 | pmap <left> pager_move left=4 | ||
667 | pmap <right> pager_move right=4 | ||
668 | pmap <home> pager_move to=0 | ||
669 | pmap <end> pager_move to=-1 | ||
670 | pmap <pagedown> pager_move down=1.0 pages=True | ||
671 | pmap <pageup> pager_move up=1.0 pages=True | ||
672 | pmap <C-d> pager_move down=0.5 pages=True | ||
673 | pmap <C-u> pager_move up=0.5 pages=True | ||
674 | |||
675 | copypmap <UP> k <C-p> | ||
676 | copypmap <DOWN> j <C-n> <CR> | ||
677 | copypmap <LEFT> h | ||
678 | copypmap <RIGHT> l | ||
679 | copypmap <HOME> g | ||
680 | copypmap <END> G | ||
681 | copypmap <C-d> d | ||
682 | copypmap <C-u> u | ||
683 | copypmap <PAGEDOWN> n f <C-F> <Space> | ||
684 | copypmap <PAGEUP> p b <C-B> | ||
685 | |||
686 | # Basic | ||
687 | pmap <C-l> redraw_window | ||
688 | pmap <ESC> pager_close | ||
689 | copypmap <ESC> q Q i <F3> | ||
690 | pmap E edit_file | ||
691 | |||
692 | # =================================================================== | ||
693 | # == Taskview Keybindings | ||
694 | # =================================================================== | ||
695 | |||
696 | # Movement | ||
697 | tmap <up> taskview_move up=1 | ||
698 | tmap <down> taskview_move down=1 | ||
699 | tmap <home> taskview_move to=0 | ||
700 | tmap <end> taskview_move to=-1 | ||
701 | tmap <pagedown> taskview_move down=1.0 pages=True | ||
702 | tmap <pageup> taskview_move up=1.0 pages=True | ||
703 | tmap <C-d> taskview_move down=0.5 pages=True | ||
704 | tmap <C-u> taskview_move up=0.5 pages=True | ||
705 | |||
706 | copytmap <UP> k <C-p> | ||
707 | copytmap <DOWN> j <C-n> <CR> | ||
708 | copytmap <HOME> g | ||
709 | copytmap <END> G | ||
710 | copytmap <C-u> u | ||
711 | copytmap <PAGEDOWN> n f <C-F> <Space> | ||
712 | copytmap <PAGEUP> p b <C-B> | ||
713 | |||
714 | # Changing priority and deleting tasks | ||
715 | tmap J eval -q fm.ui.taskview.task_move(-1) | ||
716 | tmap K eval -q fm.ui.taskview.task_move(0) | ||
717 | tmap dd eval -q fm.ui.taskview.task_remove() | ||
718 | tmap <pagedown> eval -q fm.ui.taskview.task_move(-1) | ||
719 | tmap <pageup> eval -q fm.ui.taskview.task_move(0) | ||
720 | tmap <delete> eval -q fm.ui.taskview.task_remove() | ||
721 | |||
722 | # Basic | ||
723 | tmap <C-l> redraw_window | ||
724 | tmap <ESC> taskview_close | ||
725 | copytmap <ESC> q Q w <C-c> | ||
diff --git a/.config/ranger/rifle.conf b/.config/ranger/rifle.conf new file mode 100644 index 0000000..babdcda --- /dev/null +++ b/.config/ranger/rifle.conf | |||
@@ -0,0 +1,256 @@ | |||
1 | # vim: ft=cfg | ||
2 | # | ||
3 | # This is the configuration file of "rifle", ranger's file executor/opener. | ||
4 | # Each line consists of conditions and a command. For each line the conditions | ||
5 | # are checked and if they are met, the respective command is run. | ||
6 | # | ||
7 | # Syntax: | ||
8 | # <condition1> , <condition2> , ... = command | ||
9 | # | ||
10 | # The command can contain these environment variables: | ||
11 | # $1-$9 | The n-th selected file | ||
12 | # $@ | All selected files | ||
13 | # | ||
14 | # If you use the special command "ask", rifle will ask you what program to run. | ||
15 | # | ||
16 | # Prefixing a condition with "!" will negate its result. | ||
17 | # These conditions are currently supported: | ||
18 | # match <regexp> | The regexp matches $1 | ||
19 | # ext <regexp> | The regexp matches the extension of $1 | ||
20 | # mime <regexp> | The regexp matches the mime type of $1 | ||
21 | # name <regexp> | The regexp matches the basename of $1 | ||
22 | # path <regexp> | The regexp matches the absolute path of $1 | ||
23 | # has <program> | The program is installed (i.e. located in $PATH) | ||
24 | # env <variable> | The environment variable "variable" is non-empty | ||
25 | # file | $1 is a file | ||
26 | # directory | $1 is a directory | ||
27 | # number <n> | change the number of this command to n | ||
28 | # terminal | stdin, stderr and stdout are connected to a terminal | ||
29 | # X | $DISPLAY is not empty (i.e. Xorg runs) | ||
30 | # | ||
31 | # There are also pseudo-conditions which have a "side effect": | ||
32 | # flag <flags> | Change how the program is run. See below. | ||
33 | # label <label> | Assign a label or name to the command so it can | ||
34 | # | be started with :open_with <label> in ranger | ||
35 | # | or `rifle -p <label>` in the standalone executable. | ||
36 | # else | Always true. | ||
37 | # | ||
38 | # Flags are single characters which slightly transform the command: | ||
39 | # f | Fork the program, make it run in the background. | ||
40 | # | New command = setsid $command >& /dev/null & | ||
41 | # r | Execute the command with root permissions | ||
42 | # | New command = sudo $command | ||
43 | # t | Run the program in a new terminal. If $TERMCMD is not defined, | ||
44 | # | rifle will attempt to extract it from $TERM. | ||
45 | # | New command = $TERMCMD -e $command | ||
46 | # Note: The "New command" serves only as an illustration, the exact | ||
47 | # implementation may differ. | ||
48 | # Note: When using rifle in ranger, there is an additional flag "c" for | ||
49 | # only running the current file even if you have marked multiple files. | ||
50 | |||
51 | #------------------------------------------- | ||
52 | # Websites | ||
53 | #------------------------------------------- | ||
54 | # Rarely installed browsers get higher priority; It is assumed that if you | ||
55 | # install a rare browser, you probably use it. Firefox/konqueror/w3m on the | ||
56 | # other hand are often only installed as fallback browsers. | ||
57 | ext x?html?, has surf, X, flag f = surf -- file://"$1" | ||
58 | ext x?html?, has vimprobable, X, flag f = vimprobable -- "$@" | ||
59 | ext x?html?, has vimprobable2, X, flag f = vimprobable2 -- "$@" | ||
60 | ext x?html?, has qutebrowser, X, flag f = qutebrowser -- "$@" | ||
61 | ext x?html?, has dwb, X, flag f = dwb -- "$@" | ||
62 | ext x?html?, has jumanji, X, flag f = jumanji -- "$@" | ||
63 | ext x?html?, has luakit, X, flag f = luakit -- "$@" | ||
64 | ext x?html?, has uzbl, X, flag f = uzbl -- "$@" | ||
65 | ext x?html?, has uzbl-tabbed, X, flag f = uzbl-tabbed -- "$@" | ||
66 | ext x?html?, has uzbl-browser, X, flag f = uzbl-browser -- "$@" | ||
67 | ext x?html?, has uzbl-core, X, flag f = uzbl-core -- "$@" | ||
68 | ext x?html?, has midori, X, flag f = midori -- "$@" | ||
69 | ext x?html?, has chromium-browser, X, flag f = chromium-browser -- "$@" | ||
70 | ext x?html?, has chromium, X, flag f = chromium -- "$@" | ||
71 | ext x?html?, has google-chrome, X, flag f = google-chrome -- "$@" | ||
72 | ext x?html?, has opera, X, flag f = opera -- "$@" | ||
73 | ext x?html?, has firefox, X, flag f = firefox -- "$@" | ||
74 | ext x?html?, has seamonkey, X, flag f = seamonkey -- "$@" | ||
75 | ext x?html?, has iceweasel, X, flag f = iceweasel -- "$@" | ||
76 | ext x?html?, has epiphany, X, flag f = epiphany -- "$@" | ||
77 | ext x?html?, has konqueror, X, flag f = konqueror -- "$@" | ||
78 | ext x?html?, has elinks, terminal = elinks "$@" | ||
79 | ext x?html?, has links2, terminal = links2 "$@" | ||
80 | ext x?html?, has links, terminal = links "$@" | ||
81 | ext x?html?, has lynx, terminal = lynx -- "$@" | ||
82 | ext x?html?, has w3m, terminal = w3m "$@" | ||
83 | |||
84 | #------------------------------------------- | ||
85 | # Misc | ||
86 | #------------------------------------------- | ||
87 | # Define the "editor" for text files as first action | ||
88 | mime ^text, label editor = ${VISUAL:-$EDITOR} -- "$@" | ||
89 | mime ^text, label pager = "$PAGER" -- "$@" | ||
90 | !mime ^text, label editor, ext xml|json|csv|tex|py|pl|rb|js|sh|php = ${VISUAL:-$EDITOR} -- "$@" | ||
91 | !mime ^text, label pager, ext xml|json|csv|tex|py|pl|rb|js|sh|php = "$PAGER" -- "$@" | ||
92 | |||
93 | ext 1 = man "$1" | ||
94 | ext s[wmf]c, has zsnes, X = zsnes "$1" | ||
95 | ext s[wmf]c, has snes9x-gtk,X = snes9x-gtk "$1" | ||
96 | ext nes, has fceux, X = fceux "$1" | ||
97 | ext exe = wine "$1" | ||
98 | name ^[mM]akefile$ = make | ||
99 | |||
100 | #-------------------------------------------- | ||
101 | # Code | ||
102 | #------------------------------------------- | ||
103 | ext py = python -- "$1" | ||
104 | ext pl = perl -- "$1" | ||
105 | ext rb = ruby -- "$1" | ||
106 | ext js = node -- "$1" | ||
107 | ext sh = sh -- "$1" | ||
108 | ext php = php -- "$1" | ||
109 | |||
110 | #-------------------------------------------- | ||
111 | # Audio without X | ||
112 | #------------------------------------------- | ||
113 | mime ^audio|ogg$, terminal, has mpv = mpv -- "$@" | ||
114 | mime ^audio|ogg$, terminal, has mplayer2 = mplayer2 -- "$@" | ||
115 | mime ^audio|ogg$, terminal, has mplayer = mplayer -- "$@" | ||
116 | ext midi?, terminal, has wildmidi = wildmidi -- "$@" | ||
117 | |||
118 | #-------------------------------------------- | ||
119 | # Video/Audio with a GUI | ||
120 | #------------------------------------------- | ||
121 | mime ^video|audio, has gmplayer, X, flag f = gmplayer -- "$@" | ||
122 | mime ^video|audio, has smplayer, X, flag f = smplayer "$@" | ||
123 | mime ^video, has mpv, X, flag f = mpv -- "$@" | ||
124 | mime ^video, has mpv, X, flag f = mpv --fs -- "$@" | ||
125 | mime ^video, has mplayer2, X, flag f = mplayer2 -- "$@" | ||
126 | mime ^video, has mplayer2, X, flag f = mplayer2 -fs -- "$@" | ||
127 | mime ^video, has mplayer, X, flag f = mplayer -- "$@" | ||
128 | mime ^video, has mplayer, X, flag f = mplayer -fs -- "$@" | ||
129 | mime ^video|audio, has vlc, X, flag f = vlc -- "$@" | ||
130 | mime ^video|audio, has totem, X, flag f = totem -- "$@" | ||
131 | mime ^video|audio, has totem, X, flag f = totem --fullscreen -- "$@" | ||
132 | |||
133 | #-------------------------------------------- | ||
134 | # Video without X: | ||
135 | #------------------------------------------- | ||
136 | mime ^video, terminal, !X, has mpv = mpv -- "$@" | ||
137 | mime ^video, terminal, !X, has mplayer2 = mplayer2 -- "$@" | ||
138 | mime ^video, terminal, !X, has mplayer = mplayer -- "$@" | ||
139 | |||
140 | #------------------------------------------- | ||
141 | # Documents | ||
142 | #------------------------------------------- | ||
143 | ext pdf, has llpp, X, flag f = llpp "$@" | ||
144 | ext pdf, has zathura, X, flag f = zathura -- "$@" | ||
145 | ext pdf, has mupdf, X, flag f = mupdf "$@" | ||
146 | ext pdf, has mupdf-x11,X, flag f = mupdf-x11 "$@" | ||
147 | ext pdf, has apvlv, X, flag f = apvlv -- "$@" | ||
148 | ext pdf, has xpdf, X, flag f = xpdf -- "$@" | ||
149 | ext pdf, has evince, X, flag f = evince -- "$@" | ||
150 | ext pdf, has atril, X, flag f = atril -- "$@" | ||
151 | ext pdf, has okular, X, flag f = okular -- "$@" | ||
152 | ext pdf, has epdfview, X, flag f = epdfview -- "$@" | ||
153 | ext pdf, has qpdfview, X, flag f = qpdfview "$@" | ||
154 | ext pdf, has open, X, flag f = open "$@" | ||
155 | |||
156 | ext docx?, has catdoc, terminal = catdoc -- "$@" | "$PAGER" | ||
157 | |||
158 | ext sxc|xlsx?|xlt|xlw|gnm|gnumeric, has gnumeric, X, flag f = gnumeric -- "$@" | ||
159 | ext sxc|xlsx?|xlt|xlw|gnm|gnumeric, has kspread, X, flag f = kspread -- "$@" | ||
160 | ext pptx?|od[dfgpst]|docx?|sxc|xlsx?|xlt|xlw|gnm|gnumeric, has libreoffice, X, flag f = libreoffice "$@" | ||
161 | ext pptx?|od[dfgpst]|docx?|sxc|xlsx?|xlt|xlw|gnm|gnumeric, has soffice, X, flag f = soffice "$@" | ||
162 | ext pptx?|od[dfgpst]|docx?|sxc|xlsx?|xlt|xlw|gnm|gnumeric, has ooffice, X, flag f = ooffice "$@" | ||
163 | |||
164 | ext djvu, has zathura,X, flag f = zathura -- "$@" | ||
165 | ext djvu, has evince, X, flag f = evince -- "$@" | ||
166 | ext djvu, has atril, X, flag f = atril -- "$@" | ||
167 | ext djvu, has djview, X, flag f = djview -- "$@" | ||
168 | |||
169 | ext epub, has ebook-viewer, X, flag f = ebook-viewer -- "$@" | ||
170 | ext mobi, has ebook-viewer, X, flag f = ebook-viewer -- "$@" | ||
171 | |||
172 | #------------------------------------------- | ||
173 | # Image Viewing: | ||
174 | #------------------------------------------- | ||
175 | mime ^image/svg, has inkscape, X, flag f = inkscape -- "$@" | ||
176 | mime ^image/svg, has display, X, flag f = display -- "$@" | ||
177 | |||
178 | mime ^image, has pqiv, X, flag f = pqiv -- "$@" | ||
179 | mime ^image, has sxiv, X, flag f = sxiv -- "$@" | ||
180 | mime ^image, has feh, X, flag f = feh -- "$@" | ||
181 | mime ^image, has mirage, X, flag f = mirage -- "$@" | ||
182 | mime ^image, has ristretto, X, flag f = ristretto "$@" | ||
183 | mime ^image, has eog, X, flag f = eog -- "$@" | ||
184 | mime ^image, has eom, X, flag f = eom -- "$@" | ||
185 | mime ^image, has nomacs, X, flag f = nomacs -- "$@" | ||
186 | mime ^image, has geeqie, X, flag f = geeqie -- "$@" | ||
187 | mime ^image, has gwenview, X, flag f = gwenview -- "$@" | ||
188 | mime ^image, has gimp, X, flag f = gimp -- "$@" | ||
189 | ext xcf, X, flag f = gimp -- "$@" | ||
190 | |||
191 | #------------------------------------------- | ||
192 | # Archives | ||
193 | #------------------------------------------- | ||
194 | |||
195 | # avoid password prompt by providing empty password | ||
196 | ext 7z, has 7z = 7z -p l "$@" | "$PAGER" | ||
197 | # This requires atool | ||
198 | ext ace|ar|arc|bz2?|cab|cpio|cpt|deb|dgc|dmg|gz, has atool = atool --list --each -- "$@" | "$PAGER" | ||
199 | ext iso|jar|msi|pkg|rar|shar|tar|tgz|xar|xpi|xz|zip, has atool = atool --list --each -- "$@" | "$PAGER" | ||
200 | ext 7z|ace|ar|arc|bz2?|cab|cpio|cpt|deb|dgc|dmg|gz, has atool = atool --extract --each -- "$@" | ||
201 | ext iso|jar|msi|pkg|rar|shar|tar|tgz|xar|xpi|xz|zip, has atool = atool --extract --each -- "$@" | ||
202 | |||
203 | # Listing and extracting archives without atool: | ||
204 | ext tar|gz|bz2|xz, has tar = tar vvtf "$1" | "$PAGER" | ||
205 | ext tar|gz|bz2|xz, has tar = for file in "$@"; do tar vvxf "$file"; done | ||
206 | ext bz2, has bzip2 = for file in "$@"; do bzip2 -dk "$file"; done | ||
207 | ext zip, has unzip = unzip -l "$1" | less | ||
208 | ext zip, has unzip = for file in "$@"; do unzip -d "${file%.*}" "$file"; done | ||
209 | ext ace, has unace = unace l "$1" | less | ||
210 | ext ace, has unace = for file in "$@"; do unace e "$file"; done | ||
211 | ext rar, has unrar = unrar l "$1" | less | ||
212 | ext rar, has unrar = for file in "$@"; do unrar x "$file"; done | ||
213 | |||
214 | #------------------------------------------- | ||
215 | # Flag t fallback terminals | ||
216 | #------------------------------------------- | ||
217 | # Rarely installed terminal emulators get higher priority; It is assumed that | ||
218 | # if you install a rare terminal emulator, you probably use it. | ||
219 | # gnome-terminal/konsole/xterm on the other hand are often installed as part of | ||
220 | # a desktop environment or as fallback terminal emulators. | ||
221 | mime ^ranger/x-terminal-emulator, has terminology = terminology -e "$@" | ||
222 | mime ^ranger/x-terminal-emulator, has kitty = kitty -- "$@" | ||
223 | mime ^ranger/x-terminal-emulator, has alacritty = alacritty -e "$@" | ||
224 | mime ^ranger/x-terminal-emulator, has sakura = sakura -e "$@" | ||
225 | mime ^ranger/x-terminal-emulator, has lilyterm = lilyterm -e "$@" | ||
226 | #mime ^ranger/x-terminal-emulator, has cool-retro-term = cool-retro-term -e "$@" | ||
227 | mime ^ranger/x-terminal-emulator, has termite = termite -x '"$@"' | ||
228 | #mime ^ranger/x-terminal-emulator, has yakuake = yakuake -e "$@" | ||
229 | mime ^ranger/x-terminal-emulator, has guake = guake -ne "$@" | ||
230 | mime ^ranger/x-terminal-emulator, has tilda = tilda -c "$@" | ||
231 | mime ^ranger/x-terminal-emulator, has st = st -e "$@" | ||
232 | mime ^ranger/x-terminal-emulator, has terminator = terminator -x "$@" | ||
233 | mime ^ranger/x-terminal-emulator, has urxvt = urxvt -e "$@" | ||
234 | mime ^ranger/x-terminal-emulator, has pantheon-terminal = pantheon-terminal -e "$@" | ||
235 | mime ^ranger/x-terminal-emulator, has lxterminal = lxterminal -e "$@" | ||
236 | mime ^ranger/x-terminal-emulator, has mate-terminal = mate-terminal -x "$@" | ||
237 | mime ^ranger/x-terminal-emulator, has xfce4-terminal = xfce4-terminal -x "$@" | ||
238 | mime ^ranger/x-terminal-emulator, has konsole = konsole -e "$@" | ||
239 | mime ^ranger/x-terminal-emulator, has gnome-terminal = gnome-terminal -- "$@" | ||
240 | mime ^ranger/x-terminal-emulator, has xterm = xterm -e "$@" | ||
241 | |||
242 | #------------------------------------------- | ||
243 | # Misc | ||
244 | #------------------------------------------- | ||
245 | label wallpaper, number 11, mime ^image, has feh, X = feh --bg-scale "$1" | ||
246 | label wallpaper, number 12, mime ^image, has feh, X = feh --bg-tile "$1" | ||
247 | label wallpaper, number 13, mime ^image, has feh, X = feh --bg-center "$1" | ||
248 | label wallpaper, number 14, mime ^image, has feh, X = feh --bg-fill "$1" | ||
249 | |||
250 | # Define the editor for non-text files + pager as last action | ||
251 | !mime ^text, !ext xml|json|csv|tex|py|pl|rb|js|sh|php = ask | ||
252 | label editor, !mime ^text, !ext xml|json|csv|tex|py|pl|rb|js|sh|php = ${VISUAL:-$EDITOR} -- "$@" | ||
253 | label pager, !mime ^text, !ext xml|json|csv|tex|py|pl|rb|js|sh|php = "$PAGER" -- "$@" | ||
254 | |||
255 | # The very last action, so that it's never triggered accidentally, is to execute a program: | ||
256 | mime application/x-executable = "$1" | ||
diff --git a/.config/ranger/scope.sh b/.config/ranger/scope.sh new file mode 100755 index 0000000..13a25b4 --- /dev/null +++ b/.config/ranger/scope.sh | |||
@@ -0,0 +1,216 @@ | |||
1 | #!/usr/bin/env bash | ||
2 | |||
3 | set -o noclobber -o noglob -o nounset -o pipefail | ||
4 | IFS=$'\n' | ||
5 | |||
6 | # If the option `use_preview_script` is set to `true`, | ||
7 | # then this script will be called and its output will be displayed in ranger. | ||
8 | # ANSI color codes are supported. | ||
9 | # STDIN is disabled, so interactive scripts won't work properly | ||
10 | |||
11 | # This script is considered a configuration file and must be updated manually. | ||
12 | # It will be left untouched if you upgrade ranger. | ||
13 | |||
14 | # Meanings of exit codes: | ||
15 | # code | meaning | action of ranger | ||
16 | # -----+------------+------------------------------------------- | ||
17 | # 0 | success | Display stdout as preview | ||
18 | # 1 | no preview | Display no preview at all | ||
19 | # 2 | plain text | Display the plain content of the file | ||
20 | # 3 | fix width | Don't reload when width changes | ||
21 | # 4 | fix height | Don't reload when height changes | ||
22 | # 5 | fix both | Don't ever reload | ||
23 | # 6 | image | Display the image `$IMAGE_CACHE_PATH` points to as an image preview | ||
24 | # 7 | image | Display the file directly as an image | ||
25 | |||
26 | # Script arguments | ||
27 | FILE_PATH="${1}" # Full path of the highlighted file | ||
28 | PV_WIDTH="${2}" # Width of the preview pane (number of fitting characters) | ||
29 | PV_HEIGHT="${3}" # Height of the preview pane (number of fitting characters) | ||
30 | IMAGE_CACHE_PATH="${4}" # Full path that should be used to cache image preview | ||
31 | PV_IMAGE_ENABLED="${5}" # 'True' if image previews are enabled, 'False' otherwise. | ||
32 | |||
33 | FILE_EXTENSION="${FILE_PATH##*.}" | ||
34 | FILE_EXTENSION_LOWER=$(echo ${FILE_EXTENSION} | tr '[:upper:]' '[:lower:]') | ||
35 | |||
36 | # Settings | ||
37 | HIGHLIGHT_SIZE_MAX=262143 # 256KiB | ||
38 | HIGHLIGHT_TABWIDTH=8 | ||
39 | HIGHLIGHT_STYLE='pablo' | ||
40 | PYGMENTIZE_STYLE='autumn' | ||
41 | |||
42 | |||
43 | handle_extension() { | ||
44 | case "${FILE_EXTENSION_LOWER}" in | ||
45 | # Archive | ||
46 | a|ace|alz|arc|arj|bz|bz2|cab|cpio|deb|gz|jar|lha|lz|lzh|lzma|lzo|\ | ||
47 | rpm|rz|t7z|tar|tbz|tbz2|tgz|tlz|txz|tZ|tzo|war|xpi|xz|Z|zip) | ||
48 | atool --list -- "${FILE_PATH}" && exit 5 | ||
49 | bsdtar --list --file "${FILE_PATH}" && exit 5 | ||
50 | exit 1;; | ||
51 | rar) | ||
52 | # Avoid password prompt by providing empty password | ||
53 | unrar lt -p- -- "${FILE_PATH}" && exit 5 | ||
54 | exit 1;; | ||
55 | 7z) | ||
56 | # Avoid password prompt by providing empty password | ||
57 | 7z l -p -- "${FILE_PATH}" && exit 5 | ||
58 | exit 1;; | ||
59 | |||
60 | |||
61 | pdf) | ||
62 | # Preview as text conversion | ||
63 | pdftotext -l 10 -nopgbrk -q -- "${FILE_PATH}" - | fmt -w ${PV_WIDTH} && exit 5 | ||
64 | mutool draw -F txt -i -- "${FILE_PATH}" 1-10 | fmt -w ${PV_WIDTH} && exit 5 | ||
65 | exiftool "${FILE_PATH}" && exit 5 | ||
66 | exit 1;; | ||
67 | |||
68 | # BitTorrent | ||
69 | torrent) | ||
70 | transmission-show -- "${FILE_PATH}" && exit 5 | ||
71 | exit 1;; | ||
72 | |||
73 | # OpenDocument | ||
74 | odt|ods|odp|sxw) | ||
75 | # Preview as text conversion | ||
76 | odt2txt "${FILE_PATH}" && exit 5 | ||
77 | exit 1;; | ||
78 | |||
79 | # HTML | ||
80 | htm|html|xhtml) | ||
81 | # Preview as text conversion | ||
82 | w3m -dump "${FILE_PATH}" && exit 5 | ||
83 | lynx -dump -- "${FILE_PATH}" && exit 5 | ||
84 | elinks -dump "${FILE_PATH}" && exit 5 | ||
85 | ;; # Continue with next handler on failure | ||
86 | esac | ||
87 | } | ||
88 | |||
89 | handle_image() { | ||
90 | local mimetype="${1}" | ||
91 | case "${mimetype}" in | ||
92 | # SVG | ||
93 | # image/svg+xml) | ||
94 | # convert "${FILE_PATH}" "${IMAGE_CACHE_PATH}" && exit 6 | ||
95 | # exit 1;; | ||
96 | |||
97 | # Image | ||
98 | image/*) | ||
99 | local orientation | ||
100 | orientation="$( identify -format '%[EXIF:Orientation]\n' -- "${FILE_PATH}" )" | ||
101 | # If orientation data is present and the image actually | ||
102 | # needs rotating ("1" means no rotation)... | ||
103 | if [[ -n "$orientation" && "$orientation" != 1 ]]; then | ||
104 | # ...auto-rotate the image according to the EXIF data. | ||
105 | convert -- "${FILE_PATH}" -auto-orient "${IMAGE_CACHE_PATH}" && exit 6 | ||
106 | fi | ||
107 | |||
108 | # `w3mimgdisplay` will be called for all images (unless overriden as above), | ||
109 | # but might fail for unsupported types. | ||
110 | exit 7;; | ||
111 | |||
112 | # Video | ||
113 | # video/*) | ||
114 | # # Thumbnail | ||
115 | # ffmpegthumbnailer -i "${FILE_PATH}" -o "${IMAGE_CACHE_PATH}" -s 0 && exit 6 | ||
116 | # exit 1;; | ||
117 | |||
118 | # application/pdf) | ||
119 | # pdftoppm -f 1 -l 1 \ | ||
120 | # -scale-to-x 1920 \ | ||
121 | # -scale-to-y -1 \ | ||
122 | # -singlefile \ | ||
123 | # -jpeg -tiffcompression jpeg \ | ||
124 | # -- "${FILE_PATH}" "${IMAGE_CACHE_PATH%.*}" \ | ||
125 | # && exit 6 || exit 1;; | ||
126 | |||
127 | # Preview archives using the first image inside. | ||
128 | # (Very useful for comic book collections for example.) | ||
129 | # application/zip|application/x-rar|application/x-7z-compressed|\ | ||
130 | # application/x-xz|application/x-bzip2|application/x-gzip|application/x-tar) | ||
131 | # local fn=""; local fe="" | ||
132 | # local zip=""; local rar=""; local tar=""; local bsd="" | ||
133 | # case "${mimetype}" in | ||
134 | # application/zip) zip=1 ;; | ||
135 | # application/x-rar) rar=1 ;; | ||
136 | # application/x-7z-compressed) ;; | ||
137 | # *) tar=1 ;; | ||
138 | # esac | ||
139 | # { [ "$tar" ] && fn=$(tar --list --file "${FILE_PATH}"); } || \ | ||
140 | # { fn=$(bsdtar --list --file "${FILE_PATH}") && bsd=1 && tar=""; } || \ | ||
141 | # { [ "$rar" ] && fn=$(unrar lb -p- -- "${FILE_PATH}"); } || \ | ||
142 | # { [ "$zip" ] && fn=$(zipinfo -1 -- "${FILE_PATH}"); } || return | ||
143 | # | ||
144 | # fn=$(echo "$fn" | python -c "import sys; import mimetypes as m; \ | ||
145 | # [ print(l, end='') for l in sys.stdin if \ | ||
146 | # (m.guess_type(l[:-1])[0] or '').startswith('image/') ]" |\ | ||
147 | # sort -V | head -n 1) | ||
148 | # [ "$fn" = "" ] && return | ||
149 | # [ "$bsd" ] && fn=$(printf '%b' "$fn") | ||
150 | # | ||
151 | # [ "$tar" ] && tar --extract --to-stdout \ | ||
152 | # --file "${FILE_PATH}" -- "$fn" > "${IMAGE_CACHE_PATH}" && exit 6 | ||
153 | # fe=$(echo -n "$fn" | sed 's/[][*?\]/\\\0/g') | ||
154 | # [ "$bsd" ] && bsdtar --extract --to-stdout \ | ||
155 | # --file "${FILE_PATH}" -- "$fe" > "${IMAGE_CACHE_PATH}" && exit 6 | ||
156 | # [ "$bsd" ] || [ "$tar" ] && rm -- "${IMAGE_CACHE_PATH}" | ||
157 | # [ "$rar" ] && unrar p -p- -inul -- "${FILE_PATH}" "$fn" > \ | ||
158 | # "${IMAGE_CACHE_PATH}" && exit 6 | ||
159 | # [ "$zip" ] && unzip -pP "" -- "${FILE_PATH}" "$fe" > \ | ||
160 | # "${IMAGE_CACHE_PATH}" && exit 6 | ||
161 | # [ "$rar" ] || [ "$zip" ] && rm -- "${IMAGE_CACHE_PATH}" | ||
162 | # ;; | ||
163 | esac | ||
164 | } | ||
165 | |||
166 | handle_mime() { | ||
167 | local mimetype="${1}" | ||
168 | case "${mimetype}" in | ||
169 | # Text | ||
170 | text/* | */xml) | ||
171 | # Syntax highlight | ||
172 | if [[ "$( stat --printf='%s' -- "${FILE_PATH}" )" -gt "${HIGHLIGHT_SIZE_MAX}" ]]; then | ||
173 | exit 2 | ||
174 | fi | ||
175 | if [[ "$( tput colors )" -ge 256 ]]; then | ||
176 | local pygmentize_format='terminal256' | ||
177 | local highlight_format='xterm256' | ||
178 | else | ||
179 | local pygmentize_format='terminal' | ||
180 | local highlight_format='ansi' | ||
181 | fi | ||
182 | highlight --replace-tabs="${HIGHLIGHT_TABWIDTH}" --out-format="${highlight_format}" \ | ||
183 | --style="${HIGHLIGHT_STYLE}" --force -- "${FILE_PATH}" && exit 5 | ||
184 | # pygmentize -f "${pygmentize_format}" -O "style=${PYGMENTIZE_STYLE}" -- "${FILE_PATH}" && exit 5 | ||
185 | exit 2;; | ||
186 | |||
187 | # Image | ||
188 | image/*) | ||
189 | # Preview as text conversion | ||
190 | # img2txt --gamma=0.6 --width="${PV_WIDTH}" -- "${FILE_PATH}" && exit 4 | ||
191 | exiftool "${FILE_PATH}" && exit 5 | ||
192 | exit 1;; | ||
193 | |||
194 | # Video and audio | ||
195 | video/* | audio/*) | ||
196 | mediainfo "${FILE_PATH}" && exit 5 | ||
197 | exiftool "${FILE_PATH}" && exit 5 | ||
198 | exit 1;; | ||
199 | esac | ||
200 | } | ||
201 | |||
202 | handle_fallback() { | ||
203 | echo '----- File Type Classification -----' && file --dereference --brief -- "${FILE_PATH}" && exit 5 | ||
204 | exit 1 | ||
205 | } | ||
206 | |||
207 | |||
208 | MIMETYPE="$( file --dereference --brief --mime-type -- "${FILE_PATH}" )" | ||
209 | if [[ "${PV_IMAGE_ENABLED}" == 'True' ]]; then | ||
210 | handle_image "${MIMETYPE}" | ||
211 | fi | ||
212 | handle_extension | ||
213 | handle_mime "${MIMETYPE}" | ||
214 | handle_fallback | ||
215 | |||
216 | exit 1 | ||
diff --git a/.config/redshift.conf b/.config/redshift.conf new file mode 100644 index 0000000..3330ae4 --- /dev/null +++ b/.config/redshift.conf | |||
@@ -0,0 +1,13 @@ | |||
1 | [redshift] | ||
2 | temp-day=6000 | ||
3 | temp-night=3600 | ||
4 | fade=1 | ||
5 | |||
6 | brightness-day=0.9 | ||
7 | brightness-night=0.7 | ||
8 | |||
9 | location-provider=manual | ||
10 | |||
11 | [manual] | ||
12 | lat=39.92 | ||
13 | lon=32.86 | ||
diff --git a/.config/redshift/hooks/notify.sh b/.config/redshift/hooks/notify.sh new file mode 100755 index 0000000..2b7d3e0 --- /dev/null +++ b/.config/redshift/hooks/notify.sh | |||
@@ -0,0 +1,6 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | case $1 in | ||
4 | period-changed) | ||
5 | exec notify-send "End of the $2" "Period changed to $3" --app-name="redshift" --icon="atmosphere" | ||
6 | esac | ||
diff --git a/.config/rofi/config b/.config/rofi/config new file mode 100644 index 0000000..df6e244 --- /dev/null +++ b/.config/rofi/config | |||
@@ -0,0 +1,11 @@ | |||
1 | rofi.color-enabled: true | ||
2 | rofi.color-window: #141021, #0a0f14, #195466 | ||
3 | rofi.color-normal: #141021, #ffeefc, #195466, #c23127, #ffeefc | ||
4 | rofi.color-active: #141021, #2aa889, #195466, #d26939, #ffeefc | ||
5 | rofi.color-urgent: #141021, #e4b226, #195466, #e4b226, #ffeefc | ||
6 | rofi.width: 800 | ||
7 | rofi.padding: 50 | ||
8 | rofi.font: Lato 18 | ||
9 | rofi.bw: 3 | ||
10 | rofi.separator-style: solid | ||
11 | rofi.hide-scrollbar: true | ||
diff --git a/.config/rtv/rtv.cfg b/.config/rtv/rtv.cfg new file mode 100644 index 0000000..96e9029 --- /dev/null +++ b/.config/rtv/rtv.cfg | |||
@@ -0,0 +1,162 @@ | |||
1 | ; Reddit Terminal Viewer Configuration File | ||
2 | ; https://github.com/michael-lazar/rtv | ||
3 | ; | ||
4 | ; This file should be placed in $XDG_CONFIG/rtv/rtv.cfg | ||
5 | ; If $XDG_CONFIG is not set, use ~/.config/rtv/rtv.cfg | ||
6 | |||
7 | [rtv] | ||
8 | ################## | ||
9 | # General Settings | ||
10 | ################## | ||
11 | |||
12 | ; Turn on ascii-only mode to disable all unicode characters. | ||
13 | ; This may be necessary for compatibility with some terminal browsers. | ||
14 | ascii = False | ||
15 | |||
16 | ; Turn on monochrome mode to disable color. | ||
17 | monochrome = False | ||
18 | |||
19 | ; Flash when an invalid action is executed. | ||
20 | flash = False | ||
21 | |||
22 | ; Enable debugging by logging all HTTP requests and errors to the given file. | ||
23 | ;log = /tmp/rtv.log | ||
24 | |||
25 | ; Default subreddit that will be opened when the program launches. | ||
26 | subreddit = front | ||
27 | ;subreddit = python | ||
28 | ;subreddit = python+linux+programming | ||
29 | ;subreddit = all | ||
30 | |||
31 | ; Allow rtv to store reddit authentication credentials between sessions. | ||
32 | persistent = True | ||
33 | |||
34 | ; Clear any stored credentials when the program starts. | ||
35 | clear_auth = False | ||
36 | |||
37 | ; Maximum number of opened links that will be saved in the history file. | ||
38 | history_size = 200 | ||
39 | |||
40 | ; Open external links using programs defined in the mailcap config. | ||
41 | enable_media = False | ||
42 | |||
43 | ; Maximum number of columns for a comment | ||
44 | max_comment_cols = 120 | ||
45 | |||
46 | ; Hide username if logged in, display "Logged in" instead | ||
47 | hide_username = False | ||
48 | |||
49 | ; Color theme, use "rtv --list-themes" to view a list of valid options. | ||
50 | ; This can be an absolute filepath, or the name of a theme file that has | ||
51 | ; been installed into either the custom of default theme paths. | ||
52 | ;theme = molokai | ||
53 | |||
54 | ################ | ||
55 | # OAuth Settings | ||
56 | ################ | ||
57 | ; This sections defines the paramaters that will be used during the OAuth | ||
58 | ; authentication process. rtv is registered as an "installed app", | ||
59 | ; see https://github.com/reddit/reddit/wiki/OAuth2 for more information. | ||
60 | |||
61 | ; These settings are defined at https://www.reddit.com/prefs/apps and should | ||
62 | ; not be altered unless you are defining your own developer application. | ||
63 | oauth_client_id = E2oEtRQfdfAfNQ | ||
64 | oauth_client_secret = praw_gapfill | ||
65 | oauth_redirect_uri = http://127.0.0.1:65000/ | ||
66 | |||
67 | ; Port that the rtv webserver will listen on. This should match the redirect | ||
68 | ; uri defined above. | ||
69 | oauth_redirect_port = 65000 | ||
70 | |||
71 | ; Access permissions that will be requested. | ||
72 | oauth_scope = edit,history,identity,mysubreddits,privatemessages,read,report,save,submit,subscribe,vote | ||
73 | |||
74 | ; This is a separate token for the imgur api. It's used to extract images | ||
75 | ; from imgur links and albums so they can be opened with mailcap. | ||
76 | ; See https://imgur.com/account/settings/apps to generate your own key. | ||
77 | imgur_client_id = 93396265f59dec9 | ||
78 | |||
79 | [bindings] | ||
80 | ############## | ||
81 | # Key Bindings | ||
82 | ############## | ||
83 | ; If you would like to define custom bindings, copy this section into your | ||
84 | ; config file with the [bindings] heading. All commands must be bound to at | ||
85 | ; least one key for the config to be valid. | ||
86 | ; | ||
87 | ; 1.) Plain keys can be represented by either uppercase/lowercase characters | ||
88 | ; or the hexadecimal numbers referring their ascii codes. For reference, see | ||
89 | ; https://en.wikipedia.org/wiki/ASCII#ASCII_printable_code_chart | ||
90 | ; e.g. Q, q, 1, ? | ||
91 | ; e.g. 0x20 (space), 0x3c (less-than sign) | ||
92 | ; | ||
93 | ; 2.) Special ascii control codes should be surrounded with <>. For reference, | ||
94 | ; see https://en.wikipedia.org/wiki/ASCII#ASCII_control_code_chart | ||
95 | ; e.g. <LF> (enter), <ESC> (escape) | ||
96 | ; | ||
97 | ; 3.) Other special keys are defined by curses, they should be surrounded by <> | ||
98 | ; and prefixed with KEY_. For reference, see | ||
99 | ; https://docs.python.org/2/library/curses.html#constants | ||
100 | ; e.g. <KEY_LEFT> (left arrow), <KEY_F5>, <KEY_NPAGE> (page down) | ||
101 | ; | ||
102 | ; Notes: | ||
103 | ; - Curses <KEY_ENTER> is unreliable and should always be used in conjunction | ||
104 | ; with <LF>. | ||
105 | ; - Use 0x20 for the space key. | ||
106 | ; - A subset of Ctrl modifiers are available through the ascii control codes. | ||
107 | ; For example, Ctrl-D will trigger an <EOT> signal. See the table above for | ||
108 | ; a complete reference. | ||
109 | |||
110 | ; Base page | ||
111 | EXIT = q | ||
112 | FORCE_EXIT = Q | ||
113 | HELP = ? | ||
114 | SORT_HOT = 1 | ||
115 | SORT_TOP = 2 | ||
116 | SORT_RISING = 3 | ||
117 | SORT_NEW = 4 | ||
118 | SORT_CONTROVERSIAL = 5 | ||
119 | SORT_GILDED = 6 | ||
120 | MOVE_UP = k, <KEY_UP> | ||
121 | MOVE_DOWN = j, <KEY_DOWN> | ||
122 | PREVIOUS_THEME = <KEY_F2> | ||
123 | NEXT_THEME = <KEY_F3> | ||
124 | PAGE_UP = m, <KEY_PPAGE>, <NAK> | ||
125 | PAGE_DOWN = n, <KEY_NPAGE>, <EOT> | ||
126 | PAGE_TOP = gg | ||
127 | PAGE_BOTTOM = G | ||
128 | UPVOTE = a | ||
129 | DOWNVOTE = z | ||
130 | LOGIN = u | ||
131 | DELETE = d | ||
132 | EDIT = e | ||
133 | INBOX = i | ||
134 | REFRESH = r, <KEY_F5> | ||
135 | PROMPT = / | ||
136 | SAVE = w | ||
137 | COPY_PERMALINK = y | ||
138 | COPY_URL = Y | ||
139 | |||
140 | ; Submission page | ||
141 | SUBMISSION_TOGGLE_COMMENT = 0x20 | ||
142 | SUBMISSION_OPEN_IN_BROWSER = o, <LF>, <KEY_ENTER> | ||
143 | SUBMISSION_POST = c | ||
144 | SUBMISSION_EXIT = h, <KEY_LEFT> | ||
145 | SUBMISSION_OPEN_IN_PAGER = l, <KEY_RIGHT> | ||
146 | SUBMISSION_OPEN_IN_URLVIEWER = b | ||
147 | SUBMISSION_GOTO_PARENT = K | ||
148 | SUBMISSION_GOTO_SIBLING = J | ||
149 | |||
150 | ; Subreddit page | ||
151 | SUBREDDIT_SEARCH = f | ||
152 | SUBREDDIT_POST = c | ||
153 | SUBREDDIT_OPEN = l, <KEY_RIGHT> | ||
154 | SUBREDDIT_OPEN_IN_BROWSER = o, <LF>, <KEY_ENTER> | ||
155 | SUBREDDIT_OPEN_SUBSCRIPTIONS = s | ||
156 | SUBREDDIT_OPEN_MULTIREDDITS = S | ||
157 | SUBREDDIT_FRONTPAGE = p | ||
158 | SUBREDDIT_HIDE = 0x20 | ||
159 | |||
160 | ; Subscription page | ||
161 | SUBSCRIPTION_SELECT = l, <LF>, <KEY_ENTER>, <KEY_RIGHT> | ||
162 | SUBSCRIPTION_EXIT = h, s, S, <ESC>, <KEY_LEFT> | ||
diff --git a/.config/zathura/zathurarc b/.config/zathura/zathurarc new file mode 100644 index 0000000..d021df1 --- /dev/null +++ b/.config/zathura/zathurarc | |||
@@ -0,0 +1,6 @@ | |||
1 | set selection-clipboard clipboard | ||
2 | set incremental-search "true" | ||
3 | set recolor-lightcolor "#080808" #00 | ||
4 | set recolor-darkcolor "#E0E0E0" #06 | ||
5 | set recolor "true" | ||
6 | set recolor-keephue "true" | ||
diff --git a/.gitconfig b/.gitconfig new file mode 100644 index 0000000..ae74399 --- /dev/null +++ b/.gitconfig | |||
@@ -0,0 +1,33 @@ | |||
1 | [user] | ||
2 | name = Yigit Sever | ||
3 | email = yigit.sever@tedu.edu.tr | ||
4 | signingkey = 043FE5D3E75368AA | ||
5 | [core] | ||
6 | autocrlf = input | ||
7 | safecrlf = true | ||
8 | pager = diff-so-fancy | less --tabs=4 -RFX | ||
9 | [alias] | ||
10 | co = checkout | ||
11 | ci = commit | ||
12 | st = status | ||
13 | br = branch | ||
14 | hist = log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short | ||
15 | type = cat-file -t | ||
16 | dump = cat-file -p | ||
17 | adog = log --all --decorate --oneline --graph | ||
18 | [credential] | ||
19 | helper = cache --timeout=3600 | ||
20 | [color] | ||
21 | ui = true | ||
22 | [color "diff-highlight"] | ||
23 | oldNormal = red bold | ||
24 | oldHighlight = red bold 52 | ||
25 | newNormal = green bold | ||
26 | newHighlight = green bold 22 | ||
27 | [color "diff"] | ||
28 | meta = yellow | ||
29 | frag = magenta bold | ||
30 | commit = yellow bold | ||
31 | old = red bold | ||
32 | new = green bold | ||
33 | whitespace = red reverse | ||
diff --git a/.ledgerrc b/.ledgerrc new file mode 100644 index 0000000..6f379d5 --- /dev/null +++ b/.ledgerrc | |||
@@ -0,0 +1 @@ | |||
--date-format %Y-%m-%d | |||
diff --git a/.ncmpcpp/bindings b/.ncmpcpp/bindings new file mode 100644 index 0000000..ab21cbf --- /dev/null +++ b/.ncmpcpp/bindings | |||
@@ -0,0 +1,543 @@ | |||
1 | ############################################################## | ||
2 | ## This is the example bindings file. Copy it to ## | ||
3 | ## ~/.ncmpcpp/bindings or $XDG_CONFIG_HOME/ncmpcpp/bindings ## | ||
4 | ## and set up your preferences ## | ||
5 | ############################################################## | ||
6 | ## | ||
7 | ##### General rules ##### | ||
8 | ## | ||
9 | ## 1) Because each action has runtime checks whether it's | ||
10 | ## ok to run it, a few actions can be bound to one key. | ||
11 | ## Actions will be bound in order given in configuration | ||
12 | ## file. When a key is pressed, first action in order | ||
13 | ## will test itself whether it's possible to run it. If | ||
14 | ## test succeeds, action is executed and other actions | ||
15 | ## bound to this key are ignored. If it doesn't, next | ||
16 | ## action in order tests itself etc. | ||
17 | ## | ||
18 | ## 2) It's possible to bind more that one action at once | ||
19 | ## to a key. It can be done using the following syntax: | ||
20 | ## | ||
21 | ## def_key "key" | ||
22 | ## action1 | ||
23 | ## action2 | ||
24 | ## ... | ||
25 | ## | ||
26 | ## This creates a chain of actions. When such chain is | ||
27 | ## executed, each action in chain is run until the end of | ||
28 | ## chain is reached or one of its actions fails to execute | ||
29 | ## due to its requirements not being met. If multiple actions | ||
30 | ## and/or chains are bound to the same key, they will be | ||
31 | ## consecutively run until one of them gets fully executed. | ||
32 | ## | ||
33 | ## 3) When ncmpcpp starts, bindings configuration file is | ||
34 | ## parsed and then ncmpcpp provides "missing pieces" | ||
35 | ## of default keybindings. If you want to disable some | ||
36 | ## bindings, there is a special action called 'dummy' | ||
37 | ## for that purpose. Eg. if you want to disable ability | ||
38 | ## to crop playlists, you need to put the following | ||
39 | ## into configuration file: | ||
40 | ## | ||
41 | ## def_key "C" | ||
42 | ## dummy | ||
43 | ## | ||
44 | ## After that ncmpcpp will not bind any default action | ||
45 | ## to this key. | ||
46 | ## | ||
47 | ## 4) To let you write simple macros, the following special | ||
48 | ## actions are provided: | ||
49 | ## | ||
50 | ## - push_character "character" - pushes given special | ||
51 | ## character into input queue, so it will be immediately | ||
52 | ## picked by ncmpcpp upon next call to readKey function. | ||
53 | ## Accepted values: mouse, up, down, page_up, page_down, | ||
54 | ## home, end, space, enter, insert, delete, left, right, | ||
55 | ## tab, ctrl-a, ctrl-b, ..., ctrl-z, ctrl-[, ctrl-\\, | ||
56 | ## ctrl-], ctrl-^, ctrl-_, f1, f2, ..., f12, backspace. | ||
57 | ## In addition, most of these names can be prefixed with | ||
58 | ## alt-/ctrl-/shift- to be recognized with the appropriate | ||
59 | ## modifier key(s). | ||
60 | ## | ||
61 | ## - push_characters "string" - pushes given string into | ||
62 | ## input queue. | ||
63 | ## | ||
64 | ## - require_runnable "action" - checks whether given action | ||
65 | ## is runnable and fails if it isn't. This is especially | ||
66 | ## useful when mixed with previous two functions. Consider | ||
67 | ## the following macro definition: | ||
68 | ## | ||
69 | ## def_key "key" | ||
70 | ## push_characters "custom_filter" | ||
71 | ## apply_filter | ||
72 | ## | ||
73 | ## If apply_filter can't be currently run, we end up with | ||
74 | ## sequence of characters in input queue which will be | ||
75 | ## treated just as we typed them. This may lead to unexpected | ||
76 | ## results (in this case 'c' will most likely clear current | ||
77 | ## playlist, 'u' will trigger database update, 's' will stop | ||
78 | ## playback etc.). To prevent such thing from happening, we | ||
79 | ## need to change above definition to this one: | ||
80 | ## | ||
81 | ## def_key "key" | ||
82 | ## require_runnable "apply_filter" | ||
83 | ## push_characters "custom_filter" | ||
84 | ## apply_filter | ||
85 | ## | ||
86 | ## Here, first we test whether apply_filter can be actually run | ||
87 | ## before we stuff characters into input queue, so if condition | ||
88 | ## is not met, whole chain is aborted and we're fine. | ||
89 | ## | ||
90 | ## - require_screen "screen" - checks whether given screen is | ||
91 | ## currently active. accepted values: browser, clock, help, | ||
92 | ## media_library, outputs, playlist, playlist_editor, | ||
93 | ## search_engine, tag_editor, visualizer, last_fm, lyrics, | ||
94 | ## selected_items_adder, server_info, song_info, | ||
95 | ## sort_playlist_dialog, tiny_tag_editor. | ||
96 | ## | ||
97 | ## - run_external_command "command" - runs given command using | ||
98 | ## system() function. | ||
99 | ## | ||
100 | ## 5) In addition to binding to a key, you can also bind actions | ||
101 | ## or chains of actions to a command. If it comes to commands, | ||
102 | ## syntax is very similar to defining keys. Here goes example | ||
103 | ## definition of a command: | ||
104 | ## | ||
105 | ## def_command "quit" [deferred] | ||
106 | ## stop | ||
107 | ## quit | ||
108 | ## | ||
109 | ## If you execute the above command (which can be done by | ||
110 | ## invoking action execute_command, typing 'quit' and pressing | ||
111 | ## enter), ncmpcpp will stop the player and then quit. Note the | ||
112 | ## presence of word 'deferred' enclosed in square brackets. It | ||
113 | ## tells ncmpcpp to wait for confirmation (ie. pressing enter) | ||
114 | ## after you typed quit. Instead of 'deferred', 'immediate' | ||
115 | ## could be used. Then ncmpcpp will not wait for confirmation | ||
116 | ## (enter) and will execute the command the moment it sees it. | ||
117 | ## | ||
118 | ## Note: while command chains are executed, internal environment | ||
119 | ## update (which includes current window refresh and mpd status | ||
120 | ## update) is not performed for performance reasons. However, it | ||
121 | ## may be desirable to do so in some situration. Therefore it's | ||
122 | ## possible to invoke by hand by performing 'update enviroment' | ||
123 | ## action. | ||
124 | ## | ||
125 | ## Note: There is a difference between: | ||
126 | ## | ||
127 | ## def_key "key" | ||
128 | ## action1 | ||
129 | ## | ||
130 | ## def_key "key" | ||
131 | ## action2 | ||
132 | ## | ||
133 | ## and | ||
134 | ## | ||
135 | ## def_key "key" | ||
136 | ## action1 | ||
137 | ## action2 | ||
138 | ## | ||
139 | ## First one binds two single actions to the same key whilst | ||
140 | ## second one defines a chain of actions. The behavior of | ||
141 | ## these two is different and is described in (1) and (2). | ||
142 | ## | ||
143 | ## Note: Function def_key accepts non-ascii characters. | ||
144 | ## | ||
145 | ##### List of unbound actions ##### | ||
146 | ## | ||
147 | ## The following actions are not bound to any key/command: | ||
148 | ## | ||
149 | ## - set_volume | ||
150 | ## | ||
151 | # | ||
152 | #def_key "mouse" | ||
153 | # mouse_event | ||
154 | # | ||
155 | #def_key "up" | ||
156 | # scroll_up | ||
157 | # | ||
158 | #def_key "shift-up" | ||
159 | # select_item | ||
160 | # scroll_up | ||
161 | # | ||
162 | #def_key "down" | ||
163 | # scroll_down | ||
164 | # | ||
165 | #def_key "shift-down" | ||
166 | # select_item | ||
167 | # scroll_down | ||
168 | # | ||
169 | #def_key "[" | ||
170 | # scroll_up_album | ||
171 | # | ||
172 | #def_key "]" | ||
173 | # scroll_down_album | ||
174 | # | ||
175 | #def_key "{" | ||
176 | # scroll_up_artist | ||
177 | # | ||
178 | #def_key "}" | ||
179 | # scroll_down_artist | ||
180 | # | ||
181 | #def_key "page_up" | ||
182 | # page_up | ||
183 | # | ||
184 | #def_key "page_down" | ||
185 | # page_down | ||
186 | # | ||
187 | #def_key "home" | ||
188 | # move_home | ||
189 | # | ||
190 | #def_key "end" | ||
191 | # move_end | ||
192 | # | ||
193 | #def_key "insert" | ||
194 | # select_item | ||
195 | # | ||
196 | #def_key "enter" | ||
197 | # enter_directory | ||
198 | # | ||
199 | #def_key "enter" | ||
200 | # toggle_output | ||
201 | # | ||
202 | #def_key "enter" | ||
203 | # run_action | ||
204 | # | ||
205 | #def_key "enter" | ||
206 | # play_item | ||
207 | # | ||
208 | #def_key "space" | ||
209 | # add_item_to_playlist | ||
210 | # | ||
211 | #def_key "space" | ||
212 | # toggle_lyrics_update_on_song_change | ||
213 | # | ||
214 | #def_key "space" | ||
215 | # toggle_visualization_type | ||
216 | # | ||
217 | #def_key "delete" | ||
218 | # delete_playlist_items | ||
219 | # | ||
220 | #def_key "delete" | ||
221 | # delete_browser_items | ||
222 | # | ||
223 | #def_key "delete" | ||
224 | # delete_stored_playlist | ||
225 | # | ||
226 | #def_key "right" | ||
227 | # next_column | ||
228 | # | ||
229 | #def_key "right" | ||
230 | # slave_screen | ||
231 | # | ||
232 | #def_key "right" | ||
233 | # volume_up | ||
234 | # | ||
235 | #def_key "+" | ||
236 | # volume_up | ||
237 | # | ||
238 | #def_key "left" | ||
239 | # previous_column | ||
240 | # | ||
241 | #def_key "left" | ||
242 | # master_screen | ||
243 | # | ||
244 | #def_key "left" | ||
245 | # volume_down | ||
246 | # | ||
247 | #def_key "-" | ||
248 | # volume_down | ||
249 | # | ||
250 | #def_key ":" | ||
251 | # execute_command | ||
252 | # | ||
253 | #def_key "tab" | ||
254 | # next_screen | ||
255 | # | ||
256 | #def_key "shift-tab" | ||
257 | # previous_screen | ||
258 | # | ||
259 | #def_key "f1" | ||
260 | # show_help | ||
261 | # | ||
262 | #def_key "1" | ||
263 | # show_playlist | ||
264 | # | ||
265 | #def_key "2" | ||
266 | # show_browser | ||
267 | # | ||
268 | #def_key "2" | ||
269 | # change_browse_mode | ||
270 | # | ||
271 | #def_key "3" | ||
272 | # show_search_engine | ||
273 | # | ||
274 | #def_key "3" | ||
275 | # reset_search_engine | ||
276 | # | ||
277 | #def_key "4" | ||
278 | # show_media_library | ||
279 | # | ||
280 | #def_key "4" | ||
281 | # toggle_media_library_columns_mode | ||
282 | # | ||
283 | #def_key "5" | ||
284 | # show_playlist_editor | ||
285 | # | ||
286 | #def_key "6" | ||
287 | # show_tag_editor | ||
288 | # | ||
289 | #def_key "7" | ||
290 | # show_outputs | ||
291 | # | ||
292 | #def_key "8" | ||
293 | # show_visualizer | ||
294 | # | ||
295 | #def_key "=" | ||
296 | # show_clock | ||
297 | # | ||
298 | #def_key "@" | ||
299 | # show_server_info | ||
300 | # | ||
301 | #def_key "s" | ||
302 | # stop | ||
303 | # | ||
304 | #def_key "p" | ||
305 | # pause | ||
306 | # | ||
307 | #def_key ">" | ||
308 | # next | ||
309 | # | ||
310 | #def_key "<" | ||
311 | # previous | ||
312 | # | ||
313 | #def_key "ctrl-h" | ||
314 | # jump_to_parent_directory | ||
315 | # | ||
316 | #def_key "ctrl-h" | ||
317 | # replay_song | ||
318 | # | ||
319 | #def_key "backspace" | ||
320 | # jump_to_parent_directory | ||
321 | # | ||
322 | #def_key "backspace" | ||
323 | # replay_song | ||
324 | # | ||
325 | #def_key "f" | ||
326 | # seek_forward | ||
327 | # | ||
328 | #def_key "b" | ||
329 | # seek_backward | ||
330 | # | ||
331 | #def_key "r" | ||
332 | # toggle_repeat | ||
333 | # | ||
334 | #def_key "z" | ||
335 | # toggle_random | ||
336 | # | ||
337 | #def_key "y" | ||
338 | # save_tag_changes | ||
339 | # | ||
340 | #def_key "y" | ||
341 | # start_searching | ||
342 | # | ||
343 | #def_key "y" | ||
344 | # toggle_single | ||
345 | # | ||
346 | #def_key "R" | ||
347 | # toggle_consume | ||
348 | # | ||
349 | #def_key "Y" | ||
350 | # toggle_replay_gain_mode | ||
351 | # | ||
352 | #def_key "T" | ||
353 | # toggle_add_mode | ||
354 | # | ||
355 | #def_key "|" | ||
356 | # toggle_mouse | ||
357 | # | ||
358 | #def_key "#" | ||
359 | # toggle_bitrate_visibility | ||
360 | # | ||
361 | #def_key "Z" | ||
362 | # shuffle | ||
363 | # | ||
364 | #def_key "x" | ||
365 | # toggle_crossfade | ||
366 | # | ||
367 | #def_key "X" | ||
368 | # set_crossfade | ||
369 | # | ||
370 | #def_key "u" | ||
371 | # update_database | ||
372 | # | ||
373 | #def_key "ctrl-s" | ||
374 | # sort_playlist | ||
375 | # | ||
376 | #def_key "ctrl-s" | ||
377 | # toggle_browser_sort_mode | ||
378 | # | ||
379 | #def_key "ctrl-s" | ||
380 | # toggle_media_library_sort_mode | ||
381 | # | ||
382 | #def_key "ctrl-r" | ||
383 | # reverse_playlist | ||
384 | # | ||
385 | #def_key "ctrl-f" | ||
386 | # apply_filter | ||
387 | # | ||
388 | #def_key "ctrl-_" | ||
389 | # select_found_items | ||
390 | # | ||
391 | #def_key "/" | ||
392 | # find | ||
393 | # | ||
394 | #def_key "/" | ||
395 | # find_item_forward | ||
396 | # | ||
397 | #def_key "?" | ||
398 | # find | ||
399 | # | ||
400 | #def_key "?" | ||
401 | # find_item_backward | ||
402 | # | ||
403 | #def_key "." | ||
404 | # next_found_item | ||
405 | # | ||
406 | #def_key "," | ||
407 | # previous_found_item | ||
408 | # | ||
409 | #def_key "w" | ||
410 | # toggle_find_mode | ||
411 | # | ||
412 | #def_key "e" | ||
413 | # edit_song | ||
414 | # | ||
415 | #def_key "e" | ||
416 | # edit_library_tag | ||
417 | # | ||
418 | #def_key "e" | ||
419 | # edit_library_album | ||
420 | # | ||
421 | #def_key "e" | ||
422 | # edit_directory_name | ||
423 | # | ||
424 | #def_key "e" | ||
425 | # edit_playlist_name | ||
426 | # | ||
427 | #def_key "e" | ||
428 | # edit_lyrics | ||
429 | # | ||
430 | #def_key "i" | ||
431 | # show_song_info | ||
432 | # | ||
433 | #def_key "I" | ||
434 | # show_artist_info | ||
435 | # | ||
436 | #def_key "g" | ||
437 | # jump_to_position_in_song | ||
438 | # | ||
439 | #def_key "l" | ||
440 | # show_lyrics | ||
441 | # | ||
442 | #def_key "ctrl-v" | ||
443 | # select_range | ||
444 | # | ||
445 | #def_key "v" | ||
446 | # reverse_selection | ||
447 | # | ||
448 | #def_key "V" | ||
449 | # remove_selection | ||
450 | # | ||
451 | #def_key "B" | ||
452 | # select_album | ||
453 | # | ||
454 | #def_key "a" | ||
455 | # add_selected_items | ||
456 | # | ||
457 | #def_key "c" | ||
458 | # clear_playlist | ||
459 | # | ||
460 | #def_key "c" | ||
461 | # clear_main_playlist | ||
462 | # | ||
463 | #def_key "C" | ||
464 | # crop_playlist | ||
465 | # | ||
466 | #def_key "C" | ||
467 | # crop_main_playlist | ||
468 | # | ||
469 | #def_key "m" | ||
470 | # move_sort_order_up | ||
471 | # | ||
472 | #def_key "m" | ||
473 | # move_selected_items_up | ||
474 | # | ||
475 | #def_key "n" | ||
476 | # move_sort_order_down | ||
477 | # | ||
478 | #def_key "n" | ||
479 | # move_selected_items_down | ||
480 | # | ||
481 | #def_key "M" | ||
482 | # move_selected_items_to | ||
483 | # | ||
484 | #def_key "A" | ||
485 | # add | ||
486 | # | ||
487 | #def_key "S" | ||
488 | # save_playlist | ||
489 | # | ||
490 | #def_key "o" | ||
491 | # jump_to_playing_song | ||
492 | # | ||
493 | #def_key "G" | ||
494 | # jump_to_browser | ||
495 | # | ||
496 | #def_key "G" | ||
497 | # jump_to_playlist_editor | ||
498 | # | ||
499 | #def_key "~" | ||
500 | # jump_to_media_library | ||
501 | # | ||
502 | #def_key "E" | ||
503 | # jump_to_tag_editor | ||
504 | # | ||
505 | #def_key "U" | ||
506 | # toggle_playing_song_centering | ||
507 | # | ||
508 | #def_key "P" | ||
509 | # toggle_display_mode | ||
510 | # | ||
511 | #def_key "\\" | ||
512 | # toggle_interface | ||
513 | # | ||
514 | #def_key "!" | ||
515 | # toggle_separators_between_albums | ||
516 | # | ||
517 | #def_key "L" | ||
518 | # toggle_lyrics_fetcher | ||
519 | # | ||
520 | #def_key "F" | ||
521 | # fetch_lyrics_in_background | ||
522 | # | ||
523 | #def_key "alt-l" | ||
524 | # toggle_fetching_lyrics_in_background | ||
525 | # | ||
526 | #def_key "ctrl-l" | ||
527 | # toggle_screen_lock | ||
528 | # | ||
529 | #def_key "`" | ||
530 | # toggle_library_tag_type | ||
531 | # | ||
532 | #def_key "`" | ||
533 | # refetch_lyrics | ||
534 | # | ||
535 | #def_key "`" | ||
536 | # add_random_items | ||
537 | # | ||
538 | #def_key "ctrl-p" | ||
539 | # set_selected_items_priority | ||
540 | # | ||
541 | #def_key "q" | ||
542 | # quit | ||
543 | # | ||
diff --git a/.ncmpcpp/config b/.ncmpcpp/config new file mode 100644 index 0000000..580e8de --- /dev/null +++ b/.ncmpcpp/config | |||
@@ -0,0 +1,543 @@ | |||
1 | ############################################################################## | ||
2 | ## This is the example configuration file. Copy it to $HOME/.ncmpcpp/config ## | ||
3 | ## or $XDG_CONFIG_HOME/ncmpcpp/config and set up your preferences. ## | ||
4 | ############################################################################## | ||
5 | # | ||
6 | ##### directories ###### | ||
7 | ## | ||
8 | ## Directory for storing ncmpcpp related files. Changing it is useful if you | ||
9 | ## want to store everything somewhere else and provide command line setting for | ||
10 | ## alternative location to config file which defines that while launching | ||
11 | ## ncmpcpp. | ||
12 | ## | ||
13 | # | ||
14 | #ncmpcpp_directory = ~/.ncmpcpp | ||
15 | # | ||
16 | ## | ||
17 | ## Directory for storing downloaded lyrics. It defaults to ~/.lyrics since other | ||
18 | ## MPD clients (eg. ncmpc) also use that location. | ||
19 | ## | ||
20 | # | ||
21 | #lyrics_directory = ~/.lyrics | ||
22 | # | ||
23 | ##### connection settings ##### | ||
24 | # | ||
25 | #mpd_host = localhost | ||
26 | # | ||
27 | #mpd_port = 6600 | ||
28 | # | ||
29 | #mpd_connection_timeout = 5 | ||
30 | # | ||
31 | ## Needed for tag editor and file operations to work. | ||
32 | ## | ||
33 | mpd_music_dir = ~/Music | ||
34 | # | ||
35 | #mpd_crossfade_time = 5 | ||
36 | # | ||
37 | ##### music visualizer ##### | ||
38 | ## | ||
39 | ## Note: In order to make music visualizer work you'll need to use mpd fifo | ||
40 | ## output, whose format parameter has to be set to 44100:16:1 for mono | ||
41 | ## visualization or 44100:16:2 for stereo visualization. Example configuration | ||
42 | ## (it has to be put into mpd.conf): | ||
43 | ## | ||
44 | ## audio_output { | ||
45 | ## type "fifo" | ||
46 | ## name "Visualizer feed" | ||
47 | ## path "/tmp/mpd.fifo" | ||
48 | ## format "44100:16:2" | ||
49 | ## } | ||
50 | ## | ||
51 | # | ||
52 | #visualizer_fifo_path = /tmp/mpd.fifo | ||
53 | # | ||
54 | ## | ||
55 | ## Note: Below parameter is needed for ncmpcpp to determine which output | ||
56 | ## provides data for visualizer and thus allow syncing between visualization and | ||
57 | ## sound as currently there are some problems with it. | ||
58 | ## | ||
59 | # | ||
60 | #visualizer_output_name = Visualizer feed | ||
61 | # | ||
62 | ## | ||
63 | ## If you set format to 44100:16:2, make it 'yes'. | ||
64 | ## | ||
65 | #visualizer_in_stereo = yes | ||
66 | # | ||
67 | ## | ||
68 | ## Note: Below parameter defines how often ncmpcpp has to "synchronize" | ||
69 | ## visualizer and audio outputs. 30 seconds is optimal value, but if you | ||
70 | ## experience synchronization problems, set it to lower value. Keep in mind | ||
71 | ## that sane values start with >=10. | ||
72 | ## | ||
73 | # | ||
74 | #visualizer_sync_interval = 30 | ||
75 | # | ||
76 | ## | ||
77 | ## Note: To enable spectrum frequency visualization you need to compile ncmpcpp | ||
78 | ## with fftw3 support. | ||
79 | ## | ||
80 | # | ||
81 | ## Available values: spectrum, wave, wave_filled, ellipse. | ||
82 | ## | ||
83 | #visualizer_type = wave | ||
84 | # | ||
85 | #visualizer_look = ●▮ | ||
86 | # | ||
87 | #visualizer_color = blue, cyan, green, yellow, magenta, red | ||
88 | # | ||
89 | ## Alternative subset of 256 colors for terminals that support it. | ||
90 | ## | ||
91 | #visualizer_color = 41, 83, 119, 155, 185, 215, 209, 203, 197, 161 | ||
92 | # | ||
93 | ##### system encoding ##### | ||
94 | ## | ||
95 | ## ncmpcpp should detect your charset encoding but if it failed to do so, you | ||
96 | ## can specify charset encoding you are using here. | ||
97 | ## | ||
98 | ## Note: You can see whether your ncmpcpp build supports charset detection by | ||
99 | ## checking output of `ncmpcpp --version`. | ||
100 | ## | ||
101 | ## Note: Since MPD uses UTF-8 by default, setting this option makes sense only | ||
102 | ## if your encoding is different. | ||
103 | ## | ||
104 | # | ||
105 | #system_encoding = "" | ||
106 | # | ||
107 | ##### delays ##### | ||
108 | # | ||
109 | ## Time of inactivity (in seconds) after playlist highlighting will be disabled | ||
110 | ## (0 = always on). | ||
111 | ## | ||
112 | #playlist_disable_highlight_delay = 5 | ||
113 | # | ||
114 | ## Defines how long messages are supposed to be visible. | ||
115 | ## | ||
116 | #message_delay_time = 5 | ||
117 | # | ||
118 | ##### song format ##### | ||
119 | ## | ||
120 | ## For a song format you can use: | ||
121 | ## | ||
122 | ## %l - length | ||
123 | ## %f - filename | ||
124 | ## %D - directory | ||
125 | ## %a - artist | ||
126 | ## %A - album artist | ||
127 | ## %t - title | ||
128 | ## %b - album | ||
129 | ## %y - date | ||
130 | ## %n - track number (01/12 -> 01) | ||
131 | ## %N - full track info (01/12 -> 01/12) | ||
132 | ## %g - genre | ||
133 | ## %c - composer | ||
134 | ## %p - performer | ||
135 | ## %d - disc | ||
136 | ## %C - comment | ||
137 | ## %P - priority | ||
138 | ## $R - begin right alignment | ||
139 | ## | ||
140 | ## If you want to make sure that a part of the format is displayed only when | ||
141 | ## certain tags are present, you can archieve it by grouping them with brackets, | ||
142 | ## e.g. '{%a - %t}' will be evaluated to 'ARTIST - TITLE' if both tags are | ||
143 | ## present or '' otherwise. It is also possible to define a list of | ||
144 | ## alternatives by providing several groups and separating them with '|', | ||
145 | ## e.g. '{%t}|{%f}' will be evaluated to 'TITLE' or 'FILENAME' if the former is | ||
146 | ## not present. | ||
147 | ## | ||
148 | ## Note: If you want to set limit on maximal length of a tag, just put the | ||
149 | ## appropriate number between % and character that defines tag type, e.g. to | ||
150 | ## make album take max. 20 terminal cells, use '%20b'. | ||
151 | ## | ||
152 | ## In addition, formats support markers used for text attributes. They are | ||
153 | ## followed by character '$'. After that you can put: | ||
154 | ## | ||
155 | ## - 0 - default window color (discards all other colors) | ||
156 | ## - 1 - black | ||
157 | ## - 2 - red | ||
158 | ## - 3 - green | ||
159 | ## - 4 - yellow | ||
160 | ## - 5 - blue | ||
161 | ## - 6 - magenta | ||
162 | ## - 7 - cyan | ||
163 | ## - 8 - white | ||
164 | ## - 9 - end of current color | ||
165 | ## - b - bold text | ||
166 | ## - u - underline text | ||
167 | ## - r - reverse colors | ||
168 | ## - a - use alternative character set | ||
169 | ## | ||
170 | ## If you don't want to use a non-color attribute anymore, just put it again, | ||
171 | ## but this time insert character '/' between '$' and attribute character, | ||
172 | ## e.g. {$b%t$/b}|{$r%f$/r} will display bolded title tag or filename with | ||
173 | ## reversed colors. | ||
174 | ## | ||
175 | ## If you want to use 256 colors and/or background colors in formats (the naming | ||
176 | ## scheme is described below in section about color definitions), it can be done | ||
177 | ## with the syntax $(COLOR), e.g. to set the artist tag to one of the | ||
178 | ## non-standard colors and make it have yellow background, you need to write | ||
179 | ## $(197_yellow)%a$(end). Note that for standard colors this is interchangable | ||
180 | ## with attributes listed above. | ||
181 | ## | ||
182 | ## Note: colors can be nested. | ||
183 | ## | ||
184 | # | ||
185 | #song_list_format = {%a - }{%t}|{$8%f$9}$R{$3(%l)$9} | ||
186 | # | ||
187 | #song_status_format = {{%a{ "%b"{ (%y)}} - }{%t}}|{%f} | ||
188 | # | ||
189 | #song_library_format = {%n - }{%t}|{%f} | ||
190 | # | ||
191 | #alternative_header_first_line_format = $b$1$aqqu$/a$9 {%t}|{%f} $1$atqq$/a$9$/b | ||
192 | # | ||
193 | #alternative_header_second_line_format = {{$4$b%a$/b$9}{ - $7%b$9}{ ($4%y$9)}}|{%D} | ||
194 | # | ||
195 | #current_item_prefix = $(yellow)$r | ||
196 | # | ||
197 | #current_item_suffix = $/r$(end) | ||
198 | # | ||
199 | #current_item_inactive_column_prefix = $(white)$r | ||
200 | # | ||
201 | #current_item_inactive_column_suffix = $/r$(end) | ||
202 | # | ||
203 | #now_playing_prefix = $b | ||
204 | # | ||
205 | #now_playing_suffix = $/b | ||
206 | # | ||
207 | #browser_playlist_prefix = "$2playlist$9 " | ||
208 | # | ||
209 | #selected_item_prefix = $6 | ||
210 | # | ||
211 | #selected_item_suffix = $9 | ||
212 | # | ||
213 | #modified_item_prefix = $3> $9 | ||
214 | # | ||
215 | ## | ||
216 | ## Note: attributes are not supported for the following variables. | ||
217 | ## | ||
218 | #song_window_title_format = {%a - }{%t}|{%f} | ||
219 | ## | ||
220 | ## Note: Below variables are used for sorting songs in browser. The sort mode | ||
221 | ## determines how songs are sorted, and can be used in combination with a sort | ||
222 | ## format to specify a custom sorting format. Available values for | ||
223 | ## browser_sort_mode are "name", "mtime", "format" and "noop". | ||
224 | ## | ||
225 | # | ||
226 | #browser_sort_mode = name | ||
227 | # | ||
228 | #browser_sort_format = {%a - }{%t}|{%f} {(%l)} | ||
229 | # | ||
230 | ##### columns settings ##### | ||
231 | ## | ||
232 | ## syntax of song columns list format is "column column etc." | ||
233 | ## | ||
234 | ## - syntax for each column is: | ||
235 | ## | ||
236 | ## (width of the column)[color of the column]{displayed tag} | ||
237 | ## | ||
238 | ## Note: Width is by default in %, if you want a column to have fixed size, add | ||
239 | ## 'f' after the value, e.g. (10)[white]{a} will be the column that take 10% of | ||
240 | ## screen (so the real width will depend on actual screen size), whereas | ||
241 | ## (10f)[white]{a} will take 10 terminal cells, no matter how wide the screen | ||
242 | ## is. | ||
243 | ## | ||
244 | ## - color is optional (if you want the default one, leave the field empty). | ||
245 | ## | ||
246 | ## Note: You can give a column additional attributes by putting appropriate | ||
247 | ## character after displayed tag character. Available attributes are: | ||
248 | ## | ||
249 | ## - r - column will be right aligned | ||
250 | ## - E - if tag is empty, empty tag marker won't be displayed | ||
251 | ## | ||
252 | ## You can also: | ||
253 | ## | ||
254 | ## - give a column custom name by putting it after attributes, separated with | ||
255 | ## character ':', e.g. {lr:Length} gives you right aligned column of lengths | ||
256 | ## named "Length". | ||
257 | ## | ||
258 | ## - define sequence of tags, that have to be displayed in case predecessor is | ||
259 | ## empty in a way similar to the one in classic song format, i.e. using '|' | ||
260 | ## character, e.g. {a|c|p:Owner} creates column named "Owner" that tries to | ||
261 | ## display artist tag and then composer and performer if previous ones are not | ||
262 | ## available. | ||
263 | ## | ||
264 | # | ||
265 | #song_columns_list_format = (20)[]{a} (6f)[green]{NE} (50)[white]{t|f:Title} (20)[cyan]{b} (7f)[magenta]{l} | ||
266 | # | ||
267 | ##### various settings ##### | ||
268 | # | ||
269 | ## | ||
270 | ## Note: Custom command that will be executed each time song changes. Useful for | ||
271 | ## notifications etc. | ||
272 | ## | ||
273 | execute_on_song_change = notify-send "now listening" "$(mpc current)" --app-name="ncmpcpp" --icon="folder-music" | ||
274 | # | ||
275 | ## | ||
276 | ## Note: Custom command that will be executed each time player state | ||
277 | ## changes. The environment variable MPD_PLAYER_STATE is set to the current | ||
278 | ## state (either unknown, play, pause, or stop) for its duration. | ||
279 | ## | ||
280 | # | ||
281 | #execute_on_player_state_change = "" | ||
282 | # | ||
283 | #playlist_show_mpd_host = no | ||
284 | # | ||
285 | #playlist_show_remaining_time = no | ||
286 | # | ||
287 | #playlist_shorten_total_times = no | ||
288 | # | ||
289 | #playlist_separate_albums = no | ||
290 | # | ||
291 | ## | ||
292 | ## Note: Possible display modes: classic, columns. | ||
293 | ## | ||
294 | #playlist_display_mode = columns | ||
295 | # | ||
296 | #browser_display_mode = classic | ||
297 | # | ||
298 | #search_engine_display_mode = classic | ||
299 | # | ||
300 | #playlist_editor_display_mode = classic | ||
301 | # | ||
302 | #discard_colors_if_item_is_selected = yes | ||
303 | # | ||
304 | #show_duplicate_tags = yes | ||
305 | # | ||
306 | #incremental_seeking = yes | ||
307 | # | ||
308 | #seek_time = 1 | ||
309 | # | ||
310 | #volume_change_step = 2 | ||
311 | # | ||
312 | #autocenter_mode = no | ||
313 | # | ||
314 | #centered_cursor = no | ||
315 | # | ||
316 | ## | ||
317 | ## Note: You can specify third character which will be used to build 'empty' | ||
318 | ## part of progressbar. | ||
319 | ## | ||
320 | #progressbar_look = => | ||
321 | # | ||
322 | ## Available values: database, playlist. | ||
323 | ## | ||
324 | #default_place_to_search_in = database | ||
325 | # | ||
326 | ## Available values: classic, alternative. | ||
327 | ## | ||
328 | user_interface = alternative | ||
329 | # | ||
330 | #data_fetching_delay = yes | ||
331 | # | ||
332 | ## Available values: artist, album_artist, date, genre, composer, performer. | ||
333 | ## | ||
334 | #media_library_primary_tag = artist | ||
335 | # | ||
336 | #media_library_albums_split_by_date = yes | ||
337 | # | ||
338 | ## Available values: wrapped, normal. | ||
339 | ## | ||
340 | #default_find_mode = wrapped | ||
341 | # | ||
342 | #default_tag_editor_pattern = %n - %t | ||
343 | # | ||
344 | #header_visibility = yes | ||
345 | # | ||
346 | #statusbar_visibility = yes | ||
347 | # | ||
348 | #titles_visibility = yes | ||
349 | # | ||
350 | #header_text_scrolling = yes | ||
351 | # | ||
352 | #cyclic_scrolling = no | ||
353 | # | ||
354 | #lines_scrolled = 2 | ||
355 | # | ||
356 | #lyrics_fetchers = lyricwiki, azlyrics, genius, sing365, lyricsmania, metrolyrics, justsomelyrics, jahlyrics, plyrics, tekstowo, internet | ||
357 | # | ||
358 | #follow_now_playing_lyrics = no | ||
359 | # | ||
360 | #fetch_lyrics_for_current_song_in_background = no | ||
361 | # | ||
362 | #store_lyrics_in_song_dir = no | ||
363 | # | ||
364 | #generate_win32_compatible_filenames = yes | ||
365 | # | ||
366 | #allow_for_physical_item_deletion = no | ||
367 | # | ||
368 | ## | ||
369 | ## Note: If you set this variable, ncmpcpp will try to get info from last.fm in | ||
370 | ## language you set and if it fails, it will fall back to english. Otherwise it | ||
371 | ## will use english the first time. | ||
372 | ## | ||
373 | ## Note: Language has to be expressed as an ISO 639 alpha-2 code. | ||
374 | ## | ||
375 | #lastfm_preferred_language = en | ||
376 | # | ||
377 | #space_add_mode = add_remove | ||
378 | # | ||
379 | #show_hidden_files_in_local_browser = no | ||
380 | # | ||
381 | ## | ||
382 | ## How shall screen switcher work? | ||
383 | ## | ||
384 | ## - "previous" - switch between the current and previous screen. | ||
385 | ## - "screen1,...,screenN" - switch between given sequence of screens. | ||
386 | ## | ||
387 | ## Screens available for use: help, playlist, browser, search_engine, | ||
388 | ## media_library, playlist_editor, tag_editor, outputs, visualizer, clock, | ||
389 | ## lyrics, last_fm. | ||
390 | ## | ||
391 | #screen_switcher_mode = playlist, browser | ||
392 | # | ||
393 | ## | ||
394 | ## Note: You can define startup screen by choosing screen from the list above. | ||
395 | ## | ||
396 | #startup_screen = playlist | ||
397 | # | ||
398 | ## | ||
399 | ## Note: You can define startup slave screen by choosing screen from the list | ||
400 | ## above or an empty value for no slave screen. | ||
401 | ## | ||
402 | #startup_slave_screen = "" | ||
403 | # | ||
404 | #startup_slave_screen_focus = no | ||
405 | # | ||
406 | ## | ||
407 | ## Default width of locked screen (in %). Acceptable values are from 20 to 80. | ||
408 | ## | ||
409 | # | ||
410 | #locked_screen_width_part = 50 | ||
411 | # | ||
412 | #ask_for_locked_screen_width_part = yes | ||
413 | # | ||
414 | #jump_to_now_playing_song_at_start = yes | ||
415 | # | ||
416 | #ask_before_clearing_playlists = yes | ||
417 | # | ||
418 | #clock_display_seconds = no | ||
419 | # | ||
420 | #display_volume_level = yes | ||
421 | # | ||
422 | #display_bitrate = no | ||
423 | # | ||
424 | #display_remaining_time = no | ||
425 | # | ||
426 | ## Available values: none, basic, extended, perl. | ||
427 | ## | ||
428 | #regular_expressions = perl | ||
429 | # | ||
430 | ## | ||
431 | ## Note: if below is enabled, ncmpcpp will ignore leading "The" word while | ||
432 | ## sorting items in browser, tags in media library, etc. | ||
433 | ## | ||
434 | #ignore_leading_the = no | ||
435 | # | ||
436 | ## | ||
437 | ## Note: if below is enabled, ncmpcpp will ignore diacritics while searching and | ||
438 | ## filtering lists. This takes an effect only if boost was compiled with ICU | ||
439 | ## support. | ||
440 | ## | ||
441 | #ignore_diacritics = no | ||
442 | # | ||
443 | #block_search_constraints_change_if_items_found = yes | ||
444 | # | ||
445 | #mouse_support = yes | ||
446 | # | ||
447 | #mouse_list_scroll_whole_page = yes | ||
448 | # | ||
449 | #empty_tag_marker = <empty> | ||
450 | # | ||
451 | #tags_separator = " | " | ||
452 | # | ||
453 | #tag_editor_extended_numeration = no | ||
454 | # | ||
455 | #media_library_sort_by_mtime = no | ||
456 | # | ||
457 | #enable_window_title = yes | ||
458 | # | ||
459 | ## | ||
460 | ## Note: You can choose default search mode for search engine. Available modes | ||
461 | ## are: | ||
462 | ## | ||
463 | ## - 1 - use mpd built-in searching (no regexes, pattern matching) | ||
464 | ## | ||
465 | ## - 2 - use ncmpcpp searching (pattern matching with support for regexes, but | ||
466 | ## if your mpd is on a remote machine, downloading big database to process | ||
467 | ## it can take a while | ||
468 | ## | ||
469 | ## - 3 - match only exact values (this mode uses mpd function for searching in | ||
470 | ## database and local one for searching in current playlist) | ||
471 | ## | ||
472 | # | ||
473 | #search_engine_default_search_mode = 1 | ||
474 | # | ||
475 | #external_editor = nano | ||
476 | # | ||
477 | ## Note: set to yes if external editor is a console application. | ||
478 | ## | ||
479 | #use_console_editor = yes | ||
480 | # | ||
481 | ##### colors definitions ##### | ||
482 | ## | ||
483 | ## It is possible to set a background color by setting a color value | ||
484 | ## "<foreground>_<background>", e.g. red_black will set foregound color to red | ||
485 | ## and background color to black. | ||
486 | ## | ||
487 | ## In addition, for terminals that support 256 colors it is possible to set one | ||
488 | ## of them by using a number in range [1, 256] instead of color name, | ||
489 | ## e.g. numerical value corresponding to red_black is 2_1. To find out if the | ||
490 | ## terminal supports 256 colors, run ncmpcpp and check out the bottom of the | ||
491 | ## help screen for list of available colors and their numerical values. | ||
492 | ## | ||
493 | ## What is more, there are two special values for the background color: | ||
494 | ## "transparent" and "current". The first one explicitly sets the background to | ||
495 | ## be transparent, while the second one allows you to preserve current | ||
496 | ## background color and change only the foreground one. It's used implicitly | ||
497 | ## when background color is not specified. | ||
498 | ## | ||
499 | ## Moreover, it is possible to attach format information to selected color | ||
500 | ## variables by appending to their end a colon followed by one or more format | ||
501 | ## flags, e.g. black:b or red:ur. The following variables support this syntax: | ||
502 | ## visualizer_color, color1, color2, empty_tag_color, volume_color, | ||
503 | ## state_line_color, state_flags_color, progressbar_color, | ||
504 | ## progressbar_elapsed_color, player_state_color, statusbar_time_color, | ||
505 | ## alternative_ui_separator_color. | ||
506 | ## | ||
507 | ## Note: due to technical limitations of older ncurses version, if 256 colors | ||
508 | ## are used there is a possibility that you'll be able to use only colors with | ||
509 | ## transparent background. | ||
510 | # | ||
511 | #colors_enabled = yes | ||
512 | # | ||
513 | #empty_tag_color = cyan | ||
514 | # | ||
515 | #header_window_color = default | ||
516 | # | ||
517 | #volume_color = default | ||
518 | # | ||
519 | #state_line_color = default | ||
520 | # | ||
521 | #state_flags_color = default:b | ||
522 | # | ||
523 | #main_window_color = yellow | ||
524 | # | ||
525 | #color1 = white | ||
526 | # | ||
527 | #color2 = green | ||
528 | # | ||
529 | #progressbar_color = black:b | ||
530 | # | ||
531 | #progressbar_elapsed_color = green:b | ||
532 | # | ||
533 | #statusbar_color = default | ||
534 | # | ||
535 | #statusbar_time_color = default:b | ||
536 | # | ||
537 | #player_state_color = default:b | ||
538 | # | ||
539 | #alternative_ui_separator_color = black:b | ||
540 | # | ||
541 | #window_border_color = green | ||
542 | # | ||
543 | #active_window_border = red | ||
diff --git a/.newsboat/config b/.newsboat/config new file mode 100644 index 0000000..cbef73b --- /dev/null +++ b/.newsboat/config | |||
@@ -0,0 +1,5 @@ | |||
1 | browser "firefox %u" | ||
2 | color info black color7 bold | ||
3 | color listfocus color0 color3 | ||
4 | color listfocus_unread color0 color3 bold | ||
5 | color listnormal_unread color14 default | ||
diff --git a/.newsboat/urls b/.newsboat/urls new file mode 100644 index 0000000..4f7923c --- /dev/null +++ b/.newsboat/urls | |||
@@ -0,0 +1,19 @@ | |||
1 | https://grumpy.website/feed.xml fun | ||
2 | https://movingfulcrum.com/rss/ tech | ||
3 | https://danielmiessler.com/feed/ tech blog | ||
4 | https://qntm.org/rss.php fun | ||
5 | https://byorgey.wordpress.com/feed/ tech | ||
6 | https://mathlesstraveled.com/feed/ tech | ||
7 | http://joeyh.name/blog/index.rss tech | ||
8 | https://programmingisterrible.com/rss tech | ||
9 | https://www.joelonsoftware.com/feed/ tech | ||
10 | https://www.ralfj.de/blog/feed.xml tech blog | ||
11 | https://www.anishathalye.com/feed.xml tech | ||
12 | https://bilgesusever.wordpress.com/feed/ blog | ||
13 | http://llewellynfalco.blogspot.com/feeds/posts/default | ||
14 | https://itsfoss.com/feed/ tech news | ||
15 | https://blog.djy.io/atom.xml blog | ||
16 | http://blog.amynguyen.net/?feed=rss2 blog | ||
17 | http://vas3k.com/rss/ | ||
18 | https://bullets.tech/rss/latest.xml | ||
19 | https://cli.fan/posts/index.xml | ||
diff --git a/.tmux.conf b/.tmux.conf new file mode 100644 index 0000000..a798aa3 --- /dev/null +++ b/.tmux.conf | |||
@@ -0,0 +1,84 @@ | |||
1 | # Make shift+arrows, ctrl+arrows etc work in Vim. | ||
2 | set -g xterm-keys on | ||
3 | |||
4 | # See if this fixes slow ESC issues. | ||
5 | # http://unix.stackexchange.com/questions/23138/esc-key-causes-a-small-delay-in-terminal-due-to-its-alt-behavior | ||
6 | set -s escape-time 0 | ||
7 | |||
8 | # Start numbering at 1 | ||
9 | set -g base-index 1 | ||
10 | set -g pane-base-index 1 | ||
11 | |||
12 | # Set status bar | ||
13 | set -g status-position bottom | ||
14 | set -g status-justify left | ||
15 | set -g status-bg black | ||
16 | set -g status-fg white | ||
17 | set -g status-attr bold | ||
18 | set -g status-left "#S " | ||
19 | set -g status-right '#[fg=white,bg=black,bold] %d/%m #[fg=white,bg=black,bold] %H:%M @#H' | ||
20 | |||
21 | # higlight the active window in the status bar | ||
22 | set-window-option -g window-status-current-bg white | ||
23 | set-window-option -g window-status-current-fg black | ||
24 | |||
25 | setw -g window-status-current-fg red | ||
26 | setw -g window-status-current-bg white | ||
27 | setw -g window-status-current-attr bold | ||
28 | setw -g window-status-current-format ' #I#[fg=red]:#[fg=black]#W#[fg=black]#F ' | ||
29 | |||
30 | setw -g window-status-fg white | ||
31 | setw -g window-status-bg black | ||
32 | setw -g window-status-attr dim | ||
33 | setw -g window-status-format ' #I#[fg=cyan]:#[fg=white]#W#[fg=white]#F ' | ||
34 | |||
35 | # Don't prompt to kill panes/windows. TODO you will fuck this up | ||
36 | bind-key x kill-pane | ||
37 | bind-key & kill-window | ||
38 | |||
39 | # Cycle panes. | ||
40 | bind b select-pane -t :.+ | ||
41 | bind C-b select-pane -t :.+ | ||
42 | |||
43 | # More intuitive split-window mappings. | ||
44 | bind "'" split-window -h -c "#{pane_current_path}" | ||
45 | bind - split-window -v -c "#{pane_current_path}" | ||
46 | |||
47 | # Maximize pane, e.g. for copying. | ||
48 | bind-key z resize-pane -Z | ||
49 | |||
50 | # Use vim keybindings in copy mode | ||
51 | setw -g mode-keys vi | ||
52 | |||
53 | set -g default-terminal "tmux-256color" | ||
54 | set -g default-command "${SHELL}" | ||
55 | set -g set-titles on | ||
56 | set -g mouse on | ||
57 | |||
58 | # C-b is not acceptable -- Vim uses it | ||
59 | set-option -g prefix C-space | ||
60 | bind-key C-space last-window | ||
61 | |||
62 | # vim like navigation | ||
63 | bind h select-pane -L | ||
64 | bind j select-pane -D | ||
65 | bind k select-pane -U | ||
66 | bind l select-pane -R | ||
67 | |||
68 | # The panes | ||
69 | |||
70 | #set -g pane-border-bg colour235 | ||
71 | #set -g pane-border-fg colour238 | ||
72 | #set -g pane-active-border-bg colour236 | ||
73 | #set -g pane-active-border-fg colour51 | ||
74 | |||
75 | # panes | ||
76 | #set -g pane-border-fg black | ||
77 | #set -g pane-active-border-fg brightred | ||
78 | |||
79 | # Activity monitoring | ||
80 | setw -g monitor-activity on | ||
81 | set -g visual-activity on | ||
82 | |||
83 | # Example of using a shell command in the status line | ||
84 | #set -g status-right "#[fg=yellow]#(uptime | cut -d ',' -f 2-)" | ||
diff --git a/.ycm_extra_conf.py b/.ycm_extra_conf.py new file mode 100644 index 0000000..34573ff --- /dev/null +++ b/.ycm_extra_conf.py | |||
@@ -0,0 +1,184 @@ | |||
1 | # This file is NOT licensed under the GPLv3, which is the license for the rest | ||
2 | # of YouCompleteMe. | ||
3 | # | ||
4 | # Here's the license text for this file: | ||
5 | # | ||
6 | # This is free and unencumbered software released into the public domain. | ||
7 | # | ||
8 | # Anyone is free to copy, modify, publish, use, compile, sell, or | ||
9 | # distribute this software, either in source code form or as a compiled | ||
10 | # binary, for any purpose, commercial or non-commercial, and by any | ||
11 | # means. | ||
12 | # | ||
13 | # In jurisdictions that recognize copyright laws, the author or authors | ||
14 | # of this software dedicate any and all copyright interest in the | ||
15 | # software to the public domain. We make this dedication for the benefit | ||
16 | # of the public at large and to the detriment of our heirs and | ||
17 | # successors. We intend this dedication to be an overt act of | ||
18 | # relinquishment in perpetuity of all present and future rights to this | ||
19 | # software under copyright law. | ||
20 | # | ||
21 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
22 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
23 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
24 | # IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
25 | # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
26 | # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
27 | # OTHER DEALINGS IN THE SOFTWARE. | ||
28 | # | ||
29 | # For more information, please refer to <http://unlicense.org/> | ||
30 | |||
31 | import os | ||
32 | import ycm_core | ||
33 | |||
34 | # These are the compilation flags that will be used in case there's no | ||
35 | # compilation database set (by default, one is not set). | ||
36 | # CHANGE THIS LIST OF FLAGS. YES, THIS IS THE DROID YOU HAVE BEEN LOOKING FOR. | ||
37 | flags = [ | ||
38 | '-Wall', | ||
39 | '-Wextra', | ||
40 | '-Werror', | ||
41 | '-Wno-long-long', | ||
42 | '-Wno-variadic-macros', | ||
43 | '-fexceptions', | ||
44 | '-DNDEBUG', | ||
45 | # You 100% do NOT need -DUSE_CLANG_COMPLETER in your flags; only the YCM | ||
46 | # source code needs it. | ||
47 | '-DUSE_CLANG_COMPLETER', | ||
48 | # THIS IS IMPORTANT! Without a "-std=<something>" flag, clang won't know which | ||
49 | # language to use when compiling headers. So it will guess. Badly. So C++ | ||
50 | # headers will be compiled as C headers. You don't want that so ALWAYS specify | ||
51 | # a "-std=<something>". | ||
52 | # For a C project, you would set this to something like 'c99' instead of | ||
53 | # 'c++11'. | ||
54 | '-std=c99', | ||
55 | # ...and the same thing goes for the magic -x option which specifies the | ||
56 | # language that the files to be compiled are written in. This is mostly | ||
57 | # relevant for c++ headers. | ||
58 | # For a C project, you would set this to 'c' instead of 'c++'. | ||
59 | '-x', | ||
60 | 'c', | ||
61 | '-isystem', | ||
62 | '../BoostParts', | ||
63 | '-isystem', | ||
64 | # This path will only work on OS X, but extra paths that don't exist are not | ||
65 | # harmful | ||
66 | '/System/Library/Frameworks/Python.framework/Headers', | ||
67 | '-isystem', | ||
68 | '../llvm/include', | ||
69 | '-isystem', | ||
70 | '../llvm/tools/clang/include', | ||
71 | '-I', | ||
72 | '.', | ||
73 | '-I', | ||
74 | './ClangCompleter', | ||
75 | '-isystem', | ||
76 | './tests/gmock/gtest', | ||
77 | '-isystem', | ||
78 | './tests/gmock/gtest/include', | ||
79 | '-isystem', | ||
80 | './tests/gmock', | ||
81 | '-isystem', | ||
82 | './tests/gmock/include', | ||
83 | ] | ||
84 | |||
85 | |||
86 | # Set this to the absolute path to the folder (NOT the file!) containing the | ||
87 | # compile_commands.json file to use that instead of 'flags'. See here for | ||
88 | # more details: http://clang.llvm.org/docs/JSONCompilationDatabase.html | ||
89 | # | ||
90 | # You can get CMake to generate this file for you by adding: | ||
91 | # set( CMAKE_EXPORT_COMPILE_COMMANDS 1 ) | ||
92 | # to your CMakeLists.txt file. | ||
93 | # | ||
94 | # Most projects will NOT need to set this to anything; you can just change the | ||
95 | # 'flags' list of compilation flags. Notice that YCM itself uses that approach. | ||
96 | compilation_database_folder = '' | ||
97 | |||
98 | if os.path.exists( compilation_database_folder ): | ||
99 | database = ycm_core.CompilationDatabase( compilation_database_folder ) | ||
100 | else: | ||
101 | database = None | ||
102 | |||
103 | SOURCE_EXTENSIONS = [ '.cpp', '.cxx', '.cc', '.c', '.m', '.mm' ] | ||
104 | |||
105 | def DirectoryOfThisScript(): | ||
106 | return os.path.dirname( os.path.abspath( __file__ ) ) | ||
107 | |||
108 | |||
109 | def MakeRelativePathsInFlagsAbsolute( flags, working_directory ): | ||
110 | if not working_directory: | ||
111 | return list( flags ) | ||
112 | new_flags = [] | ||
113 | make_next_absolute = False | ||
114 | path_flags = [ '-isystem', '-I', '-iquote', '--sysroot=' ] | ||
115 | for flag in flags: | ||
116 | new_flag = flag | ||
117 | |||
118 | if make_next_absolute: | ||
119 | make_next_absolute = False | ||
120 | if not flag.startswith( '/' ): | ||
121 | new_flag = os.path.join( working_directory, flag ) | ||
122 | |||
123 | for path_flag in path_flags: | ||
124 | if flag == path_flag: | ||
125 | make_next_absolute = True | ||
126 | break | ||
127 | |||
128 | if flag.startswith( path_flag ): | ||
129 | path = flag[ len( path_flag ): ] | ||
130 | new_flag = path_flag + os.path.join( working_directory, path ) | ||
131 | break | ||
132 | |||
133 | if new_flag: | ||
134 | new_flags.append( new_flag ) | ||
135 | return new_flags | ||
136 | |||
137 | |||
138 | def IsHeaderFile( filename ): | ||
139 | extension = os.path.splitext( filename )[ 1 ] | ||
140 | return extension in [ '.h', '.hxx', '.hpp', '.hh' ] | ||
141 | |||
142 | |||
143 | def GetCompilationInfoForFile( filename ): | ||
144 | # The compilation_commands.json file generated by CMake does not have entries | ||
145 | # for header files. So we do our best by asking the db for flags for a | ||
146 | # corresponding source file, if any. If one exists, the flags for that file | ||
147 | # should be good enough. | ||
148 | if IsHeaderFile( filename ): | ||
149 | basename = os.path.splitext( filename )[ 0 ] | ||
150 | for extension in SOURCE_EXTENSIONS: | ||
151 | replacement_file = basename + extension | ||
152 | if os.path.exists( replacement_file ): | ||
153 | compilation_info = database.GetCompilationInfoForFile( | ||
154 | replacement_file ) | ||
155 | if compilation_info.compiler_flags_: | ||
156 | return compilation_info | ||
157 | return None | ||
158 | return database.GetCompilationInfoForFile( filename ) | ||
159 | |||
160 | |||
161 | def FlagsForFile( filename, **kwargs ): | ||
162 | if database: | ||
163 | # Bear in mind that compilation_info.compiler_flags_ does NOT return a | ||
164 | # python list, but a "list-like" StringVec object | ||
165 | compilation_info = GetCompilationInfoForFile( filename ) | ||
166 | if not compilation_info: | ||
167 | return None | ||
168 | |||
169 | final_flags = MakeRelativePathsInFlagsAbsolute( | ||
170 | compilation_info.compiler_flags_, | ||
171 | compilation_info.compiler_working_dir_ ) | ||
172 | |||
173 | # NOTE: This is just for YouCompleteMe; it's highly likely that your project | ||
174 | # does NOT need to remove the stdlib flag. DO NOT USE THIS IN YOUR | ||
175 | # ycm_extra_conf IF YOU'RE NOT 100% SURE YOU NEED IT. | ||
176 | try: | ||
177 | final_flags.remove( '-stdlib=libc++' ) | ||
178 | except ValueError: | ||
179 | pass | ||
180 | else: | ||
181 | relative_to = DirectoryOfThisScript() | ||
182 | final_flags = MakeRelativePathsInFlagsAbsolute( flags, relative_to ) | ||
183 | |||
184 | return { 'flags': final_flags } | ||
@@ -0,0 +1,169 @@ | |||
1 | cowsay $(fortune) | ||
2 | # If you come from bash you might have to change your $PATH. | ||
3 | export PATH=$HOME/bin:/usr/local/bin:$PATH | ||
4 | export PATH="$PATH:/home/yigit/.local/bin" | ||
5 | |||
6 | # Path to your oh-my-zsh installation. | ||
7 | export ZSH=/home/yigit/.oh-my-zsh | ||
8 | |||
9 | # Set name of the theme to load. Optionally, if you set this to "random" | ||
10 | # it'll load a random theme each time that oh-my-zsh is loaded. | ||
11 | # See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes | ||
12 | # ZSH_THEME="arrow" | ||
13 | # ZSH_THEME="eastwood" | ||
14 | # ZSH_THEME="kolo" | ||
15 | # --> # ZSH_THEME="theunraveler" | ||
16 | ZSH_THEME="spaceship" | ||
17 | # ZSH_THEME="ys" | ||
18 | |||
19 | # Uncomment the following line to use case-sensitive completion. | ||
20 | # CASE_SENSITIVE="true" | ||
21 | |||
22 | # Uncomment the following line to use hyphen-insensitive completion. Case | ||
23 | # sensitive completion must be off. _ and - will be interchangeable. | ||
24 | # HYPHEN_INSENSITIVE="true" | ||
25 | |||
26 | # Uncomment the following line to disable bi-weekly auto-update checks. | ||
27 | # DISABLE_AUTO_UPDATE="true" | ||
28 | |||
29 | # Uncomment the following line to change how often to auto-update (in days). | ||
30 | # export UPDATE_ZSH_DAYS=13 | ||
31 | |||
32 | # Uncomment the following line to disable colors in ls. | ||
33 | # DISABLE_LS_COLORS="true" | ||
34 | export LS_COLORS="$(vivid generate snazzy)" | ||
35 | |||
36 | # Uncomment the following line to disable auto-setting terminal title. | ||
37 | # DISABLE_AUTO_TITLE="true" | ||
38 | |||
39 | # Uncomment the following line to enable command auto-correction. | ||
40 | # ENABLE_CORRECTION="true" | ||
41 | |||
42 | # Uncomment the following line to display red dots whilst waiting for completion. | ||
43 | COMPLETION_WAITING_DOTS="true" | ||
44 | |||
45 | # Uncomment the following line if you want to disable marking untracked files | ||
46 | # under VCS as dirty. This makes repository status check for large repositories | ||
47 | # much, much faster. | ||
48 | # DISABLE_UNTRACKED_FILES_DIRTY="true" | ||
49 | |||
50 | # Uncomment the following line if you want to change the command execution time | ||
51 | # stamp shown in the history command output. | ||
52 | # The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd" | ||
53 | # HIST_STAMPS="mm/dd/yyyy" | ||
54 | |||
55 | # Would you like to use another custom folder than $ZSH/custom? | ||
56 | # ZSH_CUSTOM=/path/to/new-custom-folder | ||
57 | |||
58 | # Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*) | ||
59 | # Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/ | ||
60 | # Example format: plugins=(rails git textmate ruby lighthouse) | ||
61 | # Add wisely, as too many plugins slow down shell startup. | ||
62 | plugins=( | ||
63 | colored-man-pages | ||
64 | cpanm | ||
65 | git | ||
66 | gitignore | ||
67 | taskwarrior | ||
68 | tmux | ||
69 | you-should-use | ||
70 | z | ||
71 | zsh-autosuggestions | ||
72 | ) | ||
73 | |||
74 | source $ZSH/oh-my-zsh.sh | ||
75 | |||
76 | # User configuration | ||
77 | |||
78 | # export MANPATH="/usr/local/man:$MANPATH" | ||
79 | |||
80 | # You may need to manually set your language environment | ||
81 | # export LANG=en_US.UTF-8 | ||
82 | |||
83 | # Preferred editor for local and remote sessions | ||
84 | if [[ -n $SSH_CONNECTION ]]; then | ||
85 | export EDITOR='nvim' | ||
86 | else | ||
87 | export EDITOR='nvim' | ||
88 | fi | ||
89 | |||
90 | [[ $TMUX = "" ]] && export TERM="xterm-256color" | ||
91 | |||
92 | # Compilation flags | ||
93 | # export ARCHFLAGS="-arch x86_64" | ||
94 | |||
95 | # ssh | ||
96 | # export SSH_KEY_PATH="~/.ssh/rsa_id" | ||
97 | |||
98 | # Set personal aliases, overriding those provided by oh-my-zsh libs, | ||
99 | # plugins, and themes. Aliases can be placed here, though oh-my-zsh | ||
100 | # users are encouraged to define aliases within the ZSH_CUSTOM folder. | ||
101 | # For a full list of active aliases, run `alias`. | ||
102 | |||
103 | # Example aliases | ||
104 | alias ll='ls -alhF --color=yes' | ||
105 | alias la='ls -A' | ||
106 | alias l='ls -CF' | ||
107 | alias vim='nvim' | ||
108 | alias pacup='sudo pacman -Syu' | ||
109 | alias bashrc='nvim ~/.zshrc && source ~/.zshrc' | ||
110 | alias taskrc='nvim ~/.taskrc' | ||
111 | alias conkyrc='nvim ~/.config/conky/conky.conf' | ||
112 | alias rm='rm -i' | ||
113 | alias cp='cp -i' | ||
114 | alias mv='mv -i' # Interactive, don't fuck shit up | ||
115 | alias free='free -m' | ||
116 | alias df='df -h' | ||
117 | alias mirrors='sudo pacman-mirrors -f 0 && sudo pacman -Syy' | ||
118 | alias -g C='| xsel -b' # Copy to clipboard | ||
119 | alias bc='bc -l' | ||
120 | alias maas="expr $(cal | awk 'FNR>2{d+=NF}END{print d}') - $(date +%d)" | ||
121 | alias gg="exit" | ||
122 | alias ledger="ledger -f ~/Dropbox/ledger.dat" | ||
123 | alias report="report -f ~/Dropbox/ledger.dat" | ||
124 | |||
125 | mkcdir () { | ||
126 | mkdir -p -- "$1" && | ||
127 | cd -P -- "$1" | ||
128 | } | ||
129 | |||
130 | PATH="/home/yigit/perl5/bin${PATH+:}${PATH}"; export PATH; | ||
131 | PERL5LIB="/home/yigit/perl5/lib/perl5${PERL5LIB+:}${PERL5LIB}"; export PERL5LIB; | ||
132 | PERL_LOCAL_LIB_ROOT="/home/yigit/perl5${PERL_LOCAL_LIB_ROOT+:}${PERL_LOCAL_LIB_ROOT}"; export PERL_LOCAL_LIB_ROOT; | ||
133 | PERL_MB_OPT="--install_base \"/home/yigit/perl5\""; export PERL_M_OPT; | ||
134 | PERL_MM_OPT="INSTALL_BASE=/home/yigit/perl5"; export PERL_MM_OPT; | ||
135 | PERL_MM_OPT="INSTALL_BASE=/home/yigit/perl5"; export PERL_MM_OPT; | ||
136 | |||
137 | RANGER_LOAD_DEFAULT_RC=FALSE; export RANGER_LOAD_DEFAULT_RC | ||
138 | |||
139 | export GPG_TTY=$(tty) | ||
140 | |||
141 | PATH="$PATH:$(ruby -e 'print Gem.user_dir')/bin" | ||
142 | export GEM_HOME=$HOME/.gem | ||
143 | |||
144 | # Getting Things Done & Taskwarrior Related | ||
145 | alias in='task add +in' # Alias for tasks with in tag (in tray) | ||
146 | alias inc='task +in +PENDING count' # Reporting the number of in things | ||
147 | |||
148 | # tickler file | ||
149 | tickle () { | ||
150 | deadline=$1 | ||
151 | shift | ||
152 | in +tickle wait:$deadline $@ | ||
153 | } | ||
154 | alias tick=tickle | ||
155 | |||
156 | #think it over | ||
157 | alias think='tickle +1d' | ||
158 | |||
159 | alias lim='nvim /home/yigit/Dropbox/ledger.dat' | ||
160 | alias maybe='task due:someday list' | ||
161 | alias music='mpv --no-vid' | ||
162 | alias s="du -hs * | sort -rh | head -5" | ||
163 | alias f="find . -name" | ||
164 | alias b="buku --suggest --colors 'onlxm'" | ||
165 | alias tp='trash-put' | ||
166 | |||
167 | [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh | ||
168 | |||
169 | source /home/yigit/.local/share/nvim/plugged/gruvbox/gruvbox_256palette.sh | ||
diff --git a/bin/bukuadd_c b/bin/bukuadd_c new file mode 100755 index 0000000..d4e1a3d --- /dev/null +++ b/bin/bukuadd_c | |||
@@ -0,0 +1,29 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | #set -e | ||
4 | url=$(xsel -b) | ||
5 | tags=$(zenity --entry --text="enter tags for $url") | ||
6 | |||
7 | if [[ $? -ne 0 ]]; then | ||
8 | exit 0 | ||
9 | fi | ||
10 | |||
11 | FOO=$(buku --np --nc -p -1) | ||
12 | OUT="$(buku --np --nc -a "$url" "$tags" 2>&1)" | ||
13 | #echo "OUT>$OUT" | ||
14 | if [[ $OUT =~ "ERROR" ]] ; then | ||
15 | notify-send "Bookmarking Failed" "$OUT" --app-name="buku" --icon="dialog-error" | ||
16 | exit 1 | ||
17 | fi | ||
18 | |||
19 | BAR=$FOO | ||
20 | |||
21 | while [[ $BAR == "$FOO" ]]; do | ||
22 | sleep 1 | ||
23 | BAR=$(buku --np --nc -p -1) | ||
24 | #echo "BAR>$BAR" | ||
25 | done; | ||
26 | |||
27 | notify-send "Success" "$BAR" --app-name="buku" --icon="checkmark" | ||
28 | |||
29 | exit 0 | ||
diff --git a/bin/type.sh b/bin/type.sh new file mode 100755 index 0000000..32e0826 --- /dev/null +++ b/bin/type.sh | |||
@@ -0,0 +1,13 @@ | |||
1 | while read line | ||
2 | do | ||
3 | grep -o . <<<$line | while read a | ||
4 | do | ||
5 | sleep 0.$((RANDOM%3)) | ||
6 | #2>&1 echo -n "${a:- }" | tee /dev/tty | ||
7 | echo -n "${a:- }" | tee /dev/tty | ||
8 | done | ||
9 | sleep 0.$((RANDOM%7)) | ||
10 | 1>&2 echo -ne $"\n" | ||
11 | echo | ||
12 | sleep 1.0 | ||
13 | done | ||