mirror of
https://github.com/Mastermindzh/dotfiles.git
synced 2024-11-22 06:44:41 +01:00
set up ranger and 'fixed' ls command
This commit is contained in:
parent
a70b7b18a6
commit
907a00cac2
@ -70,7 +70,7 @@ alias cmyip='curl -s http://ipecho.net/plain; echo'
|
|||||||
## default command fixes :P
|
## default command fixes :P
|
||||||
alias mkdir='mkdir -p'
|
alias mkdir='mkdir -p'
|
||||||
alias wget='wget -c'
|
alias wget='wget -c'
|
||||||
alias ls='ls --color=auto'
|
alias ls='ls -l --color=auto'
|
||||||
alias installed='sudo pacman -Qetq'
|
alias installed='sudo pacman -Qetq'
|
||||||
alias aurinstalled='sudo pacman -Qmq'
|
alias aurinstalled='sudo pacman -Qmq'
|
||||||
alias sudo='sudo '
|
alias sudo='sudo '
|
||||||
|
32
config/ranger/rc.conf
Normal file
32
config/ranger/rc.conf
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
set preview_images true
|
||||||
|
set confirm_on_delete true
|
||||||
|
set column_ratios 1,3,4
|
||||||
|
set viewmode miller
|
||||||
|
set unicode_ellipsis true
|
||||||
|
|
||||||
|
set preview_files true
|
||||||
|
set preview_directories true
|
||||||
|
set collapse_preview true
|
||||||
|
|
||||||
|
# git stuff
|
||||||
|
set vcs_aware false
|
||||||
|
set vcs_backend_git enabled
|
||||||
|
|
||||||
|
# Which files should be hidden? (regular expression)
|
||||||
|
set hidden_filter ^\.|\.(?:pyc|pyo|bak|swp)$|^lost\+found$|^__(py)?cache__$
|
||||||
|
|
||||||
|
# Show hidden files? You can toggle this by typing 'zh'
|
||||||
|
set show_hidden false
|
||||||
|
|
||||||
|
# Draw borders around columns? (separators, outline, both, or none)
|
||||||
|
# Separators are vertical lines between columns.
|
||||||
|
# Outline draws a box around all the columns.
|
||||||
|
# Both combines the two.
|
||||||
|
set draw_borders both
|
||||||
|
|
||||||
|
# KEY config
|
||||||
|
map <delete> delete
|
||||||
|
map <esc> quit
|
||||||
|
map <C-c> copy
|
||||||
|
map <C-x> cut
|
||||||
|
map <C-v> paste
|
84
config/ranger/rifle.conf
Normal file
84
config/ranger/rifle.conf
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
# vim: ft=cfg
|
||||||
|
#
|
||||||
|
# This is the configuration file of "rifle", ranger's file executor/opener.
|
||||||
|
# Each line consists of conditions and a command. For each line the conditions
|
||||||
|
# are checked and if they are met, the respective command is run.
|
||||||
|
#
|
||||||
|
# Syntax:
|
||||||
|
# <condition1> , <condition2> , ... = command
|
||||||
|
#
|
||||||
|
# The command can contain these environment variables:
|
||||||
|
# $1-$9 | The n-th selected file
|
||||||
|
# $@ | All selected files
|
||||||
|
#
|
||||||
|
# If you use the special command "ask", rifle will ask you what program to run.
|
||||||
|
#
|
||||||
|
# Prefixing a condition with "!" will negate its result.
|
||||||
|
# These conditions are currently supported:
|
||||||
|
# match <regexp> | The regexp matches $1
|
||||||
|
# ext <regexp> | The regexp matches the extension of $1
|
||||||
|
# mime <regexp> | The regexp matches the mime type of $1
|
||||||
|
# name <regexp> | The regexp matches the basename of $1
|
||||||
|
# path <regexp> | The regexp matches the absolute path of $1
|
||||||
|
# has <program> | The program is installed (i.e. located in $PATH)
|
||||||
|
# env <variable> | The environment variable "variable" is non-empty
|
||||||
|
# file | $1 is a file
|
||||||
|
# directory | $1 is a directory
|
||||||
|
# number <n> | change the number of this command to n
|
||||||
|
# terminal | stdin, stderr and stdout are connected to a terminal
|
||||||
|
# X | $DISPLAY is not empty (i.e. Xorg runs)
|
||||||
|
#
|
||||||
|
# There are also pseudo-conditions which have a "side effect":
|
||||||
|
# flag <flags> | Change how the program is run. See below.
|
||||||
|
# label <label> | Assign a label or name to the command so it can
|
||||||
|
# | be started with :open_with <label> in ranger
|
||||||
|
# | or `rifle -p <label>` in the standalone executable.
|
||||||
|
# else | Always true.
|
||||||
|
#
|
||||||
|
# Flags are single characters which slightly transform the command:
|
||||||
|
# f | Fork the program, make it run in the background.
|
||||||
|
# | New command = setsid $command >& /dev/null &
|
||||||
|
# r | Execute the command with root permissions
|
||||||
|
# | New command = sudo $command
|
||||||
|
# t | Run the program in a new terminal. If $TERMCMD is not defined,
|
||||||
|
# | rifle will attempt to extract it from $TERM.
|
||||||
|
# | New command = $TERMCMD -e $command
|
||||||
|
# Note: The "New command" serves only as an illustration, the exact
|
||||||
|
# implementation may differ.
|
||||||
|
# Note: When using rifle in ranger, there is an additional flag "c" for
|
||||||
|
# only running the current file even if you have marked multiple files.
|
||||||
|
|
||||||
|
#-------------------------------------------
|
||||||
|
# Websites
|
||||||
|
#-------------------------------------------
|
||||||
|
ext x?html?, has chromium-browser, X, flag f = chromium-browser -- "$@"
|
||||||
|
ext x?html?, has chromium, X, flag f = chromium -- "$@"
|
||||||
|
|
||||||
|
#--------------------------------------------
|
||||||
|
# Video/Audio with a GUI
|
||||||
|
#-------------------------------------------
|
||||||
|
mime ^video, has mpv, X, flag f = mpv -- "$@"
|
||||||
|
mime ^video|audio, has vlc, X, flag f = vlc -- "$@"
|
||||||
|
|
||||||
|
#-------------------------------------------
|
||||||
|
# Documents
|
||||||
|
#-------------------------------------------
|
||||||
|
ext pdf, has evince, X, flag f = evince -- "$@"
|
||||||
|
ext pdf, has mupdf, X, flag f = mupdf "$@"
|
||||||
|
|
||||||
|
ext pptx?|od[dfgpst]|docx?|sxc|xlsx?|xlt|xlw|gnm|gnumeric, has libreoffice, X, flag f = libreoffice "$@"
|
||||||
|
|
||||||
|
#-------------------------------------------
|
||||||
|
# Image Viewing:
|
||||||
|
#-------------------------------------------
|
||||||
|
mime ^image, has eog, X, flag f = eog -- "$@"
|
||||||
|
mime ^image/svg, has inkscape, X, flag f = inkscape -- "$@"
|
||||||
|
mime ^image, has gimp, X, flag f = gimp -- "$@"
|
||||||
|
|
||||||
|
#-------------------------------------------
|
||||||
|
# Text files
|
||||||
|
#-------------------------------------------
|
||||||
|
ext xml|json|csv|tex|py|pl|rb|js|sh|php|md|ovpn = nano -- "$@"
|
||||||
|
|
||||||
|
# The very last action, so that it's never triggered accidentally, is to execute a program:
|
||||||
|
mime application/x-executable = "$1"
|
159
config/ranger/scope.sh
Executable file
159
config/ranger/scope.sh
Executable file
@ -0,0 +1,159 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -o noclobber -o noglob -o nounset -o pipefail
|
||||||
|
IFS=$'\n'
|
||||||
|
|
||||||
|
## If the option `use_preview_script` is set to `true`,
|
||||||
|
## then this script will be called and its output will be displayed in ranger.
|
||||||
|
## 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
|
||||||
|
## 3 | fix width | Don't reload when width changes
|
||||||
|
## 4 | fix height | Don't reload when height changes
|
||||||
|
## 5 | fix both | Don't ever reload
|
||||||
|
## 6 | image | Display the image `$IMAGE_CACHE_PATH` points to as an image preview
|
||||||
|
## 7 | image | Display the file directly as an image
|
||||||
|
|
||||||
|
## Script arguments
|
||||||
|
FILE_PATH="${1}" # Full path of the highlighted file
|
||||||
|
PV_WIDTH="${2}" # Width of the preview pane (number of fitting characters)
|
||||||
|
PV_HEIGHT="${3}" # Height of the preview pane (number of fitting characters)
|
||||||
|
IMAGE_CACHE_PATH="${4}" # Full path that should be used to cache image preview
|
||||||
|
PV_IMAGE_ENABLED="${5}" # 'True' if image previews are enabled, 'False' otherwise.
|
||||||
|
|
||||||
|
FILE_EXTENSION="${FILE_PATH##*.}"
|
||||||
|
FILE_EXTENSION_LOWER="$(printf "%s" "${FILE_EXTENSION}" | tr '[:upper:]' '[:lower:]')"
|
||||||
|
|
||||||
|
## Settings
|
||||||
|
HIGHLIGHT_SIZE_MAX=262143 # 256KiB
|
||||||
|
HIGHLIGHT_TABWIDTH=${HIGHLIGHT_TABWIDTH:-8}
|
||||||
|
HIGHLIGHT_STYLE=${HIGHLIGHT_STYLE:-pablo}
|
||||||
|
HIGHLIGHT_OPTIONS="--replace-tabs=${HIGHLIGHT_TABWIDTH} --style=${HIGHLIGHT_STYLE} ${HIGHLIGHT_OPTIONS:-}"
|
||||||
|
PYGMENTIZE_STYLE=${PYGMENTIZE_STYLE:-autumn}
|
||||||
|
|
||||||
|
handle_extension() {
|
||||||
|
case "${FILE_EXTENSION_LOWER}" in
|
||||||
|
# ## Archive
|
||||||
|
# a|ace|alz|arc|arj|bz|bz2|cab|cpio|deb|gz|jar|lha|lz|lzh|lzma|lzo|\
|
||||||
|
# rpm|rz|t7z|tar|tbz|tbz2|tgz|tlz|txz|tZ|tzo|war|xpi|xz|Z|zip)
|
||||||
|
# atool --list -- "${FILE_PATH}" && exit 5
|
||||||
|
# bsdtar --list --file "${FILE_PATH}" && exit 5
|
||||||
|
# exit 1;;
|
||||||
|
# rar)
|
||||||
|
# ## Avoid password prompt by providing empty password
|
||||||
|
# unrar lt -p- -- "${FILE_PATH}" && exit 5
|
||||||
|
# exit 1;;
|
||||||
|
# 7z)
|
||||||
|
# ## Avoid password prompt by providing empty password
|
||||||
|
# 7z l -p -- "${FILE_PATH}" && exit 5
|
||||||
|
# exit 1;;
|
||||||
|
|
||||||
|
## PDF
|
||||||
|
pdf)
|
||||||
|
## Preview as text conversion
|
||||||
|
pdftotext -l 10 -nopgbrk -q -- "${FILE_PATH}" - | fmt -w "${PV_WIDTH}" && exit 5
|
||||||
|
mutool draw -F txt -i -- "${FILE_PATH}" 1-10 | fmt -w "${PV_WIDTH}" && exit 5
|
||||||
|
exiftool "${FILE_PATH}" && exit 5
|
||||||
|
exit 1;;
|
||||||
|
|
||||||
|
## OpenDocument
|
||||||
|
odt|ods|odp|sxw)
|
||||||
|
## Preview as text conversion
|
||||||
|
odt2txt "${FILE_PATH}" && exit 5
|
||||||
|
exit 1;;
|
||||||
|
|
||||||
|
## HTML
|
||||||
|
htm|html|xhtml)
|
||||||
|
## Preview as text conversion
|
||||||
|
w3m -dump "${FILE_PATH}" && exit 5
|
||||||
|
;; # Continue with next handler on failure
|
||||||
|
## JSON
|
||||||
|
json)
|
||||||
|
jq --color-output . "${FILE_PATH}" && exit 5
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
handle_image() {
|
||||||
|
## Size of the preview if there are multiple options or it has to be
|
||||||
|
## rendered from vector graphics. If the conversion program allows
|
||||||
|
## specifying only one dimension while keeping the aspect ratio, the width
|
||||||
|
## will be used.
|
||||||
|
local DEFAULT_SIZE="1920x1080"
|
||||||
|
|
||||||
|
local mimetype="${1}"
|
||||||
|
case "${mimetype}" in
|
||||||
|
## Image
|
||||||
|
image/*)
|
||||||
|
local orientation
|
||||||
|
orientation="$( identify -format '%[EXIF:Orientation]\n' -- "${FILE_PATH}" )"
|
||||||
|
## If orientation data is present and the image actually
|
||||||
|
## needs rotating ("1" means no rotation)...
|
||||||
|
if [[ -n "$orientation" && "$orientation" != 1 ]]; then
|
||||||
|
## ...auto-rotate the image according to the EXIF data.
|
||||||
|
convert -- "${FILE_PATH}" -auto-orient "${IMAGE_CACHE_PATH}" && exit 6
|
||||||
|
fi
|
||||||
|
|
||||||
|
## `w3mimgdisplay` will be called for all images (unless overriden
|
||||||
|
## as above), but might fail for unsupported types.
|
||||||
|
exit 7;;
|
||||||
|
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
handle_mime() {
|
||||||
|
local mimetype="${1}"
|
||||||
|
case "${mimetype}" in
|
||||||
|
## Text
|
||||||
|
text/* | */xml)
|
||||||
|
## Syntax highlight
|
||||||
|
if [[ "$( stat --printf='%s' -- "${FILE_PATH}" )" -gt "${HIGHLIGHT_SIZE_MAX}" ]]; then
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
if [[ "$( tput colors )" -ge 256 ]]; then
|
||||||
|
local pygmentize_format='terminal256'
|
||||||
|
local highlight_format='xterm256'
|
||||||
|
else
|
||||||
|
local pygmentize_format='terminal'
|
||||||
|
local highlight_format='ansi'
|
||||||
|
fi
|
||||||
|
env HIGHLIGHT_OPTIONS="${HIGHLIGHT_OPTIONS}" highlight \
|
||||||
|
--out-format="${highlight_format}" \
|
||||||
|
--force -- "${FILE_PATH}" && exit 5
|
||||||
|
pygmentize -f "${pygmentize_format}" -O "style=${PYGMENTIZE_STYLE}"\
|
||||||
|
-- "${FILE_PATH}" && exit 5
|
||||||
|
exit 2;;
|
||||||
|
|
||||||
|
## Image
|
||||||
|
image/*)
|
||||||
|
## Preview as text conversion
|
||||||
|
# img2txt --gamma=0.6 --width="${PV_WIDTH}" -- "${FILE_PATH}" && exit 4
|
||||||
|
exiftool "${FILE_PATH}" && exit 5
|
||||||
|
exit 1;;
|
||||||
|
|
||||||
|
## Video and audio
|
||||||
|
video/* | audio/*)
|
||||||
|
mediainfo "${FILE_PATH}" && exit 5
|
||||||
|
exiftool "${FILE_PATH}" && exit 5
|
||||||
|
exit 1;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
handle_fallback() {
|
||||||
|
echo '----- File Type Classification -----' && file --dereference --brief -- "${FILE_PATH}" && exit 5
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
MIMETYPE="$( file --dereference --brief --mime-type -- "${FILE_PATH}" )"
|
||||||
|
if [[ "${PV_IMAGE_ENABLED}" == 'True' ]]; then
|
||||||
|
handle_image "${MIMETYPE}"
|
||||||
|
fi
|
||||||
|
handle_extension
|
||||||
|
handle_mime "${MIMETYPE}"
|
||||||
|
handle_fallback
|
||||||
|
|
||||||
|
exit 1
|
@ -30,3 +30,8 @@ ScrollingUnlimited=TRUE
|
|||||||
ScrollingBar=TERMINAL_SCROLLBAR_NONE
|
ScrollingBar=TERMINAL_SCROLLBAR_NONE
|
||||||
MiscShowRelaunchDialog=TRUE
|
MiscShowRelaunchDialog=TRUE
|
||||||
|
|
||||||
|
ColorCursor=#c5c5c8c8c6c6
|
||||||
|
ColorForeground=#c5c5c8c8c6c6
|
||||||
|
ColorBackground=#000000
|
||||||
|
ColorPalette=#28282a2a2e2e;#a5a542424242;#8c8c94944040;#dede93935f5f;#5f5f81819d9d;#858567678f8f;#5e5e8d8d8787;#707078788080;#37373b3b4141;#cccc66666666;#b5b5bdbd6868;#f0f0c6c67474;#8181a2a2bebe;#b2b29494bbbb;#8a8abebeb7b7;#c5c5c8c8c6c6
|
||||||
|
|
||||||
|
2
dependencies/pacman.txt
vendored
2
dependencies/pacman.txt
vendored
@ -67,3 +67,5 @@ flameshot
|
|||||||
otf-font-awesome
|
otf-font-awesome
|
||||||
openvpn
|
openvpn
|
||||||
networkmanager-openvpn
|
networkmanager-openvpn
|
||||||
|
ranger
|
||||||
|
w3m
|
@ -119,7 +119,7 @@ bindsym $mod+shift+l exec /bin/bash ~/.config/i3/scripts/suspend.sh
|
|||||||
# Application Keys #
|
# Application Keys #
|
||||||
############################################
|
############################################
|
||||||
bindsym $mod+Return exec xfce4-terminal # terminal
|
bindsym $mod+Return exec xfce4-terminal # terminal
|
||||||
bindsym $mod+e exec nautilus # File manager
|
bindsym $mod+e exec xfce4-terminal -e ranger # File manager
|
||||||
bindsym Print exec flameshot screen -d 0 -p ~/Pictures/Screenshots # Fullscreen screenshot
|
bindsym Print exec flameshot screen -d 0 -p ~/Pictures/Screenshots # Fullscreen screenshot
|
||||||
bindsym $mod+Print exec flameshot gui # Show screenshot window
|
bindsym $mod+Print exec flameshot gui # Show screenshot window
|
||||||
bindsym $mod+shift+b exec /bin/bash ~/.config/i3/scripts/brightness.sh
|
bindsym $mod+shift+b exec /bin/bash ~/.config/i3/scripts/brightness.sh
|
||||||
|
@ -85,6 +85,7 @@ function install_config {
|
|||||||
linkDir "$PWD"/config/terminal/xfce4-term ~/.config/xfce4/terminal
|
linkDir "$PWD"/config/terminal/xfce4-term ~/.config/xfce4/terminal
|
||||||
linkDir "$PWD"/config/gtk-3.0/settings.ini ~/.config/gtk-3.0/.config
|
linkDir "$PWD"/config/gtk-3.0/settings.ini ~/.config/gtk-3.0/.config
|
||||||
linkDir "$PWD"/templates ~/Templates
|
linkDir "$PWD"/templates ~/Templates
|
||||||
|
linkDir "$PWD"/config/ranger ~/.config/
|
||||||
|
|
||||||
# link user files
|
# link user files
|
||||||
ln -sf "$PWD"/bash/.bashrc ~/.bashrc
|
ln -sf "$PWD"/bash/.bashrc ~/.bashrc
|
||||||
|
Loading…
Reference in New Issue
Block a user