Change tabs only in current group/pane - sublimetext2

I am working on a big display with high resolution, thus I work in multiple groups/panes as it is more productive (imho). I switch tabs using ctrl + tab and groups/panes using ctrl + 1 to 9. I want to 'lock' the ctrl + tab to current group/pane so it would not select tabs in another panes.
I really want that functionality but can't think of a way to achieve this. Is it possible to do this?

You can use a simple plugin to do it.
import sublime
import sublime_plugin
class ChangeViewCommand(sublime_plugin.WindowCommand):
def run(self, reverse=False):
window = self.window
group, view_index = window.get_view_index(window.active_view())
if view_index >= 0:
views = window.views_in_group(group)
if reverse:
if view_index == 0:
view_index = len(views)
if reverse:
new_index = view_index - 1
else:
new_index = (view_index + 1) % len(views)
window.focus_view(views[new_index])
Then add the following to your user key bindings.
{ "keys": ["ctrl+tab"], "command": "change_view" },
{ "keys": ["ctrl+shift+tab"], "command": "change_view", "args": { "reverse": true } }
For focus group, there are already commands to go to groups 1 - 4, but you can add the following to go further (simply change the key binding number and group number)
{ "keys": ["ctrl+1"], "command": "focus_group", "args": { "group": 0 } }

Related

nx:run-commands default args values

i have react library created inside nx mono repo using this version
nx: 15.6.3
i've added inside the packages/my-library command to run multiple commands
generate react component
generate react-stories
using these plugins #nrwl/react:component - #nrwl/react:component-story
this is the target
"generate-atom": {
"executor": "nx:run-commands",
"options": {
"commands": [
{
"command": "nx g #nrwl/react:component --project=core --style=#emotion/styled --export --directory=atoms/{args.group} --name={args.name}",
"forwardAllArgs": true,
"bgColor": "bgBlue"
},
{
"command": "nx g #nrwl/react:component-story --project=core --componentPath=atoms/{args.group || 'common'}/{args.name}/{args.name}.tsx",
"forwardAllArgs": true
}
],
"cwd": "packages/core",
"parallel": false
}
},
the components is been created inside when i call this target from nx
packages/core/src/atoms/undefined/button
this is the command i'm using
npx nx run core:generate-atom --args="--name=button"
any idea how can we default the value of group if was not passed?

Check_MK - Custom check params specified in wato not being given to check function

I am working on a check_mk plugin and can't seem to get the WATO specified params passed to the check function when it runs for one check in particular...
The check param rule shows in WATO
It writes correct looking values to rules.mk
Clicking the Analyze check parameters icon from a hosts service discovery shows the rule as active.
The check parameters displayed in service discovery show the title from the WATO file so it seems like it is associating things correctly.
Running cmk -D <hostname> shows the check as always having the default values though.
I have been staring at it for awhile and am out of ideas.
Check_MK version: 1.2.8p21 Raw
Bulk of check file:
factory_settings["elasticsearch_status_default"] = {
"min": (600, 300)
}
def inventory_elasticsearch_status(info):
for line in info:
yield restore_whitespace(line[0]), {}
def check_elasticsearch_status(item, params, info):
for line in info:
name = restore_whitespace(line[0])
message = restore_whitespace(line[2])
if name == item:
return get_status_state(params["min"], name, line[1], message, line[3])
check_info['elasticsearch_status'] = {
"inventory_function" : inventory_elasticsearch_status,
"check_function" : check_elasticsearch_status,
"service_description" : "ElasticSearch Status %s",
"default_levels_variable" : "elasticsearch_status_default",
"group" : "elasticsearch_status",
"has_perfdata" : False
}
Wato File:
group = "checkparams"
#subgroup_applications = _("Applications, Processes & Services")
register_check_parameters(
subgroup_applications,
"elasticsearch_status",
_("Elastic Search Status"),
Dictionary(
elements = [
( "min",
Tuple(
title = _("Minimum required status age"),
elements = [
Age(title = _("Warning if below"), default_value = 600),
Age(title = _("Critical if below"), default_value = 300),
]
))
]
),
None,
match_type = "dict",
)
Entry in rules.mk from WATO rule:
checkgroup_parameters.setdefault('elasticsearch_status', [])
checkgroup_parameters['elasticsearch_status'] = [
( {'min': (3600, 1800)}, [], ALL_HOSTS ),
] + checkgroup_parameters['elasticsearch_status']
Let me know if any other information would be helpful!
EDIT: pls help
Posted question here as well and the mystery got solved.
I was matching the WATO rule to item None (5th positional arg in the WATO file), but since this check had multiple items inventoried under it (none of which had the id None) the rule was applying to the host, but not to any of the specific service checks.
Fix was to replace that param with:
TextAscii( title = _("Status Description"), allow_empty = True),

