Last active
April 15, 2021 00:07
-
-
Save mbarkhau/c9835a1e5443f2fb8c0f85ba2186d08c to your computer and use it in GitHub Desktop.
sublime helpers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias tiga='tig --all' | |
alias gs='git status --untracked-files=no' | |
alias gss='git status --short' | |
alias gsss='git status' | |
alias gls="git for-each-ref --count=15 --sort=-committerdate --format='%(objectname:short) %(committerdate:iso) %(authorname) %(refname:short)' refs/heads/" | |
alias gd="git diff --color-words" | |
alias gds="git diff --stat" | |
alias gap="git add --patch" | |
alias gaf="git add" # add file | |
alias gco="git checkout" | |
alias grm="git rm" | |
alias gr="git reset" | |
alias grb="git rebase" | |
alias grbi="git rebase --interactive @{u}" | |
alias gcp="git cherry-pick" | |
alias gm="git merge" | |
alias gcop="git checkout --patch" | |
alias gpu="git push --set-upstream origin `git symbolic-ref --short HEAD`" | |
alias gst="git stash" | |
alias gstp="git stash pop" | |
alias gc="git commit -m" | |
alias ga="git commit --amend" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sublime_plugin | |
# Usage: | |
# | |
# { | |
# "keys" : ["shift+alt+up"], | |
# "command": "move_amount", | |
# "args" : { | |
# "amount" : 10, | |
# "by" : "lines", | |
# "forward": false | |
# } | |
# } | |
class MoveAmountCommand(sublime_plugin.TextCommand): | |
def run(self, edit, amount=10, **kwargs): | |
move_kwargs = kwargs.copy() | |
move_kwargs['extend'] = any( | |
len(region) > 0 | |
for region in self.view.sel() | |
) | |
if amount < 0: | |
amount *= -1 | |
move_kwargs['forward'] = False | |
else: | |
move_kwargs['forward'] = True | |
if 'by' not in move_kwargs: | |
move_kwargs['by'] = 'lines' | |
for _ in range(amount): | |
self.view.run_command("move", move_kwargs) | |
line_height = self.view.line_height() | |
vp_height = self.view.viewport_extent()[1] | |
vp_top = (self.view.viewport_position()[1] / line_height) | |
vp_bottom = (vp_top + (vp_height / line_height)) | |
for region in self.view.sel(): | |
line_index = self.view.rowcol(region.a)[0] | |
cursor_in_viewport = vp_top + 6 <= line_index <= vp_bottom - 6 | |
if not cursor_in_viewport: | |
self.view.show_at_center(region) | |
break |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
[ | |
{ "keys": ["ctrl+1"], "command": "focus_group", "args": { "group": 0 } }, | |
{ "keys": ["ctrl+2"], "command": "focus_group", "args": { "group": 1 } }, | |
{ "keys": ["ctrl+3"], "command": "focus_group", "args": { "group": 2 } }, | |
{ "keys": ["ctrl+4"], "command": "focus_group", "args": { "group": 3 } }, | |
{ "keys": ["ctrl+5"], "command": "focus_group", "args": { "group": 4 } }, | |
{ "keys": ["ctrl+6"], "command": "focus_group", "args": { "group": 5 } }, | |
{ "keys": ["ctrl+7"], "command": "focus_group", "args": { "group": 6 } }, | |
{ "keys": ["ctrl+8"], "command": "focus_group", "args": { "group": 7 } }, | |
{ "keys": ["ctrl+9"], "command": "focus_group", "args": { "group": 8 } }, | |
{ | |
"keys" : ["ctrl+t"], | |
"command": "show_panel", | |
"args" : {"panel": "console", "toggle": true} | |
}, | |
{ | |
"keys": ["alt+shift+1"], | |
"command": "set_layout", | |
"args": | |
{ | |
"cols": [0.0, 0.52, 1.0], | |
"rows": [0.0, 1.0], | |
"cells": [[0, 0, 1, 1], [1, 0, 2, 1]] | |
} | |
}, | |
{ | |
"keys": ["alt+shift+2"], | |
"command": "set_layout", | |
"args": | |
{ | |
"cols": [0.0, 0.48, 1.0], | |
"rows": [0.0, 1.0], | |
"cells": [[0, 0, 1, 1], [1, 0, 2, 1]] | |
} | |
}, | |
{ | |
"keys": ["alt+shift+3"], | |
"command": "set_layout", | |
"args": | |
{ | |
"cols": [0.0, 0.31, 0.69, 1.0], | |
"rows": [0.0, 1.0], | |
"cells": [[0, 0, 1, 1], [1, 0, 2, 1], [2, 0, 3, 1]] | |
} | |
}, | |
{ | |
"keys": ["j", "j"], | |
"command": "exit_insert_mode", | |
"context": | |
[ | |
{ "key": "setting.command_mode", "operand": false }, | |
{ "key": "setting.is_widget", "operand": false } | |
] | |
}, | |
{ | |
"keys": ["ctrl+shift+7"], | |
"command": "toggle_comment", | |
"args": { "block": false } | |
}, | |
{ "keys": ["alt+left"], "command": "jump_back"}, | |
{ "keys": ["alt+right"], "command": "jump_forward"}, | |
{ "keys": ["ctrl+shift+a"], "command": "alignment" }, | |
{ "keys": ["ctrl+shift+d"], "command": "dev_docs_search_selection"}, | |
{ "keys": ["ctrl+shift+g"], "command": "anaconda_goto"}, | |
{ "keys": ["ctrl+shift+u"], "command": "anaconda_find_usages"}, | |
{ "keys": ["ctrl+shift+q"], "command": "psql_db_query"}, | |
{ "keys": ["f5"], "command": "psql_db_refresh"}, | |
{ "keys": ["alt+m"], "command": "next_bookmark" }, | |
{ "keys": ["alt+shift+m"], "command": "prev_bookmark" }, | |
{ "keys": ["ctrl+alt+m"], "command": "toggle_bookmark" }, | |
{ "keys": ["ctrl+alt+shift+m"], "command": "clear_bookmarks" }, | |
{ "keys": ["ctrl+shift+d"], "command": "plain_tasks_complete","context": [{ "key": "selector", "operator": "equal", "operand": "text.todo" }] }, | |
{ "keys": ["ctrl+shift+c"], "command": "plain_tasks_cancel", "context": [{"key": "selector", "operator": "equal", "operand": "text.todo" }] }, | |
{ "keys": ["ctrl+shift+n"], "command": "plain_tasks_new","context": [{ "key": "selector", "operator": "equal", "operand": "text.todo" }] }, | |
{ "keys": ["alt+q", "q"], "command": "wrap_lines_plus", "args": {"width": 70}}, | |
{ "keys": ["alt+q", "5"], "command": "wrap_lines_plus", "args": {"width": 50}}, | |
{ "keys": ["alt+q", "6"], "command": "wrap_lines_plus", "args": {"width": 60}}, | |
{ "keys": ["alt+q", "7"], "command": "wrap_lines_plus", "args": {"width": 70}}, | |
{ "keys": ["alt+q", "8"], "command": "wrap_lines_plus", "args": {"width": 80}}, | |
{ "keys": ["alt+q", "9"], "command": "wrap_lines_plus", "args": {"width": 90}}, | |
{ "keys": ["alt+q", "0"], "command": "wrap_lines_plus", "args": {"width": 100}}, | |
{ "keys": ["alt+h"], "command": "move_amount", "args": { "by": "characters", "forward": false, "amount": 5 } }, | |
{ "keys": ["alt+l"], "command": "move_amount", "args": { "by": "characters", "forward": true, "amount": 5 } }, | |
{ "keys": ["alt+k"], "command": "move_amount", "args": { "by": "lines", "forward": false, "amount": 5 } }, | |
{ "keys": ["alt+j"], "command": "move_amount", "args": { "by": "lines", "forward": true, "amount": 5 } }, | |
{ "keys": ["ctrl+alt+k"], "command": "move_amount", "args": { "by": "lines", "forward": false, "amount": 15 } }, | |
{ "keys": ["ctrl+alt+j"], "command": "move_amount", "args": { "by": "lines", "forward": true, "amount": 15 } }, | |
{ "keys": ["ctrl+shift+j"], "command": "expand_selection", "args": {"to": "indentation"} }, | |
{ "keys": ["ctrl+alt+c"], "command": "git_commit"}, | |
{ "keys": ["ctrl+alt+m"], "command": "git_add_selected_hunk"}, | |
{ "keys": ["ctrl+alt+h"], "command": "git_gutter_prev_change"}, | |
{ "keys": ["ctrl+alt+n"], "command": "git_gutter_next_change"}, | |
{ "keys": ["ctrl+alt+d"], "command": "git_gutter_diff_popup", "args": {"highlight_diff": true}}, | |
{ | |
"keys": ["alt+x"], | |
"command": "exec", | |
"args": { | |
"hide_phantoms_only": true | |
} | |
}, | |
{ | |
"keys": ["ctrl+k", "ctrl+r"], | |
"command" : "show_panel" , | |
"args" : {"panel": "output.exec"} | |
}, | |
{ | |
"keys": ["ctrl+m"], | |
"command": "run_multiple_commands", | |
"args": { | |
"commands": [ | |
// {"command": "toggle_side_bar", "context": "window"}, | |
{"command": "toggle_full_screen", "context": "window"}, | |
{"command": "toggle_tabs", "context": "window"}, | |
{"command": "toggle_status_bar", "context": "window"}, | |
{"command": "toggle_menu", "context": "window"}, | |
// {"command": "toggle_side_bar", "context": "window"}, | |
// {"command": "toggle_setting", "context": "window", "args": {"setting": "line_numbers"}}, | |
// {"command": "toggle_setting", "context": "window", "args": {"setting": "gutter"}}, | |
] | |
} | |
} | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Anaconda | |
BetterFindBuffer | |
Git | |
Gitignore | |
Gitignored File Excluder | |
Sublimerge 3 | |
HaoGist | |
AutoWrap | |
Base Encoder | |
Table Editor | |
URLEncode | |
Wrap Plus | |
Evaluate | |
nginx | |
TOML | |
Cython+ | |
Package Control: Advanced Install Package | |
Anaconda,BetterFindBuffer,Git,Gitignore,Gitignored File Excluder,Sublimerge 3,HaoGist,AutoWrap,Base Encoder,Table Editor,URLEncode,Wrap Plus,nginx,TOML,Cython+ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
// editor plugins | |
// Colorsublime (for theme "Monokai Contrast") | |
// Wrap Plus | |
// syntax plugins | |
// Crontab Syntax | |
// Cython | |
// Magic Python | |
// nginx | |
// completion plugins | |
// Jedi | |
// All Autocomplete Sublime Text | |
// Utility plugins | |
// Encoding Helper | |
// JSFormat | |
// Python Flake8 Lint | |
// Base Encoder | |
// URLEncode | |
// Git | |
// GitGutter | |
// Inline Python | |
// Http Requester | |
"animation_enabled": true, | |
"caret_style": "solid", | |
"wide_caret": true, | |
"theme": "Adaptive.sublime-theme", | |
"color_scheme": "Packages/Colorsublime - Themes/Monokai-Contrast.tmTheme", | |
"default_encoding": "UTF-8", | |
"default_line_ending": "unix", | |
"drag_text": false, | |
"draw_indent_guides": false, | |
"always_show_minimap_viewport": true, | |
"draw_minimap_border": true, | |
"fold_buttons": false, | |
"folder_exclude_patterns": | |
[ | |
"venv", | |
"venv2", | |
"venv3", | |
"*egg-info", | |
".cache", | |
".git", | |
".idea", | |
".mypy_cache", | |
".pytest_cache", | |
"__pycache__" | |
], | |
// "font_face": "Monoid", | |
"font_face": "Monoisome", | |
"font_size": 11, | |
"font_options": | |
[ | |
"no_italic", | |
"gdi" | |
], | |
"line_padding_bottom": 1, | |
"line_padding_top": 1, | |
// "font_face": "Inconsolata", | |
// "font_size": 12, | |
// "line_padding_bottom": 1, | |
"highlight_modified_tabs": true, | |
"ignored_packages": | |
[ | |
"Markdown", | |
"MarkdownEditing", | |
"RestructuredText" | |
], | |
"overlay_scroll_bars": "enabled", | |
"rulers": | |
[ | |
110 | |
], | |
"scroll_speed": 0.5, | |
"shift_tab_unindent": true, | |
"tab_size": 4, | |
"translate_tabs_to_spaces": true, | |
"trim_trailing_white_space_on_save": true, | |
"vintage_start_in_command_mode": true, | |
"word_wrap": false, | |
"wrap_width": 105, | |
"auto_complete_triggers": [ | |
{"selector": "source.python", "characters": "."} | |
], | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<snippet> | |
<content>import pudb; pudb.set_trace()</content> | |
<!-- Optional: Set a tabTrigger to define how to trigger the snippet --> | |
<tabTrigger>pudb</tabTrigger> | |
<!-- Optional: Set a scope to limit where the snippet will trigger --> | |
<scope>source.python</scope> | |
</snippet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<snippet> | |
<content><![CDATA[ | |
# -*- coding: utf-8 -*- | |
from __future__ import division | |
from __future__ import print_function | |
from __future__ import absolute_import | |
from __future__ import unicode_literals | |
import adm_common.pysix as six | |
]]></content> | |
<!-- Optional: Set a tabTrigger to define how to trigger the snippet --> | |
<tabTrigger>future</tabTrigger> | |
<!-- Optional: Set a scope to limit where the snippet will trigger --> | |
<scope>source.python,source.cython</scope> | |
</snippet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"build_systems": | |
[ | |
{ | |
"name": "make devtest", | |
"working_dir": "$project_path/", | |
"shell_cmd": "make mypy fmt devtest lint", | |
"selector": "source.python", | |
"quiet": true, | |
"file_regex": "^((?:test|src)/.*.py)[^:]*:[^\\d]*(\\d+)[^:\\s]*:(\\d+)?\\s*(.+)", | |
} | |
], | |
"folders": | |
[ | |
{ | |
"path": ".", | |
//"folder_exclude_patterns": [".mypy_cache", ".pytest_cache", "htmlcov"] | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime as dt | |
import sublime_plugin | |
DEV_NAME = "mb" | |
COMPLETION_TRIGGERS = [ | |
"todo", | |
"note", | |
"fixme", | |
"wtf?!", | |
"bug", | |
"hack", | |
] | |
FMT_STR_FILETYPES = { | |
"/* {}$1 */": ['css'], | |
"# {}": [ | |
'magicpython', | |
'python', | |
'cython', | |
'ruby', | |
'shell-unix-generic', | |
'perl', | |
'yaml', | |
], | |
"// {}": [ | |
'javascript', | |
'json', | |
'php', | |
'c', | |
'c++', | |
'd', | |
'go', | |
'java', | |
'rust', | |
] | |
} | |
FILETYPE_FMT_STRS = {} | |
for fmt_str, filetypes in FMT_STR_FILETYPES.items(): | |
for filetype in filetypes: | |
FILETYPE_FMT_STRS[filetype] = fmt_str | |
class TODOCommand(sublime_plugin.EventListener): | |
def mk_completions(self, fmt_str, prefix): | |
daystr = dt.date.today().strftime("%Y-%m-%d") | |
for trigger in COMPLETION_TRIGGERS: | |
if not prefix.startswith(trigger[0]): | |
continue | |
completion = fmt_str.format("{} ({} {}): ".format( | |
trigger.upper(), DEV_NAME, daystr | |
)) | |
yield [trigger.upper(), completion] | |
def on_query_completions(self, view, prefix, locations): | |
syntax = view.settings().get('syntax', "").lower() | |
filetype = syntax.split("/")[-1].split(".")[0] | |
fallback_fmt_str = "??? " + filetype + " {} ???" | |
fmt_str = FILETYPE_FMT_STRS.get(filetype, fallback_fmt_str) | |
return list(self.mk_completions(fmt_str, prefix)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sublime_plugin | |
# Usage: | |
# | |
# { | |
# "keys" : ["shift+alt+up"], | |
# "command": "move_amount", | |
# "args" : {"amount" : -10, "by": "lines"} | |
# "args" : {"amount" : 10, "by": "lines"} | |
# } | |
class MoveAmountCommand(sublime_plugin.TextCommand): | |
def run(self, edit, amount=10, **kwargs): | |
move_kwargs = kwargs.copy() | |
move_kwargs['extend'] = any(len(region) > 0 for region in self.view.sel()) | |
if amount < 0: | |
amount *= -1 | |
move_kwargs['forward'] = False | |
else: | |
move_kwargs['forward'] = True | |
if 'by' not in move_kwargs: | |
move_kwargs['by'] = 'lines' | |
for _ in range(amount): | |
self.view.run_command("move", move_kwargs) | |
line_height = self.view.line_height() | |
vp_height = self.view.viewport_extent()[1] | |
vp_top = self.view.viewport_position()[1] / line_height | |
vp_bottom = vp_top + (vp_height / line_height) | |
for region in self.view.sel(): | |
line_index = self.view.rowcol(region.a)[0] | |
cursor_in_viewport = vp_top + 6 <= line_index <= vp_bottom - 6 | |
if not cursor_in_viewport: | |
self.view.show_at_center(region) | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment