first commit
This commit is contained in:
2
fish/.gitignore
vendored
Normal file
2
fish/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
fish_variables
|
||||
fish_plugins
|
||||
4
fish/conf.d.disabled/.gitignore
vendored
Normal file
4
fish/conf.d.disabled/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
*
|
||||
!.gitignore
|
||||
!path.fish
|
||||
!ssh-agent.fish
|
||||
11
fish/conf.d.disabled/path.fish
Normal file
11
fish/conf.d.disabled/path.fish
Normal file
@@ -0,0 +1,11 @@
|
||||
fish_add_path $HOME/.local/bin
|
||||
fish_add_path $HOME/bin
|
||||
|
||||
# cargo
|
||||
if test -f $HOME/.cargo/env.fish
|
||||
source $HOME/.cargo/env.fish
|
||||
end
|
||||
|
||||
if test -d $HOME/.scripts
|
||||
fish_add_path $HOME/.scripts
|
||||
end
|
||||
8
fish/conf.d.disabled/ssh-agent.fish
Normal file
8
fish/conf.d.disabled/ssh-agent.fish
Normal file
@@ -0,0 +1,8 @@
|
||||
if test -z "$SSH_AUTH_SOCK"
|
||||
eval (command ssh-agent -c) >/dev/null 2>&1
|
||||
for key in $HOME/.ssh/keys/*
|
||||
if test -f $key
|
||||
command ssh-add $key >/dev/null 2>&1
|
||||
end
|
||||
end
|
||||
end
|
||||
31
fish/config.fish
Executable file
31
fish/config.fish
Executable file
@@ -0,0 +1,31 @@
|
||||
if not status is-interactive
|
||||
return
|
||||
end
|
||||
|
||||
# no greeting
|
||||
set fish_greeting
|
||||
|
||||
# ls alias
|
||||
alias ls="ls --hyperlink=auto --color=auto"
|
||||
|
||||
# nvim
|
||||
if type -q nvim
|
||||
set -x EDITOR nvim
|
||||
set -x VISUAL nvim
|
||||
end
|
||||
|
||||
if test -d $HOME/.config/fish/prev.d
|
||||
for file in $HOME/.config/fish/prev.d/*.fish
|
||||
if test -f $file
|
||||
source $file
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if test -d $HOME/.config/fish/post.d
|
||||
for file in $HOME/.config/fish/post.d/*.fish
|
||||
if test -f $file
|
||||
source $file
|
||||
end
|
||||
end
|
||||
end
|
||||
140
fish/functions/__bass.py
Executable file
140
fish/functions/__bass.py
Executable file
@@ -0,0 +1,140 @@
|
||||
"""
|
||||
To be used with a companion fish function like this:
|
||||
|
||||
function refish
|
||||
set -l _x (python /tmp/bass.py source ~/.nvm/nvim.sh ';' nvm use iojs); source $_x; and rm -f $_x
|
||||
end
|
||||
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import json
|
||||
import os
|
||||
import signal
|
||||
import subprocess
|
||||
import sys
|
||||
import traceback
|
||||
|
||||
|
||||
BASH = 'bash'
|
||||
|
||||
FISH_READONLY = [
|
||||
'PWD', 'SHLVL', 'history', 'pipestatus', 'status', 'version',
|
||||
'FISH_VERSION', 'fish_pid', 'hostname', '_', 'fish_private_mode'
|
||||
]
|
||||
|
||||
IGNORED = [
|
||||
'PS1', 'XPC_SERVICE_NAME'
|
||||
]
|
||||
|
||||
def ignored(name):
|
||||
if name == 'PWD': # this is read only, but has special handling
|
||||
return False
|
||||
# ignore other read only variables
|
||||
if name in FISH_READONLY:
|
||||
return True
|
||||
if name in IGNORED or name.startswith("BASH_FUNC"):
|
||||
return True
|
||||
if name.startswith('%'):
|
||||
return True
|
||||
return False
|
||||
|
||||
def escape(string):
|
||||
# use json.dumps to reliably escape quotes and backslashes
|
||||
return json.dumps(string).replace(r'$', r'\$')
|
||||
|
||||
def escape_identifier(word):
|
||||
return escape(word.replace('?', '\\?'))
|
||||
|
||||
def comment(string):
|
||||
return '\n'.join(['# ' + line for line in string.split('\n')])
|
||||
|
||||
def gen_script():
|
||||
# Use the following instead of /usr/bin/env to read environment so we can
|
||||
# deal with multi-line environment variables (and other odd cases).
|
||||
env_reader = "%s -c 'import os,json; print(json.dumps({k:v for k,v in os.environ.items()}))'" % (sys.executable)
|
||||
args = [BASH, '-c', env_reader]
|
||||
output = subprocess.check_output(args, universal_newlines=True)
|
||||
old_env = output.strip()
|
||||
|
||||
pipe_r, pipe_w = os.pipe()
|
||||
if sys.version_info >= (3, 4):
|
||||
os.set_inheritable(pipe_w, True)
|
||||
command = 'eval $1 && ({}; alias) >&{}'.format(
|
||||
env_reader,
|
||||
pipe_w
|
||||
)
|
||||
args = [BASH, '-c', command, 'bass', ' '.join(sys.argv[1:])]
|
||||
p = subprocess.Popen(args, universal_newlines=True, close_fds=False)
|
||||
os.close(pipe_w)
|
||||
with os.fdopen(pipe_r) as f:
|
||||
new_env = f.readline()
|
||||
alias_str = f.read()
|
||||
if p.wait() != 0:
|
||||
raise subprocess.CalledProcessError(
|
||||
returncode=p.returncode,
|
||||
cmd=' '.join(sys.argv[1:]),
|
||||
output=new_env + alias_str
|
||||
)
|
||||
new_env = new_env.strip()
|
||||
|
||||
old_env = json.loads(old_env)
|
||||
new_env = json.loads(new_env)
|
||||
|
||||
script_lines = []
|
||||
|
||||
for k, v in new_env.items():
|
||||
if ignored(k):
|
||||
continue
|
||||
v1 = old_env.get(k)
|
||||
if not v1:
|
||||
script_lines.append(comment('adding %s=%s' % (k, v)))
|
||||
elif v1 != v:
|
||||
script_lines.append(comment('updating %s=%s -> %s' % (k, v1, v)))
|
||||
# process special variables
|
||||
if k == 'PWD':
|
||||
script_lines.append('cd %s' % escape(v))
|
||||
continue
|
||||
else:
|
||||
continue
|
||||
if k == 'PATH':
|
||||
value = ' '.join([escape(directory)
|
||||
for directory in v.split(':')])
|
||||
else:
|
||||
value = escape(v)
|
||||
script_lines.append('set -g -x %s %s' % (k, value))
|
||||
|
||||
for var in set(old_env.keys()) - set(new_env.keys()):
|
||||
script_lines.append(comment('removing %s' % var))
|
||||
script_lines.append('set -e %s' % var)
|
||||
|
||||
script = '\n'.join(script_lines)
|
||||
|
||||
alias_lines = []
|
||||
for line in alias_str.splitlines():
|
||||
_, rest = line.split(None, 1)
|
||||
k, v = rest.split("=", 1)
|
||||
alias_lines.append("alias " + escape_identifier(k) + "=" + v)
|
||||
alias = '\n'.join(alias_lines)
|
||||
|
||||
return script + '\n' + alias
|
||||
|
||||
script_file = os.fdopen(3, 'w')
|
||||
|
||||
if not sys.argv[1:]:
|
||||
print('__bass_usage', file=script_file, end='')
|
||||
sys.exit(0)
|
||||
|
||||
try:
|
||||
script = gen_script()
|
||||
except subprocess.CalledProcessError as e:
|
||||
sys.exit(e.returncode)
|
||||
except Exception:
|
||||
print('Bass internal error!', file=sys.stderr)
|
||||
raise # traceback will output to stderr
|
||||
except KeyboardInterrupt:
|
||||
signal.signal(signal.SIGINT, signal.SIG_DFL)
|
||||
os.kill(os.getpid(), signal.SIGINT)
|
||||
else:
|
||||
script_file.write(script)
|
||||
29
fish/functions/bass.fish
Executable file
29
fish/functions/bass.fish
Executable file
@@ -0,0 +1,29 @@
|
||||
function bass
|
||||
set -l bash_args $argv
|
||||
set -l bass_debug
|
||||
if test "$bash_args[1]_" = '-d_'
|
||||
set bass_debug true
|
||||
set -e bash_args[1]
|
||||
end
|
||||
|
||||
set -l script_file (mktemp)
|
||||
if command -v python3 >/dev/null 2>&1
|
||||
command python3 -sS (dirname (status -f))/__bass.py $bash_args 3>$script_file
|
||||
else
|
||||
command python -sS (dirname (status -f))/__bass.py $bash_args 3>$script_file
|
||||
end
|
||||
set -l bass_status $status
|
||||
if test $bass_status -ne 0
|
||||
return $bass_status
|
||||
end
|
||||
|
||||
if test -n "$bass_debug"
|
||||
cat $script_file
|
||||
end
|
||||
source $script_file
|
||||
command rm $script_file
|
||||
end
|
||||
|
||||
function __bass_usage
|
||||
echo "Usage: bass [-d] <bash-command>"
|
||||
end
|
||||
34
fish/post.d/fetch.fish
Normal file
34
fish/post.d/fetch.fish
Normal file
@@ -0,0 +1,34 @@
|
||||
if not set -q fetch_logo_type
|
||||
set -g fetch_logo_type "auto"
|
||||
end
|
||||
|
||||
if test "$fetch_logo_type" = "symbols"
|
||||
set -g fetch_args "--logo-type raw --logo-width 32 --logo \"$HOME/.config/fastfetch/logo_mugi/32x.symbols\""
|
||||
set -g fetch_args_brief "--logo-type raw --logo-width 24 --logo \"$HOME/.config/fastfetch/logo_mugi/24x.symbols\""
|
||||
else if test "$fetch_logo_type" = "logo"
|
||||
set -g fetch_args "--logo-type builtin"
|
||||
set -g fetch_args_brief "--logo-type small"
|
||||
else if test "$fetch_logo_type" = "sixel"
|
||||
set -g fetch_args "--logo-type raw --logo-width 32 --logo \"$HOME/.config/fastfetch/logo_mugi/32x.sixel\""
|
||||
set -g fetch_args_brief "--logo-type raw --logo-width 24 --logo \"$HOME/.config/fastfetch/logo_mugi/24x.sixel\""
|
||||
else # "kitty" or "auto" and others
|
||||
set -g fetch_args "--logo-type $fetch_logo_type --logo-height 21 --logo \"$HOME/.config/fastfetch/logo_mugi/mugi_3.png\""
|
||||
set -g fetch_args_brief "--logo-type $fetch_logo_type --logo-height 13 --logo \"$HOME/.config/fastfetch/logo_mugi/mugi_1.png\""
|
||||
end
|
||||
|
||||
if type -q fastfetch
|
||||
alias ff="fastfetch -c $HOME/.config/fastfetch/config.jsonc $fetch_args"
|
||||
|
||||
if test -f "$HOME/.config/fastfetch/brief.jsonc"
|
||||
alias ff-brief="fastfetch -c $HOME/.config/fastfetch/brief.jsonc $fetch_args_brief"
|
||||
else
|
||||
alias ff-brief=ff
|
||||
end
|
||||
end
|
||||
|
||||
# add 'set -g no_fetch' somewhere other than post.d to disable fetching
|
||||
if not set -q no_fetch
|
||||
if type -q ff-brief
|
||||
ff-brief
|
||||
end
|
||||
end
|
||||
6
fish/prev.d/.gitignore
vendored
Normal file
6
fish/prev.d/.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
*
|
||||
!.gitignore
|
||||
!zoxide.fish
|
||||
!prompt.fish
|
||||
!ssh-agent.fish
|
||||
!theme.fish
|
||||
12
fish/prev.d/prompt.fish
Normal file
12
fish/prev.d/prompt.fish
Normal file
@@ -0,0 +1,12 @@
|
||||
function fish_prompt -d "Write out the prompt"
|
||||
# This shows up as USER@HOST /home/user/ >, with the directory colored
|
||||
# $USER and $hostname are set by fish, so you can just use them
|
||||
# instead of using `whoami` and `hostname`
|
||||
printf '%s@%s %s%s%s > ' $USER $hostname \
|
||||
(set_color $fish_color_cwd) (prompt_pwd) (set_color normal)
|
||||
end
|
||||
|
||||
# oh-my-posh
|
||||
if test -f $HOME/.config/posh_theme.omp.json; and type -q oh-my-posh
|
||||
oh-my-posh init fish --config $HOME/.config/posh_theme.omp.json | source
|
||||
end
|
||||
6
fish/prev.d/theme.fish
Normal file
6
fish/prev.d/theme.fish
Normal file
@@ -0,0 +1,6 @@
|
||||
set -l theme 'Catpuccin Mocha'
|
||||
|
||||
if not set -q fish_current_theme; or not string match -q "$theme" "$fish_current_theme"
|
||||
set -U fish_current_theme "$theme"
|
||||
fish_config theme save "$theme"
|
||||
end
|
||||
4
fish/prev.d/zoxide.fish
Normal file
4
fish/prev.d/zoxide.fish
Normal file
@@ -0,0 +1,4 @@
|
||||
if type -q zoxide
|
||||
zoxide init fish | source
|
||||
alias cd=z
|
||||
end
|
||||
30
fish/themes/Catppuccin Frappe.theme
Normal file
30
fish/themes/Catppuccin Frappe.theme
Normal file
@@ -0,0 +1,30 @@
|
||||
# name: 'Catppuccin Frappé'
|
||||
# url: 'https://github.com/catppuccin/fish'
|
||||
# preferred_background: 303446
|
||||
|
||||
fish_color_normal c6d0f5
|
||||
fish_color_command 8caaee
|
||||
fish_color_param eebebe
|
||||
fish_color_keyword e78284
|
||||
fish_color_quote a6d189
|
||||
fish_color_redirection f4b8e4
|
||||
fish_color_end ef9f76
|
||||
fish_color_comment 838ba7
|
||||
fish_color_error e78284
|
||||
fish_color_gray 737994
|
||||
fish_color_selection --background=414559
|
||||
fish_color_search_match --background=414559
|
||||
fish_color_option a6d189
|
||||
fish_color_operator f4b8e4
|
||||
fish_color_escape ea999c
|
||||
fish_color_autosuggestion 737994
|
||||
fish_color_cancel e78284
|
||||
fish_color_cwd e5c890
|
||||
fish_color_user 81c8be
|
||||
fish_color_host 8caaee
|
||||
fish_color_host_remote a6d189
|
||||
fish_color_status e78284
|
||||
fish_pager_color_progress 737994
|
||||
fish_pager_color_prefix f4b8e4
|
||||
fish_pager_color_completion c6d0f5
|
||||
fish_pager_color_description 737994
|
||||
30
fish/themes/Catppuccin Latte.theme
Normal file
30
fish/themes/Catppuccin Latte.theme
Normal file
@@ -0,0 +1,30 @@
|
||||
# name: 'Catppuccin Latte'
|
||||
# url: 'https://github.com/catppuccin/fish'
|
||||
# preferred_background: eff1f5
|
||||
|
||||
fish_color_normal 4c4f69
|
||||
fish_color_command 1e66f5
|
||||
fish_color_param dd7878
|
||||
fish_color_keyword d20f39
|
||||
fish_color_quote 40a02b
|
||||
fish_color_redirection ea76cb
|
||||
fish_color_end fe640b
|
||||
fish_color_comment 8c8fa1
|
||||
fish_color_error d20f39
|
||||
fish_color_gray 9ca0b0
|
||||
fish_color_selection --background=ccd0da
|
||||
fish_color_search_match --background=ccd0da
|
||||
fish_color_option 40a02b
|
||||
fish_color_operator ea76cb
|
||||
fish_color_escape e64553
|
||||
fish_color_autosuggestion 9ca0b0
|
||||
fish_color_cancel d20f39
|
||||
fish_color_cwd df8e1d
|
||||
fish_color_user 179299
|
||||
fish_color_host 1e66f5
|
||||
fish_color_host_remote 40a02b
|
||||
fish_color_status d20f39
|
||||
fish_pager_color_progress 9ca0b0
|
||||
fish_pager_color_prefix ea76cb
|
||||
fish_pager_color_completion 4c4f69
|
||||
fish_pager_color_description 9ca0b0
|
||||
30
fish/themes/Catppuccin Macchiato.theme
Normal file
30
fish/themes/Catppuccin Macchiato.theme
Normal file
@@ -0,0 +1,30 @@
|
||||
# name: 'Catppuccin Macchiato'
|
||||
# url: 'https://github.com/catppuccin/fish'
|
||||
# preferred_background: 24273a
|
||||
|
||||
fish_color_normal cad3f5
|
||||
fish_color_command 8aadf4
|
||||
fish_color_param f0c6c6
|
||||
fish_color_keyword ed8796
|
||||
fish_color_quote a6da95
|
||||
fish_color_redirection f5bde6
|
||||
fish_color_end f5a97f
|
||||
fish_color_comment 8087a2
|
||||
fish_color_error ed8796
|
||||
fish_color_gray 6e738d
|
||||
fish_color_selection --background=363a4f
|
||||
fish_color_search_match --background=363a4f
|
||||
fish_color_option a6da95
|
||||
fish_color_operator f5bde6
|
||||
fish_color_escape ee99a0
|
||||
fish_color_autosuggestion 6e738d
|
||||
fish_color_cancel ed8796
|
||||
fish_color_cwd eed49f
|
||||
fish_color_user 8bd5ca
|
||||
fish_color_host 8aadf4
|
||||
fish_color_host_remote a6da95
|
||||
fish_color_status ed8796
|
||||
fish_pager_color_progress 6e738d
|
||||
fish_pager_color_prefix f5bde6
|
||||
fish_pager_color_completion cad3f5
|
||||
fish_pager_color_description 6e738d
|
||||
30
fish/themes/Catppuccin Mocha.theme
Normal file
30
fish/themes/Catppuccin Mocha.theme
Normal file
@@ -0,0 +1,30 @@
|
||||
# name: 'Catppuccin Mocha'
|
||||
# url: 'https://github.com/catppuccin/fish'
|
||||
# preferred_background: 1e1e2e
|
||||
|
||||
fish_color_normal cdd6f4
|
||||
fish_color_command 89b4fa
|
||||
fish_color_param f2cdcd
|
||||
fish_color_keyword f38ba8
|
||||
fish_color_quote a6e3a1
|
||||
fish_color_redirection f5c2e7
|
||||
fish_color_end fab387
|
||||
fish_color_comment 7f849c
|
||||
fish_color_error f38ba8
|
||||
fish_color_gray 6c7086
|
||||
fish_color_selection --background=313244
|
||||
fish_color_search_match --background=313244
|
||||
fish_color_option a6e3a1
|
||||
fish_color_operator f5c2e7
|
||||
fish_color_escape eba0ac
|
||||
fish_color_autosuggestion 6c7086
|
||||
fish_color_cancel f38ba8
|
||||
fish_color_cwd f9e2af
|
||||
fish_color_user 94e2d5
|
||||
fish_color_host 89b4fa
|
||||
fish_color_host_remote a6e3a1
|
||||
fish_color_status f38ba8
|
||||
fish_pager_color_progress 6c7086
|
||||
fish_pager_color_prefix f5c2e7
|
||||
fish_pager_color_completion cdd6f4
|
||||
fish_pager_color_description 6c7086
|
||||
Reference in New Issue
Block a user