Sensu checks results event data

I am working on Sensu. I have installed sensu in CentOS. I need to get the event messages which is generated by Sensu checks.I have added some of the sensu community plugins like check-procs.rb,check-load.rb,check-banner.rb, metrics-ebs-volume.rb etc. I have written some handler files to event handle these .rb files. I am getting events in sensu-server.log.
Example:
{"timestamp":"2016-08-10T07:32:08.000003+0000","level":"info","message":"publishing check request","payload":{"name":"swap-free","issued":1470814327,"command":"check-swap.sh 20 10"},"subscribers":["base_centos_monitoring"]}
I have written a ruby file "nephele_events_handler.rb" which sends events messages through rest call to another server. The ruby file is in the location "/etc/sensu/handlers/". I am reading events from STDIN.read, i have read from official sensu documentation that events will be stored inside STDIN.
#!/opt/sensu/embedded/bin/ruby
require "#{File.dirname(__FILE__)}/base"
require 'rubygems'
require 'json'
require 'uri'
require 'net/http'
require 'net/https'
require 'json'
class RunProcs < BaseHandler
def payload_check
#Read event data
sensuhash = "{ \"SensuMessage\"" + ":"
braces = "}"
s = sensuhash.to_s
event = JSON.parse(STDIN.read, :symbolize_names => true)
eventPayload = event.to_json
sensujson = s + eventPayload + braces
uri = URI.parse("https://localhost:8080/Processor/services/sourceEvents/requestMsg")
https = Net::HTTP.new(uri.host,uri.port)
https.use_ssl = false
req = Net::HTTP::Post.new(uri.path, initheader = {'Content-Type' =>'application/json'})
req.body = "[ #{sensujson} ]"
res = https.request(req)
end
info = RunProcs.new
info.payload_check
end
Am writing handler json file "processor.json" inside the location "/etc/sensu/conf.d/handlers".
{
"handlers": {
"nephele_processor": {
"type": "pipe",
"command": "nephele_events_handler.rb"
}
}
}
But the issue am facing is am only getting events from 'check-procs'
{"client":{"address":"10.81.1.105","subscriptions":["base_centos","base_chef-client","python","base_centos_monitoring","base_centos_monitoring_metrics","sensu_client","base_aws","base_aws_monitoring","sensu_master","all"],"name":"ip-localhost.internal","hostname":"ip-localhost","version":"0.25.3","timestamp":1470896756},"check":{"command":"check-procs.rb --pattern='chef-client' -W=1","subscribers":["base_centos_monitoring"],"handlers":["base_with_jira"],"interval":60,"team":"ops","aggregate":true,"occurrences":3,"refresh":300,"ticket":true,"name":"process-chef-client","issued":1470896771,"executed":1470896771,"duration":0.864,"output":"CheckProcs CRITICAL: Found 0 matching processes; cmd /chef-client/\n","status":2,"type":"standard","history":["2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2"],"total_state_change":0},"occurrences":19879,"action":"create","timestamp":1470896772,"id":"dc2b0698-dbac-416d-a9ae-42aa09d53cc3","last_state_change":1469690268,"last_ok":null}
The Check which is getting executed
{
"checks": {
"process-chef-client": {
"command": "check-procs.rb --pattern='chef-client' -W=1",
"subscribers": [
"base_centos_monitoring"
],
"handlers": [
"base_with_jira"
],
"interval": 60,
"team": "ops",
"aggregate": true,
"occurrences": 3,
"interval": 60,
"refresh": 300,
"ticket": true
}
}
}
base_with_jira.json
{
"handlers": {
"base_with_jira": {
"type": "set",
"handlers": [
"jira",
"nephele_processor"
],
"config": "http://apache.enron.nephele.solutions/uchiwa"
}
}
}
I am not getting events from other plugins. Can you explain what i have to do for this.

