Skip to content

Commit e0f978a

Browse files
committed
hi
1 parent 97310af commit e0f978a

7 files changed

Lines changed: 718 additions & 4 deletions

File tree

.bashrc

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ COLOR_LIGHT_GREEN=$(tput sgr0 && tput bold && tput setaf 2)
1212
COLOR_LIGHT_RED=$(tput sgr0 && tput bold && tput setaf 1)
1313
COLOR_LIGHT_CYAN=$(tput sgr0 && tput bold && tput setaf 6)
1414
COLOR_RESET=$(tput sgr0)
15+
BOLD=$(tput bold)
1516

1617
# shellcheck disable=SC1091
1718
ITERM_SHELL_INTEGRATION="${HOME}.iterm2_shell_integration.bash"
@@ -1219,19 +1220,41 @@ lbl() {
12191220
else
12201221
echo "All labels on ${1} matching '${2}' (case insensitive):"
12211222
echo "${result}" | jq -r '.result[] | select(.fullName|test("'"${2}"'"; "i")) | .fullName' | while read -r line ; do
1222-
stmt "${1}" "'${line}: ' + Label.${line}"
1223+
stmt "${1}" "'${line}: ' + Label.${line}" quiet
12231224
done
12241225
fi
12251226
}
12261227

12271228
# Execute an apex statement against an environment
12281229
stmt() {
12291230
if [[ -z "$1" ]] || [[ -z "$2" ]]; then
1230-
echo "Usage: stmt [ORG_ID] [STATEMENT_TO_EVALUATE]"
1231+
echo "Execute a statement, and print the output. Takes the apex statement you pass in and wraps it in a System.debug() call."
1232+
echo "Pass quiet or q as the last paremeter to supress notification messages"
1233+
echo "Usage: stmt [ORG_ID] [STATEMENT_TO_EVALUATE] ['quiet' | 'q']"
12311234
return 1
12321235
fi
12331236

1234-
sfdx force:apex:execute -u "${1}" -f /dev/stdin<<<'System.debug('"${2}"');' | # Execute the statement inside a system.debug(). execute expects a file, so use <<< trick to make it seem like a file
1235-
grep USER_DEBUG | # search for the debug line
1237+
local apexCommand
1238+
apexCommand='System.debug('"${2}"');'
1239+
if [ "$3" != "quiet" ] && [ "$3" != "q" ]; then
1240+
>&2 echo "${COLOR_BLUE}${BOLD}Executing:${COLOR_RESET}"
1241+
>&2 echo "${COLOR_BLUE}${apexCommand}${COLOR_RESET}"
1242+
>&2 echo
1243+
fi
1244+
1245+
# Example apex output, to see what we're grepping for. Logs for the
1246+
# multline command System.debug('a\nb'):
1247+
# 11:38:56.11 (11521203)|EXECUTION_STARTED
1248+
# 11:38:56.11 (11525424)|CODE_UNIT_STARTED|[EXTERNAL]|execute_anonymous_apex
1249+
# 11:38:56.11 (11944606)|USER_DEBUG|[1]|DEBUG|a
1250+
# b
1251+
# 11:38:56.11 (11980694)|CUMULATIVE_LIMIT_USAGE
1252+
# 11:38:56.11 (11980694)|LIMIT_USAGE_FOR_NS|(default)|
1253+
# We need to find from the start of USER_DEBUG to the next non-debug line.
1254+
# Notice "b" is put on a line by itself, making it tricky to include in output
1255+
1256+
sfdx force:apex:execute -u "${1}" -f /dev/stdin<<<"$apexCommand" | # Execute the statement inside a system.debug(). execute expects a file, so use <<< trick to make it seem like a file
1257+
pcregrep -M 'USER_DEBUG(.|\n)+?([\d]{2}:[\d]{2}:[\d]{2})' | # find debug line, and try to search up to the next apex ouptut line, starting with dd:dd:dd
1258+
sed '$d' | # remove the last line, which is the first non-debug line
12361259
sed 's/.*\|//' # find everything after the last pipe, which will be the debugged output
12371260
}

.vim/bundle/winresizer/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.un~
2+
doc/tags

.vim/bundle/winresizer/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2011
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

