summaryrefslogtreecommitdiff
path: root/.bashrc
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2020-07-15 09:29:55 -0400
committerluxagraf <sng@luxagraf.net>2020-07-15 09:29:55 -0400
commit768a4df311c1a0b296481860258a7f58d3a87fa6 (patch)
tree2e0b10a24ebc607b9bdfcc727f99f802ee89348d /.bashrc
parentfe4d14419e52e4afbc2a7feefdc34cae2f30a3e1 (diff)
added latest tweaks to my setup
Diffstat (limited to '.bashrc')
-rw-r--r--.bashrc61
1 files changed, 55 insertions, 6 deletions
diff --git a/.bashrc b/.bashrc
index 8c3348c..b10576d 100644
--- a/.bashrc
+++ b/.bashrc
@@ -55,12 +55,20 @@ HISTTIMEFORMAT='%F %T '
shopt -s autocd
shopt -s cdable_vars
+export FZF_DEFAULT_OPTS="
+--color dark,hl:33,hl+:37,fg+:235,bg+:136,fg+:254
+--color info:254,prompt:37,spinner:108,pointer:235,marker:235
+ --no-mouse --height 70% -1 --multi --inline-info --preview='[[ \$(file --mime {}) =~ binary ]] && echo {} is a binary file || (bat --style=numbers --color=always {} || cat {}) 2> /dev/null | head -300' --preview-window='right:hidden:wrap' --bind='f3:execute(bat --style=numbers {} || less -f {}),f2:toggle-preview,ctrl-d:half-page-down,ctrl-u:half-page-up,ctrl-a:select-all+accept,ctrl-y:execute-silent(echo {+} | wl-copy),ctrl-x:execute(rm -i {+})+abort'"
+if type rg &> /dev/null; then
+ export FZF_DEFAULT_COMMAND='rg --files --no-ignore-vcs --hidden'
+ export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
+fi
# Don't use ~ to define your home here, it won't work.
export wir="$HOME/writing/wired"
export reg="$HOME/writing/register"
export ars="$HOME/writing/ars-technica/"
export l="$HOME/writing/luxagraf/"
-export lux="$HOME/Sites/luxagraf"
+export lux="$HOME/sites/luxagraf.net"
export d="$HOME/documents"
export rec="$HOME/documents/recipes"
@@ -89,7 +97,20 @@ export PS1="\[\033[33;1m\]\[\033[m\]\$(pwd-prompt.bash) \[$txtred\]\$git_dirty\[
# Complete all the things
source ~/bin/pass-completion.bash
-
+source /usr/share/fzf/key-bindings.bash
+source /usr/share/fzf/completion.bash
+
+fzf-snippet() {
+ selected="$(cat ~/documents/snippets | sed '/^$/d' | sort -n | fzf -e -i )"
+ # remove tags, leading and trailing spaces, also no newline
+ printf "$selected" | sed -e s/\;\;\.\*\$// | sed 's/^[ \t]*//;s/[ \t]*$//' | wl-copy
+}
+
+fzf-snip() {
+ selected="$(python ~/bin/snippet.py | fzf -e -i )"
+ #strip tags and any trailing space before sending to wl-copy
+ echo -e "$selected"| sed -e 's/tags\:\.\*\$//;$d' | wl-copy
+}
# get a forecast:
function fore(){
@@ -113,10 +134,18 @@ function fnt(){
#fuzzy find
function f() {
- find ${2:-.} -name \*$1\*
+ rg -l $1 ${2:-.} | fzf --preview="bat {}" --preview-window=right:70%:wrap
}
+#fuzzy find file names only
+function ff() {
+ ag -g "$1" ${2:-.} | fzf --preview="bat {}" --preview-window=right:70%:wrap
+}
+# Notational Velocity
+function fn() {
+ rg -l $1 ${2:-~/notes} | fzf --preview="bat {}" --preview-window=right:70%:wrap
+}
function tolux() {
scp $3 $1 lxf:/home/lxf/$2
@@ -154,6 +183,8 @@ function extract() # Handy Extract Program
export PIP_REQUIRE_VIRTUALENV=true
# cache pip-installed packages to avoid re-downloading
export PIP_DOWNLOAD_CACHE=$HOME/.pip/cache
+export BAT_PAGER="less -R"
+export BAT_THEME="Monokai Extended"
# Create a new directory and enter it
function md() {
@@ -231,9 +262,7 @@ function markdone(){
}
fd() {
- local dir
- dir=$(find ${1:-.} -path '*/\.*' -prune \
- -o -type d -print 2> /dev/null | fzf +m) &&
+ dir=$(zg ${1:-~/} -path '*/\.*' -prune -o -type d -print 2> /dev/null | fzf +m) &&
cd "$dir"
}
@@ -350,3 +379,23 @@ ssh-add -l >/dev/null || alias ssh='ssh-add -l >/dev/null || ssh-add && unalias
#PATH="$(ruby -e 'print Gem.user_dir')/bin:$PATH"
+
+fd() {
+ local dir
+ dir=$(find ${1:-.} -path '*/\.*' -prune \
+ -o -type d -print 2> /dev/null | fzf +m) &&
+ cd "$dir"
+}
+
+# fshow - git commit browser
+fshow() {
+ git log --graph --color=always \
+ --format="%C(auto)%h%d %s %C(black)%C(bold)%cr" "$@" |
+ fzf --ansi --no-sort --reverse --tiebreak=index --bind=ctrl-s:toggle-sort \
+ --bind "ctrl-m:execute:
+ (grep -o '[a-f0-9]\{7\}' | head -1 |
+ xargs -I % sh -c 'git show --color=always % | less -R') << 'FZF-EOF'
+ {}
+FZF-EOF"
+}
+RIPGREP_CONFIG_PATH=~/.ripgreprc