how can I delete the command history in swi-prolog - command-line

So, I enjoy the option of using the up and down arrow keys to search through the command history in Swi-Prolog instead of retyping commands. I want to know how I can delete the command history.

The history is per-directory kept in ~/.swipl-dir-history. The files there are base32 encoded directory names. So, stop Prolog, find the right file, delete it and restart Prolog.

Related

Where does breakpoints stores

In VSCode, where do the breakpoints store?
When I relaunch VSCode, those breakpoints still exists, so there should be a place for VSCode to store them. But it is stored neither in the workspace, nor in .vscode.
I need to know where they store so that I can backup/restore/add/modify/delete multiple breakpoints conveniently and efficiently.
Where are the breakpoints stored?
On Windows, the breakpoints are stored in:
%APPDATA%/Code/User/workspaceStorage/(long_hash)/state.vscdb
On Linux, they are in (per Matt's comment):
$HOME/.config/Code/User/workspaceStorage/(long_hash)/state.vscdb
To locate the (long_hash), I added a breakpoint and looked for a file that was recently modified. If you have Cygwin bash, a command like this works, right after adding or removing a breakpoint:
$ cd $APPDATA/Code
$ find . -mmin -1
The state.vscdb file is a SQLite database. I'm able to pull some data out of it using strings (another Cygwin command):
$ strings state.vscdb | grep 'debug.breakpoint'
debug.breakpoint
debug.breakpoint
debug.breakpoint[{"enabled":true,"uri":{"$mid":1,"fsPath":"d:\\wrk\\learn\\vscode\\cpphello\\helloworld.cpp","_sep":1,"external":"file:///d%3A/wrk/learn/vscode/cpphello/helloworld.cpp","path":"/D:/wrk/learn/vscode/cpphello/helloworld.cpp","scheme":"file"},"lineNumber":12},{"enabled":true,"uri":{"$mid":1,"fsPath":"d:\\wrk\\learn\\vscode\\cpphello\\helloworld.cpp","_sep":1,"external":"file:///d%3A/wrk/learn/vscode/cpphello/helloworld.cpp","path":"/D:/wrk/learn/vscode/cpphello/helloworld.cpp","scheme":"file"},"lineNumber":13}]g
debug.breakpoint[{"enabled":true,"uri":{"$mid":1,"fsPath":"d:\\wrk\\learn\\vscode\\cpphello\\helloworld.cpp","_sep":1,"external":"file:///d%3A/wrk/learn/vscode/cpphello/helloworld.cpp","path":"/D:/wrk/learn/vscode/cpphello/helloworld.cpp","scheme":"file"},"lineNumber":12}]
The above is with a single breakpoint at helloworld.cpp line 12.
Is accessing this file a good idea?
Probably not!
If your goal is to query or manipulate the breakpoints yourself by modifying this file, I'd caution that that risks corrupting VSCode's internal storage (even if using a proper SQLite client).
I recommend instead using the VSCode extension APIs debug.breakpoints and debug.addBreakpoints to query and modify them from within VSCode.
On mac, it's
~/Library/Application Support/Code/User/workspaceStorage/<hash>

Accidentally deleted the Git Shell shortcut

So where is it? I checked the usual suspects, namely Program Files and Program Files (x86), but I didn't see any mention of GitHub there.
I know someone offered an answer but deleted it for whatever reason before I could accept it, so here goes.
You need to create a shortcut to a command, which is actually rather convoluted.
Right-click on the desktop and do New > Shortcut
Browse to any file, but make sure it's not a .exe file!!
Click next through the rest of the wizard and accept the defaults
Now right-click the shortcut, go to Properties > Shortcut tab
Set the Target to: "C:\Documents and Settings\\AppData\Local\GitHub\GitHub.appref-ms" --open-shell
In step 5 above, the quotes are required.
A better solution is to run
%LOCALAPPDATA%\GitHub\GitHub.appref-ms --reinstall-shortcuts
which will recreate the shortcut on the desktop.

Filtering ZSH history by command

I was told that in ZSH you could do something like command and then when you hit up it would filter the history based on the given command. But when I try this it just cycles the history like bash does. Is this disabled by default?
Hit Ctrl+R, type some letters, it will find the previous command with these letters, keep hitting Ctrl+R to continue through the previous findings.
Works in bash, zsh (and other shells i suppose).
What i personally like to have is: type some letters, press Up, the previous commands starting with the same letters appear. Very powerful, i love it.
You have to bind the keys you want to history-beginning-search-backward and history-beginning-search-forward.
In case it's not enough for you, zsh has a lot of options, try to look in Zsh Line Editor and tell us.
For bash, less powerful but more common, Bash commands for history.
Use exclamation point:
> !<starts-with this string>
You can arrow up/down through all commands that started with that. I use "!v" all the time to get my previous command for opening a file with Vim.
You can also use a question mark to search beyond matching the beginning of the string,
> !?status
Can find "git status".
Use percol to dynamically search and navigate through your history with Ctrl-r.
install percol: sudo pip install percol
add the zsh-history-search code snippet to your .zshrc file.
After a Ctrl-r, you can see your whole history in the same window. Searching for a keyword (dynamically) narrows that list down. You can use key-bindings (like this emacs like config) to navigate up and down the list and eventually make a selection.
Here is a search for all sudo install commands available in history with sudo make install selected.
Enter issues the selected command.
We can also use fzf to fuzzy search the command history interactively.
Here is how to install:
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
~/.fzf/install
Say yes to all its configs. After that, restart your zsh shell, and press Ctrl-R, whoa, interactive command history search pops up. Enjoy!
With the vim keybindings activated in zsh you can use vi-history-search-backward (/) when in vi command mode.
That's a feature available in fish, but it seems like someone made a zsh plugin for it. It's not available in standard ZSH.
If you don't want to add any keybindings, you can search by default using Ctrl+R to move backward & Ctrl+S to move forward.
You can start search with any of the key shortcuts Ctrl+R or Ctrl+S

emacs on Windows: .emacs is no valid file name

I've found out where to put my .emacs file, but it seems it can't begin with a ".".
I tried naming it "emacs" or "_emacs", but how can I find out if it is used?
You can always create the file using Emacs itself: C-x C-f ~/.emacs. The ~ represents your home directory, which you can set as environment variable HOME.
Have a look at this page and this one for start up instructions.
If you are creating a file in Explorer, it won't allow you to use a .name (gives this error).
A simple work-around, if you have bash (cygwin, git-bash, or any other variant) installed is to use that to rename the file. It may also work in powershell or command prompt, I've not tested those.
Files can start with '.', this doesn't cause any trouble alone, but explorer won't let you name them with it.
Windows Explorer disallows the creation of filenames starting with a dot. A simple workaround with builtin Windows tools is to create the file with a dummy name (eg. _emacs), then use cmd.exe to rename it:
cd path/to/file
ren _emacs .emacs
Recent versions of windows (e.g. Windows 7) seem to allow creation of a .emacs file using windows explorer. When creating/renaming the file simply enter .emacs. instead of .emacs.
To test if the .emacs that you are editing is the .emacs that is being loaded, you could put the following elisp command in it:
(minibuffer-message "it worked")
Now exit and restart emacs, while watching the minibuffer at the bottom of the screen to see if it appears (it will only appear for 2 seconds).
Windows allows the creation and use of that type of file, but Windows Explorer does not allow a file to be named to that using Windows Explorer. Use another tool (like the command line, or emacs) to create the file with that name.

a question about clearcase: how to open a file checked out in emacs?

I have a question about clearcase. in linux, I open a terminal, and use "xclearcase" command to lunch file browser of clearcase. Then I check out a file and I want to open it in Emacs, I know I should cd to the folder contains the checked out file, but before I do this, the terminal still effected by the "xclearcase" command, how could I type some commands now?
When you launch xclearcase, do so by adding a & to the end of it. This will make the shell send it to the background so you can do more stuff in your shell. E.g.
xclearcase &
That will allow you to further interact with your shell while xclearcase is running.
Also, if you're working in the terminal, I would recommend getting comfortable with cleartool for basic operations. For example, to checkout and edit a file:
cleartool co src/path/to/file.c
emacs src/path/to/file.c
Then, to checkin the file:
cleartool ci src/path/to/file.c
As Nemo mentions in the comments, the vc-clearcase Emacs mode allows you to checkout a file right from an Emacs session (C-x v v).
It will handle hijacked file, asking whether to keep the changes in said hijacked file through the question "Claim lock retaining changes?"
It will ask for a comment
It allows for checkouting a directory
It handle file with a -nocheckout rule on their config spec