summaryrefslogtreecommitdiff
path: root/.bashrc
diff options
context:
space:
mode:
Diffstat (limited to '.bashrc')
-rw-r--r--.bashrc64
1 files changed, 52 insertions, 12 deletions
diff --git a/.bashrc b/.bashrc
index 5b65c26..3933adc 100644
--- a/.bashrc
+++ b/.bashrc
@@ -14,6 +14,11 @@ export PATH=/usr/local/bin:$PATH
export PATH=$PATH:$HOME/bin
export PATH=$PATH:$HOME/bin/bash-scripts
+# set vi mode but keep control l
+set -o vi
+bind -m vi-command 'Control-l: clear-screen'
+bind -m vi-insert 'Control-l: clear-screen'
+
# Alias definitions
if [ -f ~/.aliases ]; then
. ~/.aliases
@@ -131,11 +136,11 @@ function fntt(){
find ~/notes ~/documents/bookmarks ~/documents/reading\ notes -type f -maxdepth 2 -print0 | xargs -0 grep -$2i $1
}
function fnt(){
- ${EDITOR:-nvim} "$(rg -l $1 ~/notes/ ~/documents/bookmarks/ ~/documents/reading\ notes/ ~/lux/ | fzf --preview="bat {}" --preview-window=right:70%:wrap)";
+ ${EDITOR:-vim} "$(rg -l $1 ~/notes/ ~/documents/bookmarks/ ~/documents/reading\ notes/ ~/lux/ | fzf --preview="bat {}" --preview-window=right:70%:wrap)";
}
#fuzzy find
function f() {
- ${EDITOR:-nvim} "$(rg -l $1 ${2:-.} | fzf --preview="bat {}" --preview-window=right:70%:wrap)";
+ ${EDITOR:-vim} "$(rg -l $1 ${2:-.} | fzf --preview="bat {}" --preview-window=right:70%:wrap)";
}
#fuzzy find file names only
@@ -245,6 +250,18 @@ function timer(){
mpv ~/bin/clap.mp3 &>/dev/null
}
+function ,n(){
+ # mirrors a notes search within vim
+ # optional search term
+
+ if [ $# -eq 0 ]; then
+ SEL=$(rg --max-depth=1 -l ".*" ~/notes/ --line-number --sort path | cut -c 17- | fzf -e -i --bind 'tab:up')
+ else
+ SEL=$(rg --max-depth=1 -l "$1" ~/notes/ --line-number --sort path | cut -c 17- | fzf -e -i --bind 'tab:up')
+ fi
+ content=~/notes/"$SEL"
+ vim "$content"
+}
# Some GTD scripts
#
#
@@ -284,31 +301,54 @@ function ca() {
function na() {
# na = (show) next actions
- # print all next actions (tasks prefaced by 'qq')
- # optional project, area, or context i.e. @email @phone
+ # print all next actions (anothing not a project basically)
+ # optional project, area, or context, or both proj, area and context i.e. @email @phone
clear
if [ $# -eq 0 ]; then
echo '----------- all tasks ----------'
echo ' '
- rg -l ".*" $GTD_DIR -g '!proj*' --line-number --sort path | cut -c 21- | rev | cut -c 5- | rev | nl
+ rg --max-depth=1 -l ".*" $GTD_DIR -g '!proj*' --line-number --sort path | cut -c 21- | rev | cut -c 5- | rev | nl
echo ' '
echo '-----------------------------------'
else
- echo "----------- all $1 tasks ----------"
- echo ' '
- rg -l "$1" $GTD_DIR -g '!proj*' --line-number --sort path | cut -c 21- | rev | cut -c 5- | rev | nl
+ #test for negation (not prefix)
+ if [[ "$1" =~ ^not* ]]; then
+ myString="${1:3}"
+ #test for second input
+ if [ $# -eq 2 ]; then
+ echo "----------- all $1 tasks that are $2 ----------"
+ echo ' '
+ rg --max-depth=1 --files-without-match "$myString" $GTD_DIR -g '!proj*' --line-number --sort path | while read line; do rg --with-filename "$2" "$line"| cut -c 21- ; done
+ else
+ # just one negative search
+ echo "----------- all $1 tasks ----------"
+ echo ' '
+ rg --max-depth=1 --files-without-match "$myString" $GTD_DIR -g '!proj*' --line-number --sort path | cut -c 21- | rev | cut -c 5- | rev | nl
+ fi
+ else
+ #test for second input
+ if [ $# -eq 2 ]; then
+ echo "----------- all $1 tasks that are $2 ----------"
+ echo ' '
+ rg --max-depth=1 -l "$1" $GTD_DIR -g '!proj*' --line-number --sort path | while read line; do rg --line-number --with-filename "$2" "$line"| cut -c 21- ; done
+ #rg -l "$1" $GTD_DIR -g '!proj*' --line-number --sort path | rg "$2" | cut -c 21- | rev | cut -c 5- | rev | nl
+ else
+ # just one search
+ echo "----------- all $1 tasks ----------"
+ echo ' '
+ rg -l --max-depth=1 "$1" $GTD_DIR -g '!proj*' --line-number --sort path | cut -c 21- | rev | cut -c 5- | rev | nl
+ fi
+ fi
echo ' '
echo '-----------------------------------'
fi
}
-
-
function ea() {
# ea = edit action
# pull a list of tasks with an optional search term
# then edit the selected task with vim
- SEL=$(rg -l $1 $GTD_DIR -g '!proj*'| cut -c 21- | fzf -e -i --bind 'tab:up')
+ SEL=$(rg --max-depth=1 -l $1 $GTD_DIR -g '!proj*'| cut -c 21- | fzf -e -i --bind 'tab:up')
#trickery to add to beginning of the file
content="$GTD_DIR$SEL"
vim "$content"
@@ -339,7 +379,7 @@ function da(){
then
return 0
else
- rm "$content"
+ mv "$content" "$GTD_DIR""done/"
fi
}