Skip to content

Commit

Permalink
Raycast & more (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
denisidoro authored Mar 8, 2022
1 parent 7677130 commit 555255a
Show file tree
Hide file tree
Showing 40 changed files with 941 additions and 109 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ local/
.lein-env
modules
Cargo.lock
launchers/alfred/**/*.png
launchers/alfred/**/*.png
raycast/gen*.sh
storm*.txt
16 changes: 9 additions & 7 deletions editors/vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
"files.autoSave": "onFocusChange",
"files.trimFinalNewlines": true,
"editor.formatOnPaste": true,
// "editor.formatOnSave": true,
"editor.formatOnSave": false,
// "editor.formatOnPaste": false,
"editor.formatOnSave": true,
// "editor.formatOnSave": false,
"editor.minimap.enabled": true,
"editor.mouseWheelZoom": true,
"explorer.sortOrder": "default",
Expand All @@ -29,8 +30,7 @@
// UI
// ==================
"workbench.activityBar.visible": false,
"workbench.editor.enablePreview": false,
"workbench.editor.enablePreviewFromQuickOpen": false,
"workbench.editor.enablePreviewFromQuickOpen": true,
"workbench.editor.highlightModifiedTabs": true,
"workbench.list.keyboardNavigation": "simple",
"customizeUI.activityBar": "bottom",
Expand All @@ -52,14 +52,15 @@
"**/.DS_Store": true,
"**/node_modules": true,
"**/.gen": true,
"**/gen": true,
"/gen": true,
// "**/gen": true,
// gen": true,
"**/.glue": true,
"**/.tmp": true,
"**/vendor": true,
"**/go-build": true,
"bazel-*": true,
"pkg*": true,
"**/.gradle": true,
"**/.classpath": true,
"**/.project": true,
"**/.settings": true,
Expand Down Expand Up @@ -227,5 +228,6 @@
"typescript.inlayHints.functionLikeReturnTypes.enabled": true,
"typescript.inlayHints.parameterTypes.enabled": true,
"typescript.inlayHints.propertyDeclarationTypes.enabled": true,
"typescript.inlayHints.variableTypes.enabled": true
"typescript.inlayHints.variableTypes.enabled": true,
"workbench.editor.enablePreviewFromCodeNavigation": true
}
2 changes: 1 addition & 1 deletion git/config
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,4 @@

[credential]
helper = ""
helper = manager-core
helper = manager-core
1 change: 1 addition & 0 deletions git/ignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Sensitive data
.zshrc-secrets
local.properties
.dotsecrets
# *secret*
# *credential*
# *password*
Expand Down
5 changes: 4 additions & 1 deletion navi/cheats/filesystem.cheat
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ find -L . -name . -o -type d -prune -o -type l -exec rm {} +
du -sh

# Edit fre entries
dot code vscode "${HOME}/Library/Application Support/fre/fre.json"
dot code vscode "${HOME}/Library/Application Support/fre/fre.json"

