aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYaroslav de la Peña Smirnov <yps@yaroslavps.com>2021-01-21 23:29:58 +0300
committerYaroslav de la Peña Smirnov <yps@yaroslavps.com>2021-01-21 23:29:58 +0300
commite4672d66a9302f557ce26b0a418746deffe0decc (patch)
treefe1e226c629061411c9fe8de7d16e861deaff223
parent64d645f2bd1d18aeefdde07621a1a4d1e07cb1cd (diff)
downloadswayrice-e4672d66a9302f557ce26b0a418746deffe0decc.tar.gz
swayrice-e4672d66a9302f557ce26b0a418746deffe0decc.zip
Friendship ended with ranger, again. lf it is now
Too many changes made, basically all of them related to lf. Sorry ranger. You're too slow 🦔.
-rwxr-xr-xartix.sh7
-rw-r--r--dotfiles/.config/lf/icons84
-rw-r--r--dotfiles/.config/lf/lfrc92
-rw-r--r--dotfiles/.config/sway/config3
-rwxr-xr-xdotfiles/.config/sxiv/exec/key-handler4
-rw-r--r--dotfiles/.config/zsh/shortcuts22
-rwxr-xr-xdotfiles/.local/bin/scope60
-rw-r--r--dotfiles/.profile2
8 files changed, 265 insertions, 9 deletions
diff --git a/artix.sh b/artix.sh
index 17262e9..968388e 100755
--- a/artix.sh
+++ b/artix.sh
@@ -18,10 +18,10 @@ pacman -Sy --noconfirm zsh zsh-syntax-highlighting openresolv wireguard-tools \
noto-fonts-cjk noto-fonts-emoji ttf-joypixels otf-latin-modern \
otf-latinmodern-math powerline-fonts python-pygit2 polkit polkit-gnome \
zathura zathura-pdf-mupdf zathura-djvu gst-libav vifm blueman bluez \
- bluez-runit acpilight accountsservice lightdm xdg-user-dirs abook ranger \
+ bluez-runit acpilight accountsservice lightdm xdg-user-dirs abook \
terminus-font qutebrowser jq stow wdiff texlive-most units isync notmuch \
pass translate-shell gnome-keyring pacman-contrib linux-headers \
- v4l2loopback-dkms
+ v4l2loopback-dkms highlight mediainfo
# Copy system config files
cp system/sudoers /etc/
@@ -39,7 +39,8 @@ chown -R "$1:$1" build
cd build
sudo -u "$1" "git clone https://aur.archlinux.org/yay.git && cd yay && makepkg -si"
-yay -S --noconfirm aerc-git ttf-symbola ttf-ms-fonts pam-gnupg ncpamixer mimeo xdg-utils-mimeo cli-visualizer
+yay -S --noconfirm aerc-git ttf-symbola ttf-ms-fonts pam-gnupg ncpamixer mimeo \
+ xdg-utils-mimeo cli-visualizer lf dragon-drag-and-drop
# Copy some fonts to make them available system-wide
mkdir -p /usr/share/fonts/rice
diff --git a/dotfiles/.config/lf/icons b/dotfiles/.config/lf/icons
new file mode 100644
index 0000000..776e078
--- /dev/null
+++ b/dotfiles/.config/lf/icons
@@ -0,0 +1,84 @@
+export LF_ICONS="di=📁:\
+fi=📃:\
+tw=🤝:\
+ow=📂:\
+ln=⛓:\
+or=❌:\
+ex=🏎:\
+*.txt=📜:\
+*.mom=📜:\
+*.me=📜:\
+*.ms=📜:\
+*.png=🖼:\
+*.webp=🖼:\
+*.ico=🖼:\
+*.jpg=🖼:\
+*.jpe=🖼:\
+*.jpeg=🖼:\
+*.gif=🖼:\
+*.svg=🖊:\
+*.tif=🖼:\
+*.tiff=🖼:\
+*.nef=📷:\
+*.xcf=🖌:\
+*.html=🌎:\
+*.url=🌎:\
+*.xml=📰:\
+*.gpg=🔒:\
+*.css=🎨:\
+*.pdf=📖:\
+*.djvu=📖:\
+*.epub=📖:\
+*.csv=📓:\
+*.xlsx=📓:\
+*.tex=📘:\
+*.md=📘:\
+*.r=📊:\
+*.R=📊:\
+*.rmd=📊:\
+*.Rmd=📊:\
+*.m=📊:\
+*.mp3=🎵:\
+*.opus=🎵:\
+*.ogg=🎵:\
+*.m4a=🎵:\
+*.flac=🎵:\
+*.wav=🎵:\
+*.mod=🎵:\
+*.xm=🎵:\
+*.mkv=🎥:\
+*.mp4=🎥:\
+*.webm=🎥:\
+*.mpeg=🎥:\
+*.avi=🎥:\
+*.mov=🎥:\
+*.mpg=🎥:\
+*.wmv=🎥:\
+*.m4b=🎥:\
+*.flv=🎥:\
+*.zip=📦:\
+*.rar=📦:\
+*.7z=📦:\
+*.tar.gz=📦:\
+*.apk=📦:\
+*.z64=🎮:\
+*.v64=🎮:\
+*.n64=🎮:\
+*.gba=🎮:\
+*.nes=🎮:\
+*.gdi=🎮:\
+*.gcm=🎮:\
+*.1=ℹ:\
+*.nfo=ℹ:\
+*.info=ℹ:\
+*.log=📙:\
+*.iso=📀:\
+*.img=📀:\
+*.qcow2=📀:\
+*.bib=📚:\
+*.ged=👪:\
+*.part=💔:\
+*.torrent=🔽:\
+*.jar=♨:\
+*.java=♨:\
+"
diff --git a/dotfiles/.config/lf/lfrc b/dotfiles/.config/lf/lfrc
new file mode 100644
index 0000000..4c2a3ba
--- /dev/null
+++ b/dotfiles/.config/lf/lfrc
@@ -0,0 +1,92 @@
+# Personal lf conf
+# Inspired by the official example conf and Luke Smith's voidrice's
+
+set icons
+set scrolloff 10
+set ratios 1:4:3
+set period 1
+set ifs "\n"
+set info size
+set previewer ~/.local/bin/scope
+
+# Custom commands
+
+cmd on-cd &{{
+ # '&' commands run silently in background (which is what we want here),
+ # but are not connected to stdout.
+ # To make sure our escape sequence still reaches stdout we pipe it to /dev/tty
+ printf "\033]0; lf - $PWD\007" > /dev/tty
+}}
+
+on-cd
+
+cmd mkdir $mkdir -p "$(echo $* | tr ' ' '\ ')"
+
+cmd delete ${{
+ clear; tput cup $(($(tput lines)/3)); tput bold
+ set -f
+ printf "%s\n\t" "$fx"
+ printf "delete?[y/N]"
+ read ans
+ [ $ans = "y" ] && rm -rf -- $fx
+}}
+
+# compress current file or selected files with tar and gunzip
+cmd tar ${{
+ set -f
+ mkdir $1
+ cp -r $fx $1
+ tar -czf $1.tar.gz $1
+ rm -rf $1
+}}
+
+# extract the current file with the right command
+# (xkcd link: https://xkcd.com/1168/)
+cmd extract ${{
+ set -f
+ case $f in
+ *.tar.bz|*.tar.bz2|*.tbz|*.tbz2) tar xjvf $f;;
+ *.tar.gz|*.tgz) tar xzvf $f;;
+ *.tar.xz|*.txz) tar xJvf $f;;
+ *.zip) unzip $f;;
+ *.rar) unrar x $f;;
+ *.7z) 7z x $f;;
+ esac
+}}
+
+# change dir with fzf
+cmd fzf_jump ${{
+ res="$(find . -type d | fzf --header='Jump to location')"
+ if [ -d "$res" ]; then
+ cmd="cd"
+ else
+ cmd="select"
+ fi
+ lf -remote "send $id $cmd \"$res\""
+}}
+
+# drag and drop prompt
+cmd dragon $dragon-drag-and-drop -a $fx
+
+# copy path to clipboard
+cmd yank-path &printf '%s' "$fx" | wl-copy
+
+# Bindings
+map A rename
+map c
+map cc clear
+map cd push :cd<space>
+map cw push A<c-u> # rename from zero
+map I push A<c-a> # rename from the beginning
+map i push A<a-b><a-b><a-f> # rename before extention
+map a push A<a-b> # rename after extention
+map <c-n> push :mkdir<space>
+map <c-r> reload
+map <enter> shell
+map D delete
+map <enter> shell
+map f :fzf_jump
+map t :dragon
+map W $setsid $TERMINAL & # open new terminal window
+map Y :yank-path
+map L $LESSOPEN='| ~/.local/bin/scope %s' less -R $f # open file preview in pager
diff --git a/dotfiles/.config/sway/config b/dotfiles/.config/sway/config
index 74d1272..675afc7 100644
--- a/dotfiles/.config/sway/config
+++ b/dotfiles/.config/sway/config
@@ -121,7 +121,7 @@ input 6127:24647:Lenovo_ThinkPad_Compact_USB_Keyboard_with_TrackPoint {
# Desktop mouse
input 1118:2083:Microsoft_Microsoft___Classic_IntelliMouse__ {
accel_profile flat
- pointer_accel 0.5
+ pointer_accel 0
}
# Default wallpaper
@@ -177,7 +177,6 @@ bindsym --to-code {
$mod+F4 exec menublk
$mod+F10 exec chcolors
$mod+F12 exec menutz
- $mod+r exec $term -t "ranger" -e ranger
$mod+t exec --no-startup-id toggletorrent
$mod+Ctrl+t exec --no-startup-id launch-transmission
$mod+s exec "xway steam"
diff --git a/dotfiles/.config/sxiv/exec/key-handler b/dotfiles/.config/sxiv/exec/key-handler
index d9bad9f..17abf60 100755
--- a/dotfiles/.config/sxiv/exec/key-handler
+++ b/dotfiles/.config/sxiv/exec/key-handler
@@ -35,9 +35,9 @@ while read file; do
dir="$(dirname "$file")"
name="$(basename "$file")"
base="${name%.*}"
- mv "$file" ~/etc/temp/trash/
+ mv "$file" ~/.local/trash/
if [ "JPEG" = "$(basename $dir)" ]; then
- mv $(dirname "$dir")/"$base".NEF ~/etc/temp/trash/
+ mv $(dirname "$dir")/"$base".NEF ~/.local/trash/
fi
exit ;;
"C-comma") rotate 270 $file ;;
diff --git a/dotfiles/.config/zsh/shortcuts b/dotfiles/.config/zsh/shortcuts
index 67f9652..a5c414a 100644
--- a/dotfiles/.config/zsh/shortcuts
+++ b/dotfiles/.config/zsh/shortcuts
@@ -10,6 +10,7 @@ alias units="units -H ''"
alias trans="trans -v -pager='less -R'"
alias lsdp="swaymsg -pt get_outputs | less"
alias op="xdg-open"
+alias drag="dragon-drag-and-drop"
corona() { curl -s https://corona-stats.online/$1 ;} # It's corona time
wintitle() { printf "\033]2;%s\a" "$1";}
sass-watch() {
@@ -32,8 +33,25 @@ alias spw="setsid $TERMINAL >/dev/null 2>&1 &"
alias testinet="ping -c2 example.com"
# Fuzzy finder
-alias fzd='cd "$(find * -type d | fzf || echo ".")"'
-alias fzv='nvim $(find * -type f | fzf)'
+alias fzd='cd "$(find . -type d | fzf || echo ".")"'
+alias fzv='nvim $(find . -type f | fzf)'
+alias fzo='op $(find . -type f | fzf)'
+
+# Function for changing working dir after exiting lf
+lfcd () {
+ tmp="$(mktemp)"
+ lf -last-dir-path="$tmp" "$@"
+ if [ -f "$tmp" ]; then
+ dir="$(cat "$tmp")"
+ rm -f "$tmp"
+ if [ -d "$dir" ]; then
+ if [ "$dir" != "$(pwd)" ]; then
+ cd "$dir"
+ fi
+ fi
+ fi
+}
+bindkey -s '^o' 'lfcd\n'
# Mounting drive shortcuts
alias mnt="udisksctl mount -b"
diff --git a/dotfiles/.local/bin/scope b/dotfiles/.local/bin/scope
new file mode 100755
index 0000000..3f19948
--- /dev/null
+++ b/dotfiles/.local/bin/scope
@@ -0,0 +1,60 @@
+#!/bin/bash
+
+set -C -f -u
+#IFS=$'\n'
+IFS="$(printf '%b_' '\n')"; IFS="${IFS%_}"
+
+# ANSI color codes are supported.
+# STDIN is disabled, so interactive scripts won't work properly
+
+# This script is considered a configuration file and must be updated manually.
+
+# Meanings of exit codes:
+# code | meaning | action of ranger
+# -----+------------+-------------------------------------------
+# 0 | success | Display stdout as preview
+# 1 | no preview | Display no preview at all
+# 2 | plain text | Display the plain content of the file
+
+# Script arguments
+FILE_PATH="${1}" # Full path of the highlighted file
+#HEIGHT="${2}"
+
+#FILE_EXTENSION="${FILE_PATH##*.}"
+#FILE_EXTENSION_LOWER=$(echo ${FILE_EXTENSION} | tr '[:upper:]' '[:lower:]')
+
+# Settings
+HIGHLIGHT_SIZE_MAX=262143 # 256KiB
+HIGHLIGHT_TABWIDTH=8
+HIGHLIGHT_STYLE='pablo'
+
+
+handle_mime() {
+ local mimetype="${1}"
+ case "${mimetype}" in
+ text/html) w3m -dump "${FILE_PATH}" ;;
+ text/troff) man ./ "${FILE_PATH}" | col -b ;;
+ text/* | */xml)
+ if [ "$( stat --printf='%s' -- "${FILE_PATH}" )" -gt "${HIGHLIGHT_SIZE_MAX}" ]; then
+ exit 2
+ fi
+ if [ "$( tput colors )" -ge 256 ]; then
+ local highlight_format='xterm256'
+ else
+ local highlight_format='ansi'
+ fi
+ highlight --replace-tabs="${HIGHLIGHT_TABWIDTH}" --out-format="${highlight_format}" \
+ --style="${HIGHLIGHT_STYLE}" --force -- "${FILE_PATH}" ;;
+ application/zip) unzip -l -- "${FILE_PATH}" ;;
+ application/gzip) tar -ztf "${FILE_PATH}" ;;
+ application/x-rar) unrar lb -- "${FILE_PATH}" ;;
+ video/* | audio/*|application/octet-stream | image/*) mediainfo "${FILE_PATH}" | awk -F':' '{ print $2 }' || exit 1;;
+ */pdf) pdftotext -l 10 -nopgbrk -q -- "${FILE_PATH}" - ;;
+ *opendocument*) odt2txt "${FILE_PATH}" ;;
+ *) file -b "${FILE_PATH}" ;;
+ esac
+}
+
+MIMETYPE="$( file --dereference --brief --mime-type -- "${FILE_PATH}" )"
+handle_mime "${MIMETYPE}"
+exit 1
diff --git a/dotfiles/.profile b/dotfiles/.profile
index 34d7b73..0c34ff9 100644
--- a/dotfiles/.profile
+++ b/dotfiles/.profile
@@ -34,6 +34,8 @@ export GTK2_RC_FILES="$XDG_CONFIG_HOME/gtk-2.0/gtkrc-2.0"
export GOPATH="$XDG_DATA_HOME/go"
eval "$(dircolors "$HOME/.config/dir_colors")"
+. "$HOME/.config/lf/icons"
+
# Start sway automatically upon login on tty1 or tty2
if [ -z $DISPLAY ] && [ $(tty) = /dev/tty1 ] || [ $(tty) = /dev/tty2 ]; then
# DBUS variables (for Artix)