RStudio HiDPI support - r

RStudio is great IDE for R development. I wonder if there is any way for nice support HiDPI resolution?
I currently have 13 inch display and 3200x1800 resolution, it is even hard to read RStudio options to adjust more appropriate setting.
This is of course not an RStudio issue but general issue related to high resolution display which requires HiDPI support to make it reasonably usable.
Posting it here as question because RStudio still doesn't allow to fill questions/issues on github.

RStudio is a Qt application. I've solved this by setting a scaling factor in Qt with this environment variable (note it must be an integer):
export QT_DEVICE_PIXEL_RATIO=2
The Arch wiki has some excellent advice on getting HiDPI working.

UPDATE: This solution is only for WINDOWS!
There is a simple solution for you, it comes from the option "Compatibility" of the execute file.
Close all current RStudio windows.
Right click on the shortcut of RStudio (or the original exe file) and choose Properties
In the RStudio Properties pop-up windows, choose the tab Compatibility
Tick on option Override hide DPI scaling... and then choose System from the drop-down list.
Apply > OK.
(Re)open Rstudio to see the change
Note that, on the HiDPI screen, resolution of modified RStudio is not so good but it really solved the bad scale problem.
You can also apply this technique to other apps without supporting HiDPI.

I use the following bash script to determine the current screen resolution and substitute the scaling factor by 1 (normal resolution) or 1.75 (high resolution) in the RStudio desktop file:
#!/bin/bash
# Determine resolution
width=$(xdpyinfo | grep 'dimensions:' | grep -o -E '[0-9]+' | head -1 | sed -e 's/^0\+//')
echo "Screen width is $width pixels"
if [ $width -gt 3000 ]; then
echo "High resolution detected -> setting zoom level to 1.75"
sed -i 's/view.zoomLevel.*/view.zoomLevel=1.75/' ~/.config/RStudio/desktop.ini
else
echo "Normal resolution detected -> setting zoom level to 1.0"
sed -i 's/view.zoomLevel.*/view.zoomLevel=1/' ~/.config/RStudio/desktop.ini
fi
QT_QPA_PLATFORMTHEME=gtk2 /usr/lib/rstudio/bin/rstudio %F
I am on Ubuntu 17.10. If I want to use the GTK theme, I have to set the QT_QPA_PLATFORMTHEME environment variable.

Related

How to scroll up in Vim buffer with R (using Nvim-R)

I'm a happy user of the Nvim-R plugin, but I cannot find out how to scroll up in the buffer window that the plugin opens with R. Say for instance that I have a large output in console, but I cannot see the top of it - how do I scroll up to see this? In tmux for instance there's a copy mode that quite handily lets you do this, but how is this done in the R buffer?
An example below where I'm very curious to see what's on the line above the one begining with "is.na(a)...". How can this be achieved?
I have scoured the documentation found here, but without luck.
The answer is apparently to use Ctrl+\ Ctrl+n according to this answer on the bugreports for NVim-R.
Here's what my output looks like when I output mtcars:
When I hit Ctrl+\ Ctrl+n, I can move the cursor and I get line numbers:
To get back to interactive, I just use i, the same way I normally would.
Apparently, if you are using neovim, then you can add let R_esc_term = 0 in your ~/.vimrc file and you can then use the escape key, but if you don't use neovim, you are stuck using the two ctrl commands ¯\_(ツ)_/¯.
As pointed out by ZNK, it is about switching to normal mode in Vim's terminal. This, however, can easily fail due to cumbersome keybinding. If such is the case, remap the default keybinding to something reasonable, say, by putting this in your .vimrc:
tnoremap jk <C-\><C-n>
This works for me in Linux running Vim 8.0 in terminal (e.g. does not require Neovim). As you can see, I use 'jk' to switch from insert to normal mode. One can use Esc instead of jk, however, this makes me unable to use up arrow to retrieve command line history as been reported elsewhere.

Changing directory color with zsh + Prezto

I am using Prezto + zsh as my shell. I would like to change the color of
directories when I ls my directory. For instance, here is what I currently
have:
Obviously, this is no fun, as I’m hardly able to read my directories because the
blue is so dark. I’d like to change it to white or orange or something lighter.
This dark blue is specific only to directories. Files show up in a nice white
text. Where and what settings must I find to change this?
Update
I've seen this answer still getting attention, so here's an update. Instead of messing with individual colours as below, simply adjust the Minimum Contrast within Preferences ... -> Profiles -> Colors. I set mine to 60.
Original answer
The easier way to do this is to change the colour scheme of your terminal. For example if you are using iTerm2 on a Mac then:
Launch iTerm2
type CMD+i
In the "Colors" tab, change the setting for "Blue" (and potentially the "Bright" equivalient)
In the "General" tab, click "Copy Current Settings to Selected Profile"
If you want to revert back to the defaults you can always select a value from the "Color presets..." dropdown in the "Colors" tab.
Do the equivalent in your favourite terminal if you don't use iTerm2 on a Mac.
The answer depends on your ls. BSD ls uses the environment variable LSCOLORS; coreutils ls uses LS_COLORS instead. See your man page.
The utility module of Prezto uses dircolors (if available) to customize the colors of coreutils ls, which also comes with coreutils. So if you have coreutils, then you can use dircolors to provide actually human-readable color definitions. Read the man page of dircolors for details. Prezto reads from $HOME/.dir_colors by default, otherwise it just use the default colors defined by dircolors. You can of course specify other locations by editing on top of Prezto.
For BSD ls, there's probably no utility comparable to dircolors, so one has to manually define LSCOLORS. See the ENVIRONMENT section of the man page on its format, which should be pretty clear. An example is LSCOLORS='exfxcxdxbxGxDxabagacad', used by Prezto by default. To have it take effect, put it in runcoms, after loading Prezto's utility module.
I may be late to the party but I found the answer here: https://github.com/sorin-ionescu/prezto/issues/1539
Run in the Terminal or add to your .zshrc file
export LSCOLORS="ExGxBxDxCxEgEdxbxgxcxd"

