Skip to content

Commit

Permalink
feat: fish, neovim, starship
Browse files Browse the repository at this point in the history
  • Loading branch information
mscharley committed Sep 19, 2024
1 parent cd01c7d commit 9972fae
Show file tree
Hide file tree
Showing 25 changed files with 908 additions and 69 deletions.
14 changes: 7 additions & 7 deletions install.pl
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@
}

sub get_filename {
my ($file) = (@_, $_);
$file =~ s/\.(?:example)$//;
$file =~ s!%!/!g;
return $file;
my $file = shift || $_; # take the first argument or use default ($_)
$file =~ s/\.example$//; # remove '.example' at the end of filename
$file =~ tr/%/\\/; # replace '%' with '/'
return $file;
}

sub replace_file {
my ($src_file, $target_file) = @_;
system("rm", "-rf", $target_file);
link_file($src_file, $target_file)
my ($src_file, $target_file) = @_;
system("rm", "-rf", $target_file); # remove the target file if it exists
link($src_file, $target_file); # create a hard link from src to target
}

sub link_file {
Expand Down
14 changes: 14 additions & 0 deletions xdg-config/fish%conf.d/01.init.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
if test -f /var/mail/$USER
export MAILPATH=/var/mail/$USER
end

# Load some overrides for bash scripts.
export BASH_ENV="$HOME/.bashenv"

# Set a default CODE_HOME directory in case one hasn't been configured in zshenv
set -q CODE_HOME || set CODE_HOME "$HOME/Code"
export CODE_HOME

# Configure xz compression to smartly use available processing capacity
export XZ_DEFAULTS="-T 0"

57 changes: 57 additions & 0 deletions xdg-config/fish%conf.d/05.xdg.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
set -q XDG_CONFIG_HOME || set XDG_CONFIG_HOME "$HOME/.config"
set -q XDG_CACHE_HOME || set XDG_CACHE_HOME "$HOME/.cache"
set -q XDG_BIN_HOME || set XDG_BIN_HOME "$HOME/.local/bin"
set -q XDG_DATA_HOME || set XDG_DATA_HOME "$HOME/.local/share"
export XDG_CONFIG_HOME
export XDG_CACHE_HOME
export XDG_BIN_HOME
export XDG_DATA_HOME

# Backport XDG into applications that can support it implicitly through configuration.

if test -d $HOME/Library/Android/sdk; then
export ANDROID_HOME="$HOME/Library/Android/sdk"
else if test -d $HOME/Android/Sdk; then
export ANDROID_HOME="$HOME/Android/Sdk"
else
set -q ANDROID_HOME || set ANDROID_HOME "$XDG_CONFIG_HOME/android"
export ANDROID_HOME
end

export DOCKER_CONFIG="$XDG_CONFIG_HOME/docker"
export ELINKS_CONFDIR="$XDG_CONFIG_HOME/elinks"
export ICEAUTHORITY="$XDG_CACHE_HOME/ICEauthority"
export SCREENRC="$XDG_CONFIG_HOME/screen/screenrc"

####
# Node
##
export NODE_REPL_HISTORY="$XDG_DATA_HOME/node/repl_history"
export NPM_CONFIG_USERCONFIG="$XDG_CONFIG_HOME/npm/npmrc"

####
# Perl
##
export PATH="$PATH:$XDG_DATA_HOME/perl5/bin"

# export PERL5LIB="$XDG_DATA_HOME/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}"
# export PERL_LOCAL_LIB_ROOT="$XDG_DATA_HOME/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}"
export PERL_MB_OPT="--install_base \"$XDG_DATA_HOME/perl5\""
export PERL_MM_OPT="INSTALL_BASE=$XDG_DATA_HOME/perl5"

####
# Rust
##
export CARGO_HOME="$XDG_DATA_HOME/cargo"
export RUSTUP_HOME="$XDG_DATA_HOME/rustup"

# XDG Runtime support - must be made available by the OS but use it if provided.
if test -n "$XDG_RUNTIME_DIR"
export TMUX_TMPDIR="$XDG_RUNTIME_DIR"
if test -z $XAUTHORITY
export XAUTHORITY="$XDG_RUNTIME_DIR/Xauthority"
end
end

# Vim needs a special $VIMINIT option set, but due to complexity with neovim and other forks this is offloaded to a
# script in $XDG_BIN_HOME.
6 changes: 6 additions & 0 deletions xdg-config/fish%conf.d/08.abbr.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
if which podman &> /dev/null
abbr --add docker podman
abbr --add dc 'podman compose'
else
abbr --add dc 'docker compose'
end
13 changes: 13 additions & 0 deletions xdg-config/fish%conf.d/10.starship.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
if status is-interactive
# Load starship if it's available
if which starship &> /dev/null
function starship_transient_prompt_func
starship module character
end
function starship_transient_rprompt_func
starship module time
end
starship init fish | source
enable_transience
end
end
30 changes: 30 additions & 0 deletions xdg-config/fish%conf.d/15.asdf.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
export ASDF_CONFIG_FILE="$XDG_CONFIG_HOME/asdf/asdfrc"
export ASDF_DIR="$XDG_DATA_HOME/asdf"
export ASDF_DATA_DIR="$XDG_CACHE_HOME/asdf"

if test -s "$ASDF_DIR"
if ! test -e "$ASDF_DIR/completions/asdf.fish"
ln -s "$ASDF_DIR/completions/asdf.fish" "$XDG_CONFIG_HOME/fish/completions/asdf.fish"
end
source "$ASDF_DIR/asdf.fish"

# asdf shims hide the real path to where corepack installs the binaries.
abbr --add yarn "corepack yarn"
abbr --add yarnpkg "corepack yarnpkg"
abbr --add pnpm "corepack pnpm"
abbr --add pnpx "corepack pnpx"
abbr --add npm "corepack npm"
abbr --add npx "corepack npx"
else
function init-asdf
git clone https://github.com/asdf-vm/asdf.git "$ASDF_DIR"
pushd $ASDF_DIR &> /dev/null
git checkout "$(git tag --sort version:refname | tail -n 1)"
popd &> /dev/null
source "$ASDF_DIR/asdf.sh"

asdf plugin add nodejs
asdf plugin add ruby
end
end

3 changes: 3 additions & 0 deletions xdg-config/fish%config.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
if status is-interactive
# Commands to run in interactive sessions can go here
end
4 changes: 4 additions & 0 deletions xdg-config/fish%functions/codestral.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
function codestral --wraps podman
podman start ollama &> /dev/null
podman exec -it ollama ollama run codestral $argv
end
20 changes: 20 additions & 0 deletions xdg-config/fish%functions/fish_prompt.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
function fish_prompt --description 'Informative prompt'
#Save the return status of the previous command
set -l last_pipestatus $pipestatus
set -lx __fish_last_status $status # Export for __fish_print_pipestatus.

if functions -q fish_is_root_user; and fish_is_root_user
printf '%s@%s %s%s%s# ' $USER (prompt_hostname) (set -q fish_color_cwd_root
and set_color $fish_color_cwd_root
or set_color $fish_color_cwd) \
(prompt_pwd) (set_color normal)
else
set -l status_color (set_color $fish_color_status)
set -l statusb_color (set_color --bold $fish_color_status)
set -l pipestatus_string (__fish_print_pipestatus "[" "]" "|" "$status_color" "$statusb_color" $last_pipestatus)

printf '[%s] %s%s@%s %s%s %s%s%s \n> ' (date "+%H:%M:%S") (set_color brblue) \
$USER (prompt_hostname) (set_color $fish_color_cwd) $PWD $pipestatus_string \
(set_color normal)
end
end
4 changes: 4 additions & 0 deletions xdg-config/fish%functions/mistral.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
function codestral --wraps podman
podman start ollama &> /dev/null
podman exec -it ollama ollama run mistral-large $argv
end
4 changes: 4 additions & 0 deletions xdg-config/fish%functions/ollama.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
function ollama --wraps podman
podman start ollama &> /dev/null
podman exec -it ollama ollama $argv
end
Loading

0 comments on commit 9972fae

Please sign in to comment.