How can one scroll through multi-line commands in the Zsh history without selecting each line of each command? - zsh

If one runs the following commands in succession in Zsh (on macOS or Ubuntu):
date +%s
echo \
a\
b\
c
One can then scroll back to the first command by pressing the up-arrow 5 times.
Is there a way to scroll back to the first command with just 2 key presses (i.e. the first key press selects the echo command and the 2nd key press selects the date command)?
When the history contains several long multi-line commands, scrolling back through them with the up-arrow key is a pain.
I was hoping to find some Zsh key shortcuts that would scroll up and down through the command history without stopping en-route to edit multi-line commands, but I haven't yet managed to find any.

Add the following to your .zshrc file:
bindkey '^P' up-history
bindkey '^N' down-history
Now you can press ControlP to go up in history and ControlN to go down in history, regardless of how many lines the current editing buffer has or which line you are on.
For more info, see https://zsh.sourceforge.io/Doc/Release/Zsh-Line-Editor.html#History-Control
Alternatively, my zsh-autocomplete plugin contains a history menu that lets you step up and down through history items, with just one keypress per item, including multi-line items.

Related

Atom 'Select Next' selects more than just unique occurrences of a variable

is
this is really cool
code
this is really cool
code
Highlight the 'is' in the code above and press alt-f3 on your keyboard. Only unique occurrences of 'is' should be highlighted. Atom currently highlights the 'is' in th'is' as well. I don't want this. How do I disable this behavior?
This is what I want to happen:
I was highlighting is and then pressing Ctrl-D. This is not the correct way to Select-Next. You need to first put the cursor in front of the word you want to Select-Next, then press Ctrl-D. I hope this helps somebody in the future.
Bonus Tip - If you perform the same routine, but instead use Alt-F3 you'll automatically select all occurrences of the word under consideration.

How do I customize Jupyter Notebook autocomplete accept suggestion keyboard shortcut?

When I type a '.' after an object name and press the TAB key I am able to see the suggested completions. To confirm and insert a suggested completion I have to use the arrow keys to select the completion I want and then press the ENTER key to confirm my selection. Is there a way to change this so that the TAB key confirms my selection?
Is there a way to change this so that the TAB key confirms my selection?
No there is no way to do that.

Autosys Job holding in different boxes

Suppose we have some 400 jobs in different boxes then I want to put on hold the daily running jobs at 9-10 pm pm only?
Do you use WCC or command line?
In WCC you can just use a comma-separated list of jobs to see only the jobs you want. You can filter by status and select the jobs you want to take action on, then select 'change status' to do a sendevent but check off the 'future' box. Set it up so you send an 'on-hold' event at 9pm and again for an 'off-hold' at 10pm.
If you use command line you'll want to do something like below. Do all of your boxes have some naming conventions in common? If so you can run the command only once using the string that returns your boxes. In the AutoSys instance I work in we use a prefix structure...
To get the list of running jobs:
autorep -J prefix% | [find for windows or egrep for unix] " RU "
... Where you need the spaces between the double quotes and the two-letter status otherwise it would return lines where the item name contains those two characters.
To do a future sendevent use the usual sendevent syntax and just append the switches to indicate the time you want the action taken.
Will this accomplish what you're looking to do? If not please let us know if you're using windows or Unix as well as any additional information that can help us understand the specifics of your scenario.

Which utility or UNIX command can help to submit a bulk of event data to Google Universal Analytics?

https://developers.google.com/analytics/devguides/collection/protocol/v1/reference
In the link above the Measurements Protocol is elaborated. Suppose I have a CSV file with columns like EventName, ClientID etc and I'd like to submit it to the Universal Analytics system. Is there a UNIX command, utility or a third-party software that will allow me to submit that data from command line or any kind of a friendlier UI?
I'm not a bash wizard myself so there will be any kind of ways to improve this ( I adapted an example I found on the web), but here is barebone example.
To group the hits into sessions (if applicable) you need a client id. Client id is a mandatory parameter, but if you want to log each row from your file as a new session you can use a random number for the cid parameter.
However the example assumes that the first column in your csv file contains a parameter that can be used as cid. Be aware that a session has max 500 hits (so after that you need to switch the cid) and that there is a limit of 20 hits per session that is replenished at 2 hits per second, so probably you want to build a delay into your script.
The example assumes a csv file with a semicolon as a delimiter (can be adjusted in the IFS variable). It also assumes that there are three columns, one for the cid, one for the page path, one for the document title. if you have more than three columns the last value (pagetitle) will consume all remaining columns (so if there are more than three columns append the columns names in the line that starts with "while").
Then the script simply builds an url (the variables from the line that starts with "while" are intefied by a dollar sign in front of the name) and uses wget to call the Google tracking server (the server returns a gif image which wget will store - I'm sure there is an option that tells wget to dismiss the content from the request).
#!/bin/bash
UAID="UA-XXXXX-XX" // Google Analytics Account ID
INPUT=data.cvs // Input file name
OLDIFS=$IFS // store default csv delimiter
IFS=; // set csv delimiter
[ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; } // nice error message if input file is missing
while cid page pagetitle // while there are rows in the csv read fields
do
wget "www.google-analytics.com/collect?v=1&tid=$UAID&cid=$cid&t=pageview&dp=$page&dt=$pagetitle" // call Google Tracking server
done < $INPUT // no more rows
IFS=$OLDIFS // restore default csv delimiter
Obviously you'd have to make this script executable. I tested this (recent Debian/bash) so I'm rather sure this will work. It might be not very efficent though.

Xcode 4 automatic code completion -- how to insert NO into code

If I try to type NO into my code somewhere, it brings up a completion list. The highlighted item in the list is always "noisy", which is a variable that frequently appears in my code. Then I have to move to the right item in the list, because if I hit enter it will insert "noisy".
Is there a simple way to insert NO into my code?
Just hit space after typing NO, instead of enter. It looks confusing because you see the word you don't want there; but if you hit space, it will revert to just the characters you typed.

Resources