Unicode character bug upon exiting tmux with alternate screen overridden

I've removed and added a few times now the following line to ~/.tmux.conf:
set -ga terminal-overrides ',xterm*:smcup#:rmcup#'
Which according to the person who provided it does the following:
to fool the multiplexers into thinking that the terminal has no "alternate screen" mode (such as that used by pico, mutt, etc). This is accomplished by setting termcap commands for the session.
The 'xterm*' part of the command should be set to whatever your terminal-emulator is declared as.
The end result is that the overflow ends up in the terminal's scrollback buffer instead of disappearing. Of course, since this is one static buffer, things will get messy as you switch between screen or tmux windows, but this is handy for quickly flicking up to see the output of an ls command or the such.
I don't quite understand the bolded section (emphasis added), but guess this is the source of what I'm seeing. It's causing some weird sort of unicode overspill upon exiting tmux.
Pasted as plaintext this text won't show up, but the symbol [001B]112 appears alongside the usual [exited]:
]112[exited]
(FWIW I think it has pasted in that line, but isn't displaying)
I followed this advice ("Use terminal scrollbar with tmux"), and while it does work, this is just ugly/annoying to see that upon exiting. Can anyone advise how to fix or avoid the output message?
Offhand, I would get the unwanted "message" is some hard-coded application (or script) which is helpfully resetting the xterm dynamic text cursor color. See XTerm Control Sequences in the description of Operating System Controls:
The dynamic colors can also be reset to their default
(resource) values:
...
Ps = 1 1 2 -> Reset text cursor color.
So... somewhere there is some script doing the equivalent of
echo -n -e '\e]112\a
The results probably depend most on what particular terminal emulator you are using. Both screen and tmux filter out escape sequences that their developers did not care to implement, and pass through those that the terminal "should" handle.
Just take a look at sentence you provided: "The 'xterm*' part of the command should be set to whatever your terminal-emulator is declared as."
In my case, the $TERM has value xterm-256color and the corresponding line in ~/.tmux.conf looks like:
set -g terminal-overrides "xterm-color256:smcup#:rmcup#"

UNIX open multiple windows and pass login/password

Straight to the point; I'd like to create a script in UNIX to open two windows at a specific location on the screen, enter in username and password (which would be given by the user as an argument) and then execute another script.
I'd like to know if this is possible and if so; where should I look?
I'm new to UNIX, but am quite familiar with scripting and programming.
EDIT after thb and notfed responded
I am currently running SunOS 5.6 on OS X
Regarding the location of the windows, review X(7) -- that is, type the command man 7 X at the terminal and review the result -- and scroll down that man page to the section GEOMETRY SPECIFICATIONS, if your version of the man page has such a section. In brief, to have the program xfoo open its window with a size of 200 horizontally and 160 vertically, with its upper left corner at coordinates (40, 100), give the command xfoo -geometry 200x160+40+100.
This may not be a complete answer to your question, since you prudently have not given full details, but one suspects that it will set you on the right track, so to speak.
Regarding your authentication question, the crypt(3) manpage and its SEE ALSO section might help. For more advanced handling, see Libpam, where PAM stands for Pluggable Authentication Modules.
If the two windows are Xterms, then there's an easy way to do this;
Note this is from a ksh script, but should work in bash
## This is how big (how many columns & rows) your Xterm will be
GEOM0=198x20
GEOM1=98x45
## Colors
COLOR="-bg black -fg white -cr red"
## Xterm Options (See Man page)
XOPTS="+ah +ai -b 2 -cb +cn -j -ls -rw -aw -si +sk"
## Scroll-back Buffer
SCRLB="9999"
## Commands to execute (you could put an SSH command here)
CMD0="-e /bin/gtail -F /var/adm/messages"
CMD1="-e /bin/gtail -F /var/log/secure"
TITLE="-title Something Clever Here "
TERMBIN=/usr/openwin/bin/xterm
# PLACEMENT
# We specify where we want the window to pop-up by adding "+#+#" to the GEOM.
################################################################################
## Top-Left corner (For my monitor, that's "+2+2")
${TERMBIN} ${XOPTS} -sl ${SCRLB} -fn 6x10 ${COLOR} -geometry ${GEOM0}+2+2 ${TITLE} ${CMD0} &
## Top-Center (For my monitor, that's "+2+233")
${TERMBIN} ${XOPTS} -sl ${SCRLB} -fn 6x10 ${COLOR} -geometry ${GEOM1}+2+233 ${TITLE} ${CMD1} &

any way to get rxvt to recognize shift+tab?

I'm simply trying to get shift+tab to be a recognized key sequence during my rxvt terminal sessions. So I can map it to usefulness such as:
bindkey "\e[Z" reverse-menu-complete
But, based on my research, I'm pretty sure the answer is no. Just want to make sure.
This is a hard limitation of rxvt? (Is there a technical reason for this limitation? Or just an unsupported feature?)
I can't get it to emit that either, although strangely enough, the rxvt source code (as shipped with Cygwin) does appear to have support for it:
case XK_Tab:
if (shft)
STRCPY(kbuf, "\033[Z");
else {
...
Anyway, rxvt development stopped eight years ago. Try its successor, rxvt-unicode, aka urxvt, where this does work. If you're on Cygwin or MSYS and you were using rxvt without an X server, which urxvt does require, try mintty.

Resources