mirror of
https://github.com/danbee/dotfiles-local
synced 2025-03-04 08:49:07 +00:00
Compare commits
5 Commits
72742bd18d
...
a8143ba043
| Author | SHA1 | Date | |
|---|---|---|---|
| a8143ba043 | |||
|
|
acbedc62bb | ||
|
|
7d4755ab42 | ||
|
|
884a5fc156 | ||
|
|
752ed91f74 |
21
bin/lib/os.rb
Normal file
21
bin/lib/os.rb
Normal 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
48
bin/lib/tools.rb
Normal 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
|
||||
@ -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
|
||||
@ -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
5
bin/os
Executable file
@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require_relative "lib/os"
|
||||
|
||||
puts OS.new.os
|
||||
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require_relative "tools_lib/tools"
|
||||
require_relative "lib/tools"
|
||||
|
||||
tools = Tools.new
|
||||
tools.list_tools
|
||||
|
||||
@ -1,5 +0,0 @@
|
||||
class EmptyFile
|
||||
def lines
|
||||
[]
|
||||
end
|
||||
end
|
||||
@ -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
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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) "
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -56,3 +56,5 @@ if (( $+commands[thefuck] )); then
|
||||
fi
|
||||
|
||||
export PATH="$HOME/.bin:$PATH"
|
||||
|
||||
eval "$(starship init zsh)"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user