-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.bash_aliases
76 lines (64 loc) · 1.55 KB
/
.bash_aliases
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
# Source local bash script if exists
if [[ -f ~/.bash_aliases.local ]]; then
source ~/.bash_aliases.local
fi
# Utilities
## Editing
alias v="search_and_edit"
alias vim="nvim"
alias vimdiff="nvim -d"
alias vimrc="vim ~/.config/nvim"
search_and_edit() {
selection=$(fzf)
[[ -z $selection ]] && return
history -s vim $selection
vim $selection
}
## Helpful aliases
alias python="python3"
alias bashrc="vim ~/.bash_aliases"
cdl() { cd "$@" && ls; }
mkd() { mkdir "$@" && cd "$@"; }
if [[ -z $FILESHARE_PATH ]]; then
echo "WARNING: no FILESHARE_PATH defined"
else
# Open shared todo file
todo() {
vim -c "cd $FILESHARE_PATH" ~/SyncThing/FileShare/TODO.md
}
fi
## Notes
NOTES_PATH=~/.notes
# Create new note
note() {
printf -v date '%(%Y-%m-%d)T\n' -1
date=$(echo $date | xargs) #trim whitespace
vim $NOTES_PATH/${date}.txt
}
# Open note
notes() {
selection=$(ls -r $NOTES_PATH | fzf --preview="less ${NOTES_PATH}/{}")
[[ -z $selection ]] && return
vim $NOTES_PATH/$selection
}
# Use Telescope live_grep to search for a
# string in current directory
search_files() {
nvim -c "Telescope live_grep theme=dropdown"
}
# "find file"
alias ff="search_files"
search_notes() {
pushd $NOTES_PATH > /dev/null
search_files
popd > /dev/null
}
# "find note"
alias fn="search_notes"
# command used to track dotfiles in git
alias config='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME'
# Source local bash script if exists
if [[ -f ~/.bash_aliases.after ]]; then
source ~/.bash_aliases.after
fi