GitXplorerGitXplorer
k

reload.fish

public
5 stars
2 forks
0 issues

Commits

List of commits on branch main.
Verified
181ea65bfabc544e0b3b3dd03615900959ce32ca

Update README.md

kkenji-miyake committed 3 years ago
Unverified
92a034b8ee59bb7c1f956539da0b99f4c29dc4b5

Apply format

committed 3 years ago
Unverified
5ed3a6f0883a30de0c5b220c7ab540a025062833

Protect COLORTERM

committed 3 years ago
Unverified
f74747e82d85b866ee2680e73504b68271cbe8df

Protect VSCODE_GIT_IPC_HANDLE

committed 3 years ago
Unverified
49d408906b3808868bf59192b283fdf7cbfd1b5d

Protect Zellij-related variables

committed 3 years ago
Unverified
feca9c6743447d911c6a9a783155cd58ecd72796

Protect XDG_RUNTIME_DIR

committed 3 years ago

README

The README file for this repository.

reload.fish

reload function for fish-shell

Prerequisites

This plugin suppose fish isn't your login shell and called from bash.
If you'd like to launch fish automatically, please write the following sentences in ~/.bashrc.

# ~/.bashrc

if [ -z "$FISH_VERSION" ]; then
    command -v fish > /dev/null 2>&1 && exec fish
fi

With this, fish will run when you open a new terminal, and you can launch bash from fish.

~
❯ bash
kenji@desktop:~$

Installation

Using fisher (recommended)

fisher install kenji-miyake/reload.fish

Using local-install script (for development)

git clone git@github.com:kenji-miyake/reload.fish.git
cd reload.fish
./install

Usage

Just call reload and your environment will be refreshed.

reload

Also, you can set some environment variables before reloading.

# `echo ROS_DISTRO=$ROS_DISTRO` is written in .bashrc
$ reload -e 'ROS_DISTRO=rolling'
ROS_DISTRO=rolling

If you'd like to evaluate a command before reloading, please use -c option.

# `echo ROS_DISTRO=$ROS_DISTRO` is written in .bashrc
$ cd YOUR_ROLLING_WORKSPACE
$ reload -c 'bass source install/setup.bash' -e 'ROS_DISTRO=$ROS_DISTRO'
ROS_DISTRO=rolling

Example

~set value 1

~echo $value
1

~
❯ reload
~echo $value

Tips

For ROS users

With this tool, you can reload your shell in ROS1 or ROS2 mode, without modifying your .bashrc and re-launching a new terminal.

// .bashrc

echo "before: ROS_DISTRO=$ROS_DISTRO, ROS_VERSION=$ROS_VERSION"

# ROS
if [ "$ROS_DISTRO" = "rolling" ]; then
    source /opt/ros/rolling/setup.bash
elif [ "$ROS_DISTRO" = "foxy" ]; then
    source /opt/ros/foxy/setup.bash
elif [ "$ROS_DISTRO" = "noetic" ]; then
    source /opt/ros/noetic/setup.bash
else
    echo "Invalid ROS_DISTRO `$ROS_DISTRO` was given."
fi

echo "after: ROS_DISTRO=$ROS_DISTRO, ROS_VERSION=$ROS_VERSION"
$ reload -e 'ROS_DISTRO=rolling'
before: ROS_DISTRO=rolling, ROS_VERSION=
after: ROS_DISTRO=rolling, ROS_VERSION=2

$ reload -e 'ROS_DISTRO=foxy'
before: ROS_DISTRO=foxy, ROS_VERSION=
after: ROS_DISTRO=foxy, ROS_VERSION=2

$ reload -e 'ROS_DISTRO=noetic'
before: ROS_DISTRO=noetic, ROS_VERSION=
after: ROS_DISTRO=noetic, ROS_VERSION=1