add bashrc script
This commit is contained in:
parent
80cb374abb
commit
7f5c8c112a
2 changed files with 111 additions and 12 deletions
42
README.md
42
README.md
|
@ -61,7 +61,7 @@ podman run --privileged -it --rm \
|
||||||
-v $XDG_RUNTIME_DIR/$WAYLAND_DISPLAY:/runtime_dir/$WAYLAND_DISPLAY \
|
-v $XDG_RUNTIME_DIR/$WAYLAND_DISPLAY:/runtime_dir/$WAYLAND_DISPLAY \
|
||||||
-v ~/.local/share/nvim/sessions:/root/.local/share/nvim/sessions \
|
-v ~/.local/share/nvim/sessions:/root/.local/share/nvim/sessions \
|
||||||
--workdir /data \
|
--workdir /data \
|
||||||
-v "./:/data:rw" \
|
-v "$(pwd):/data:rw" \
|
||||||
neovim:latest
|
neovim:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -69,18 +69,26 @@ function for opening current dir or some files/folders in temporary container:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
function nvim() {
|
function nvim() {
|
||||||
|
# Mount current folder OR folders/files given as parameters, then
|
||||||
|
# open neovim. Container will be removed on neovim exit.
|
||||||
|
# Mount wayland for clipboard sync.
|
||||||
|
# Also pass all parameters to neovim as its arguments.
|
||||||
|
|
||||||
for arg in "$@"; do
|
for arg in "$@"; do
|
||||||
if [ "$arg" ] && [ -f "$arg" -o -d "$arg" ] ; then
|
if [ -f "$arg" ] || [ -d "$arg" ] ; then
|
||||||
local MOUNT_FILE="$MOUNT_FILE -v "$arg:$arg:rw"";
|
local MOUNT_FILE="$MOUNT_FILE -v "$arg:$arg:rw""
|
||||||
echo "Mounting $arg"
|
echo "Mounting $arg"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if [ -z "$MOUNT_FILE" ]; then
|
if [ -z "$MOUNT_FILE" ]; then
|
||||||
# mount current workdir if no arguments with path
|
# mount current workdir if no arguments with path
|
||||||
# mount on base_path to make sessions saving work
|
# mount on base_path to make sessions saving work
|
||||||
local base_path="$(pwd)"
|
local base_path
|
||||||
|
base_path="$(pwd)"
|
||||||
local MOUNT_FOLDER="--workdir /data$base_path -v "$base_path:/data$base_path:rw""
|
local MOUNT_FOLDER="--workdir /data$base_path -v "$base_path:/data$base_path:rw""
|
||||||
fi
|
fi
|
||||||
|
# make sure there is a folder for sessions on default path
|
||||||
|
mkdir -p ~/.local/share/nvim/sessions
|
||||||
|
|
||||||
podman run --privileged -it --rm \
|
podman run --privileged -it --rm \
|
||||||
-e XDG_RUNTIME_DIR=/runtime_dir \
|
-e XDG_RUNTIME_DIR=/runtime_dir \
|
||||||
|
@ -100,22 +108,36 @@ then use function below.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
function nvim_project() {
|
function nvim_project() {
|
||||||
|
# Mount current folder to a container that will not be removed on exit.
|
||||||
|
# Requires first argument to be a name for the container so it can be
|
||||||
|
# easily reentered later.
|
||||||
|
# If you specify some paths as latter parameters, then these paths will
|
||||||
|
# be mounted instead of current folder.
|
||||||
|
# Also mounts wayland for clipboard sync.
|
||||||
|
|
||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
echo "give project/container name as first parameter";
|
echo "give project/container name as first parameter"
|
||||||
return 1;
|
return 1
|
||||||
fi
|
fi
|
||||||
|
local container_name
|
||||||
|
container_name="$1"
|
||||||
|
shift # skip first parameter as it can be name of a folder/file in
|
||||||
|
# current dir so it could try mounting it later
|
||||||
for arg in "$@"; do
|
for arg in "$@"; do
|
||||||
if [ "$arg" ] && [ -f "$arg" -o -d "$arg" ] ; then
|
if [ -f "$arg" ] || [ -d "$arg" ] ; then
|
||||||
local MOUNT_FILE="$MOUNT_FILE -v "$arg:$arg:rw"";
|
local MOUNT_FILE="$MOUNT_FILE -v "$arg:$arg:rw""
|
||||||
echo "Mounting $arg"
|
echo "Mounting $arg"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if [ -z "$MOUNT_FILE" ]; then
|
if [ -z "$MOUNT_FILE" ]; then
|
||||||
# mount current workdir if no arguments with path
|
# mount current workdir if no arguments with path
|
||||||
# mount on base_path to make sessions saving work
|
# mount on base_path to make sessions saving work
|
||||||
local base_path="$(pwd)"
|
local base_path
|
||||||
|
base_path="$(pwd)"
|
||||||
local MOUNT_FOLDER="--workdir /data$base_path -v "$base_path:/data$base_path:rw""
|
local MOUNT_FOLDER="--workdir /data$base_path -v "$base_path:/data$base_path:rw""
|
||||||
fi
|
fi
|
||||||
|
# make sure there is a folder for sessions on default path
|
||||||
|
mkdir -p ~/.local/share/nvim/sessions
|
||||||
|
|
||||||
podman run --privileged -it \
|
podman run --privileged -it \
|
||||||
-e XDG_RUNTIME_DIR=/runtime_dir \
|
-e XDG_RUNTIME_DIR=/runtime_dir \
|
||||||
|
@ -125,7 +147,7 @@ function nvim_project() {
|
||||||
$MOUNT_FILE \
|
$MOUNT_FILE \
|
||||||
$MOUNT_FOLDER \
|
$MOUNT_FOLDER \
|
||||||
--entrypoint bash \
|
--entrypoint bash \
|
||||||
--name "$1" \
|
--name $container_name \
|
||||||
neovim:latest
|
neovim:latest
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
77
bashrc_nvim.sh
Normal file
77
bashrc_nvim.sh
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
function nvim() {
|
||||||
|
# Mount current folder OR folders/files given as parameters, then
|
||||||
|
# open neovim. Container will be removed on neovim exit.
|
||||||
|
# Mount wayland for clipboard sync.
|
||||||
|
# Also pass all parameters to neovim as its arguments.
|
||||||
|
|
||||||
|
for arg in "$@"; do
|
||||||
|
if [ -f "$arg" ] || [ -d "$arg" ] ; then
|
||||||
|
local MOUNT_FILE="$MOUNT_FILE -v "$arg:$arg:rw""
|
||||||
|
echo "Mounting $arg"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [ -z "$MOUNT_FILE" ]; then
|
||||||
|
# mount current workdir if no arguments with path
|
||||||
|
# mount on base_path to make sessions saving work
|
||||||
|
local base_path
|
||||||
|
base_path="$(pwd)"
|
||||||
|
local MOUNT_FOLDER="--workdir /data$base_path -v "$base_path:/data$base_path:rw""
|
||||||
|
fi
|
||||||
|
# make sure there is a folder for sessions on default path
|
||||||
|
mkdir -p ~/.local/share/nvim/sessions
|
||||||
|
|
||||||
|
podman run --privileged -it --rm \
|
||||||
|
-e XDG_RUNTIME_DIR=/runtime_dir \
|
||||||
|
-e WAYLAND_DISPLAY="$WAYLAND_DISPLAY" \
|
||||||
|
-v "$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY:/runtime_dir/$WAYLAND_DISPLAY:rw" \
|
||||||
|
-v ~/.local/share/nvim/sessions:/root/.local/share/nvim/sessions:rw \
|
||||||
|
$MOUNT_FILE \
|
||||||
|
$MOUNT_FOLDER \
|
||||||
|
neovim:latest "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
function nvim_project() {
|
||||||
|
# Mount current folder to a container that will not be removed on exit.
|
||||||
|
# Requires first argument to be a name for the container so it can be
|
||||||
|
# easily reentered later.
|
||||||
|
# If you specify some paths as latter parameters, then these paths will
|
||||||
|
# be mounted instead of current folder.
|
||||||
|
# Also mounts wayland for clipboard sync.
|
||||||
|
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
echo "give project/container name as first parameter"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
local container_name
|
||||||
|
container_name="$1"
|
||||||
|
shift # skip first parameter as it can be name of a folder/file in
|
||||||
|
# current dir so it could try mounting it later
|
||||||
|
for arg in "$@"; do
|
||||||
|
if [ -f "$arg" ] || [ -d "$arg" ] ; then
|
||||||
|
local MOUNT_FILE="$MOUNT_FILE -v "$arg:$arg:rw""
|
||||||
|
echo "Mounting $arg"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [ -z "$MOUNT_FILE" ]; then
|
||||||
|
# mount current workdir if no arguments with path
|
||||||
|
# mount on base_path to make sessions saving work
|
||||||
|
local base_path
|
||||||
|
base_path="$(pwd)"
|
||||||
|
local MOUNT_FOLDER="--workdir /data$base_path -v "$base_path:/data$base_path:rw""
|
||||||
|
fi
|
||||||
|
# make sure there is a folder for sessions on default path
|
||||||
|
mkdir -p ~/.local/share/nvim/sessions
|
||||||
|
|
||||||
|
podman run --privileged -it \
|
||||||
|
-e XDG_RUNTIME_DIR=/runtime_dir \
|
||||||
|
-e WAYLAND_DISPLAY="$WAYLAND_DISPLAY" \
|
||||||
|
-v "$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY:/runtime_dir/$WAYLAND_DISPLAY:rw" \
|
||||||
|
-v ~/.local/share/nvim/sessions:/root/.local/share/nvim/sessions:rw \
|
||||||
|
$MOUNT_FILE \
|
||||||
|
$MOUNT_FOLDER \
|
||||||
|
--entrypoint bash \
|
||||||
|
--name $container_name \
|
||||||
|
neovim:latest
|
||||||
|
}
|
Loading…
Reference in a new issue