.vim/bundle/winresizer/README.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
winresizer.vim
2+
================
3+
4+
Very simple vim plugin for easy resizing of your vim windows.
5+
6+
You can resize windows continuously by using typical keymaps of Vim. (`h`, `j`, `k`, `l`)
7+
The WindowResize mode makes your operation more quickly and more naturally.
8+
9+
## Demo
10+
11+
### For terminal vim
12+
13+
#### Resize mode
14+
15+
![demo-for-terminal](https://raw.github.com/wiki/simeji/winresizer/images/demo-for-terminal.gif)
16+
17+
#### Window Move mode
18+
19+
You can move windows.
20+
![demo-move](https://raw.github.com/wiki/simeji/winresizer/images/demo-move.gif)
21+
22+
#### Change the focus & resize window
23+
24+
Focus mode -> Resize mode
25+
![demo-focus](https://raw.github.com/wiki/simeji/winresizer/images/demo-focus.gif)
26+
27+
### For MacVim(gui vim)
28+
29+
* MacVim Window resize
30+
* Vim window resize
31+
32+
![demo-for-macvim](https://raw.github.com/wiki/simeji/winresizer/images/demo-for-gui.gif)
33+
34+
## In default setting
35+
36+
1. You press keys `Ctrl + E` or execute `:WinResizerStartResize` on vim(in normal mode), to run this plugin
37+
38+
2. Start 'window resize mode', and you can resize current vim windows using 'h', 'j', 'k', 'l' keys
39+
40+
3. You want to finish resize mode, then press "Enter" key
41+
42+
4. If you cancel window resize, then press "q" key.
43+
You will get window size of before change
44+
45+
5. You can change the mode if you press "e" in 'window resize mode'
46+
47+
## Customize options
48+
49+
You can change setting and key mappings by using below options.(in your vimrc)
50+
51+
|variable name|default value|description|
52+
|:-----------|:---------:|:----------|
53+
|g:winresizer_enable|1|Use winresizer (If this value is 0, this plugin will not work)|
54+
|g:winresizer_gui_enable|0|Use winresizer in GUI Vim (If this value is 0, this plugin will not work in GUI Vim such as Mac Vim)|
55+
|g:winresizer_finish_with_escape|1|If this value is 1, window resize mode is finished(fixed) by `Esc`|
56+
|g:winresizer_vert_resize|10|The change width of window size when `left` or `right` key is pressed|
57+
|g:winresizer_horiz_resize|3|The change height of window size when `down` or `up` key is pressed|
58+
|g:winresizer_start_key|`Ctrl + e`|Start window resize mode|
59+
|g:winresizer_gui_start_key|`Ctrl + a`|Start window resize mode (in GUI Vim)|
60+
|g:winresizer_keycode_left|104(`h`)|Expand window size to left|
61+
|g:winresizer_keycode_right|108(`l`)|Expand window size to right|
62+
|g:winresizer_keycode_down|106(`j`)|Expand window size to down|
63+
|g:winresizer_keycode_up|107(`k`)|Expand window size to up|
64+
|g:winresizer_keycode_focus|102(`f`)|Change a mode to `Focus mode`|
65+
|g:winresizer_keycode_move|109(`m`)|Change a mode to `Move mode`|
66+
|g:winresizer_keycode_resize|114(`r`)|Change a mode to `Resize mode`|
67+
|g:winresizer_keycode_mode|101(`e`)|Rotate a mode (Resize -> Move -> Focus -> Resize ...)|
68+
|g:winresizer_keycode_finish|13(`Enter`)|Fix and escape from window resize mode|
69+
|g:winresizer_keycode_cancel|113(`q`)|Cancel and quit window resize mode|
70+
71+
If you want to resize MacVim window itself, you must set below.
72+
73+
```your_vimrc
74+
let g:winresizer_gui_enable = 1
75+
```
76+
77+
78+
#### _Example in your .vimrc_
79+
80+
:memo: If you use winresizer with default settings. Don't have to do any settings.
81+
82+
" If you want to start window resize mode by `Ctrl+T`
83+
let g:winresizer_start_key = '<C-T>'
84+
85+
" If you cancel and quit window resize mode by `z` (keycode 122)
86+
let g:winresizer_keycode_cancel = 122
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
if exists('g:loaded_autoload_winresizer')
2+
finish
3+
endif
4+
5+
let g:loaded_autoload_winresizer = 1
6+
7+
let s:save_cpo = &cpo
8+
set cpo&vim
9+
10+
" when value is 1 in return dictionary,
11+
" current window has edge in direction of dictionary key name
12+
fun! winresizer#getEdgeInfo()
13+
let chk_direct = ['left', 'down', 'up', 'right']
14+
let result = {}
15+
for direct in chk_direct
16+
exe 'let result["' . direct . '"] = ' . !winresizer#canMoveCursorFromCurrentWindow(direct)
17+
endfor
18+
return result
19+
endfun
20+
21+
fun! winresizer#canMoveCursorFromCurrentWindow(direct)
22+
let map_direct = {'left':'h', 'down':'j', 'up':'k', 'right':'l'}
23+
if has_key(map_direct, a:direct)
24+
let direct = map_direct[a:direct]
25+
elseif index(values(map_direct), a:direct) != -1
26+
let direct = a:direct
27+
endif
28+
let from = winnr()
29+
exe "wincmd " . direct
30+
let to = winnr()
31+
exe from . "wincmd w"
32+
return from != to
33+
endfun
34+
35+
fun! winresizer#swapTo(direct)
36+
let direct = 'left'
37+
let map_direct = {'left':'h', 'down':'j', 'up':'k', 'right':'l'}
38+
if has_key(map_direct, a:direct)
39+
let direct = map_direct[a:direct]
40+
elseif index(values(map_direct), a:direct) != -1
41+
let direct = a:direct
42+
endif
43+
let from = winnr()
44+
exe "wincmd " . direct
45+
let to = winnr()
46+
exe from . "wincmd w"
47+
48+
if to != from
49+
call winresizer#swapWindow(to)
50+
endif
51+
52+
endfun
53+
54+
fun! winresizer#swapWindow(to)
55+
let curNum = winnr()
56+
let curBuf = bufnr( "%" )
57+
exe a:to . "wincmd w"
58+
let toBuf = bufnr( "%" )
59+
exe 'hide buf' curBuf
60+
exe curNum . "wincmd w"
61+
exe 'hide buf' toBuf
62+
exe a:to ."wincmd w"
63+
endfun
64+
65+
let &cpo = s:save_cpo

0 commit comments

Comments
 (0)