diff options
| author | EuAndreh <eu@euandre.org> | 2022-03-28 08:59:06 -0300 |
|---|---|---|
| committer | EuAndreh <eu@euandre.org> | 2022-03-28 08:59:06 -0300 |
| commit | bbb80cb4460520700c83ca5cff6019f06466a1e7 (patch) | |
| tree | 93dd7a616f187657b2c59129e3e71f9f543368b8 | |
| parent | sh/ps1.sh: Factor decisions into separate functions (diff) | |
| download | dotfiles-bbb80cb4460520700c83ca5cff6019f06466a1e7.tar.gz dotfiles-bbb80cb4460520700c83ca5cff6019f06466a1e7.tar.xz | |
sh/symlinks.sh: Link ~/.bash_login to the same file as ~/.bash_profile
| -rw-r--r-- | sh/fzf.sh | 63 | ||||
| -rw-r--r-- | sh/symlinks.sh | 1 |
2 files changed, 38 insertions, 26 deletions
@@ -1,5 +1,7 @@ #!/bin/sh +# FIXME: fix "history" commands + # shellcheck source=/dev/null . "$(fzf-share)/completion.bash" # Disable fzf key-bindings @@ -14,14 +16,17 @@ export FZF_CTRL_T_OPTS=' export FZF_ALT_C_OPTS='--preview "tree -C {} | head -200"' -fzg() { - fn=$(git grep -n "$1" | \ - cut -d: -f -2 | \ +# FIXME: +# g '^\w.*json_destroy(' +g() { + # shellcheck disable=2086 + fn=$(git grep -n -- "$1" ${2:-} | \ + cut -d: -f -2 | \ fzf --select-1 \ --exit-0 \ --preview "echo {} | \ cut -d: -f1 | \ - xargs -I% awk -v bounds=15 -v pat=\"$1\" -v n=\$(echo {} | cut -d: -f2) ' + xargs -I% awk -v bounds=25 -v pat=\"$1\" -v n=\$(echo {} | cut -d: -f2) ' (n - bounds < NR) && (NR < n + bounds) && (NR != n) { print } NR==n { gsub(pat, \"\033[1;33m&\033[1;000m\"); print } ' %") @@ -29,46 +34,52 @@ fzg() { f="$(echo "$fn" | cut -d: -f1)" n="$(echo "$fn" | cut -d: -f2)" # shellcheck disable=2068 - history -s fzg $@ + history -s g "$@" history -s vi "+$n" "$f" vi "+$n" "$f" fi } f() { - profile="f-shell-function$(pwd | sed -e 's_/_-_g')" - file="$(git ls-files | remembering -p "$profile" -c "fzf --select-1 --exit-0 --query \"$2\" --preview 'cat {}'")" + # FIXME: speed + # profile="f-shell-function$(pwd | sed -e 's_/_-_g')" + # file="$(git ls-files | grep ${2:-.} | remembering -p "$profile" -c "fzf --select-1 --exit-0 --preview 'cat {}'")" + # shellcheck disable=2086 + file="$(git ls-files | grep ${2:-.} | fzf --select-1 --exit-0 --preview 'cat {}')" if [ -n "$file" ]; then # shellcheck disable=2068 - history -s f $@ + # history -s f $@ history -s "$1" "$file" "$1" "$file" fi } -V_FILES=' -annex/TODOs.md -tmp/scratch.txt -annex/bin/misc/git/mrconfig.ini -annex/bin/misc/dependencies.dot -archive/vid/playlist.txt -dev/others/dinheiros/money.ledger -' +V_FILES="$(echo ' +~/annex/txt/TODOs.md +~/tmp/scratch.txt +'"$(find ~/annex/txt/*.md -not -name TODOs.md | + sed 's|^/home/andreh|~|' | + LANG=POSIX.UTF-8 sort)"' +~/annex/bin/misc/git/mrconfig.ini +~/dev/libre/package-repository/dependencies.dot +~/dev/others/dinheiros/dinheiros.ledger +~/dev/libre/dotfiles/configuration.nix +' | tr ' ' '\n' | grep .)" v() { - # I want to keep the pre-defined order - f="$(echo "$V_FILES" | awk /./ | fzf --select-1 --exit-0 --query "$1")" + f="$(echo "$V_FILES" | fzf --select-1 --exit-0 --query "$1")" if [ -n "$f" ]; then - history -s v "$@" - # shellcheck disable=2088 - history -s vi "~/$f" - echo "$f" - vi "$HOME/$f" + history -s vi $f + vi "$HOME/${f#'~/'}" fi } -cm() { +cn() { CHOICE="$(git log --oneline | fzf)" - INDEX="$(git log --oneline | grep -nF "$CHOICE" | cut -d: -f1)" - git rev-parse "HEAD~$INDEX" + git log --oneline | grep -nF "$CHOICE" | cut -d: -f1 +} + +cm() { + n="$(cn)" + git rev-parse "HEAD~$((n - 1))" } diff --git a/sh/symlinks.sh b/sh/symlinks.sh index 20e0dbb3..21bc63c1 100644 --- a/sh/symlinks.sh +++ b/sh/symlinks.sh @@ -1,6 +1,7 @@ #!/bin/sh ln -fs "$DOTFILES/sh/bashrc.sh" ~/.bashrc +ln -fs "$DOTFILES/sh/bash_profile.sh" ~/.bash_login ln -fs "$DOTFILES/sh/bash_profile.sh" ~/.bash_profile ln -fs "$DOTFILES/git/gitattributes" ~/.gitattributes ln -fs "$DOTFILES/git/gitignore" ~/.gitignore_global |