# Resize pngs to 128x128
\ls ./*[^(_128)].png | sed 's/.png//' | xargs -I% convert "%.png" -resize 128x128 "%_128.png"
63 changes: 63 additions & 0 deletions navi/cheats/tmp.cheat
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,68 @@ rg <opts1> <pattern> <path>
# search 2
rg <opts2> <pattern> <path>

# make install path
echo make DESTDIR=<dst> install

$ dst: echo "$HOME" --- --fzf-overrides '--no-select-1'
$ opts1: echo -e 'option;description\n--column;show column numbers\n-l;print filenames with maches\n--files-without-match;print filenames without matches' | column -t -s';' --- --column 1 --header-lines 1 --multi --map "tr '\n' ' '"
$ opts2: echo -e 'option;description\n--column;show column numbers\n-l;print filenames with maches\n--files-without-match;print filenames without matches' | column -t -s';' --- --column 1 --header-lines 1 --multi --map "tr c f"

% slow

# Slow command
echo <a> <b>

$ a: printf 'Loading...' >&2; sleep 2; printf '%b' '\r\033[2K' >&2; echo "a c" | tr ' ' '\n'
$ b: sleep 2 && echo "b d" | tr ' ' '\n'

% table

# my make command
echo make <cfg>

$ cfg: for x in 1 2 3; do \
for y in a b c; do \
echo "$x $y"; \
done; \
done \
--- --expand --prevent-extra

% shell

# env
cat ${HOME}/dotfiles/shell/bash/bashrc | wc
echoerr foo

% err

# check for error
log="<log>"
if [ -n "$log" ]; then
echo "my git log has <words> words"
else
echo "failed to get git log"
fi

$ log: echo "foo bar"
$ words: echo "$log" | wc -w | xargs


% default

# default test
echo "<n>"

$ n: echo -e "16\n"

% src

# This will output "foo\nyes"
echo foo
true \
&& echo yes `# comment 1` \
|| echo no `# comment 2`

# echoerr
source "${HOME}/dotfiles/shell/aux/core.bash"
echoerr foo
2 changes: 1 addition & 1 deletion navi/cheats/yabai.cheat
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ yabai -m window --swap first
yabai -m window --swap mouse

# cycle window clockwise
win=$(yabai -m query --windows --window last | jq '.id')
win="$(yabai -m query --windows --window last | jq '.id')"
while : ; do
yabai -m window "$win" --swap prev &> /dev/null
if [[ $? -eq 1 ]]; then
Expand Down
4 changes: 3 additions & 1 deletion navi/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,6 @@ cheats:
# tags: git,!checkout # equivalent to the --tag-rules option

shell:
command: zsh # shell used for shell out. possible values: bash, zsh, dash, ...
# shell used for shell out. possible values: bash, zsh, dash, ...
finder_command: /usr/local/bin/bash
command: env BASH_ENV="${HOME}/dotfiles/shell/bash/bashrc" /usr/local/bin/bash --norc --noprofile
2 changes: 1 addition & 1 deletion raycast/navi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# @raycast.mode silent

# Optional parameters:
# @raycast.icon 💬
# @raycast.icon /Users/denis.isidoro/Pictures/Icons/navi_128.png
# @raycast.packageName Browser

# Documentation:
Expand Down
41 changes: 41 additions & 0 deletions raycast/slack-jump.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash --norc --noprofile

# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Jump to...
# @raycast.mode silent

# Optional parameters:
# @raycast.icon images/slack-logo.png
# @raycast.packageName Slack
# @raycast.argument1 { "type": "text", "placeholder": "Channel / DM / File / Misc" }

# Documentation:
# @raycast.author Jakub Lanski
# @raycast.authorURL https://github.com/jaklan

main() {
local query="$1"

bash "${HOME}/dotfiles/raycast/slack.sh"

local code
set +e
read -r -d '' code <<EOF
set inputDelay to 0.5
set enterDelay to 0.5
tell application "System Events"
keystroke "k" using command down
delay inputDelay
keystroke "$query"
delay enterDelay
key code 36
end tell
EOF
set -e

osascript -e "$code"
}

main "$@"
13 changes: 12 additions & 1 deletion repos/tasker-js/src/main.ts
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
console.log(42)
import { Db } from "./db"

const txt = `TODO`

const db = new Db(txt)

const files = db.data.fs.files;
files.forEach(file => {
const id = file.id
const path = db.fsFileFullPath(id)
console.log(`${path};${id};${file.kb};${file.date}`)
})
48 changes: 24 additions & 24 deletions repos/tasker-js/test/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,31 +54,31 @@ const out = `
1,blob.rar,4,2;5;3;6`

describe('Db', () => {
it('idempotency', () => {
const db = new Db(txt)
const db2 = new Db(db.serialize())
const db3 = new Db(db2.serialize())
assert.deepStrictEqual(db3.serialize().trim(), db.serialize().trim())
});
it('idempotency', () => {
const db = new Db(txt)
const db2 = new Db(db.serialize())
const db3 = new Db(db2.serialize())
assert.deepStrictEqual(db3.serialize().trim(), db.serialize().trim())
});

it('integration test', () => {
const db = new Db(txt)
db.fsFileAdd("Pictures/DCIM/img01.jpg", 323, 150630)
db.fsFileAdd("Books/Fiction/LotR2.pdf", 1123, 181203)
db.fsFileAdd("Books/Fiction/LotR2.pdf", 1123, 181203)
db.telegramUploadAdd("Pictures/DCIM/img01.jpg.7z", 666, 777)
db.telegramUploadAdd("/Pictures/DCIM/img01.jpg", 666, 777)
db.telegramUploadAdd("/Pictures/DCIM/img01b.jpg", 666, 777)
db.azureFileAdd("/Books/blob.rar", ["Pictures/DCIM/img01.jpg.7z", "Pictures/DCIM/img03.jpg", "/Books/Fiction/LotR2.pdf", "Books/German/nein.pdf"])
db.telegramUploadAdd("/Documents/ID/rg.jpg", 666, 777)
db.telegramUploadAdd("/Documents/ID/titre.jpg", 666, 777)
it('integration test', () => {
const db = new Db(txt)
db.fsFileAdd("Pictures/DCIM/img01.jpg", 323, 150630)
db.fsFileAdd("Books/Fiction/LotR2.pdf", 1123, 181203)
db.fsFileAdd("Books/Fiction/LotR2.pdf", 1123, 181203)
db.telegramUploadAdd("Pictures/DCIM/img01.jpg.7z", 666, 777)
db.telegramUploadAdd("/Pictures/DCIM/img01.jpg", 666, 777)
db.telegramUploadAdd("/Pictures/DCIM/img01b.jpg", 666, 777)
db.azureFileAdd("/Books/blob.rar", ["Pictures/DCIM/img01.jpg.7z", "Pictures/DCIM/img03.jpg", "/Books/Fiction/LotR2.pdf", "Books/German/nein.pdf"])
db.telegramUploadAdd("/Documents/ID/rg.jpg", 666, 777)
db.telegramUploadAdd("/Documents/ID/titre.jpg", 666, 777)

assert.deepStrictEqual(db.azurePathsNotUploaded(), [
'Pictures/DCIM/img01b.jpg',
'Documents/ID/rg.jpg',
'Documents/ID/titre.jpg'
])
assert.deepStrictEqual(db.azurePathsNotUploaded(), [
'Pictures/DCIM/img01b.jpg',
'Documents/ID/rg.jpg',
'Documents/ID/titre.jpg'
])

assert.deepStrictEqual(db.serialize().trim(), out.trim())
});
assert.deepStrictEqual(db.serialize().trim(), out.trim())
});
});
32 changes: 16 additions & 16 deletions repos/tasker-js/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
module.exports = {
devtool: 'inline-source-map',
entry: './src/main.ts',
output: {
filename: 'bundle.js',
path: `${__dirname}/dist`,
},
resolve: {
extensions: ['.ts', '.js']
},
module: {
rules: [
{ test: /\.ts?$/, loader: 'awesome-typescript-loader' },
],
},
plugins: [
],
devtool: 'inline-source-map',
entry: './src/main.ts',
output: {
filename: 'bundle.js',
path: `${__dirname}/dist`,
},
resolve: {
extensions: ['.ts', '.js']
},
module: {
rules: [
{ test: /\.ts?$/, loader: 'awesome-typescript-loader' },
],
},
plugins: [
]
};
33 changes: 30 additions & 3 deletions scripts/core/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,19 @@ doc::help_msg() {
doc::maybe_help() {
local -r sh_file="$0"

case "${!#:-}" in
doc::autocomplete "$@"

case "${1:-}" in
-h|--help|--version) doc::help_msg "$sh_file"; exit 0 ;;
esac
}

doc::help_or_fail() {
local -r sh_file="$0"

case "${!#:-}" in
doc::autocomplete "$@"

case "${1:-}" in
-h|--help|--version) doc::help_msg "$sh_file"; exit 0 ;;
esac

Expand All @@ -154,6 +158,9 @@ doc::help_or_fail() {

doc::parse() {
local -r sh_file="$0"

doc::autocomplete "$@"

local -r help="$(doc::help_msg "$sh_file")"
local docopt="${DOT_DOCOPT:-}"

Expand All @@ -179,4 +186,24 @@ doc::parse() {
eval "$("$docopt" -h "${help}" : "${@:1}")"
}

export_f doc::help_msg doc::maybe_help doc::help_or_fail doc::parse
doc::autocomplete() {
if [ "${1:-}" != "_autocomplete" ]; then
return 0
fi

shift

if ! has _autocomplete; then
exit 99
fi

local -r out="$(_autocomplete "$@")"
if [ -n "$out" ]; then
echo "$out"
exit 0
else
exit 1
fi
}

export_f doc::help_msg doc::maybe_help doc::help_or_fail doc::parse doc::autocomplete
Loading

0 comments on commit 555255a

Please sign in to comment.