Remove fundle and add rofi pdf finder

This commit is contained in:
coolneng 2020-04-21 00:53:01 +02:00
parent 4fe43f1c2e
commit 932c82162a
Signed by: coolneng
GPG Key ID: 9893DA236405AF57
10 changed files with 137 additions and 492 deletions

View File

@ -1,24 +1,18 @@
# Fish config file
fundle plugin 'decors/fish-colored-man'
fundle plugin 'oh-my-fish/theme-nai'
fundle init
function fish_title
true
end
# Man colors
set -g man_standout -o blue
set -g man_bold -o magenta
# Text Editor
set -x EDITOR nvim
# ZFS GRUB
set -x ZPOOL_VDEV_NAME_PATH 1
# Compiler
set -x CC /usr/bin/clang
set -x CXX /usr/bin/clang++
# Man colors
set -g man_standout -o blue
set -g man_bold -o magenta
# Aliases
alias f "fff"
alias peerflix "peerflix -d"
alias xa "xbps-install -S"
alias xu "xbps-install -Su"
alias xc "xbps-remove -o"
@ -30,12 +24,8 @@ alias vim "nvim"
alias docker "podman"
alias docker-compose "podman-compose"
# Compiler
set -x CC /usr/bin/clang
set -x CXX /usr/bin/clang++
# Additional paths
set PATH /opt/texlive/2019/bin/x86_64-linux/ /bin /usr/bin /usr/local/bin /usr/local/sbin /usr/sbin /sbin
set PATH /opt/texlive/2020/bin/x86_64-linux/ /bin /usr/bin /usr/local/bin /usr/local/sbin /usr/sbin /sbin
set PATH $PATH /$HOME/.local/bin
set PATH $PATH /$HOME/.local/share/go/bin
set PATH $PATH /$HOME/.emacs.d/bin
@ -43,12 +33,8 @@ set PATH $PATH /$HOME/.emacs.d/bin
# Go workspace
set -x GOPATH $HOME/.local/share/go/
# fff
## Directory color [0-9]
set -x FFF_COL1 3
set -x FFF_COL2 8
## Favourites (keys 1-9) (dir or file)
set -x FFF_FAV1 /$HOME/Documents/Uni
set -x FFF_FAV2 /$HOME/Documents/Papers
set -x FFF_FAV3 /$HOME/Documents/Books/Academic/
set -x FFF_FAV4 /$HOME/Documents/Education/
# fff favourites
set -x FFF_FAV1 $HOME/Documents/Uni
set -x FFF_FAV2 $HOME/Documents/Papers
set -x FFF_FAV3 $HOME/Documents/Books/Academic/
set -x FFF_FAV4 $HOME/Documents/Education/

View File

@ -0,0 +1,38 @@
# name: nai
# Display the following bits on the left:
# * Current directory name
# * Git branch and dirty state (if inside a git repo)
function _git_branch_name
echo (command git symbolic-ref HEAD 2> /dev/null | sed -e 's|^refs/heads/||')
end
function _git_dirty
echo (command git status -s --ignore-submodules=dirty 2> /dev/null)
end
function fish_prompt
set -l yellow (set_color yellow)
set -l green (set_color green)
set -l normal (set_color normal)
set -l cwd (basename (prompt_pwd))
echo -e ""
echo -n -s ' ' $cwd $normal
if [ (_git_branch_name) ]
set -l git_branch (_git_branch_name)
if [ (_git_dirty) ]
set git_info $yellow $git_branch
else
set git_info $green $git_branch
end
echo -n -s ' ' $git_info $normal
end
echo -n -s ' ' $normal
end

View File

@ -1,453 +0,0 @@
set __fundle_current_version '0.7.0'
function __fundle_seq -a upto
seq 1 1 $upto 2>/dev/null
end
function __fundle_next_arg -a index
set -l args $argv[2..-1]
set -l arg_index (math $index + 1)
if test (count $args) -lt $arg_index
echo "missing argument for $args[$index]"
return 1
end
set -l arg $args[$arg_index]
switch $arg
case '--*'
echo "expected argument for $args[$index], got $arg"; and return 1
case '*'
echo $arg; and return 0
end
end
function __fundle_compare_versions -a version1 -a version2
for i in (__fundle_seq 4)
set -l v1 (echo $version1 | cut -d '.' -f $i | sed -Ee 's/[a-z]+//g')
set -l v2 (echo $version2 | cut -d '.' -f $i | sed -Ee 's/[a-z]+//g')
if test \( -n $v1 -a -z $v2 \) -o \( -n $v1 -a -n $v2 -a $v1 -lt $v2 \)
echo -n "lt"; and return 0
else if test \( -z $v1 -a -n $v2 \) -o \( -n $v1 -a -n $v2 -a $v1 -gt $v2 \)
echo -n "gt"; and return 0
end
end
echo -n "eq"; and return 0
end
function __fundle_date -d "returns a date"
set -l d (date +%s%N)
if echo $d | string match -rvq 'N'
echo $d
else
gdate +%s%N
end
return 0
end
function __fundle_self_update -d "updates fundle"
set -l fundle_repo_url "https://github.com/tuvistavie/fundle.git"
# This `sed` stays for now since doing it easily with `string` requires "--filter", which is only in 2.6.0
set -l latest (command git ls-remote --tags $fundle_repo_url | sed -n -e 's|.*refs/tags/v\(.*\)|\1|p' | tail -n 1)
if test (__fundle_compare_versions $latest (__fundle_version)) != "gt"
echo "fundle is already up to date"; and return 0
else
set -l file_url_template 'https://raw.githubusercontent.com/tuvistavie/fundle/VERSION/functions/fundle.fish'
set -l file_url (string replace 'VERSION' -- "v$latest" $file_url_template)
set -l tmp_file (mktemp /tmp/fundle.XXX)
set -l update_message "fundle has been updated to version $latest"
curl -Ls $file_url > $tmp_file; and mv $tmp_file (status -f); and echo $update_message; and return 0
end
end
function __fundle_url_rev -d "prints the revision from the url" -a git_url
set -l rev (echo $git_url | cut -d '#' -f 2 -s)
if test -n "$rev"
echo $rev
else
echo master
end
end
function __fundle_remote_url -d "prints the remote url from the full git url" -a git_url
echo $git_url | cut -d '#' -f 1
end
function __fundle_rev_parse -d "prints the revision if any" -a dir -a commitish
set -l sha (command git --git-dir $dir rev-parse -q --verify $commitish 2>/dev/null)
if test $status -eq 0
echo -n $sha
return 0
end
return 1
end
function __fundle_commit_sha -d "returns sha of the commit-ish" -a dir -a commitish
if test -d "$dir/.git"
set dir "$dir/.git"
end
if __fundle_rev_parse $dir "origin/$commitish"
return 0
end
__fundle_rev_parse $dir $commitish
end
function __fundle_plugins_dir -d "returns fundle directory"
if test -z "$fundle_plugins_dir"
if test -n "$XDG_CONFIG_HOME"
echo $XDG_CONFIG_HOME/fish/fundle
else
echo $HOME/.config/fish/fundle
end
else
echo $fundle_plugins_dir
end
end
function __fundle_no_git -d "check if git is installed"
# `command -q` is >= 2.5.0
if not command -s git > /dev/null 2>&1
echo "git needs to be installed and in the path"
return 0
end
return 1
end
function __fundle_check_date -d "check date"
if date +%s%N | string match -rvq 'N'
return 0
end
if command -s gdate > /dev/null 2>&1
return 0
end
echo "You need to have a GNU date compliant date installed to use profiling. Use 'brew install coreutils' on OSX"
return 1
end
function __fundle_get_url -d "returns the url for the given plugin" -a repo
echo "https://github.com/$repo.git"
end
function __fundle_plugin_index -d "returns the index of the plugin" -a plugin
for i in (__fundle_seq (count $__fundle_plugin_names))
if test "$__fundle_plugin_names[$i]" = "$plugin"
return $i
end
end
# NOTE: should never reach this point
echo "could not find plugin: $plugin"
exit 1
end
function __fundle_checkout_revision -a plugin -a git_url
set -l plugin_dir (__fundle_plugins_dir)/$plugin
set -l git_dir $plugin_dir/.git
set -l sha (__fundle_commit_sha $git_dir (__fundle_url_rev $git_url))
if test $status -eq 0
command git --git-dir="$git_dir" --work-tree="$plugin_dir" checkout -q -f $sha
else
echo "Could not checkout $plugin revision $sha"
return 1
end
end
function __fundle_update_plugin -d "update the given plugin" -a plugin -a git_url
echo "Updating $plugin"
set -l remote_url (__fundle_remote_url $git_url)
set -l git_dir (__fundle_plugins_dir)/$plugin/.git
command git --git-dir=$git_dir remote set-url origin $remote_url 2>/dev/null
command git --git-dir=$git_dir fetch -q 2>/dev/null
__fundle_checkout_revision $plugin $git_url
end
function __fundle_install_plugin -d "install the given plugin" -a plugin -a git_url
if __fundle_no_git
return 1
end
set -l plugin_dir (__fundle_plugins_dir)/$plugin
set -l git_dir $plugin_dir/.git
set -l remote_url (__fundle_remote_url $git_url)
if test -d $plugin_dir
echo "$argv[1] installed in $plugin_dir"
return 0
else
echo "Installing $plugin"
command git clone -q $remote_url $plugin_dir
__fundle_checkout_revision $plugin $git_url
end
end
function __fundle_update -d "update the given plugin, or all if unspecified" -a plugin
if test -n "$plugin"; and test ! -d (__fundle_plugins_dir)/$plugin/.git
echo "$plugin not installed. You may need to run 'fundle install'"
return 1
end
if test -n "$plugin"
set -l index (__fundle_plugin_index $plugin)
__fundle_update_plugin "$plugin" $__fundle_plugin_urls[$index]
else
for i in (__fundle_seq (count $__fundle_plugin_names))
__fundle_update_plugin $__fundle_plugin_names[$i] $__fundle_plugin_urls[$i]
end
end
end
function __fundle_show_doc_msg -d "show a link to fundle docs"
if test (count $argv) -ge 1
echo $argv
end
echo "See the docs for more info. https://github.com/tuvistavie/fundle"
end
function __fundle_load_plugin -a plugin -a path -a fundle_dir -a profile -d "load a plugin"
if begin; set -q __fundle_loaded_plugins; and contains $plugin $__fundle_loaded_plugins; end
return 0
end
set -l plugin_dir (string replace -r '/.$' '' -- "$fundle_dir/$plugin/$path")
if not test -d $plugin_dir
__fundle_show_doc_msg "$plugin not installed. You may need to run 'fundle install'"
return 0
end
# Take everything but "plugin-" from the last path component
set -l plugin_name (string replace -r '.*/(plugin-)?(.*)$' '$2' -- $plugin)
set -l init_file "$plugin_dir/init.fish"
set -l conf_dir "$plugin_dir/conf.d"
set -l bindings_file "$plugin_dir/key_bindings.fish"
set -l functions_dir "$plugin_dir/functions"
set -l completions_dir "$plugin_dir/completions"
set -l plugin_paths $__fundle_plugin_name_paths
if begin; test -d $functions_dir; and not contains $functions_dir $fish_function_path; end
set fish_function_path $fish_function_path[1] $functions_dir $fish_function_path[2..-1]
end
if begin; test -d $completions_dir; and not contains $completions_dir $fish_complete_path; end
set fish_complete_path $fish_complete_path[1] $completions_dir $fish_complete_path[2..-1]
end
if test -f $init_file
source $init_file
else if test -d $conf_dir
# read all *.fish files in conf.d
for f in $conf_dir/*.fish
source $f
end
else
# For compatibility with oh-my-fish themes, if there is no `init.fish` file in the plugin,
# which is the case with themses, the root directory of the plugin is trerated as a functions
# folder, so we include it in the `fish_function_path` variable.
if not contains $plugin_dir $fish_function_path
set fish_function_path $fish_function_path[1] $plugin_dir $fish_function_path[2..-1]
end
end
if test -f $bindings_file
set -g __fundle_binding_paths $bindings_file $__fundle_binding_paths
end
set -g __fundle_loaded_plugins $plugin $__fundle_loaded_plugins
set -l dependencies (printf '%s\n' $plugin_paths $__fundle_plugin_name_paths | sort | uniq -u)
for dependency in $dependencies
set -l name_path (string split : -- $dependency)
if test "$profile" -eq 1
set -l start_time (__fundle_date +%s%N)
__fundle_load_plugin $name_path[1] $name_path[2] $fundle_dir $profile
set -l ellapsed_time (math \((__fundle_date +%s%N) - $start_time\) / 1000)
echo "$name_path[1]": {$ellapsed_time}us
else
__fundle_load_plugin $name_path[1] $name_path[2] $fundle_dir $profile
end
end
emit "init_$plugin_name" $plugin_dir
end
function __fundle_bind -d "set up bindings"
if functions -q fish_user_key_bindings; and not functions -q __fish_user_key_bindings
functions -c fish_user_key_bindings __fish_user_key_bindings
end
function fish_user_key_bindings
for bindings in $__fundle_binding_paths
source $bindings
end
if functions -q __fish_user_key_bindings
__fish_user_key_bindings
end
end
end
function __fundle_init -d "initialize fundle"
set -l fundle_dir (__fundle_plugins_dir)
if test (count $__fundle_plugin_names) -eq 0
__fundle_show_doc_msg "No plugin registered. You need to call 'fundle plugin NAME' before using 'fundle init'. \
Try reloading your shell if you just edited your configuration."
return 1
end
set -l profile 0
if begin; contains -- -p $argv; or contains -- --profile $argv; and __fundle_check_date; end
set profile 1
end
for name_path in $__fundle_plugin_name_paths
set -l name_path (string split : -- $name_path)
if test "$profile" -eq 1
set -l start_time (__fundle_date +%s%N)
__fundle_load_plugin $name_path[1] $name_path[2] $fundle_dir $profile
set -l ellapsed_time (math \((__fundle_date +%s%N) - $start_time\) / 1000)
echo "$name_path[1]": {$ellapsed_time}us
else
__fundle_load_plugin $name_path[1] $name_path[2] $fundle_dir $profile
end
end
__fundle_bind
end
function __fundle_install -d "install plugin"
if test (count $__fundle_plugin_names) -eq 0
__fundle_show_doc_msg "No plugin registered. You need to call 'fundle plugin NAME' before using 'fundle install'"
end
for i in (__fundle_seq (count $__fundle_plugin_names))
__fundle_install_plugin $__fundle_plugin_names[$i] $__fundle_plugin_urls[$i] $argv
end
set -l original_plugins_count (count (__fundle_list -s))
__fundle_init
# if plugins count increase after init, new plugins have dependencies
# install new plugins dependencies if any
if test (count (__fundle_list -s)) -gt $original_plugins_count
__fundle_install $argv
end
end
function __fundle_clean -d "cleans fundle directory"
set -l fundle_dir (__fundle_plugins_dir)
set -l used_plugins (__fundle_list -s)
set -l installed_plugins $fundle_dir/*/*/
for installed_plugin in $installed_plugins
set -l plugin (string trim --chars="/" \
(string replace -r -- "$fundle_dir" "" $installed_plugin))
if not contains $plugin $used_plugins
echo "Removing $plugin"
rm -rf $fundle_dir/$plugin
end
end
end
function __fundle_plugin -d "add plugin to fundle" -a name
set -l plugin_url ""
set -l plugin_path "."
set -l argv_count (count $argv)
set -l skip_next true
if test $argv_count -eq 0 -o -z "$argv"
echo "usage: fundle plugin NAME [[--url] URL] [--path PATH]"
return 1
else if test $argv_count -gt 1
for i in (__fundle_seq (count $argv))
test $skip_next = true; and set skip_next false; and continue
set -l arg $argv[$i]
switch $arg
case '--url'
set plugin_url (__fundle_next_arg $i $argv)
test $status -eq 1; and echo $plugin_url; and return 1
set skip_next true
case '--path'
set plugin_path (__fundle_next_arg $i $argv)
test $status -eq 1; and echo $plugin_path; and return 1
set skip_next true
case '--*'
echo "unknown flag $arg"; and return 1
case '*'
test $i -ne 2; and echo "invalid argument $arg"; and return 1
set plugin_url $arg
end
end
end
test -z "$plugin_url"; and set plugin_url (__fundle_get_url $name)
if not contains $name $__fundle_plugin_names
set -g __fundle_plugin_names $__fundle_plugin_names $name
set -g __fundle_plugin_urls $__fundle_plugin_urls $plugin_url
set -g __fundle_plugin_name_paths $__fundle_plugin_name_paths $name:$plugin_path
end
end
function __fundle_version -d "prints fundle version"
echo $__fundle_current_version
end
function __fundle_print_help -d "prints fundle help"
echo "usage: fundle (init | plugin | list | install | update | clean | self-update | version | help)"
end
function __fundle_list -d "list registered plugins"
if begin; contains -- -s $argv; or contains -- --short $argv; end
for name in $__fundle_plugin_names
echo $name
end
else
for i in (__fundle_seq (count $__fundle_plugin_names))
echo {$__fundle_plugin_names[$i]}\n\t{$__fundle_plugin_urls[$i]}
end
end
end
function fundle -d "run fundle"
if __fundle_no_git
return 1
end
set -l sub_args ""
switch (count $argv)
case 0
__fundle_print_help
return 1
case 1
case '*'
set sub_args $argv[2..-1]
end
switch $argv[1]
case "init"
__fundle_init $sub_args
case "plugin"
__fundle_plugin $sub_args
case "list"
__fundle_list $sub_args
case "plugins"
echo "'fundle plugins' has been replaced by 'fundle list'"
case "install"
__fundle_install $sub_args
case "update"
__fundle_update $sub_args
case "clean"
__fundle_clean
case "self-update"
__fundle_self_update
case "version" -v --version
__fundle_version
case "help" -h --help
__fundle_print_help
return 0
case "*"
__fundle_print_help
return 1
end
end

