pimping navigation
This commit is contained in:
parent
57ee57797e
commit
d34d652a2d
4 changed files with 71 additions and 37 deletions
59
bashrc
59
bashrc
|
@ -1,6 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# tavo custom bashrc file
|
# tavo custom bashrc file
|
||||||
|
|
||||||
# If not running interactively, don't do anything
|
# If not running interactively, don't do anything
|
||||||
[[ $- != *i* ]] && return
|
[[ $- != *i* ]] && return
|
||||||
|
|
||||||
|
@ -42,9 +41,12 @@ alias \
|
||||||
vid="cd $HOME/Videos/ && ls" \
|
vid="cd $HOME/Videos/ && ls" \
|
||||||
mus="cd $HOME/Music/ && ls" \
|
mus="cd $HOME/Music/ && ls" \
|
||||||
ent="cd /mnt/Entr/ && ls" \
|
ent="cd /mnt/Entr/ && ls" \
|
||||||
|
fzfscripts="fzf_nav /home/$(whoami)/.config/scripts" \
|
||||||
ls="exa -al --group-directories-first" \
|
ls="exa -al --group-directories-first" \
|
||||||
|
fzf="fzf --cycle --reverse" \
|
||||||
diff="diff --color=auto" \
|
diff="diff --color=auto" \
|
||||||
grep="grep --color=auto" \
|
grep="grep --color=auto" \
|
||||||
|
notes="note list" \
|
||||||
def="dict" \
|
def="dict" \
|
||||||
calc="bc -l" \
|
calc="bc -l" \
|
||||||
cp="cp -iv" \
|
cp="cp -iv" \
|
||||||
|
@ -58,11 +60,11 @@ export \
|
||||||
QT_QPA_PLATFORMTHEME="qt6ct" \
|
QT_QPA_PLATFORMTHEME="qt6ct" \
|
||||||
DATE=$(date -I) \
|
DATE=$(date -I) \
|
||||||
|
|
||||||
# Clipboard config
|
# DE opts
|
||||||
|
# Clipboard
|
||||||
export \
|
export \
|
||||||
CM_SELECTIONS="clipboard" \
|
CM_SELECTIONS="clipboard" \
|
||||||
CM_MAX_CLIPS=10 \
|
CM_MAX_CLIPS=10 \
|
||||||
|
|
||||||
# Default programs
|
# Default programs
|
||||||
export \
|
export \
|
||||||
OPENER="xdg-open" \
|
OPENER="xdg-open" \
|
||||||
|
@ -74,48 +76,37 @@ export \
|
||||||
IMAGE="sxiv" \
|
IMAGE="sxiv" \
|
||||||
VIDEO="mpv" \
|
VIDEO="mpv" \
|
||||||
|
|
||||||
# Functions
|
# Functions & binds
|
||||||
fzf_list_dir() {
|
fzf_nav() {
|
||||||
|
[ -d "$1" ] && cd "$1"
|
||||||
# Fun POSIX way of listing stuff
|
# Fun POSIX way of listing stuff
|
||||||
for entry in * ; do
|
while true ; do
|
||||||
# If 'entry' is a directory, append '/'
|
opt=$(for entry in * ; do
|
||||||
test "${entry#*.*}" = "$entry" && entry="$entry/"
|
[ -d "$entry" ] && entry="$entry/"
|
||||||
echo $entry
|
[ "$entry" = "*" ] && entry=""
|
||||||
done | fzf
|
echo "$entry"
|
||||||
|
done)
|
||||||
|
opt=$(printf "../\n$opt" | fzf --cycle --reverse --padding 2% --preview 'p {}')
|
||||||
|
[ -d "$opt" ] && cd "$opt" > /dev/null 2>&1 || break
|
||||||
|
done
|
||||||
|
ls
|
||||||
|
[ -n "$opt" ] && printf "\nOpen $opt? [y/N]: " && read -r open || return 0
|
||||||
|
[ "$open" = "y" ] && o "$opt"
|
||||||
}
|
}
|
||||||
|
bind '"\C-n":"fzf_nav\C-m"'
|
||||||
|
|
||||||
note() {
|
note() {
|
||||||
# Just edit today's note if no argument is given
|
# Just edit today's note if no argument is given
|
||||||
[ -z "$1" ] && cd ~/Documents/notes && $EDITOR $HOME/Documents/notes/note-$DATE.md && exit
|
[ -z "$1" ] && cd ~/Documents/notes && $EDITOR $HOME/Documents/notes/note-$DATE.md && exit
|
||||||
# 'list' arg will list notes wither with fzf or regular ls
|
# 'list' arg will list notes either with fzf or regular ls
|
||||||
if [ "$1" = "list" ] ; then
|
if [ "$1" = "list" ] ; then
|
||||||
cd ~/Documents/notes
|
cd ~/Documents/notes
|
||||||
# If fzf is present, list notes
|
# If fzf is present, use it, ls otherwise
|
||||||
if [ -e '/usr/bin/fzf' ] ; then
|
[ -e '/usr/bin/fzf' ] || ls && fzf_nav
|
||||||
while test "${note#*.md}" = "$note" && cd "$note" && ; do
|
|
||||||
ls
|
|
||||||
done
|
|
||||||
note=$(fzf_list_dir)
|
|
||||||
# Regular ls otherwise
|
|
||||||
else ; ls
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
follow() { # cd if found after 'which' command
|
bind '"\C-e":"fzfscripts\C-m"'
|
||||||
[ -z "$1" ] && echo "Usage: follow <command>" ||
|
|
||||||
cd "$(which $1 | sed s/$1//g)"
|
|
||||||
}
|
|
||||||
|
|
||||||
follow-edit() { # open in $EDITOR
|
|
||||||
[ -z "$1" ] && echo "Usage: follow <command>" ||
|
|
||||||
$EDITOR "$(which $1)"
|
|
||||||
}
|
|
||||||
|
|
||||||
quitcd() { # cd into NNN's exported dir: Ctrl + G
|
|
||||||
cd $(grep -oP '"\K[^"\047]+(?=["\047])' ~/.config/nnn/.lastd)
|
|
||||||
}
|
|
||||||
bind '"\C-g":"quitcd\C-m"'
|
|
||||||
|
|
||||||
# Autostart dwm after tty login
|
# Autostart dwm after tty login
|
||||||
type systemctl 2>/dev/null 1>&2 && if systemctl -q is-active graphical.target && [[ ! $DISPLAY && $XDG_VTNR -eq 1 ]]; then
|
type systemctl 2>/dev/null 1>&2 && if systemctl -q is-active graphical.target && [[ ! $DISPLAY && $XDG_VTNR -eq 1 ]]; then
|
||||||
|
|
12
scripts/p
Executable file
12
scripts/p
Executable file
|
@ -0,0 +1,12 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# Preview files & dirs
|
||||||
|
file="$1"
|
||||||
|
|
||||||
|
# If directory, list contents
|
||||||
|
[ -d "$file" ] && (cd "$file" && /usr/bin/ls -A1Fx --color --group-directories-first)
|
||||||
|
|
||||||
|
case $file in
|
||||||
|
*.csv) column -s, -t < "$file" ;;
|
||||||
|
*.html) links -dump "$file" ;;
|
||||||
|
*) ! [ -d "$file" ] && head -n 47 "$file" && printf "\n\n ..." ;;
|
||||||
|
esac
|
31
vim/view/~=+.config=+bashrc=
Normal file
31
vim/view/~=+.config=+bashrc=
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
let s:so_save = &g:so | let s:siso_save = &g:siso | setg so=0 siso=0 | setl so=-1 siso=-1
|
||||||
|
argglobal
|
||||||
|
setlocal fdm=manual
|
||||||
|
setlocal fde=0
|
||||||
|
setlocal fmr={{{,}}}
|
||||||
|
setlocal fdi=#
|
||||||
|
setlocal fdl=0
|
||||||
|
setlocal fml=1
|
||||||
|
setlocal fdn=20
|
||||||
|
setlocal fen
|
||||||
|
silent! normal! zE
|
||||||
|
6,8fold
|
||||||
|
10,15fold
|
||||||
|
17,27fold
|
||||||
|
29,55fold
|
||||||
|
57,61fold
|
||||||
|
63,77fold
|
||||||
|
79,109fold
|
||||||
|
111,117fold
|
||||||
|
let &fdl = &fdl
|
||||||
|
let s:l = 1 - ((0 * winheight(0) + 19) / 38)
|
||||||
|
if s:l < 1 | let s:l = 1 | endif
|
||||||
|
keepjumps exe s:l
|
||||||
|
normal! zt
|
||||||
|
keepjumps 1
|
||||||
|
normal! 0
|
||||||
|
let &g:so = s:so_save | let &g:siso = s:siso_save
|
||||||
|
set hlsearch
|
||||||
|
nohlsearch
|
||||||
|
doautoall SessionLoadPost
|
||||||
|
" vim: set ft=vim :
|
|
@ -83,5 +83,5 @@ set noshowmode
|
||||||
map gy :Goyo<CR>
|
map gy :Goyo<CR>
|
||||||
autocmd! User GoyoLeave highlight Normal ctermbg=NONE
|
autocmd! User GoyoLeave highlight Normal ctermbg=NONE
|
||||||
|
|
||||||
autocmd BufWinLeave bibliography zM | mkview
|
autocmd BufWinLeave bibliography,bashrc zM | mkview
|
||||||
autocmd BufWinEnter bibliography silent loadview
|
autocmd BufWinEnter bibliography,bashrc silent loadview
|
||||||
|
|
Loading…
Reference in a new issue