basic emacs commands not working preventing saving of files - unix

I am operating in a linux environment (not familiar to me) and I am handling a bunch of files in django. Bit embarrassing but I seem to have done something subtle to the server that disallows me from setting up separate work stations from my terminal... i.e. emacs file.py & won't work for me; it just says that the emacs window is loading but it won't actually appear - I've waited 5 minutes.
It's not a big deal as emacs file.py works fine and I can "Reset terminal" once I'm done editing the file. However, saving the file could be a problem as the saving options are different between the "&" and "without &" versions of the command. It's such a basic thing that there seems to be no info on it online... any tips?
NOTE: it all started when I mistakenly typed emacs file.py and forgot the & and now something seems to be irreversibly changed that logging in and out again doesn't fix...

When using emacs in a text terminal, start it without the &, you need to run it in foreground. To save a file, use the standard C-xC-s (if your terminal interprets the keystrokes differently, you have to configure the terminal). After saving the file, you can get back to the shell by pressing C-z. It would stop emacs, but you can get back in by typing fg or %em or similar.
To quit emacs, use C-xC-c.

Related

Julia REPL -- Legacy Console Mode Issue

I've had trouble using Julia in Windows Terminal for the last few releases because the ANSI escapes refuse to render properly unless I enable Legacy Console Mode which helps in CMD prompts, but not in Windows Terminal.
When launched in Terminal, it looks like this:
When launched with --color=no, it looks like this:
Which is marginally more useful, but both the inputs and outputs are muddled by the ANSI escapes, which makes the REPL effectively useless.
My workaround has been to enable the "Legacy Console" and use an alias to launch julia in a separate CMD-based window when I need REPL functionality, but this is disruptive.
I have tried various combinations of (multiple releases of) Windows Terminal (stable and dev), Powershell (stable and dev), and Legacy Console mode. There must be a configuration issue on my machine that I just can't nail down because no one else seems to have this issue.
What am I missing?
Can you file this over at https://github.com/microsoft/terminal/issues?
By all accounts, this should work. Seeing the literal escapes in the buffer like that makes me think that Julia isn't enabling ENABLE_VIRTUAL_TERMINAL_PROCESSING, which they would need for escape sequences to work. Though, if you're on a version of julia from 2021, I would presume that they're aware of that and would be setting that mode by now. (That flag was added in like, 2016)
Hopefully we can help diagnose more over at the Terminal repo ☺️

Difference between iTerm2, zsh and oh-my-zsh

I have been using the default bash of linux for over 1 year and one of colleague recommended me switch over to using iTerm2 alongwith zsh and oh-my-zsh. He also recommended this post to install and configure those :
https://www.freecodecamp.org/news/how-to-configure-your-macos-terminal-with-zsh-like-a-pro-c0ab3f3c1156/
When i asked what are they the answer he gave me was kind of confusing, so i ask you overlords kind do tell mewhat actually those are and if you have some insights about what actually a bash is, i would be happy to learn that too :)
Thank you all
Pawan
When you are at a command line, typing in commands and reading output you are working in a program called a terminal (or console on windows). The terminal is taking your commands and forwarding them to a program, called a shell, who's job is to actually execute the commands you type in to the terminal and possibly print some output. The output from the shell is then displayed in your terminal window.
The terminal is like the web browser and the shell is like the javascript engine. Your browser takes your input (click, keypresses, mousemoves) and sends them along to javascript which processes those actions and the browser displays the results.
iTerm2 is a terminal emulator meant to be a replacement for macOS terminal and is far more feature rich. It's the terminal program providing you with a command line interface.
ZSH is a specific shell, as is bash, the same way linux is a specific operating system. There are different shells that provide different syntax, features and functionality. There's bash, cshell, fish, powershell, zsh and others.
Installing ZSH, you are essentially downloading a new program and telling your terminal to use that program (say, instead of bash) to process the commands and run scripts.
oh-my-zsh provides a way of managing your zsh configurations, themes and plugins to extend the look and functionality of your shell.
I can't reccomend this setup enough- it's like the cadillac of command lines. You have a good friend there.

Console on windows-subsystem-for-linux slow when entering text

I'm using the windows-subsystem-for-linux console. Recently it sometimes pauses when typing text, the typed text appears after a few seconds. In the past it worked fine.
I'm searching for what causes this and how I can fix it.
I thought it might be caused by the command completion in bash together with the environment from the Visual Studio Developer Command Prompt (see this question's history)
This seems not to be the case:
The delays happen without the environment from the Visual Studio Developer command prompt.
The delays also happen when I type an answer to a prompt from git add --patch.
Perhaps it is tmux (I'm using version 1.8) or byobu (version 5.74) in combination with the windows conconsole?
What causes this problem?
How can I make bash responsive again?

Refresh R console without quitting the session?

I usually open the R console all day long, but sometimes I need to clean my history and my workspace's background so that I can test functions or load new data.
I'm wondering whether there is an easier way to use a command line in .Rprofile so that I can refresh the R console without quitting or rebooting my current session.
What I have usually done for this is to q() without saving and then start R again and clean the History. I think somebody here might be able to give me some better suggestions.
Thanks in advance.
For what concerns history, in UNIX-like systems (mine is Debian) this command refreshes it
loadhistory("")
However, as said in comments, loadhistory seems to be platform-dependent.
Check your ?loadhistory if present on your platform. Mine says:
There are several history mechanisms available for the different
R consoles, which work in similar but not identical ways. There
are separate versions of this help file for Unix and Windows.
The functions described here work on Unix-alikes under the
readline command-line interface but may not otherwise (for
example, in batch use or in an embedded application)

set environment variables for system() in R?

I've been using R in Ubuntu to make system calls using system() for things like spinning up Amazon EC2 instances, managing files on S3, etc. If I start R from the command line everything works fine. But if I start R from a script using Rscript, or from ESS, I have issues with environment variables not being set.
I think this is an issue with me not properly grokking where to set environment variables in Ubuntu. I thought the "right place" (for some definition of "right") was to set user environment variables in ~/.bashrc. This is where I set things like export EC2_HOME=/home/jd/ec2 but when I execute R from ESS and make system calls, the .bashrc script is not being run. I've tried Googing about and I see many an exegesis on environment variables in Ubuntu, such as this one. My knee jerk reaction is to try each recommendation in the aforementioned thread and stop giving a shit as soon as one of the options works. But then I end up with non-standard settings which bite me in the ass later.
So how should I set environment variables so that they are properly set when I run a system() call in R?
You can try to set them in R itself using Sys.setenv.
I think you are confusing the issue. I fear this may be about login shells versus non-login shells. See the bash manual page for the fine print ... which has driven me bonkers in the past.
That said, if you can set environment variables system-wide, you have a few options:
/etc/environment is a very good place as it is shell-agnostic should you ever use a different shell
for login versus non-login shells, the one way to get complete control that I found suitable was to put my changes into something like ~/.local_bashrc
the add . ~/.local_bashrc from and and all of
~./bashrc
~/.bash_profile
~/.profile`
etc pp.
You can precede the sourcing with a echo Hello from FILE where you replace FILE with the name of the file. That shows you the difference between shells starting from login (eg via gdm et al), via ssh connection, via new xterm etc terminals and so on.
You can force the system to read your .bashrc file by using the source command
source ~/.bashrc
Lots of inelegant and ugly ways to apply this

Resources