I am trying to set a different NVIM_LISTEN_ADDRESS for each Tmux session, so that each session can run its own Neovim server.
I have tried the following:
session=$("tmux display-message -p '#S'")
tmux set-environment -t "$session" NVIM_LISTEN_ADDRESS /tmp/"$session"
But while that then allows you to tmux show-environment NVIM_LISTEN_ADDRESS, it does not allow you to echo $NVIM_LISTEN_ADDRESS, which is what I need.
I have also tried the following in my .tmux.conf, but it does nothing:
set-option -g default-command "NVIM_LISTEN_ADDRESS=/tmp/#S reattach-to-user-namespace -l /usr/local/bin/zsh"
Also tried:
set-option -g default-command "reattach-to-user-namespace -l NVIM_LISTEN_ADDRESS=/tmp/#S /usr/local/bin/zsh"
(Previously, this was set-option -g default-command "reattach-to-user-namespace -l /usr/local/bin/zsh", which is necessary to integration the Tmux and Mac OS X clipboards.)
What should I do?
Solved -- /.zshrc:
session=$(tmux display-message -p '#S')
address="/tmp/$session"
local NVIM_LISTEN_ADDRESS="$address"
Related
I'm running a command in a network namespace using nsenter, and I wish to run it as an ordinary (non-root) user because I want to access an Android SDK installation, which exists in my own home directory.
I find that although I can specify which user I want in my nsenter command, my environment variables don't get set accordingly, and I don't see a way to set those variables. What can I do?
sudo nsenter --net=/var/run/netns/netns1 -S 1000 bash -c -l whoami
# => bash: /root/.bashrc: Permission denied
# => myuser
sudo nsenter --net=/var/run/netns/netns1 -S 1000 bash -c 'echo $HOME'
# => /root
Observe that:
When I attempt a login shell (with -l), bash attempts to source /root/.bashrc instead of /home/myuser/.bashrc
$HOME is /root
If I prepend my command with a variable assignment (HOME=/home/markham sudo nsenter --net=/var/run/netns/netns1 -S 1000 bash -c -l whoami), I get the same results.
(I'm on version nsenter from util-linux 2.34.)
Mine is a bit of a peculiar situation, I created a dockerfile that "works" if not for some proiblems,
Here is a "working" version:
ARG IMGVERS=latest
FROM bensuperpc/tinycore:${IMGVERS}
LABEL maintainer "Vinnie Costante <****#gmail.com>"
ARG DOWNDIR=/tmp/download
ARG INSTDIR=/opt/vscodium
ARG REPOAPI="https://api.github.com/repos/VSCodium/vscodium/releases/latest"
ENV LANG=C.UTF-8 LC_ALL=C PATH="${PATH}:${INSTDIR}/bin/"
RUN tce-load -wic Xlibs nss gtk3 libasound libcups python3.9 tk8.6 \
&& rm -rf /tmp/tce/optional/*
RUN sudo ln -s /lib /lib64 \
&& sudo ln -s /usr/local/etc/fonts /etc/fonts \
&& sudo mkdir -p ${DOWNDIR} ${INSTDIR} \
&& sudo chown -R tc:staff ${DOWNDIR} ${INSTDIR}
#COPY VSCodium-linux-x64-1.57.1.tar.gz ${DOWNDIR}/
RUN wget http://192.168.43.6:8000/VSCodium-linux-x64-1.57.1.tar.gz -P ${DOWNDIR}
RUN tar xvf ${DOWNDIR}/VSCodium*.gz -C ${INSTDIR} \
&& rm -rf ${DOWNDIR}
CMD ["codium"]
The issues are these:
Starting the image with this command vscodium does not start, but entering the shell (adding /bin/ash to the end of the docker run) and then running codium instead vscodium starts. I tried many ways, even changing the entrypoint, the result is always the same. But if I try to add any other graphic program (like firefox) and replace the argument of the CMD instruction inside the dockerfile, everything works as it should.
docker run -it --rm \
--net=host \
--env="DISPLAY=unix${DISPLAY}" \
--workdir /home/tc \
--volume="$HOME/.Xauthority:/root/.Xauthority:rw" \
--name tc \
tinycodium
the last two versions of codium (1.58.0 and 1.58.1) don't work at all on docker but they start normally on the same distro not containerized. I tried installing other dependencies but nothing worked. Right now I don't know how to understand what's wrong with these two new versions.
I don't know how to set a volume to save codium data, I tried something like this --volume=/home/vinnie/docker:/home/tc but there are always problems with user/group permissions. I've also tried booting the container as user by adding it to the docker group but there's always a mess with permissions. If someone could explain me how to proceed, the directories I want to save are these:
/home/tc/.vscode-oss
/home/tc/.cache/mesa_shader_cache
/home/tc/.config/VSCodium
/home/tc/.config/glib-2.0/settings
/home/tc/.local/share
Try running codium --verbose and see if the container starts
I'm trying to build a Docker image based on oracle/database:11.2.0.2-xe (which is based on Oracle Linux based on RHEL) and want to change the system locale in this image (using some RUN command inside a Dockerfile).
According to this guide I should use localectl set-locale <MYLOCALE> but this command is failing with Failed to create bus connection: No such file or directory message. This is a known Docker issue for commands that require SystemD to be launched.
I tried to start the SystemD anyway (using /usr/sbin/init as first process as well as using -v /sys/fs/cgroup:/sys/fs/cgroup:ro -v /run thanks to this help) but then the localectl set-locale failed with Could not get properties: Connection timed out message.
So I'm now trying to avoid the usage of localectl to change my system globale locale, how could I do this?
According to this good guide on setting locale on Linux, I should use
localedef -c -i fr_FR -f ISO-8859-15 fr_FR.ISO-8859-15
But this command failed with
cannot read character map directory `/usr/share/i18n/charmaps': No such file or directory`
This SO reply indicated one could use yum reinstall glibc-common -y to fix this and it worked.
So my final working Dockerfile is:
RUN yum reinstall glibc-common -y && \
localedef -c -i fr_FR -f ISO-8859-15 fr_FR.ISO-8859-15 && \
echo "LANG=fr_FR.ISO-8859-15" > /etc/locale.conf
ENV LANG fr_FR.ISO-8859-15
On a normal server e.g. a Linode VPS I would normally do:
localectl set-locale LANG=<locale>.utf8
timedatectl set-timezone <timezone>
But since systemd is not present or does not work on containers I get:
Failed to create bus connection: No such file or directory
Now, my goal is just to change these settings without using systemd but such approach seems to go undocumented. Is there a reference for non-systemd alternatives to config tools?
Some documentation about locale setting in arch wiki: https://wiki.archlinux.org/index.php/locale
In Dockerfile, adjust LANG to your desired locale. You can add more than one locale in /etc/locale.gen to have a choice later.
Works on debian, arch, but locale-gen misses on fedora:
ENV LANG=en_US.utf8
RUN echo "$LANG UTF-8" >> /etc/locale.gen
RUN locale-gen
RUN update-locale --reset LANG=$LANG
More general is localedef, works on fedora, too:
ENV LANG=en_US.UTF-8
localedef --verbose --force -i en_US -f UTF-8 en_US.UTF-8
Put this in your Dockerfile
ENV TZ=America/Denver
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
Edit .bash_profile or .bashrc from root and add the following.
TZ='Asia/Kolkata'
export TZ
Save file and commit image after its done.
Based on a technique used in sti-base, I came up with the following workaround for https://github.com/ncoghlan/fedbuildenv/blob/09a18d91e7af64a45394669bac2595a4b628960d/Dockerfile#L26:
# Set a useful default locale
RUN echo "export LANG=en_US.utf-8" > /opt/export_LANG.sh
ENV BASH_ENV=/opt/export_LANG.sh \
ENV=/opt/export_LANG.sh \
PROMPT_COMMAND="source /opt/export_LANG.sh"
BASH_ENV covers non-interactive bash sessions, ENV covers sh sessions, and PROMPT_COMMAND covers interactive bash sessions.
this seems to be the debians's equivalent of locale-gen:
RUN localedef -v -c -i fr_FR -f UTF-8 fr_FR.UTF-8 || true
I am a former Windows guy and I am having trouble with Unix shell.
su - $USER -p -c "$CMD" this command like this one has to access path variables of the given environment but it does not. When I change it to su - $USER -p -c "export PATH=$PATH; $CMD", it works as expected. (I guess).
I am trying this code in an init script and I have another question here related to this one. (Sorry for duplication, but I am sure where is the correct place to ask.)
First question is why su - $USER -c $CMD forgets all previously defined env variables?
Is it a correct approach to insert path inside the command like su - $USER -p -c "export PATH=$PATH; $CMD"
Edit
su $USER -p -c "whoami && echo $PATH && $CMD", I tried removing -. Still not working.
When I experiment with the following command su - $USER -p -c "whoami && echo $PATH && $CMD" I can see that $user and $path are set correctly. But it still cannot find binaries under the $PATH.
Edit-2
I made a few more experiments and I have come to shortest working form: su $USER -c "PATH=$PATH; $CMD". I am still not sure if this is the best practise?
su - means switch user and load the new user's environment (similar to what's loaded when you log in as the user to begin with). Try doing su instead without the -. This switches user but keeps the environment how it was before you swapped the user.
Well su - means use a login shell. So it is taking on the env of the user you are su'ing to. If you want to keep your env omit the -
man su:
The value of $PATH is reset to /bin:/usr/bin for normal users...