Skip to content

kenji-miyake/reload.fish

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

reload function for fish-shell

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages