From 2fd57e8772db6c2775757118bf9e521839631cdd Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Wed, 26 Feb 2020 15:26:00 -0500 Subject: [PATCH] add lf --- .gitmodules | 3 + Makefile | 14 ++- bin/.gitignore | 1 + bootstrap.sh | 12 +- fish/.config/fish/completions/lf.fish | 11 ++ .../functions/fish_user_key_bindings.fish | 3 +- fish/.config/fish/functions/is_git.fish | 3 +- fish/.config/fish/functions/lfcd.fish | 27 ++++ lf/.config/lf/lfrc | 115 ++++++++++++++++++ lf/.stow-local-ignore | 1 + lf/lf | 1 + vim/.vim/bundle/vim-gitgutter | 2 +- weechat/.weechat/irc.conf | 49 +++++++- weechat/.weechat/spell.conf | 2 +- weechat/.weechat/weechat.conf | 1 + 15 files changed, 229 insertions(+), 16 deletions(-) create mode 100644 bin/.gitignore mode change 100755 => 100644 bootstrap.sh create mode 100644 fish/.config/fish/completions/lf.fish create mode 100644 fish/.config/fish/functions/lfcd.fish create mode 100644 lf/.config/lf/lfrc create mode 100644 lf/.stow-local-ignore create mode 160000 lf/lf diff --git a/.gitmodules b/.gitmodules index e8e19d2..0c5ca96 100644 --- a/.gitmodules +++ b/.gitmodules @@ -26,3 +26,6 @@ [submodule "vim/.vim/bundle/vim-fish"] path = vim/.vim/bundle/vim-fish url = https://github.com/dag/vim-fish +[submodule "lf/lf"] + path = lf/lf + url = https://github.com/gokcehan/lf diff --git a/Makefile b/Makefile index fcbee3a..7bb60c8 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ endif install: @make $(UNAME) -Linux: bash fzf fish git mutt byobu weechat vim nvim gnupg bin +Linux: bash bin byobu fish git gnupg lf mutt nvim vim weechat Windows: bash git vim Other: bash git vim @@ -28,6 +28,7 @@ clean: stow -t "$$HOME" -D fish stow -t "$$HOME" -D git stow -t "$$HOME" -D gnupg + stow -t "$$HOME" -D lf/.config stow -t "$$HOME" -D mutt stow -t "$$HOME" -D nvim stow -t "$$HOME" -D vim @@ -37,7 +38,7 @@ bash: @printf "$(YELLOW)--- bash -----------------------------------------------\n$(RESET)" stow -t "$$HOME" bash -bin: +bin: lf @printf "$(YELLOW)--- bin ------------------------------------------------\n$(RESET)" mkdir -p "$$HOME/bin" stow -t "$$HOME" bin @@ -66,6 +67,13 @@ gnupg: chmod 700 "$$HOME/.gnupg" stow -t "$$HOME" gnupg +lf: + @printf "$(YELLOW)--- lf --------------------------------------------------\n$(RESET)" + git submodule update --remote --init -- lf/lf + cd lf/lf; CGO_ENABLED=0 go build -ldflags="-s -w" -o ../../bin/bin/lf + mkdir -p ~/.trash + stow -t "$$HOME" lf + mutt: @printf "$(YELLOW)--- mutt -----------------------------------------------\n$(RESET)" stow -t "$$HOME" mutt @@ -89,4 +97,4 @@ nuke: @printf "$(RED)--- nuking existing files ------------------------------\n$(RESET)" rm -rf ~/.byobu ~/.config/fish ~/.fzf ~/.bash* -.PHONY: bash fzf fish git vim nvim mutt byobu weechat gnupg bin clean install nuke Windows Linux Other +.PHONY: bash fzf fish git vim nvim lf mutt byobu weechat gnupg bin clean install nuke Windows Linux Other diff --git a/bin/.gitignore b/bin/.gitignore new file mode 100644 index 0000000..886f9fa --- /dev/null +++ b/bin/.gitignore @@ -0,0 +1 @@ +bin/lf diff --git a/bootstrap.sh b/bootstrap.sh old mode 100755 new mode 100644 index ca12ac3..d16de53 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -5,14 +5,16 @@ RELEASE="$2" PKGLIST="${DISTRO}.pkglist" [ -z $DISTRO -o -z $RELEASE ] && \ - echo "usage: sudo $0 " && exit 1 + printf "usage: sudo %s \n" "$0" && exit 1 [[ $(id -u) != 0 ]] && \ - echo "re-run this as root" && exit 1 + printf "re-run this as root\n" && exit 1 # make sure we have sources -echo "deb https://apt.syncthing.net/ syncthing stable" > /etc/apt/sources.list.d/syncthing.list -echo "deb https://weechat.org/${DISTRO} ${RELEASE} main" > /etc/apt/sources.list.d/weechat.list +printf "deb https://mirror.bhh.sh/syncthing/ syncthing stable\n" \ + > /etc/apt/sources.list.d/syncthing.list +printf "deb https://mirror.bhh.sh/weechat/%s %s main \n" "${DISTRO}" "${RELEASE}" \ + > /etc/apt/sources.list.d/weechat.list apt update apt upgrade -y @@ -21,7 +23,7 @@ apt full-upgrade -y apt install -y $(xargs < ${PKGLIST}) -echo -n "install makefiles? [y/n]" +printf "install makefiles? [y/n]" read answer [[ "$answer" = "y" ]] && \ diff --git a/fish/.config/fish/completions/lf.fish b/fish/.config/fish/completions/lf.fish new file mode 100644 index 0000000..9fb6ba9 --- /dev/null +++ b/fish/.config/fish/completions/lf.fish @@ -0,0 +1,11 @@ +complete -c lf -o command -r -d 'command to execute on client initialization' +complete -c lf -o cpuprofile -r -d 'path to the file to write the CPU profile' +complete -c lf -o doc -d 'show documentation' +complete -c lf -o last-dir-path -r -d 'path to the file to write the last dir on exit (to use for cd)' +complete -c lf -o memprofile -r -d 'path to the file to write the memory profile' +complete -c lf -o remote -x -d 'send remote command to server' +complete -c lf -o selection-path -r -d 'path to the file to write selected files on open (to use as open file dialog)' +complete -c lf -o server -d 'start server (automatic)' +complete -c lf -o version -d 'show version' +complete -c lf -o help -d 'show help' + diff --git a/fish/.config/fish/functions/fish_user_key_bindings.fish b/fish/.config/fish/functions/fish_user_key_bindings.fish index 350a9da..73037da 100644 --- a/fish/.config/fish/functions/fish_user_key_bindings.fish +++ b/fish/.config/fish/functions/fish_user_key_bindings.fish @@ -1,3 +1,4 @@ function fish_user_key_bindings - fzf_key_bindings + fzf_key_bindings + bind \co 'lfcd; commandline -f repaint' end diff --git a/fish/.config/fish/functions/is_git.fish b/fish/.config/fish/functions/is_git.fish index a0f3091..a8370f4 100644 --- a/fish/.config/fish/functions/is_git.fish +++ b/fish/.config/fish/functions/is_git.fish @@ -1,5 +1,4 @@ function is_git - git rev-parse --verify HEAD >/dev/null ^&1 - # keeping ^ for now for v2 backwards compatibility + git rev-parse --verify HEAD >/dev/null 2>&1 end diff --git a/fish/.config/fish/functions/lfcd.fish b/fish/.config/fish/functions/lfcd.fish new file mode 100644 index 0000000..4e8e041 --- /dev/null +++ b/fish/.config/fish/functions/lfcd.fish @@ -0,0 +1,27 @@ +function lfcd + set tmp (mktemp) + set fid (mktemp) + + lf -command '$printf $id > "'$fid'"' -last-dir-path=$tmp $argv + + set id (cat $fid) + set archivemount_dir "/tmp/__lf_archivemount_"$id + + if test -f "$archivemount_dir" + for line in (cat $archivemount_dir) + umount "$line" + rm -rf "$line" + end + end + + if test -f "$tmp" + set dir (cat $tmp) + rm -f "$tmp" + if test -d "$dir" + if test "$dir" != (pwd) + cd "$dir" + end + end + end +end + diff --git a/lf/.config/lf/lfrc b/lf/.config/lf/lfrc new file mode 100644 index 0000000..fd7e826 --- /dev/null +++ b/lf/.config/lf/lfrc @@ -0,0 +1,115 @@ +# interpreter for shell commands (needs to be POSIX compatible) +set shell sh + +# set '-eu' options for shell commands +# These options are used to have safer shell commands. Option '-e' is used to +# exit on error and option '-u' is used to give error for unset variables. +# Option '-f' disables pathname expansion which can be useful when $f, $fs, and +# $fx variables contain names with '*' or '?' characters. However, this option +# is used selectively within individual commands as it can be limiting at +# times. +set shellopts '-eu' + +# set internal field separator (IFS) to "\n" for shell commands +# This is useful to automatically split file names in $fs and $fx properly +# since default file separator used in these variables (i.e. 'filesep' option) +# is newline. You need to consider the values of these options and create your +# commands accordingly. +set ifs "\n" + +# leave some space at the top and the bottom of the screen +set scrolloff 10 + +# use enter for shell commands +map shell + +# execute current file (must be executable) +map x $$f +map X !$f + +# dedicated keys for file opener actions +map o &mimeopen $f +map O $mimeopen --ask $f + +# define a custom 'open' command +# This command is called when current file is not a directory. You may want to +# use either file extensions and/or mime types here. Below uses an editor for +# text files and a file opener for the rest. +cmd open ${{ + case "$f" in + *.tar.bz|*.tar.bz2|*.tbz|*.tbz2|*.tar.gz|*.tgz|*.tar.xz|*.txz|*.zip|*.rar|*.iso) + mntdir="$f-archivemount" + [ ! -d "$mntdir" ] && { + mkdir "$mntdir" + archivemount "$f" "$mntdir" + echo "$mntdir" >> "/tmp/__lf_archivemount_$id" + } + lf -remote "send $id cd \"$mntdir\"" + lf -remote "send $id reload" + ;; + *) + case $(file --mime-type $f -b) in + text/*) + $EDITOR $fx + ;; + *) + for f in $fx; do + setsid $OPENER $f > /dev/null 2> /dev/null & + done + ;; + esac + ;; +}} + +# define a custom 'rename' command without prompt for overwrite +cmd rename %[ -e $1 ] && printf "file exists" || mv $f $1 +map r push :rename + +# move current file or selected files to trash folder +# (also see 'man mv' for backup/overwrite options) +cmd trash %set -f; mv $fx ~/.trash + +cmd delete ${{ + set -f + printf "$fx\n" + printf "delete?[y/n]" + read ans + [ $ans = "y" ] && rm -rf $fx +}} + +# use '' key for either 'trash' or 'delete' command +map trash +# map delete + +# 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 +}} + +# 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 +}} + +# compress current file or selected files with zip +cmd zip ${{ + set -f + mkdir $1 + cp -r $fx $1 + zip -r $1.zip $1 + rm -rf $1 +}} + diff --git a/lf/.stow-local-ignore b/lf/.stow-local-ignore new file mode 100644 index 0000000..66787ac --- /dev/null +++ b/lf/.stow-local-ignore @@ -0,0 +1 @@ +lf diff --git a/lf/lf b/lf/lf new file mode 160000 index 0000000..3c5abbb --- /dev/null +++ b/lf/lf @@ -0,0 +1 @@ +Subproject commit 3c5abbbc5dafa2eff0593a8e27aadb3f325d2d43 diff --git a/vim/.vim/bundle/vim-gitgutter b/vim/.vim/bundle/vim-gitgutter index da2c785..c337eef 160000 --- a/vim/.vim/bundle/vim-gitgutter +++ b/vim/.vim/bundle/vim-gitgutter @@ -1 +1 @@ -Subproject commit da2c785221810b3d57479bb4b3678aabf32f3b88 +Subproject commit c337eef1b735906411577f488e977be69506ef08 diff --git a/weechat/.weechat/irc.conf b/weechat/.weechat/irc.conf index ceff899..615c90d 100644 --- a/weechat/.weechat/irc.conf +++ b/weechat/.weechat/irc.conf @@ -187,7 +187,7 @@ tilde.local_hostname tilde.usermode tilde.command = "/msg operserv login ${sec.data.pass}" tilde.command_delay -tilde.autojoin = "#meta,#secret-sudoers,#admin,#opers,#music,#politics,#gopher,#tildeverse,#idlerpg,#tilderadio,#minecraft,#tildelinux,#cosmic,#institute,#.tilde,#tildetel,#thunix,#theasylum,#aussie,#uucp,#projects,#hamradio,#vim,#black,#pink,#~,#netnews,#bots,#ctrl-c,#radiofreqs,#envs,#wilde,#tildegames,#tildenet,#gemini,#club,#zine,#team,#summit,#adventofcode,#geocities,#services,#security,#zaphod,#helpdesk,#radiobot,#honeypot,#flamewars,#chaos :10:20,secretsudoteam,adminsonly" +tilde.autojoin = "#meta,#secret-sudoers,#admin,#opers,#music,#politics,#gopher,#tildeverse,#idlerpg,#tilderadio,#minecraft,#tildelinux,#cosmic,#institute,#.tilde,#tildetel,#thunix,#theasylum,#aussie,#uucp,#projects,#hamradio,#vim,#black,#pink,#~,#netnews,#bots,#ctrl-c,#radiofreqs,#envs,#wilde,#tildegames,#tildenet,#gemini,#club,#zine,#team,#summit,#adventofcode,#geocities,#services,#security,#zaphod,#helpdesk,#radiobot,#honeypot,#flamewars :10:20,secretsudoteam,adminsonly" tilde.autorejoin tilde.autorejoin_delay tilde.connection_timeout @@ -359,7 +359,7 @@ sdf.local_hostname sdf.usermode sdf.command sdf.command_delay -sdf.autojoin = "#sdf,#gopher,#anonradio,#helpdesk,#spanish :kick:20:75" +sdf.autojoin = "#sdf,#gopher,#anonradio,#helpdesk,#spanish,#minecraft :kick:20:75" sdf.autorejoin sdf.autorejoin_delay sdf.connection_timeout @@ -445,7 +445,7 @@ oftc.local_hostname oftc.usermode oftc.command oftc.command_delay -oftc.autojoin = "#debian-devel,#fish" +oftc.autojoin = "#debian-devel,#fish,#debian-offtopic" oftc.autorejoin oftc.autorejoin_delay oftc.connection_timeout @@ -846,3 +846,46 @@ anope.msg_quit anope.notify anope.split_msg_max_length anope.charset_message +unix.addresses = "unix.chat/6697" +unix.proxy +unix.ipv6 +unix.ssl = on +unix.ssl_cert +unix.ssl_password +unix.ssl_priorities +unix.ssl_dhkey_size +unix.ssl_fingerprint +unix.ssl_verify = off +unix.password +unix.capabilities +unix.sasl_mechanism +unix.sasl_username +unix.sasl_password +unix.sasl_key +unix.sasl_timeout +unix.sasl_fail +unix.autoconnect +unix.autoreconnect +unix.autoreconnect_delay +unix.nicks +unix.nicks_alternate +unix.username +unix.realname +unix.local_hostname +unix.usermode +unix.command = "/ns identify ${sec.data.unix.chat}" +unix.command_delay +unix.autojoin = "#unix" +unix.autorejoin +unix.autorejoin_delay +unix.connection_timeout +unix.anti_flood_prio_high +unix.anti_flood_prio_low +unix.away_check +unix.away_check_max_nicks +unix.msg_kick +unix.msg_part +unix.msg_quit +unix.notify +unix.split_msg_max_length +unix.charset_message diff --git a/weechat/.weechat/spell.conf b/weechat/.weechat/spell.conf index ef9e2c8..c0355f3 100644 --- a/weechat/.weechat/spell.conf +++ b/weechat/.weechat/spell.conf @@ -19,7 +19,7 @@ suggestion_delimiter_word = cyan commands = "ame,amsg,away,command,cycle,kick,kickban,me,msg,notice,part,query,quit,topic" default_dict = "en" during_search = off -enabled = on +enabled = off real_time = off suggestions = 2 word_min_length = 2 diff --git a/weechat/.weechat/weechat.conf b/weechat/.weechat/weechat.conf index cb57610..ede4dfd 100644 --- a/weechat/.weechat/weechat.conf +++ b/weechat/.weechat/weechat.conf @@ -486,6 +486,7 @@ meta-a = "/input jump_smart" meta-b = "/input move_previous_word" meta-d = "/input delete_next_word" meta-f = "/input move_next_word" +meta-g = "/go" meta-h = "/input hotlist_clear" meta-jmeta-f = "/buffer -" meta-jmeta-l = "/buffer +"