Difference between revisions of "How to indicate that shell session is running inside Vifm"
Jump to navigation
Jump to search
(Initial version of the page) |
(Fix syntax highlighting errors (use pre instead of source tag)) |
||
Line 16: | Line 16: | ||
It will look similar to this: | It will look similar to this: | ||
− | < | + | <pre> |
-- VIFM SHELL SESSION -- | -- VIFM SHELL SESSION -- | ||
-- VIFM_SESSION -- | -- VIFM_SESSION -- | ||
Line 22: | Line 22: | ||
Linux | Linux | ||
-- VIFM_SESSION -- | -- VIFM_SESSION -- | ||
− | </ | + | </pre> |
=== Variant #2. Demonstrated using bash === | === Variant #2. Demonstrated using bash === | ||
Line 43: | Line 43: | ||
Will look similar to this: | Will look similar to this: | ||
− | < | + | <pre> |
[V][~]$ | [V][~]$ | ||
− | </ | + | </pre> |
==== Drawbacks ==== | ==== Drawbacks ==== |
Revision as of 21:07, 31 August 2018
The idea is to make shell indicate whether it was run inside by Vifm and exiting it will bring Vifm back or not.
Variant #1. Demonstrated using zsh
Add the following to .zshrc
:
if [ $(ps -ocommand= $(ps -oppid= -p $$)) = "vifm" ]
then
printf "\e[48;5;21m"
echo "-- VIFM SHELL SESSION --"
export PROMPT="-- VIFM_SESSION --"$'\n'"${ret_status} %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)"
fi
It will look similar to this:
-- VIFM SHELL SESSION -- -- VIFM_SESSION -- ➜ ~ uname Linux -- VIFM_SESSION --
Variant #2. Demonstrated using bash
To be added to vifmrc
:
let $INSIDE_VIFM = 'true'
In .bashrc
:
if [ -n "$INSIDE_VIFM" ]; then
PS1="[V]$PS1"
unset INSIDE_VIFM
fi
Will look similar to this:
[V][~]$
Drawbacks
Environment variable might "leak" to some child process, which will later spawn a shell and trick it into reporting as if it's inside Vifm.