I've made a stupid mistake and run an Octave session overnight to produce results to the terminal, with the intention of manually copying and pasting the terminal output to a file. However, I now find that I can't scroll far enough back to copy all the session output. What can I do to access the current session history that is not observable in the terminal window? An added complication is that the terminal I'm using is terminator and there doesn't seem to be an edit option, so edit -> select all -> copy is not available to me. As I write this, the terminal and Octave session are still open, and I need to view the earlier history without either quitting Octave or closing the terminal.
suggest u look at my other post on stackoverflow
this tool lets u auto connect but as part of the global configuration it sets history as unlimited.
Once you run it for the first time your config file is generated and puts these in
cat ~/.config/terminator/config|head -15
[global_config]
enabled_plugins = LaunchpadCodeURLHandler, APTURLHandler, LaunchpadBugURLHandler
title_transmit_bg_color = "#ef191d"
[keybindings]
[profiles]
[[default]]
scrollback_infinite = True
split_to_group = True
foreground_color = "#ffffff"
[layouts]
as you can see the default config as scrll back inifinite true
Related
Is there a way to make NeoVim as default text/code editor (without any bad side effects) ?Trust me, I looked to lots of StackOverflow question/answers and tried a few things but nothing worked for me.
Note: I'm on macOS Big Sur (version 11.2.1). What I want is when I click on files to open in NeoVim.
--> For example, in ~/.zshrc (and added to ~/.bash_profile also just in case) I have:
Note: zsh is my default shell
alias nvim=$HOME/nvim-osx64/bin/nvim
export EDITOR="nvim"
export VISUAL="nvim"
When I do set in Terminal it shows:
EDITOR=nvim
VISUAL=nvim
And yes, I quit and started the terminal (I'm using iTerm2). I even reboot.
--> I will place my $PATH here just in case it has anything to do it that. When I do echo $PATH it shows:
--> And, just in case someone suggests:
I can't Select a File > Open With... and select NeoVim as default text editor, since that option doesn't show and I can't do Choose Other since I can't select NeoVim in that way.
If anyone needs more information, please say and I will edit the question with that info. Thanks!
Setting variables in the terminal will not affect the GUI file associations. To do that you have to change the OS's file associations.
Though it appears to be a small project and unsupported, I've had a good experience using duti. It's a wrapper around the Apple file extension API. The configuration did take me a minute to figure out. I'll post it if I can find it.
After a while I found the answer to my own question, here it is how you can set NeoVim in Mac as the default text editor. Now, you will be able click on files and opening them in NeoVim:
Some people recommended me to have a look at the follow links:
https://gist.github.com/Huluk/5117702
https://superuser.com/questions/139352/mac-os-x-how-to-open-vim-in-terminal-when-double-click-on-a-file
That didn't work for me but it served as a reference to look up related topics (automator + neovim).
After a while, I discover this blog:
https://blog.schembri.me/post/neovim-everywhere-on-macos/
Go and have a look at the blog, but here it is how you do it:
Launch Automator (Finder -> Applications -> Automator)
New Document -> Choose a type for your document: Application
In Actions search for Run AppleScript and drag that to where it says something like "Drag actions here..."
Delete the default example of AppleScript
Copy and Paste the code in the blog (where it says NeoVim.app) to where it previous had the default code
Save the new Automator app (save as aplicattion format). Save it in the Applications folder
Right-Click a file type you wish to open every time you click on them (e.g. .php file). Select Get Info or do cmd + i, it will open informations about that file. Scroll to wher it says Open With and select Other. Then just go to Aplicattions folder and select your new NeoVim "app".
Do the same to other file types if you wish.
You can now double click on your PHP files (or others if you did the same) and open them in NeoVim. Enjoy!
Note: You really need to do Right-Click, Get Info and look for Open With to change in all files with that extension. If you skip Get Info and just Right-Click + Open With, it will only work for that specific file...
This is the code from the blog:
on run {input, parameters}
set cmd to "nvim"
if input is not {} then
set filePath to POSIX path of input
set cmd to "nvim \"" & filePath & "\""
end if
tell application "iTerm"
create window with default profile
tell the current window
tell the current session to write text cmd
end tell
end tell
end run
This would open a new window even if you already had one open.
I change it so that it would open in a tab:
on run {input, parameters}
set cmd to "nvim"
if input is not {} then
set filePath to POSIX path of input
set cmd to "nvim \"" & filePath & "\""
end if
tell application "iTerm"
tell the current window
create tab with default profile
tell the current session to write text cmd
end tell
end tell
end run
Note: I'm using iTerm2. If you are using another Terminal Emulator, change where it says iTerm to the name of your terminal...
For anyone using Kitty on MacOS, I found a pretty simple way to accomplish this using the remote control feature.
First you need the following set in your kitty.conf:
allow_remote_control yes
listen_on unix:/tmp/mykitty
Using Automator like in #DGF's answer, I created an Application with the "Run Shell Script" action, and this is the script:
if [ -z "$(pgrep kitty)" ]
then
open /Applications/kitty.app
sleep 3 # allow ample time to startup and start listening
fi
/usr/local/bin/kitty # --to=unix:/tmp/mykitty-$(pgrep kitty) launch --type=os-window nvim "$#"
Save that as an application somewhere, and select it from "Open with"!
Note: to be honest, the logic to handle starting up kitty if it's not already running is a little flaky. But it seems to work great when kitty is already running, which of course it is most of the time for me. Also, it doesn't work at all if kitty is running but has no windows. :\
Choose nvim as the default application by means of a txt file sub-menu like here with Preview for PDFs:
I used code ~/zshrc. to go into the file and do some custom styling for my terminal. One of those things I added was echo -e " \e[5m \e[25m" which causes my command line to blink if I haven't initialized git tracking. I did it just for fun and decided after pressing cmd + q in vs code that I wanted to change it. However, this was lost and now when I run code ~/zshrc. it brings me to a blank file with none of the settings I personally added. When I did this I was definitely in my home directory. I'm wondering if there is any way I can undo some changes, go back to the way it was on a previous day, or just reset. Any recommendations? My terminal is not usable with everything flashing. Even running ls all my directories are flashing and I can hardly read it.
Thought I'd post an update. After a break, I came back the next day and noticed that the command I should've been running was code ~/.zshrc and not code ~/zshrc.. That fixed the whole problem so I could edit my zshrc file.
I just started using zsh and I have the terminalapp and git plugins so that new terminal tabs open in the current working directory. However, if a process is running in the foreground (a server, vim, etc), new tabs open in the home directory.
How can I change this behavior?
I'm using Terminal.app on OSX Mavercks.
Look at the "Startup" section at the Terminal preferences, "Same Working Directory".
See this blog post
http://russellfinn.com/2013/10/25/current-working-directory-restoration-in-mavericks-terminal-with-tcsh/
Most likely the value is getting cleared when you issue a new command and it is set again after the command finishes. Try placing the escape sequence (from the linked blog post) at the precmd_functions hook (i.e. search the zshall manual page for add-zsh-hook).
PS: see this answer https://superuser.com/questions/313650/resume-zsh-terminal-os-x-lion
I have a program that will run for a long time , This program edit and run in remote server .I use
the computer in office to remote connect the server and run it . The progress shows on the computer screen of the computer in my office ...
I want to see the output in my home , How can I capture the output which is on the screen of computer in office and see the result at home?
I think about writing the output to a file , but I need to close the file . So I should open file then write output , close .. open again?
thanks
I don't know the proper tag should use , but the program is written in perl .....
you can tee it
your_program.pl | tee logfile.txt
and see the lastest result in logfile.txt at home with
tail -f logfile.txt
Why not just redirect to a log file and tail it (or load it in an editor etc.) ?
$ myprog.pl >/tmp/logfile 2>&1
The above redirects your output to a log file (/tmp/logfile - you may wish to choose a better location since /tmp is temporary and can be trashed during a reboot) and redirects stdout/stderr to the same place. Note that this captures the output of your program and you don't need to modify your script.
An alternative is to run your program within screen
Perhaps one of the most useful features is that you can re-connect to
your sessions after you log out, move to another computer, or get
disconnected, and continue working as if nothing happened. All your
edit sessions, shell windows, etc. will be there just as you left
them.
Personally, I use screen for this sort of thing.
Connect to the server
Enter the command screen. It displays a nice message stating the version of screen and that it's under the GPL.
Run the actual command.
At any time, hit ctrl-A, D to disconnect from the screen session. You'll see a message along the lines of [detached from pid.tty.server]. Log out from the server normally.
Connect to the server again and enter the command screen -x to reconnect to your session.
I made a mistake in my gnome terminal configuration. I entered a command to start with in the preferences, but that command fails, and now all I get is a window that opens and closes right away, and I basically can't use gnome terminal anymore :-( Is there any way I can remove the configuration file and restart fresh??
Thanks!
Open the XTerm (Standard terminal for linux) and enter this command
gnome-terminal -e bash
It opens the gnome-terminal. Open profile preferences and configure your terminal to "Hold the terminal open".
Editing preferences
$HOME/.gconfd/saved_state
the above file might be of interest depending on exactly what configuration you changed. Of course, it holds configuration from other programs as well.
If you are on the newer gnome terminal that uses dconf, it's a little trickier, but still doable:
Profiles are stored with a UUID, you need to find the UUID of the profile to remove:
dconf dump /org/gnome/terminal/ | less
Search for a visible-name='...' entry matching the profile you want to remove. Look above that for the section header like [legacy/profiles:/:...]. The full name of the item you want to delete is thus /org/gnome/terminal/legacy/profiles:/:.... Delete it thus:
dconf reset -f /org/gnome/terminal/legacy/profiles:/:...
Side note: This Q&A probably should be moved to unix.stackexchange.com.