-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
simple os-detection with shell script #7
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/usr/bin/env sh | ||
|
||
# detect os platform | ||
OS_TYPE="$(uname -s)" | ||
case "${OS_TYPE}" in | ||
Linux*) sort_command=sort grep_command=grep;; | ||
Darwin*) sort_command=gsort grep_command=ggrep;; | ||
CYGWIN*) sort_command=sort grep_command=grep;; | ||
OpenBSD*) sort_command=sort grep_command=grep;; | ||
FreeBSD*) sort_command=sort grep_command=grep;; | ||
*) sort_command="UNKNOWN" grep_command="UNKNOWN";; | ||
esac | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,23 @@ | ||
#!/bin/bash | ||
zkt-raw | fzf --height 100% --no-info --no-multi \ | ||
--bind "ctrl-o:execute-silent[tmux send-keys -t \{left\} Escape :read Space ! Space echo Space && \ | ||
tmux send-keys -t \{left\} -l '\"\\'{2}'\"' && \ | ||
tmux send-keys -t \{left\} Enter]" \ | ||
--bind "ctrl-y:execute-silent(echo {2} | pbcopy),enter:execute[ \ | ||
ggrep -F --color=always -i {2} *.md -l | \ | ||
fzf --ansi --height 100% --preview-window=top:65% \ | ||
--bind 'enter:execute-silent$ \ | ||
tmux send-keys -t \{left\} Escape :e Space && \ | ||
tmux send-keys -t \{left\} -l \{} && \ | ||
tmux send-keys -t \{left\} Enter \ | ||
$' \ | ||
--preview 'bat --color always --language md --style plain \{}' \ | ||
]" | ||
|
||
# load os detect script | ||
. os-detect | ||
|
||
case "${grep_command}" in | ||
UNKNOWN*) echo "support only unix system";; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not put this part in the os-detect file with an exit? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just got the idea from you, just adding exit $? in the end of os-detect right?to be honest, my knowledge of shell scripts is lacking |
||
*) | ||
zkt-raw | fzf --height 100% --no-info --no-multi \ | ||
--bind "ctrl-o:execute-silent[tmux send-keys -t \{left\} Escape :read Space ! Space echo Space && \ | ||
tmux send-keys -t \{left\} -l '\"\\'{2}'\"' && \ | ||
tmux send-keys -t \{left\} Enter]" \ | ||
--bind "ctrl-y:execute-silent(echo {2} | pbcopy),enter:execute[ \ | ||
${grep_command} -F --color=always -i {2} *.md -l | \ | ||
fzf --ansi --height 100% --preview-window=top:65% \ | ||
--bind 'enter:execute-silent$ \ | ||
tmux send-keys -t \{left\} Escape :e Space && \ | ||
tmux send-keys -t \{left\} -l \{} && \ | ||
tmux send-keys -t \{left\} Enter \ | ||
$' \ | ||
--preview 'bat --color always --language md --style plain \{}' \ | ||
]";; | ||
esac |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,14 @@ | ||
#!/bin/bash | ||
# useful for editors, used in zkt | ||
rg -o "#[\w\-_]{3,}" -t md -N --no-filename "$ZK_PATH" | | ||
rg -v "^#(notes-|import-)" | \ | ||
awk ' { tot[$0]++ } END { for (i in tot) print tot[i], "\t", i } ' | \ | ||
gsort -r --numeric-sort | ||
|
||
# load os detect script | ||
. os-detect | ||
|
||
case "${sort_command}" in | ||
UNKNOWN*) echo "support only unix system";; | ||
*) | ||
rg -o "#[\w\-_]{3,}" -t md -N --no-filename "$ZK_PATH" | | ||
rg -v "^#(notes-|import-)" | \ | ||
awk ' { tot[$0]++ } END { for (i in tot) print tot[i], "\t", i } ' | \ | ||
${sort_command} -r --numeric-sort;; | ||
esac |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If these don't exist, we'll need to print a warning to install them!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry, I was too late to respond to this. based on 000bbf7#r470224199 i think we could print a warning. and then do exit from os-detect file. is it good?