How do I save my command snippets for quick access from the commandline? - ruby

I have a huge file with all the commands I use on and off the commandline. This file is getting harder to open and navigate as its size gets larger. I am looking for a commandline utility that makes this process easier. I found this gem, which does something similar to what I want, but it's terrible with long lines of code with multiple quotation marks.
What does everyone use to keep your code snippets and easily access it from your terminal?

I keep a similar file myself. This example isn't directly useful with your file. However when I find that I need to run a particular command I recently used, without looking it up again, I run a grep on history.
For example:
history | grep "svn co"

You may try Komandi, a multiplatform command snippets manager.

Related

Windows 11 - Not kind sort command for viewing all files in subfolders

I used to use a sort command when trying to view all files across a bunch of folders at once. It makes sorting files easier. I do know part of the command was written as not sort kind, however I am unable to remember which parts need to be capitalised, and where the colon (:) goes. I have trying googling the answer, and even gone through hours of YouTube videos trying to find the answer. I would prefer not to use the asterisk (*) command or the DIR command Screenshot showing one of many attempted iterationsas that is not suitable for my use. Thank you.
I have since been alerted on StackExchange that the answer to the issue I was having is kind:NOT Folder.

how do I run my .py file from within python command line?

background info:
I know this question has been asked countless times, but I'm not understanding the answers.
Today is the first time I've ever done anything with python, so I'm a total noob.
I'm using windows 7.
python 3.3.5 lives here: C:\Python33\python.exe
I have a .py file I want to run saved here: C:\Users\Scydmarc\Documents\cs188\python_basics\myfile.py
If I simply double click on myfile.py, it opens, runs, and closes super fast. By doing a perfectly timed printscreen, I can see that it works. It is my understanding that I need to run the file from within python.exe to get the window to stay open and allow me to mess with variables etc after it runs. So I open python.exe. What exactly do I need to type to run myfile.py? I've found lots of people trying to do this, but I guess I'm not understanding the answers. When I try to follow along, I get tangled up with errors. Do you still need to put python before the file name while in the python.exe window? Do I somehow need to specify a full path to the file? Some are actually running from the windows command prompt and not the python command prompt. When trying to change PYTHONPATH, are you supposed to do that from inside python, or the windows command prompt? Some examples use '/', while some use '\'. So, I think a complete example (what to actually type, in what window, line by line, with real filepaths) would clarify a lot for me and be super helpful. I'm thinking if I can actually see it done once, I can figure out how to make it do what I want in the future. Thanks for any help you can give.
in your python dir type python.exe pathtofile.py or set python.exe to your classpath
edit: https://www.youtube.com/watch?v=IokKz-LZsEo

Why does Powershell search every directory within one's $PATH for a PSConsoleHostReadLine file?

all!
I noticed that Powershell, or more specifically, pasting and tab-completing within Powershell, was a lot slower on my machine after upgrading to v3 from v2. I opened up procmon to see what was going on, only to find out that every attempt to tab-complete or paste anything triggers Powershell to find various permutations of the file provided in the subject. I have some network folders in my $PATH and walking through those folders every time I paste something seems non-ideal.
It seems that this file allows Powershell to behave more like Bash. While this is absolutely FANTASTIC and I'm looking forward to abusing this feature in the very near future, is there any way to configure Powershell such that it only attempts to find this file in one directory?
Thanks!
PSConsoleHostReadLine is actually a function. If PoSH can't find a method, alias, or anything else executable with that name, it falls back to it's default 'cooked' readline with editing, etc.
To redefine it, create a function:
function PSConsoleHostReadline {
[Console]::Readline()
}
As written, this method disables editing, etc. Write your own insane magic to do whatever you wish.
I'm guessing it's searching all the extra locations due to Powershell 3 having "Module Auto Load" which checks for a function in all locations known in the ENV:PSModulePath, and auto-loads the module which contains said method.
This was an oversight in V3. V4 will only search for functions or aliases - it won't search for external exes when looking for PSConsoleHostReadline.
If you're looking for a bash like experience - check out https://github.com/lzybkr/PSReadLine

Reduce how much xcodebuild writes to command-line

I have a simple script that runs xcodebuild for a C++ project. However it prints out a huge amount of output for each file compiled, 10-20 lines, which makes it impossible to read easily. Ideally I'd jut like to see a list of the files compiled, one per line.
I'm not a nix guy but it seems like nix command-line can do pretty much anything... is there a neat way to do this? xcodebuild itself doesn't seem to have any control options for verbosity.
This question might help:
How to filter the xcodebuild command line output?
Basically, you can just pipe the output and search what you need to show with grep.

How do I make sense of a batch file?

I have no prior experience working with batch files or shell scripting in general. I need to understand the operations being carried out by a batch file used in a related project. Any resource that gives exhaustive list of batch file commands and what each one does?
Once you get acquainted with the general .BAT file information, using some of the pointers to useful information that other users have posted in the other answers, you might try some of the following strategies that help you understand and analyze the BAT files used int your projects:
add an ECHO command in front of all command invocations
read HELP command for each command line in the BAT file
execute at the command prompt each command line in the BAT file
remove the #echo off at the top of the .BAT file, and see how the BAT progresses
add some PAUSEs to keep viewing some commands on screen before they disappear.
There are some useful answers here in this Stack Overflow question: Best free resource for learning advanced batch-file usage?
As well there are quite a few resources available through google search for Batch file resources, as well as the Wikipedia entry http://en.wikipedia.org/wiki/Batch_files
That should get you started at least.
A little search on google should give a lot of tutorials and websites with information on writing them for both Windows and Linux.
Maybe you should start from the beginning though.
http://ss64.com/nt/
http://academic.evergreen.edu/projects/biophysics/technotes/program/batch.htm
http://www.robvanderwoude.com/batchcommands.php
http://en.wikipedia.org/wiki/List_of_MS-DOS_commands
They're just a few examples i found with a little google search. You should search it and find something thats better for you.
Hope this helps.

Resources