File tree 9 files changed +61
-41
lines changed
9 files changed +61
-41
lines changed Original file line number Diff line number Diff line change @@ -99,6 +99,8 @@ unset hook
99
99
100
100
# modify path to include useful scripts
101
101
# shellcheck source=/dev/null
102
+ source " ${DOTFILES__ROOT} /.dotfiles/dotenv/lib/utils.sh"
103
+ # shellcheck source=/dev/null
102
104
source " ${DOTFILES__ROOT} /.dotfiles/dotenv/lib/path.sh"
103
105
__dot_path_setup
104
106
Original file line number Diff line number Diff line change @@ -22,8 +22,14 @@ alias mv="mv -i"
22
22
# run this after plugins are loaded in case gnu grep and gnu ls is added to path in plugins
23
23
function __grep_ls_colors() {
24
24
local LS_COLOR_FLAG LS_BIN GREP_BIN
25
- LS_BIN=" $( unalias ls & > /dev/null; command -v ls) "
26
- GREP_BIN=" $( unalias grep & > /dev/null; command -v grep) "
25
+ LS_BIN=" $(
26
+ unalias ls & > /dev/null
27
+ command -v ls
28
+ ) "
29
+ GREP_BIN=" $(
30
+ unalias grep & > /dev/null
31
+ command -v grep
32
+ ) "
27
33
28
34
# Colorize grep matches
29
35
# test if color is supported, if it is, always add color
@@ -88,3 +94,7 @@ alias extip="curl -s https://api.ipify.org/?format=text"
88
94
# Reload the current shell
89
95
# shellcheck disable=SC2139
90
96
alias reload=" exec ${SHELL} -l"
97
+
98
+ # Alias vi to a found editor
99
+ # shellcheck disable=SC2139
100
+ alias vi=" $( __find_editor) "
Original file line number Diff line number Diff line change 1
1
# shellcheck shell=bash
2
2
# Shortcuts
3
3
4
- # Alias vi to vim
5
- if command -v vim & > /dev/null; then
6
- alias vi=" vim"
7
- fi
8
-
9
4
# Networking shortcuts
10
5
function ips() {
11
6
ifconfig | grep ' inet\>' | perl -nle' /(\d+\.\d+\.\d+\.\d+)/ && print $1'
Original file line number Diff line number Diff line change @@ -18,5 +18,6 @@ export COMP_TAR_INTERNAL_PATHS
18
18
# Make = a wordbreak character
19
19
COMP_WORDBREAKS=${COMP_WORDBREAKS/ =/ }
20
20
21
- # set $EDITOR to vi(m) if not already set
22
- export EDITOR=" ${EDITOR:- $(command -v vim &>/ dev/ null && echo vim || echo vi)} "
21
+ # set $EDITOR to a if not already set
22
+ EDITOR=" ${EDITOR:- $(__find_editor)} "
23
+ export EDITOR
Original file line number Diff line number Diff line change 1
1
# shellcheck shell=bash
2
2
3
- # push a command to the prompt command
4
- function __push_prompt_command() {
5
- local command=" ${1/% ;/ } "
6
- PROMPT_COMMAND=" $( echo " $( echo " ${PROMPT_COMMAND/% ;/ } " | tr ' ;' ' \n' | grep -v -F " ${command} " | grep -v ' ^ *$' | tr ' \n' ' ;' ) ${command} ;" | sed ' s/;;/;/' | sed ' s/^;//' ) "
7
- }
8
-
9
- # internal prompt command stack to simplify the PROMPT_COMMAND variable
10
- declare -a __prompt_actions
11
- function __push_internal_prompt_command() {
12
- local command=" ${1/% ;/ } "
13
- __prompt_actions+=(" ${command} " )
14
- }
15
- function __run_prompt_command() {
16
- for l in " ${__prompt_actions[@]} " ; do
17
- eval " $l "
18
- done
19
- }
20
-
21
3
# update the dotfiles repo
22
4
function dotfiles-update() (
23
5
# shellcheck disable=SC2164
Original file line number Diff line number Diff line change
1
+ # shellcheck shell=bash
2
+
3
+ # push a command to the prompt command
4
+ function __push_prompt_command() {
5
+ local command=" ${1/% ;/ } "
6
+ PROMPT_COMMAND=" $( echo " $( echo " ${PROMPT_COMMAND/% ;/ } " | tr ' ;' ' \n' | grep -v -F " ${command} " | grep -v ' ^ *$' | tr ' \n' ' ;' ) ${command} ;" | sed ' s/;;/;/' | sed ' s/^;//' ) "
7
+ }
8
+
9
+ # internal prompt command stack to simplify the PROMPT_COMMAND variable
10
+ declare -a __prompt_actions
11
+ function __push_internal_prompt_command() {
12
+ local command=" ${1/% ;/ } "
13
+ __prompt_actions+=(" ${command} " )
14
+ }
15
+ function __run_prompt_command() {
16
+ for l in " ${__prompt_actions[@]} " ; do
17
+ eval " $l "
18
+ done
19
+ }
20
+
21
+ # helper function get the closest base editor
22
+ function __find_editor() {
23
+ local editor
24
+ # shellcheck disable=SC2209
25
+ editor=" $( which vi nano | head -1) "
26
+
27
+ if command -v code-insiders & > /dev/null && echo " ${PATH} " | grep -q " /.vscode-server-insiders/bin/" && ! (echo " ${PATH} " | grep -q " /.vscode-server/bin/" ); then
28
+ editor=" code-insiders --wait"
29
+ elif command -v code & > /dev/null && echo " ${PATH} " | grep -q " /.vscode-server/bin/" ; then
30
+ editor=" code --wait"
31
+ elif [[ -n " ${DOT___IS_WSL} " ]] && command -v npp & > /dev/null; then
32
+ editor=npp
33
+ elif command -v nvim & > /dev/null; then
34
+ editor=nvim
35
+ elif command -v vim & > /dev/null; then
36
+ editor=vim
37
+ fi
38
+
39
+ echo " ${editor} "
40
+ }
Original file line number Diff line number Diff line change 1
1
# shellcheck shell=bash
2
2
3
- # Alias vi to vim
4
- if command -v vim & > /dev/null; then
5
- alias vi=" vim"
6
- fi
7
-
8
3
# Networking shortcuts
9
4
function ips() {
10
5
ip addr | grep ' inet\>' | perl -nle' /(\d+\.\d+\.\d+\.\d+)/ && print $1'
Original file line number Diff line number Diff line change 4
4
# test by running `net.exe sessions` vs winsudo net.exe sessions
5
5
alias wudo=" winsudo"
6
6
alias wsl-sudo=" winsudo"
7
-
8
- # Alias vi to vscode or notepad++
9
- if command -v code-insiders & > /dev/null && echo " ${PATH} " | grep -q " /.vscode-server-insiders/bin/" && ! (echo " ${PATH} " | grep -q " /.vscode-server/bin/" ); then
10
- alias vi=" code-insiders --wait"
11
- elif command -v code & > /dev/null && echo " ${PATH} " | grep -q " /.vscode-server/bin/" ; then
12
- alias vi=" code --wait"
13
- elif command -v npp & > /dev/null; then
14
- alias vi=" npp"
15
- fi
Original file line number Diff line number Diff line change @@ -7,6 +7,10 @@ if [[ -d "$(wslpath -ua "c:/")Program Files (x86)/Notepad++/" ]]; then
7
7
fi
8
8
9
9
PROGRAM=" $( wslpath -ua " c:/${PGM_PATH} /Notepad++/notepad++.exe" ) "
10
+ if [[ ! -e " ${PROGRAM} " ]]; then
11
+ # fallback to a vi program
12
+ exec " $( which nvim vim vi | head -1) " " $@ "
13
+ fi
10
14
11
15
# if there are any baked in arguments they are defined here
12
16
args=()
You can’t perform that action at this time.
0 commit comments