View File

@ -0,0 +1,41 @@
function man --wraps man --description 'Format and display manual pages'
set -q man_blink; and set -l blink (set_color $man_blink); or set -l blink (set_color -o red)
set -q man_bold; and set -l bold (set_color $man_bold); or set -l bold (set_color -o 5fafd7)
set -q man_standout; and set -l standout (set_color $man_standout); or set -l standout (set_color 949494)
set -q man_underline; and set -l underline (set_color $man_underline); or set -l underline (set_color -u afafd7)
set -l end (printf "\e[0m")
set -lx LESS_TERMCAP_mb $blink
set -lx LESS_TERMCAP_md $bold
set -lx LESS_TERMCAP_me $end
set -lx LESS_TERMCAP_so $standout
set -lx LESS_TERMCAP_se $end
set -lx LESS_TERMCAP_us $underline
set -lx LESS_TERMCAP_ue $end
set -lx LESS '-R -s'
set -lx GROFF_NO_SGR yes # fedora
set -lx MANPATH (string join : $MANPATH)
if test -z "$MANPATH"
type -q manpath
and set MANPATH (command manpath)
end
# Check data dir for Fish 2.x compatibility
set -l fish_data_dir
if set -q __fish_data_dir
set fish_data_dir $__fish_data_dir
else
set fish_data_dir $__fish_datadir
end
set -l fish_manpath (dirname $fish_data_dir)/fish/man
if test -d "$fish_manpath" -a -n "$MANPATH"
set MANPATH "$fish_manpath":$MANPATH
command man $argv
return
end
command man $argv
end