How can I jump to line in Sublime Text?

Does anyone know of a shortcut for jumping to a specific line (given a #) in Sublime Text?
Ex: I run code and get an error at line 5765. I want to be able to jump quickly in Sublime Text to line 5765, without scrolling.
Windows: Ctrl + G
Mac: Control + G
Linux:Ctrl + G
or
Windows: Ctrl + P + :
Mac: Command + P + :
Linux: Ctrl + P + :
Then type the line number. It will automatically find it for you and if it requires scrolling to get to - it will snap your view to the line number level.
Rather than Control+G, if you're used to using CMD+P or CMD+T, you can just type :
Also useful:
CMD+R go to function in current file
CMD+Shift+R find function in any file (CMD+, "binary_file_patterns" ignore node_modules)
CMD+Option+Down jump to function definition in another file (from cursor word)
CMD+D / CMD+U jump & accumulate next word occurrence & populate search query / (undo). from cursor becomes an exact match (case and word boundary) vs from selection is a partial match (ignore case and word boundary). D and U also work in less bash / zshell pager to scroll down / up half pages
CMD+G / CMD+Shift+G jump or "go" to next / previous search query (CMD+D amazing with this)
CMD+{ / CMD+} focuses left / right tab (same in terminals, browser, kapeli dash, etc.)
CMD+[ / CMD+] shift line left / right (chrome forward / backward nav, devtools changes panel)
CMD+Control+Up / CMD+Control+Down shift line up / down
CMD+K->(some number) fold to indentation
CMD+K->J unfold all
CMD+Option+[ / CMD+Option+] fold / unfold current line's children
CMD+, is preferences in most all Mac applications
As pointed out by #maxTuzz, I use Ubuntu 16.06 and Sublime regularly,
this Ctrl+P then Pressing : and Starting typing the Line Number you want to Navigate.
Or
Directly we can type Ctrl+G Starting typing the Line Number you want to Navigate.
In My Mac, Performance>>Key Bindings add:
//line duplicate & delete
{ "keys": ["super+y"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Delete Line.sublime-macro"} },
{ "keys": ["super+d"], "command": "duplicate_line" },
//replace
{ "keys": ["super+r"], "command": "show_panel", "args": {"panel": "replace", "reverse": false} },
//goto
{ "keys": ["super+l"], "command": "show_overlay", "args": {"overlay": "goto", "text": ":"} },
{ "keys": ["super+g"], "command": "show_overlay", "args": {"overlay": "goto", "text": "#"} },
//upper or lower
{ "keys": ["super+shift+u"], "command": "swap_case" },
//sidebar toggle
{ "keys": ["super+shift+t"], "command": "toggle_side_bar" },
base is to press Ctrl + P and a then type : and then write the line that you want to go , BUT there is a shortcut for this :
Just hit Ctrl + G , and it does the same steps for you!
on your keyboard click the:
command + p
then type : on your keyboard follow by the line number, example 374
:374
then click the enter key on your keyboard to jump to the desired line number

Option to copy lines with carets NOT separated with empty lines

Sublime text 2 (Windows 7) has such feature: several lines with carets (no selections made,only carets) are copied to Clipboard separated with empty lines. Can i disable these empty line separators, to copy w/o them?
detail:
open few lines text file
place 3-4 carets using Ctrl+Click on few lines
press Ctrl+C to copy to clibboard
paste into new file-- u see empty line separators for copied text
Think you need a plugin to do it. I didn't test this, but it should work. It's pretty straight forward.
import sublime
import sublime_plugin
class EmptyLineCopyCommand(sublime_plugin.TextCommand):
def run(self, edit):
view = self.view
lines = []
for cursor in view.sel():
lines.append(view.substr(view.line(cursor)))
sublime.set_clipboard("\n".join(lines))
Put the following in your user key bindings.
{"keys": ["ctrl+c"], "command": "empty_line_copy", "context": [
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true }
]},