1
0
Fork 0

Compare commits

..

No commits in common. "00f86727c90ce4e2227d1f21c1af46cbf2ccb729" and "466ff6507c3a57c11ed0ca0d31a1a4ff35e793a6" have entirely different histories.

8 changed files with 331 additions and 328 deletions

10
.bashrc
View File

@ -21,12 +21,18 @@ alias lll="ls -AFl"
HISTCONTROL="ignoreboth:erasedups"
HISTFILESIZE=-1
HISTSIZE=-1
HISTIGNORE="exit:q"
HISTIGNORE="q"
shopt -s histappend
PROMPT_COMMAND=${PROMPT_COMMAND:+${PROMPT_COMMAND%;}; }"history -a; history -c; history -r;"
# bash completion
[ -f /usr/share/bash-completion/bash_completion ] && . /usr/share/bash-completion/bash_completion
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
# osc7
osc7_cwd() {

View File

@ -1,12 +1,13 @@
# vars #########################################################################
################################################################################
# set ##########################################################################
# keys
set $mod mod4
set $left h
set $down j
set $up k
set $right l
# colors
set $black #000000
set $white #e2e2e2
set $blue #856cff
@ -15,76 +16,7 @@ set $red #fa3500
set $orange #d06600
set $green #009843
# configuration ################################################################
################################################################################
workspace_layout tabbed
xwayland disable
# class border background text indicator
client.focused $magenta $magenta $black $red
client.focused_inactive $blue $blue $black $black
client.unfocused $blue $blue $black $black
client.urgent $red $red $black $black
default_border normal 0
default_floating_border normal 0
focus_wrapping yes
font monospace 13
input "type:keyboard" {
xkb_options caps:escape,compose:ralt
repeat_delay 200
repeat_rate 30
}
input "type:touchpad" tap enabled
seat * hide_cursor when-typing enable
output * background $black solid_color
# windows ######################################################################
################################################################################
# floating
bindsym $mod+shift+f floating toggle
# focus
bindsym $mod+$up focus up
bindsym $mod+$down focus down
bindsym $mod+$left focus left
bindsym $mod+$right focus right
bindsym $mod+a focus parent
bindsym $mod+s focus child
bindsym $mod+g focus mode_toggle
# fullscreen
bindsym $mod+f fullscreen toggle
# move
bindsym $mod+shift+$up move up
bindsym $mod+shift+$down move down
bindsym $mod+shift+$left move left
bindsym $mod+shift+$right move right
bindsym $mod+colon move scratchpad
# scratchpad
bindsym $mod+semicolon scratchpad show
# sticky
bindsym $mod+shift+g sticky toggle
# resize
bindsym $mod+control+$left resize shrink width
bindsym $mod+control+$down resize grow height
bindsym $mod+control+$up resize shrink height
bindsym $mod+control+$right resize grow width
# workspaces ###################################################################
################################################################################
# workspaces
set $wsq 0:q:bot
set $wsw 1:w:www
set $wse 2:e:txt
@ -96,106 +28,13 @@ set $wsi 7:i:cmd
set $wso 8:o:cmd
set $wsp 9:p:top
bindsym $mod+tab workspace back_and_forth
bindsym $mod+q workspace $wsq
bindsym $mod+w workspace $wsw
bindsym $mod+e workspace $wse
bindsym $mod+r workspace $wsr
bindsym $mod+t workspace $wst
bindsym $mod+y workspace $wsy
bindsym $mod+u workspace $wsu
bindsym $mod+i workspace $wsi
bindsym $mod+o workspace $wso
bindsym $mod+p workspace $wsp
bindsym $mod+bracketleft workspace prev
bindsym $mod+bracketright workspace next
bindsym $mod+shift+tab move workspace back_and_forth, workspace back_and_forth
bindsym $mod+shift+q move workspace $wsq, workspace $wsq
bindsym $mod+shift+w move workspace $wsw, workspace $wsw
bindsym $mod+shift+e move workspace $wse, workspace $wse
bindsym $mod+shift+r move workspace $wsr, workspace $wsr
bindsym $mod+shift+t move workspace $wst, workspace $wst
bindsym $mod+shift+y move workspace $wsy, workspace $wsy
bindsym $mod+shift+u move workspace $wsu, workspace $wsu
bindsym $mod+shift+i move workspace $wsi, workspace $wsi
bindsym $mod+shift+o move workspace $wso, workspace $wso
bindsym $mod+shift+p move workspace $wsp, workspace $wsp
bindsym $mod+shift+bracketleft move workspace prev, workspace prev
bindsym $mod+shift+bracketright move workspace next, workspace next
# modes ########################################################################
################################################################################
# modes
set $session_mode "session: (r)eload (l)ock (q)uit (s)uspend (h)ibernate re(b)oot (p)oweroff"
mode $session_mode {
bindsym {
r reload, mode default
l exec $swaylock, mode default
q exit, mode default
s exec systemctl suspend, mode default
h exec systemctl hibernate, mode default
b exec systemctl reboot, mode default
p exec systemctl poweroff, mode default
escape mode default
}
}
bindsym $mod+escape mode $session_mode, fullscreen disable
set $layout_mode "layout: split(h) split(v) (s)tacking (t)abbed"
mode $layout_mode {
bindsym {
h layout splith, mode default
v layout splitv, mode default
s layout stacking, mode default
t layout tabbed, mode default
escape mode default
}
}
bindsym $mod+d mode $layout_mode, fullscreen disable
set $find_exclude_expr \( -path "$HOME/.cache" -o -path "$HOME/.mozilla" -o -path "$HOME/.thunderbird" -o -name .git \)
# laptop #######################################################################
################################################################################
set $notify_hint string:x-canonical-private-synchronous
bindsym XF86AudioRaiseVolume exec wpctl set-volume @DEFAULT_AUDIO_SINK@ 1%+, exec notify-send -e -t 2000 -h $notify_hint:audio "$(wpctl get-volume @DEFAULT_AUDIO_SINK@)"
bindsym XF86AudioLowerVolume exec wpctl set-volume @DEFAULT_AUDIO_SINK@ 1%-, exec notify-send -e -t 2000 -h $notify_hint:audio "$(wpctl get-volume @DEFAULT_AUDIO_SINK@)"
bindsym XF86AudioMute exec wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle, exec notify-send -e -t 2000 -h $notify_hint:audio "$(wpctl get-volume @DEFAULT_AUDIO_SINK@)"
bindsym XF86AudioMicMute exec wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle, exec notify-send -e -t 2000 -h $notify_hint:audio "$(wpctl get-volume @DEFAULT_AUDIO_SOURCE@)"
bindsym XF86MonBrightnessUp exec brightnessctl -qn set +1%, exec notify-send -e -t 2000 -h $notify_hint:brightness "Brightness: $(brightnessctl get)"
bindsym XF86MonBrightnessDown exec brightnessctl -qn set 1%-, exec notify-send -e -t 2000 -h $notify_hint:brightness "Brightness: $(brightnessctl get)"
bindsym shift+XF86MonBrightnessUp exec brightnessctl -qn set +10%, exec notify-send -e -t 2000 -h $notify_hint:brightness "Brightness: $(brightnessctl get)"
bindsym shift+XF86MonBrightnessDown exec brightnessctl -qn set 10%-, exec notify-send -e -t 2000 -h $notify_hint:brightness "Brightness: $(brightnessctl get)"
# run ##########################################################################
################################################################################
bindsym $mod+return exec $TERMINAL
bindsym $mod+n exec makoctl dismiss
bindsym $mod+shift+n exec makoctl restore
bindsym print exec grim - | wl-copy
bindsym $mod+space exec fuzzel
set $findignore \( -path "$HOME"/.cache -o -path "$HOME"/.mozilla -o -path "$HOME"/.thunderbird -o -name .git \)
bindsym $mod+shift+space exec 'cd "$(find "$PWD" $findignore -prune -o -type d | fuzzel -dp"cd > ")" || exit; find "$PWD" $findignore -prune -o -print | fuzzel -dp"open > " | xargs -rI{} xdg-open "{}"'
# autorun ######################################################################
################################################################################
exec systemctl --user import-environment DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP
exec dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP=sway
exec mako --max-visible=0
exec devmon --exec-on-drive 'notify-send "Mounted %f at %d"' --exec-on-unmount 'notify-send "Unmounted %f"'
exec foot -s
exec wlsunset -l 45 -L 15
# commands
set $swaylock swaylock -f \
--color=$black \
--indicator-radius 1200 \
@ -209,32 +48,247 @@ set $swaylock swaylock -f \
--text-ver-color=#00000000 \
--text-wrong-color=#00000000
exec swayidle -w \
timeout 300 'brightnessctl -s set 1%' resume 'brightnessctl -r' \
timeout 600 '$swaylock' \
timeout 900 'swaymsg -q "output * power off"' resume 'swaymsg -q "output * power on"' \
timeout 1800 'systemctl suspend-then-hibernate' \
before-sleep '$swaylock'
# bar ##########################################################################
################################################################################
bar {
separator_symbol " "
separator_symbol " | "
status_command exec swaystatus
status_edge_padding 0
status_padding 0
strip_workspace_numbers yes
wrap_scroll yes
colors {
background $blue
statusline $black
separator $black
background $black
statusline $blue
separator $blue
# border background text
focused_workspace $magenta $magenta $black
active_workspace $white $white $black
inactive_workspace $blue $blue $black
urgent_workspace $red $red $black
focused_workspace $black $black $magenta
active_workspace $black $black $white
inactive_workspace $black $black $blue
urgent_workspace $black $black $red
}
}
# workspace_layout #############################################################
workspace_layout tabbed
# xwayland #####################################################################
# xwayland disable
# bindsym ######################################################################
# floating
bindsym $mod+shift+f floating toggle
# focus
bindsym {
$mod+$up focus up
$mod+$down focus down
$mod+$left focus left
$mod+$right focus right
$mod+a focus parent
$mod+s focus child
$mod+g focus mode_toggle
}
# fullscreen
bindsym $mod+f fullscreen toggle
# mark
bindsym {
$mod+shift+grave mark --toggle '`'
$mod+shift+1 mark --toggle '1'
$mod+shift+2 mark --toggle '2'
$mod+shift+3 mark --toggle '3'
$mod+shift+4 mark --toggle '4'
$mod+shift+5 mark --toggle '5'
$mod+shift+6 mark --toggle '6'
$mod+shift+7 mark --toggle '7'
$mod+shift+8 mark --toggle '8'
$mod+shift+9 mark --toggle '9'
$mod+shift+0 mark --toggle '0'
$mod+shift+minus mark --toggle '-'
$mod+shift+equal mark --toggle '='
}
bindsym {
$mod++grave [con_mark="`"] focus
$mod++1 [con_mark="1"] focus
$mod++2 [con_mark="2"] focus
$mod++3 [con_mark="3"] focus
$mod++4 [con_mark="4"] focus
$mod++5 [con_mark="5"] focus
$mod++6 [con_mark="6"] focus
$mod++7 [con_mark="7"] focus
$mod++8 [con_mark="8"] focus
$mod++9 [con_mark="9"] focus
$mod++0 [con_mark="0"] focus
$mod++minus [con_mark="-"] focus
$mod++equal [con_mark="="] focus
}
# mode
bindsym {
$mod+d mode $layout_mode, fullscreen disable
$mod+escape mode $session_mode, fullscreen disable
}
# move
bindsym --to-code {
$mod+shift+$up move up
$mod+shift+$down move down
$mod+shift+$left move left
$mod+shift+$right move right
$mod+shift+tab move workspace back_and_forth, workspace back_and_forth
$mod+shift+q move workspace $wsq, workspace $wsq
$mod+shift+w move workspace $wsw, workspace $wsw
$mod+shift+e move workspace $wse, workspace $wse
$mod+shift+r move workspace $wsr, workspace $wsr
$mod+shift+t move workspace $wst, workspace $wst
$mod+shift+y move workspace $wsy, workspace $wsy
$mod+shift+u move workspace $wsu, workspace $wsu
$mod+shift+i move workspace $wsi, workspace $wsi
$mod+shift+o move workspace $wso, workspace $wso
$mod+shift+p move workspace $wsp, workspace $wsp
$mod+shift+bracketleft move workspace prev, workspace prev
$mod+shift+bracketright move workspace next, workspace next
$mod+colon move scratchpad
}
# scratchpad
bindsym $mod+semicolon scratchpad show
# sticky
bindsym $mod+shift+g sticky toggle
# exec
bindsym --to-code {
$mod+return exec "$TERMINAL"
$mod+space exec fuzzel
$mod+slash exec find "$HOME" $find_exclude_expr -prune -o -print | fuzzel -dp'open > ' | xargs -r xdg-open
$mod+question exec find "$HOME" $find_exclude_expr -prune -o -type f -print0 | xargs -0r grep -in "$(wl-paste)" 2>/dev/null | awk -F: '{ printf("%8s %-62s\t%-80s\\n","+"$2,"\\""$1"\\"",$3) }' | fuzzel -dw160 -p"open > " | cut -f1 | xargs -r "$TERMINAL" "$EDITOR"
$mod+apostrophe exec swaymsg -t get_tree | jq -r 'recurse(.nodes[]) | select(.nodes==[] and .type=="con" and .focused==false) | (.id|tostring) + "\t" + .name' | fuzzel -dp'focus > ' | cut -f1 | xargs -rI{} swaymsg [con_id={}] focus
$mod+home exec "$TERMINAL" nmtui connect
$mod+shift+home exec "$TERMINAL" nmtui
$mod+end exec devmon -c
$mod+n exec makoctl dismiss
$mod+shift+n exec makoctl restore
print exec grim - | wl-copy
}
# exec (laptop)
bindsym {
XF86AudioRaiseVolume exec wpctl set-volume @DEFAULT_AUDIO_SINK@ 1%+, exec notify-send -e -t 2000 -h string:x-canonical-private-synchronous:audio "$(wpctl get-volume @DEFAULT_AUDIO_SINK@)"
XF86AudioLowerVolume exec wpctl set-volume @DEFAULT_AUDIO_SINK@ 1%-, exec notify-send -e -t 2000 -h string:x-canonical-private-synchronous:audio "$(wpctl get-volume @DEFAULT_AUDIO_SINK@)"
XF86AudioMute exec wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle, exec notify-send -e -t 2000 -h string:x-canonical-private-synchronous:audio "$(wpctl get-volume @DEFAULT_AUDIO_SINK@)"
XF86AudioMicMute exec wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle, exec notify-send -e -t 2000 -h string:x-canonical-private-synchronous:audio "$(wpctl get-volume @DEFAULT_AUDIO_SOURCE@)"
XF86MonBrightnessUp exec brightnessctl -n set +1%, exec notify-send -e -t 2000 -h string:x-canonical-private-synchronous:brightness "Brightness: $(brightnessctl get)"
XF86MonBrightnessDown exec brightnessctl -n set 1%-, exec notify-send -e -t 2000 -h string:x-canonical-private-synchronous:brightness "Brightness: $(brightnessctl get)"
shift+XF86MonBrightnessUp exec brightnessctl -n set +10%, exec notify-send -e -t 2000 -h string:x-canonical-private-synchronous:brightness "Brightness: $(brightnessctl get)"
shift+XF86MonBrightnessDown exec brightnessctl -n set 10%-, exec notify-send -e -t 2000 -h string:x-canonical-private-synchronous:brightness "Brightness: $(brightnessctl get)"
}
# resize
bindsym {
$mod+control+$left resize shrink width
$mod+control+$down resize grow height
$mod+control+$up resize shrink height
$mod+control+$right resize grow width
}
# workspace
bindsym --to-code {
$mod+tab workspace back_and_forth
$mod+q workspace $wsq
$mod+w workspace $wsw
$mod+e workspace $wse
$mod+r workspace $wsr
$mod+t workspace $wst
$mod+y workspace $wsy
$mod+u workspace $wsu
$mod+i workspace $wsi
$mod+o workspace $wso
$mod+p workspace $wsp
$mod+bracketleft workspace prev
$mod+bracketright workspace next
}
# client.* #####################################################################
# class border background text indicator child_border
client.focused $magenta $magenta $black $red $black
client.focused_inactive $blue $blue $black $black $black
client.unfocused $blue $blue $black $black $black
client.urgent $red $red $black $black $black
# default_border ###############################################################
default_border normal 0
# default_floating_border ######################################################
default_floating_border normal 0
# exec #########################################################################
exec {
systemctl --user import-environment DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP
hash dbus-update-activation-environment 2>/dev/null && \
dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP=sway
swayidle -w \
timeout 300 'brightnessctl -s set 1%' resume 'brightnessctl -r' \
timeout 600 '$swaylock' \
timeout 900 'swaymsg "output * power off"' resume 'swaymsg "output * power on"' \
timeout 1800 'systemctl suspend-then-hibernate' \
before-sleep '$swaylock'
wlsunset -l 45 -L 15
mako --max-visible=0
devmon --exec-on-drive 'notify-send "Mounted %f at %d"' --exec-on-unmount 'notify-send "Unmounted %f"'
foot -s
wayneko --layer overlay --type inu --background-colour 0xe2e2e2 --outline-colour 0x856cff
}
# focus_wrapping ###############################################################
focus_wrapping yes
# font #########################################################################
font monospace 13
# input ########################################################################
# keyboard
input "type:keyboard" {
xkb_layout us,si
xkb_options caps:escape,grp:alt_shift_toggle,compose:ralt
repeat_delay 200
repeat_rate 30
}
# touchpad
input "type:touchpad" tap enabled
# mode #########################################################################
# session
mode $session_mode {
bindsym {
r reload, mode default
l exec $swaylock, mode default
q exit, mode default
s exec systemctl suspend, mode default
h exec systemctl hibernate, mode default
b exec systemctl reboot, mode default
p exec systemctl poweroff, mode default
escape mode default
}
}
# layout
mode $layout_mode {
bindsym {
h layout splith, mode default
v layout splitv, mode default
s layout stacking, mode default
t layout tabbed, mode default
escape mode default
}
}
# seat #########################################################################
seat * hide_cursor 1000
# output #######################################################################
output * background $black solid_color

View File

@ -6,33 +6,43 @@ local P, S, B = lpeg.P, lpeg.S, lpeg.B
local lex = lexer.new(..., {no_user_word_lists = true})
local md = '.markdown'
local ws = lex:get_rule('whitespace')
local nl = P('\n')
local bl = nl * nl
local nws = lexer.any - lexer.space
-- Heading.
lex:add_rule('heading',
lex:tag(lexer.COMMENT, lexer.starts_line(P('#')^-6)) *
P(' ') *
lex:tag(lexer.HEADING, lexer.to_eol(lexer.any) * #P('\n\n')))
-- List.
lex:add_rule('list',
lex:tag(lexer.COMMENT, lexer.starts_line(P(S('-*') * ' ') + P('(@' * P(lexer.alnum + S('-_'))^0 * ')' + S(' \n')), true)))
lex:tag(lexer.HEADING, lexer.to_eol(nws) *
#bl))
-- Blockquote.
lex:add_rule('block_quote',
lex:add_rule('blockquote',
lex:tag(lexer.COMMENT,
lexer.starts_line(P('>' + P(' '))^1, true)))
lexer.starts_line(P('>' + P(' '))^1)))
-- Horizontal rule.
lex:add_rule('hr',
lex:tag(lexer.COMMENT, B('\n\n') * S('*-_')^3 * #P('\n\n')))
lex:tag(lexer.COMMENT, B(bl) * S('*-_')^3 * #bl))
-- Native div.
lex:add_rule("native_div",
lex:tag(lexer.COMMENT, lexer.starts_line(lexer.to_eol(P(':')^3))))
-- Code block.
lex:add_rule("block_code",
lex:tag(lexer.COMMENT,
lexer.starts_line('~~~' + P('```'))))
local code_line = lexer.starts_line(
(B(' ') + B('\t')) * lexer.to_eol(), true)
local code_block = lexer.range(lexer.starts_line('```', true), lexer.starts_line(P('```'))) +
lexer.range(lexer.starts_line('~~~', true), lexer.starts_line(P('~~~')))
local code_inline = lpeg.Cmt(lpeg.C(P('`')^1), function(input, index, bt)
local _, e = input:find('[^`]' .. bt .. '%f[^`]', index)
return (e or #input) + 1
end)
lex:add_rule('block_code', lex:tag(lexer.CODE, code_line + code_block))
-- Escape.
lex:add_rule('escape', lex:tag(lexer.DEFAULT, P('\\') * 1))
@ -77,7 +87,7 @@ local function flanked_range(s, not_inword)
local fl_char = lexer.any - s - lexer.space
local left_fl = B(punct_space - s) * s * #fl_char + s * #(fl_char - lexer.punct)
local right_fl = B(lexer.punct) * s * #(punct_space - s) + B(fl_char) * s
return left_fl * (lexer.any - P('\n\n') - (not_inword and s * #punct_space or s))^0 * right_fl
return left_fl * (lexer.any - bl - (not_inword and s * #punct_space or s))^0 * right_fl
end
local asterisk_strong = flanked_range('**')
@ -94,15 +104,15 @@ local html_start_rule = lexer.starts_line(P(' ')^-3) *
#P('<') *
html:get_rule('tag') +
html:get_rule('comment')
local html_end_rule = #P('\n\n') * lexer.space
local html_end_rule = #bl * ws
lex:embed(html, html_start_rule, html_end_rule)
-- Embedded YAML.
local yaml = lexer.load('yaml')
local doc_bounds_rule = yaml:get_rule('doc_bounds')
local hr_rule = lex:get_rule('hr')
local yaml_start_rule = doc_bounds_rule * P('\n') - hr_rule
local yaml_end_rule = doc_bounds_rule * P('\n') - hr_rule
local yaml_start_rule = doc_bounds_rule - hr_rule
local yaml_end_rule = doc_bounds_rule - hr_rule
lex:embed(yaml, yaml_start_rule, yaml_end_rule)
return lex

View File

@ -42,7 +42,7 @@ lexers.STYLE_CURSOR_LINE = 'underlined'
lexers.STYLE_COLOR_COLUMN = 'fore:black,back:blue'
lexers.STYLE_SELECTION = 'fore:black,back:white'
lexers.STYLE_STATUS = 'fore:blue'
lexers.STYLE_STATUS_FOCUSED = 'fore:magenta'
lexers.STYLE_STATUS_FOCUSED = 'fore:blue'
lexers.STYLE_SEPARATOR = 'fore:blue'
lexers.STYLE_INFO = 'fore:red'
lexers.STYLE_EOF = 'fore:blue'

View File

@ -15,10 +15,12 @@ local e = vis.events
-- init
e.subscribe(e.INIT, function()
-- load theme
require('themes/basic')
require("themes/basic")
local lexers = vis.lexers
lexers.lexers = {}
if lexers.load and not lexers.property then lexers.load("text") end
-- mappings
if os.getenv('WAYLAND_DISPLAY') then
vis:map(m.NORMAL, 'y', '<vis-register>+<vis-operator-yank>')
vis:map(m.VISUAL, 'y', '<vis-register>+<vis-operator-yank>')
vis:map(m.NORMAL, 'y', '<vis-register>+<vis-operator-yank>')
@ -31,50 +33,22 @@ e.subscribe(e.INIT, function()
vis:map(m.NORMAL, 'P', '<vis-register>+<vis-put-before>')
vis:map(m.VISUAL, 'P', '<vis-register>+<vis-put-before>')
vis:map(m.VISUAL_LINE, 'P', '<vis-register>+<vis-put-before>')
end
vis:map(m.NORMAL, 'f', '<vis-selections-save><vis-motion-to-right>')
vis:map(m.OPERATOR_PENDING, 'f', '<vis-motion-to-right>')
vis:map(m.VISUAL, 'f', '<vis-motion-to-right>')
vis:map(m.NORMAL, 'F', '<vis-selections-save><vis-motion-to-left>')
vis:map(m.OPERATOR_PENDING, 'F', '<vis-motion-to-left>')
vis:map(m.VISUAL, 'F', '<vis-motion-to-left>')
vis:map(m.NORMAL, 't', '<vis-selections-save><vis-motion-till-right>')
vis:map(m.OPERATOR_PENDING, 't', '<vis-motion-till-right>')
vis:map(m.VISUAL, 't', '<vis-motion-till-right>')
vis:map(m.NORMAL, 'T', '<vis-selections-save><vis-motion-till-left>')
vis:map(m.OPERATOR_PENDING, 'T', '<vis-motion-till-left>')
vis:map(m.VISUAL, 'T', '<vis-motion-till-left>')
vis:map(m.NORMAL, '?', '<vis-selections-save><vis-search-backward>')
vis:map(m.NORMAL, '/', '<vis-selections-save><vis-search-forward>')
vis:map(m.NORMAL, 'zz', '<vis-window-redraw-bottom><vis-window-redraw-center>') -- fixes a bug with `zz`
vis:map(m.NORMAL, ' w', function() vis:command('w') end)
vis:map(m.NORMAL, ' W', function() vis:command('w!') end)
vis:map(m.NORMAL, ' q', function() vis:command('q') end)
vis:map(m.NORMAL, ' Q', function() vis:command('q!') end)
vis:map(m.NORMAL, ' e', function()
local s, f = vis:pipe('find -name .git -prune -o -type f | vis-menu -l 5 -p "Edit file"')
if s ~= 0 or f == nil then return end
local s, f = vis:pipe('find -type f | vis-menu -l 5 -p "Edit file"')
if s ~= 0 or not f then return end
cmd = ('e "%s"'):format(f:sub(1, -2))
vis:info(cmd)
vis:command(cmd)
end, 'Edit file')
vis:map(m.NORMAL, ' o', function()
local s, f = vis:pipe('find -name .git -prune -o -type f | vis-menu -l 5 -p "Open file"')
if s ~= 0 or f == nil then return end
cmd = ('o "%s"'):format(f:sub(1, -2))
vis:info(cmd)
vis:command(cmd)
end, 'Open file')
vis:map(m.NORMAL, ' cd', function()
local s, f = vis:pipe('find -name .git -prune -o -type d | vis-menu -l 5 -p "Change directory"')
if s ~= 0 or f == nil then return end
local s, f = vis:pipe('find -type d | vis-menu -l 5 -p "Change directory"')
if s ~= 0 or not f then return end
cmd = ('cd "%s"'):format(f:sub(1, -2))
vis:info(cmd)
vis:command(cmd)
@ -90,10 +64,10 @@ e.subscribe(e.WIN_OPEN, function(win)
win.options.numbers = true
if win.syntax == 'markdown' then
win.options.breakat = ' ,]_'
win.options.breakat = " ,]_"
win.options.expandtab = true
win.options.tabwidth = 2
win.options.wrapcolumn = 80
win.options.wrapcolumn = 81
end
if win.syntax == 'css' then
@ -134,7 +108,7 @@ e.subscribe(e.WIN_STATUS, function(win)
-- character under cursor
table.insert(right_parts,
'<'
..(file:content(selection and selection.pos or 0, 1):byte() or 'nil')
..(string.byte(file:content(selection.pos, 1)) or '0')
..'>')
-- line and column count
@ -151,11 +125,10 @@ end)
-- set title
local modified = false
local function set_title(name)
os.execute(('printf "\\e];%s%s\\e"'):format(name, modified and '[+]' or ''))
local function set_title(title)
os.execute('printf "\\e];'..title..(modified and '[+]' or '')..'\\e"')
end
if os.getenv('TERM') ~= 'linux' then
e.subscribe(e.WIN_OPEN, function(win)
set_title(win.file.name or '[No Name]')
end)
@ -171,60 +144,3 @@ if os.getenv('TERM') ~= 'linux' then
set_title(win.file.name or '[No Name]')
end
end)
end
-- cursor position
local cursors_path = os.getenv('XDG_CACHE_HOME')..'/vis-cursors'
local cursors = {}
local files = {}
local function get_cursors()
local f = io.open(cursors_path)
if f == nil then return end
files = {}
for l in f:lines() do
local path, pos = l:match('(.+):(%d+)')
cursors[path] = pos
table.insert(files, path)
end
f:close()
end
e.subscribe(e.INIT, get_cursors)
e.subscribe(e.WIN_OPEN, function(win)
if win.file == nil or win.file.path == nil then return end
if win.file.path:match('%.git/COMMIT_EDITMSG$') then return end
if win.file.path:match('^/tmp/') then return end
local pos = cursors[win.file.path]
if pos == nil then
cursors[win.file.path] = win.selection.pos
return
end
win.selection.pos = tonumber(pos)
vis:feedkeys('zz')
end)
e.subscribe(e.WIN_CLOSE, function(win)
if win.file == nil or win.file.path == nil then return end
get_cursors()
for i, path in ipairs(files) do
if path == win.file.path then table.remove(files, i) end
end
if win.selection.pos == 0 then return end
table.insert(files, 1, win.file.path)
cursors[win.file.path] = win.selection.pos
end)
e.subscribe(e.QUIT, function()
local f = io.open(cursors_path, 'w+')
if f == nil then return end
local buf = {}
for i, path in ipairs(files) do
table.insert(buf, ('%s:%d'):format(path, cursors[path]))
if i > 100 then break end -- remember only 100
end
local out = table.concat(buf, '\n')
f:write(out)
f:close()
end)

View File

@ -23,6 +23,6 @@ while :; do
swaymsg -t get_tree | jq -cj 'recurse(.nodes[]) | select(.name=="__i3_scratch").floating_nodes | {"full_text":length,"urgent":length}, ","'
printf "],"
# timeout
timeout 0.9 swaymsg -qt subscribe '["binding"]' >/dev/null
timeout 1 swaymsg -qt subscribe '["binding"]' >/dev/null
sleep 0.1
done

View File

@ -0,0 +1,17 @@
#!/bin/sh
case "$(file -i "$1" 2>/dev/null)" in
*": text/"* | *": application/javascript"*)
DIRPATH="$(dirname "$1")"
while :; do
[ "$DIRPATH" = "/" ] && DIRPATH=$HOME
[ "$DIRPATH" = "$HOME" ] || [ -n "$(find "$DIRPATH" ! -path "$DIRPATH" -prune -type d -name .git)" ] && break
DIRPATH="$(dirname "$DIRPATH")"
done
exec $TERMINAL -D "$DIRPATH" "$EDITOR" "$1"
;;
*": inode/directory;"*)
exec $TERMINAL -D "$1"
;;
*) exec /usr/bin/xdg-open "$1" ;;
esac

View File

@ -1,5 +1,5 @@
[Desktop Entry]
Type=Application
Exec=-T "NetworkManager TUI" nmtui
Name=NetworkManager TUI
Exec=-Tnmtui nmtui
Name=nmtui
Terminal=true