@ -1 +0,0 @@
Subproject commit c1e9db7765c932587b795d6c8965e9cff2fd849a

@ -1 +0,0 @@
Subproject commit 9616e644e95fe79eb59b8c9d77fe44b9f096db2f

View File

@ -9,10 +9,12 @@ Debug/
bin
obj/
# LaTeX
auto/
/**/auto/
# Misc
.*.swp
.#*
.DS_Store
# Python
.mypy_cache
# Emacs
.dir-locals.el

View File

@ -50,10 +50,6 @@ set laststatus=0
autocmd BufNewFile,BufRead /tmp/neomutt* set filetype=markdown
""Quit whether Goyo is active or not
function! s:goyo_enter()
if executable('tmux') && strlen($TMUX)
silent !tmux set status off
silent !tmux list-panes -F '\#F' | grep -q Z || tmux resize-pane -Z
endif
set noshowmode
set noshowcmd
set scrolloff=999
@ -64,10 +60,6 @@ function! s:goyo_enter()
endfunction
function! s:goyo_leave()
if executable('tmux') && strlen($TMUX)
silent !tmux set status on
silent !tmux list-panes -F '\#F' | grep -q Z && tmux resize-pane -Z
endif
set showmode
set showcmd
set scrolloff=5

View File

@ -0,0 +1,39 @@
#!/usr/bin/env bash
#PUT THIS FILE IN ~/.local/share/rofi/finder.sh
#USE: rofi -show find -modi find:~/.local/share/rofi/finder.sh
if [ ! -z "$@" ]
then
QUERY=$@
if [[ "$@" == /* ]]
then
if [[ "$@" == *\?\? ]]
then
coproc ( xdg-open "${QUERY%\/* \?\?}" > /dev/null 2>&1 )
exec 1>&-
exit;
else
coproc ( xdg-open "$@" > /dev/null 2>&1 )
exec 1>&-
exit;
fi
elif [[ "$@" == \!\!* ]]
then
echo "!!-- Type your search query to find files"
echo "!!-- To search again type !<search_query>"
echo "!!-- To search parent directories type ?<search_query>"
echo "!!-- You can print this help by typing !!"
elif [[ "$@" == \?* ]]
then
while read -r line; do
echo "$line" \?\?
done <<< $(fd -e pdf -i "${QUERY#\?}" $HOME/Documents/Uni 2>&1 | grep -v 'Permission denied\|Input/output error')
else
fd -e pdf -i "${QUERY#!}" $HOME/Documents/Uni 2>&1 | grep -v 'Permission denied\|Input/output error'
fi
else
echo "!!-- Type your search query to find files"
echo "!!-- To seach again type !<search_query>"
echo "!!-- To seach parent directories type ?<search_query>"
echo "!!-- You can print this help by typing !!"
fi

View File

@ -270,6 +270,8 @@ exec swaymsg split vertical
bindsym Print exec grim
# slurp + grim to clipboard
bindsym Shift+Print exec slurp | grim -g - - | wl-copy
# find PDFs with rofi
bindsym $mod+f exec rofi -show find -modi find:~/.local/share/rofi/finder.sh
# power menu
bindsym $mod+Pause mode "$Pause-break"