1
0
mirror of https://github.com/danbee/dotfiles-local synced 2025-03-04 08:49:07 +00:00

Compare commits

...

5 Commits

Author SHA1 Message Date
a8143ba043 Starship in ZSH with OS custom prompt 2021-12-22 17:21:06 -06:00
Daniel Barber
acbedc62bb Update global NodeJS version 2021-12-22 15:57:22 -06:00
Daniel Barber
7d4755ab42 Add yarn to tools 2021-12-22 13:04:33 -06:00
Daniel Barber
884a5fc156 Update fish config 2021-12-22 12:47:18 -06:00
Daniel Barber
752ed91f74 Use asdf current to get tools 2021-12-22 12:47:18 -06:00
13 changed files with 105 additions and 48 deletions

21
bin/lib/os.rb Normal file
View File

@ -0,0 +1,21 @@
class OS
ICONS = {
"Darwin" => "",
"Linux" => "",
"FreeBSD" => "",
}
def os
"#{icon} #{name}"
end
private
def name
@os ||= `uname -s`.strip
end
def icon
ICONS[name]
end
end

48
bin/lib/tools.rb Normal file
View File

@ -0,0 +1,48 @@
require_relative "tools/file"
require_relative "tools/icons"
class Tools
include ToolIcons
attr_reader :tools
def initialize
@tools = ToolsFile.new.tools
end
def list_tools
tools.sort.each do |tool, meta|
if available_tools.include?(tool)
puts "#{tool_icon(tool)}" \
"#{tool.ljust(max_length)} " \
"#{version(meta)}"
end
end
end
private
def version(meta)
if installed?(meta)
"\e[37m#{meta[:version]}"
else
"\e[31m#{meta[:version]}* (not installed)"
end
end
def max_length
@max_length ||= installed_tools.max_by(&:length).length
end
def installed_tools
tools.keys & available_tools
end
def available_tools
TOOL_ICONS.keys
end
def installed?(meta)
meta[:source].start_with?("/")
end
end

View File

@ -1,5 +1,3 @@
require_relative "empty_file"
class ToolsFile
def initialize
end
@ -12,13 +10,12 @@ class ToolsFile
def format_tools
Hash[tools_file.lines.map do |tool|
tool.split
name, version, source = tool.split
[name, { version: version, source: source }]
end]
end
def tools_file
File.read(".tool-versions")
rescue
EmptyFile.new
`asdf current 2>&1`
end
end

View File

@ -6,7 +6,8 @@ module ToolIcons
"nodejs" => "\e[38;5;118m",
"python" => "\e[0;33m",
"ruby" => "\e[1;31m",
"rust" => "\e[1;37m"
"rust" => "\e[1;37m",
"yarn" => "\e[0;34m",
}.freeze
def tool_icon(tool)

5
bin/os Executable file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env ruby
require_relative "lib/os"
puts OS.new.os

View File

@ -1,6 +1,6 @@
#!/usr/bin/env ruby
require_relative "tools_lib/tools"
require_relative "lib/tools"
tools = Tools.new
tools.list_tools

View File

@ -1,5 +0,0 @@
class EmptyFile
def lines
[]
end
end

View File

@ -1,32 +0,0 @@
require_relative "tools_file"
require_relative "tool_icons"
class Tools
include ToolIcons
attr_reader :tools
def initialize
@tools = ToolsFile.new.tools
end
def list_tools
tools.sort.each do |tool, version|
if available_tools.include? tool
puts "#{tool_icon(tool)}#{tool.ljust(max_length)} #{version}"
end
end
end
def max_length
@max_length ||= installed_tools.max_by(&:length).length
end
def installed_tools
tools.keys & available_tools
end
def available_tools
TOOL_ICONS.keys
end
end

View File

@ -1,5 +1,10 @@
fish_add_path /opt/homebrew/bin
fish_add_path /opt/homebrew/sbin
starship init fish | source
source (brew --prefix)/opt/asdf/libexec/asdf.fish
source ~/.aliases.local
set fish_user_paths .git/safe/../../bin ~/.bin

View File

@ -28,4 +28,4 @@ SETUVAR fish_pager_color_completion:\x1d
SETUVAR fish_pager_color_description:B3A06D\x1eyellow
SETUVAR fish_pager_color_prefix:normal\x1e\x2d\x2dbold\x1e\x2d\x2dunderline
SETUVAR fish_pager_color_progress:brwhite\x1e\x2d\x2dbackground\x3dcyan
SETUVAR fish_user_paths:/Users/daniel\x2ebarber/\x2ebin\x1e\x2egit/safe/\x2e\x2e/\x2e\x2e/bin
SETUVAR fish_user_paths:\x2egit/safe/\x2e\x2e/\x2e\x2e/bin\x1e/Users/daniel\x2ebarber/\x2ebin

View File

@ -1,4 +1,4 @@
format="$all$directory$character"
format="$all$custom$jobs$directory$character"
[character]
success_symbol = "[](bold cyan)"
@ -13,6 +13,21 @@ symbol = " "
[aws]
symbol = " "
[python]
symbol = " "
[elixir]
symbol = " "
[custom.os]
disabled = false
command = "os"
style = "bold white"
format = "[$symbol($output )]($style)"
symbol = ""
when = "true"
shell = ["bash", "--noprofile", "--norc"]
[git_branch]
format = "[$symbol$branch]($style) "

View File

@ -1,5 +1,5 @@
ruby 2.7.4
nodejs 15.8.0
nodejs 17.3.0
python 3.9.1
erlang 23.2.4
elixir 1.11.3

View File

@ -56,3 +56,5 @@ if (( $+commands[thefuck] )); then
fi
export PATH="$HOME/.bin:$PATH"
eval "$(starship init zsh)"