mirror of
https://github.com/ViViDboarder/shoestrap.git
synced 2024-11-22 06:46:33 +00:00
Improve color detection over ssh
This commit is contained in:
parent
06e3aea526
commit
96a2dc9381
@ -1,6 +1,7 @@
|
||||
#! /usr/bin/env python3
|
||||
import argparse
|
||||
import os
|
||||
import sys
|
||||
import textwrap
|
||||
from subprocess import Popen, PIPE, check_output
|
||||
from typing import Tuple
|
||||
@ -42,6 +43,17 @@ def get_terminal_profile(force=False):
|
||||
if not force and TERM_VAR in os.environ:
|
||||
return os.environ[TERM_VAR]
|
||||
|
||||
# If over SSH, quit. Colorschemes should instead be forwarded
|
||||
if is_ssh():
|
||||
print(
|
||||
("Warning: Cannot derive colors. "
|
||||
"SSH sessions won't allow detecting the terminal profile."
|
||||
f" Instead forward {TERM_VAR} from your source machine."),
|
||||
file=sys.stderr,
|
||||
)
|
||||
exit(0)
|
||||
|
||||
|
||||
term_program = os.environ.get("TERM_PROGRAM")
|
||||
if term_program == "Apple_Terminal":
|
||||
tty = check_output(["tty"]).strip()
|
||||
@ -53,7 +65,10 @@ def get_terminal_profile(force=False):
|
||||
raise SystemError("Could not get results from applescript")
|
||||
return stdout
|
||||
elif term_program == "iTerm.app":
|
||||
if "ITERM_PROFILE" in os.environ:
|
||||
return os.environ["ITERM_PROFILE"]
|
||||
else:
|
||||
raise ValueError("Using iTerm but no profile found")
|
||||
elif term_program == "Alacritty":
|
||||
return "Alacritty"
|
||||
|
||||
@ -202,6 +217,12 @@ def print_env(var: str, val: str, export=False, fish=False):
|
||||
print(f'set -g {var} "{val}";')
|
||||
|
||||
|
||||
def is_ssh() -> bool:
|
||||
if os.environ.get("SSH_TTY"):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
args = parse_args()
|
||||
if args.print_term:
|
||||
|
@ -6,21 +6,24 @@ set -gx XDG_CACHE_HOME "$HOME/.cache"
|
||||
# Increase memory sizes for java using Ant
|
||||
set -gx ANT_OPTS "-Xmx2048m -Xms512m"
|
||||
|
||||
# FZF
|
||||
if type -q rg
|
||||
# Interractive env variables
|
||||
if status --is-interactive
|
||||
# FZF
|
||||
if type -q rg
|
||||
set -gx FZF_DEFAULT_COMMAND 'rg --files'
|
||||
# set -gx FZF_DEFAULT_COMMAND 'rg --files --no-ignore-vcs --hidden'
|
||||
else if type -q ag
|
||||
else if type -q ag
|
||||
set -gx FZF_DEFAULT_COMMAND 'ag -g ""'
|
||||
end
|
||||
if [ -n "$FZF_DEFAULT_COMMAND" ]
|
||||
end
|
||||
if [ -n "$FZF_DEFAULT_COMMAND" ]
|
||||
set -gx FZF_CTRL_T_COMMAND "$FZF_DEFAULT_COMMAND \$dir"
|
||||
end
|
||||
set -gx FZF_DEFAULT_OPTS "
|
||||
--preview-window=:hidden
|
||||
--preview='__fzf_preview {}'
|
||||
--bind '?:toggle-preview'
|
||||
"
|
||||
end
|
||||
set -gx FZF_DEFAULT_OPTS "
|
||||
--preview-window=:hidden
|
||||
--preview='__fzf_preview {}'
|
||||
--bind '?:toggle-preview'
|
||||
"
|
||||
|
||||
# Export colors
|
||||
eval ($HOME/bin/derive_colors.py --export --fish)
|
||||
# Export colors
|
||||
eval ($HOME/bin/derive_colors.py --export --fish)
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user