Populate dotfiles repository
This commit is contained in:
39
fish/.config/fish/config.fish
Normal file
39
fish/.config/fish/config.fish
Normal file
@@ -0,0 +1,39 @@
|
||||
# Fish config file
|
||||
fundle plugin 'decors/fish-colored-man'
|
||||
fundle plugin 'oh-my-fish/theme-nai'
|
||||
|
||||
fundle init
|
||||
|
||||
# Man colors
|
||||
set -g man_standout -o blue
|
||||
set -g man_bold -o magenta
|
||||
|
||||
# Text Editor
|
||||
export EDITOR="vim"
|
||||
|
||||
# Aliases
|
||||
alias f "fff"
|
||||
alias tmux "tmux -2"
|
||||
alias peerflix "peerflix -d"
|
||||
alias xclip "xclip -selection clipboard"
|
||||
|
||||
function fish_title
|
||||
true
|
||||
end
|
||||
|
||||
# Spacemacs
|
||||
if test -n "$EMACS"
|
||||
set -x TERM eterm-color
|
||||
end
|
||||
|
||||
# fff
|
||||
## Directory color [0-9]
|
||||
export FFF_COL1=3
|
||||
export FFF_COL2=8
|
||||
|
||||
## Favourites (keys 1-9) (dir or file)
|
||||
export FFF_FAV1=/home/coolneng/Nextcloud/Documents/Archive-uni/Second\ year/
|
||||
export FFF_FAV2=/home/coolneng/Nextcloud/Documents/Books/Academic/
|
||||
export FFF_FAV3=/home/coolneng/Nextcloud/Documents/Papers
|
||||
export FFF_FAV4=/home/coolneng/Nextcloud/Documents/Knowledge/
|
||||
export FFF_FAV5=/home/coolneng/Nextcloud/Photos/
|
||||
29
fish/.config/fish/fish_variables
Normal file
29
fish/.config/fish/fish_variables
Normal file
@@ -0,0 +1,29 @@
|
||||
# This file contains fish universal variable definitions.
|
||||
# VERSION: 3.0
|
||||
SETUVAR fish_color_autosuggestion:555\x1ebrblack
|
||||
SETUVAR fish_color_cancel:\x2dr
|
||||
SETUVAR fish_color_command:005fd7
|
||||
SETUVAR fish_color_comment:990000
|
||||
SETUVAR fish_color_cwd:green
|
||||
SETUVAR fish_color_cwd_root:red
|
||||
SETUVAR fish_color_end:009900
|
||||
SETUVAR fish_color_error:ff0000
|
||||
SETUVAR fish_color_escape:00a6b2
|
||||
SETUVAR fish_color_history_current:\x2d\x2dbold
|
||||
SETUVAR fish_color_host:normal
|
||||
SETUVAR fish_color_match:\x2d\x2dbackground\x3dbrblue
|
||||
SETUVAR fish_color_normal:normal
|
||||
SETUVAR fish_color_operator:00a6b2
|
||||
SETUVAR fish_color_param:00afff
|
||||
SETUVAR fish_color_quote:999900
|
||||
SETUVAR fish_color_redirection:00afff
|
||||
SETUVAR fish_color_search_match:bryellow\x1e\x2d\x2dbackground\x3dbrblack
|
||||
SETUVAR fish_color_selection:white\x1e\x2d\x2dbold\x1e\x2d\x2dbackground\x3dbrblack
|
||||
SETUVAR fish_color_user:brgreen
|
||||
SETUVAR fish_color_valid_path:\x2d\x2dunderline
|
||||
SETUVAR fish_greeting:Welcome\x20to\x20fish\x2c\x20the\x20friendly\x20interactive\x20shell
|
||||
SETUVAR fish_key_bindings:fish_default_key_bindings
|
||||
SETUVAR fish_pager_color_completion:\x1d
|
||||
SETUVAR fish_pager_color_description:B3A06D\x1eyellow
|
||||
SETUVAR fish_pager_color_prefix:white\x1e\x2d\x2dbold\x1e\x2d\x2dunderline
|
||||
SETUVAR fish_pager_color_progress:brwhite\x1e\x2d\x2dbackground\x3dcyan
|
||||
425
fish/.config/fish/functions/fundle.fish
Normal file
425
fish/.config/fish/functions/fundle.fish
Normal file
@@ -0,0 +1,425 @@
|
||||
set __fundle_current_version '0.7.0'
|
||||
|
||||
function __fundle_seq -a upto
|
||||
seq 1 1 $upto 2>/dev/null
|
||||
end
|
||||
|
||||
function __fundle_next_arg -a index
|
||||
set -l args $argv[2..-1]
|
||||
set -l arg_index (math $index + 1)
|
||||
if test (count $args) -lt $arg_index
|
||||
echo "missing argument for $args[$index]"
|
||||
return 1
|
||||
end
|
||||
set -l arg $args[$arg_index]
|
||||
switch $arg
|
||||
case '--*'
|
||||
echo "expected argument for $args[$index], got $arg"; and return 1
|
||||
case '*'
|
||||
echo $arg; and return 0
|
||||
end
|
||||
end
|
||||
|
||||
function __fundle_compare_versions -a version1 -a version2
|
||||
for i in (__fundle_seq 4)
|
||||
set -l v1 (echo $version1 | cut -d '.' -f $i | sed -Ee 's/[a-z]+//g')
|
||||
set -l v2 (echo $version2 | cut -d '.' -f $i | sed -Ee 's/[a-z]+//g')
|
||||
if test \( -n $v1 -a -z $v2 \) -o \( -n $v1 -a -n $v2 -a $v1 -lt $v2 \)
|
||||
echo -n "lt"; and return 0
|
||||
else if test \( -z $v1 -a -n $v2 \) -o \( -n $v1 -a -n $v2 -a $v1 -gt $v2 \)
|
||||
echo -n "gt"; and return 0
|
||||
end
|
||||
end
|
||||
echo -n "eq"; and return 0
|
||||
end
|
||||
|
||||
function __fundle_date -d "returns a date"
|
||||
set -l d (date +%s%N)
|
||||
if echo $d | string match -rvq 'N'
|
||||
echo $d
|
||||
else
|
||||
gdate +%s%N
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
function __fundle_self_update -d "updates fundle"
|
||||
set -l fundle_repo_url "https://github.com/tuvistavie/fundle.git"
|
||||
# This `sed` stays for now since doing it easily with `string` requires "--filter", which is only in 2.6.0
|
||||
set -l latest (command git ls-remote --tags $fundle_repo_url | sed -n -e 's|.*refs/tags/v\(.*\)|\1|p' | tail -n 1)
|
||||
if test (__fundle_compare_versions $latest (__fundle_version)) != "gt"
|
||||
echo "fundle is already up to date"; and return 0
|
||||
else
|
||||
set -l file_url_template 'https://raw.githubusercontent.com/tuvistavie/fundle/VERSION/functions/fundle.fish'
|
||||
set -l file_url (string replace 'VERSION' -- "v$latest" $file_url_template)
|
||||
set -l tmp_file (mktemp /tmp/fundle.XXX)
|
||||
set -l update_message "fundle has been updated to version $latest"
|
||||
curl -Ls $file_url > $tmp_file; and mv $tmp_file (status -f); and echo $update_message; and return 0
|
||||
end
|
||||
end
|
||||
|
||||
function __fundle_url_rev -d "prints the revision from the url" -a git_url
|
||||
set -l rev (echo $git_url | cut -d '#' -f 2 -s)
|
||||
if test -n "$rev"
|
||||
echo $rev
|
||||
else
|
||||
echo master
|
||||
end
|
||||
end
|
||||
|
||||
function __fundle_remote_url -d "prints the remote url from the full git url" -a git_url
|
||||
echo $git_url | cut -d '#' -f 1
|
||||
end
|
||||
|
||||
function __fundle_rev_parse -d "prints the revision if any" -a dir -a commitish
|
||||
set -l sha (command git --git-dir $dir rev-parse -q --verify $commitish 2>/dev/null)
|
||||
if test $status -eq 0
|
||||
echo -n $sha
|
||||
return 0
|
||||
end
|
||||
return 1
|
||||
end
|
||||
|
||||
function __fundle_commit_sha -d "returns sha of the commit-ish" -a dir -a commitish
|
||||
if test -d "$dir/.git"
|
||||
set dir "$dir/.git"
|
||||
end
|
||||
if __fundle_rev_parse $dir "origin/$commitish"
|
||||
return 0
|
||||
end
|
||||
__fundle_rev_parse $dir $commitish
|
||||
end
|
||||
|
||||
function __fundle_plugins_dir -d "returns fundle directory"
|
||||
if test -z "$fundle_plugins_dir"
|
||||
if test -n "$XDG_CONFIG_HOME"
|
||||
echo $XDG_CONFIG_HOME/fish/fundle
|
||||
else
|
||||
echo $HOME/.config/fish/fundle
|
||||
end
|
||||
else
|
||||
echo $fundle_plugins_dir
|
||||
end
|
||||
end
|
||||
|
||||
function __fundle_no_git -d "check if git is installed"
|
||||
# `command -q` is >= 2.5.0
|
||||
if not command -s git > /dev/null 2>&1
|
||||
echo "git needs to be installed and in the path"
|
||||
return 0
|
||||
end
|
||||
return 1
|
||||
end
|
||||
|
||||
function __fundle_check_date -d "check date"
|
||||
if date +%s%N | string match -rvq 'N'
|
||||
return 0
|
||||
end
|
||||
if command -s gdate > /dev/null 2>&1
|
||||
return 0
|
||||
end
|
||||
echo "You need to have a GNU date compliant date installed to use profiling. Use 'brew install coreutils' on OSX"
|
||||
return 1
|
||||
end
|
||||
|
||||
function __fundle_get_url -d "returns the url for the given plugin" -a repo
|
||||
echo "https://github.com/$repo.git"
|
||||
end
|
||||
|
||||
function __fundle_update_plugin -d "update the given plugin" -a git_dir -a remote_url
|
||||
command git --git-dir=$git_dir remote set-url origin $remote_url 2>/dev/null; and \
|
||||
command git --git-dir=$git_dir fetch -q 2>/dev/null
|
||||
end
|
||||
|
||||
function __fundle_install_plugin -d "install/update the given plugin" -a plugin -a git_url
|
||||
if __fundle_no_git
|
||||
return 1
|
||||
end
|
||||
|
||||
set -l plugin_dir (__fundle_plugins_dir)/$plugin
|
||||
set -l git_dir $plugin_dir/.git
|
||||
set -l remote_url (__fundle_remote_url $git_url)
|
||||
set -l update ""
|
||||
|
||||
if contains __update $argv
|
||||
set update true
|
||||
end
|
||||
|
||||
if test -d $plugin_dir
|
||||
if test -n "$update"
|
||||
echo "Updating $plugin"
|
||||
__fundle_update_plugin $git_dir $remote_url
|
||||
else
|
||||
echo "$argv[1] installed in $plugin_dir"
|
||||
return 0
|
||||
end
|
||||
else
|
||||
echo "Installing $plugin"
|
||||
command git clone -q $remote_url $plugin_dir
|
||||
end
|
||||
|
||||
set -l sha (__fundle_commit_sha $git_dir (__fundle_url_rev $git_url))
|
||||
if test $status -eq 0
|
||||
command git --git-dir="$git_dir" --work-tree="$plugin_dir" checkout -q -f $sha
|
||||
else
|
||||
echo "Could not update $plugin"
|
||||
return 1
|
||||
end
|
||||
end
|
||||
|
||||
function __fundle_show_doc_msg -d "show a link to fundle docs"
|
||||
if test (count $argv) -ge 1
|
||||
echo $argv
|
||||
end
|
||||
echo "See the docs for more info. https://github.com/tuvistavie/fundle"
|
||||
end
|
||||
|
||||
function __fundle_load_plugin -a plugin -a path -a fundle_dir -a profile -d "load a plugin"
|
||||
if begin; set -q __fundle_loaded_plugins; and contains $plugin $__fundle_loaded_plugins; end
|
||||
return 0
|
||||
end
|
||||
|
||||
set -l plugin_dir (string replace -r '/.$' '' -- "$fundle_dir/$plugin/$path")
|
||||
|
||||
if not test -d $plugin_dir
|
||||
__fundle_show_doc_msg "$plugin not installed. You may need to run 'fundle install'"
|
||||
return 0
|
||||
end
|
||||
|
||||
# Take everything but "plugin-" from the last path component
|
||||
set -l plugin_name (string replace -r '.*/(plugin-)?(.*)$' '$2' -- $plugin)
|
||||
set -l init_file "$plugin_dir/init.fish"
|
||||
set -l conf_dir "$plugin_dir/conf.d"
|
||||
set -l bindings_file "$plugin_dir/key_bindings.fish"
|
||||
set -l functions_dir "$plugin_dir/functions"
|
||||
set -l completions_dir "$plugin_dir/completions"
|
||||
set -l plugin_paths $__fundle_plugin_name_paths
|
||||
|
||||
if begin; test -d $functions_dir; and not contains $functions_dir $fish_function_path; end
|
||||
set fish_function_path $functions_dir $fish_function_path
|
||||
end
|
||||
|
||||
if begin; test -d $completions_dir; and not contains $completions_dir $fish_complete_path; end
|
||||
set fish_complete_path $completions_dir $fish_complete_path
|
||||
end
|
||||
|
||||
if test -f $init_file
|
||||
source $init_file
|
||||
else if test -d $conf_dir
|
||||
# read all *.fish files in conf.d
|
||||
for f in $conf_dir/*.fish
|
||||
source $f
|
||||
end
|
||||
else
|
||||
# read all *.fish files if no init.fish or conf.d found
|
||||
for f in $plugin_dir/*.fish
|
||||
source $f
|
||||
end
|
||||
end
|
||||
|
||||
if test -f $bindings_file
|
||||
set -g __fundle_binding_paths $bindings_file $__fundle_binding_paths
|
||||
end
|
||||
|
||||
set -g __fundle_loaded_plugins $plugin $__fundle_loaded_plugins
|
||||
|
||||
set -l dependencies (printf '%s\n' $plugin_paths $__fundle_plugin_name_paths | sort | uniq -u)
|
||||
for dependency in $dependencies
|
||||
set -l name_path (string split : -- $dependency)
|
||||
if test "$profile" -eq 1
|
||||
set -l start_time (__fundle_date +%s%N)
|
||||
__fundle_load_plugin $name_path[1] $name_path[2] $fundle_dir $profile
|
||||
set -l ellapsed_time (math \((__fundle_date +%s%N) - $start_time\) / 1000)
|
||||
echo "$name_path[1]": {$ellapsed_time}us
|
||||
else
|
||||
__fundle_load_plugin $name_path[1] $name_path[2] $fundle_dir $profile
|
||||
end
|
||||
end
|
||||
|
||||
emit "init_$plugin_name" $plugin_dir
|
||||
end
|
||||
|
||||
function __fundle_bind -d "set up bindings"
|
||||
if functions -q fish_user_key_bindings; and not functions -q __fish_user_key_bindings
|
||||
functions -c fish_user_key_bindings __fish_user_key_bindings
|
||||
end
|
||||
|
||||
function fish_user_key_bindings
|
||||
for bindings in $__fundle_binding_paths
|
||||
source $bindings
|
||||
end
|
||||
if functions -q __fish_user_key_bindings
|
||||
__fish_user_key_bindings
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function __fundle_init -d "initialize fundle"
|
||||
set -l fundle_dir (__fundle_plugins_dir)
|
||||
|
||||
if test (count $__fundle_plugin_names) -eq 0
|
||||
__fundle_show_doc_msg "No plugin registered. You need to call 'fundle plugin NAME' before using 'fundle init'. \
|
||||
|
||||
Try reloading your shell if you just edited your configuration."
|
||||
return 1
|
||||
end
|
||||
|
||||
set -l profile 0
|
||||
if begin; contains -- -p $argv; or contains -- --profile $argv; and __fundle_check_date; end
|
||||
set profile 1
|
||||
end
|
||||
|
||||
for name_path in $__fundle_plugin_name_paths
|
||||
set -l name_path (string split : -- $name_path)
|
||||
if test "$profile" -eq 1
|
||||
set -l start_time (__fundle_date +%s%N)
|
||||
__fundle_load_plugin $name_path[1] $name_path[2] $fundle_dir $profile
|
||||
set -l ellapsed_time (math \((__fundle_date +%s%N) - $start_time\) / 1000)
|
||||
echo "$name_path[1]": {$ellapsed_time}us
|
||||
else
|
||||
__fundle_load_plugin $name_path[1] $name_path[2] $fundle_dir $profile
|
||||
end
|
||||
end
|
||||
|
||||
__fundle_bind
|
||||
end
|
||||
|
||||
function __fundle_install -d "install plugin"
|
||||
if test (count $__fundle_plugin_names) -eq 0
|
||||
__fundle_show_doc_msg "No plugin registered. You need to call 'fundle plugin NAME' before using 'fundle install'"
|
||||
end
|
||||
|
||||
if begin; contains -- -u $argv; or contains -- --upgrade $argv; end
|
||||
echo "deprecation warning: please use 'fundle update' to update plugins"
|
||||
set argv $argv __update
|
||||
end
|
||||
|
||||
for i in (__fundle_seq (count $__fundle_plugin_names))
|
||||
__fundle_install_plugin $__fundle_plugin_names[$i] $__fundle_plugin_urls[$i] $argv
|
||||
end
|
||||
|
||||
set -l original_plugins_count (count (__fundle_list -s))
|
||||
__fundle_init
|
||||
|
||||
# if plugins count increase after init, new plugins have dependencies
|
||||
# install new plugins dependencies if any
|
||||
if test (count (__fundle_list -s)) -gt $original_plugins_count
|
||||
__fundle_install $argv
|
||||
end
|
||||
end
|
||||
|
||||
function __fundle_clean -d "cleans fundle directory"
|
||||
set -l fundle_dir (__fundle_plugins_dir)
|
||||
set -l used_plugins (__fundle_list -s)
|
||||
set -l installed_plugins $fundle_dir/*/*/
|
||||
for installed_plugin in $installed_plugins
|
||||
set -l plugin (string trim --chars="/" \
|
||||
(string replace -r -- "$fundle_dir" "" $installed_plugin))
|
||||
if not contains $plugin $used_plugins
|
||||
echo "Removing $plugin"
|
||||
rm -rf $fundle_dir/$plugin
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function __fundle_plugin -d "add plugin to fundle" -a name
|
||||
set -l plugin_url ""
|
||||
set -l plugin_path "."
|
||||
set -l argv_count (count $argv)
|
||||
set -l skip_next true
|
||||
if test $argv_count -eq 0 -o -z "$argv"
|
||||
echo "usage: fundle plugin NAME [[--url] URL] [--path PATH]"
|
||||
return 1
|
||||
else if test $argv_count -gt 1
|
||||
for i in (__fundle_seq (count $argv))
|
||||
test $skip_next = true; and set skip_next false; and continue
|
||||
set -l arg $argv[$i]
|
||||
switch $arg
|
||||
case '--url'
|
||||
set plugin_url (__fundle_next_arg $i $argv)
|
||||
test $status -eq 1; and echo $plugin_url; and return 1
|
||||
set skip_next true
|
||||
case '--path'
|
||||
set plugin_path (__fundle_next_arg $i $argv)
|
||||
test $status -eq 1; and echo $plugin_path; and return 1
|
||||
set skip_next true
|
||||
case '--*'
|
||||
echo "unknown flag $arg"; and return 1
|
||||
case '*'
|
||||
test $i -ne 2; and echo "invalid argument $arg"; and return 1
|
||||
set plugin_url $arg
|
||||
end
|
||||
end
|
||||
end
|
||||
test -z "$plugin_url"; and set plugin_url (__fundle_get_url $name)
|
||||
|
||||
if not contains $name $__fundle_plugin_names
|
||||
set -g __fundle_plugin_names $__fundle_plugin_names $name
|
||||
set -g __fundle_plugin_urls $__fundle_plugin_urls $plugin_url
|
||||
set -g __fundle_plugin_name_paths $__fundle_plugin_name_paths $name:$plugin_path
|
||||
end
|
||||
end
|
||||
|
||||
function __fundle_version -d "prints fundle version"
|
||||
echo $__fundle_current_version
|
||||
end
|
||||
|
||||
function __fundle_print_help -d "prints fundle help"
|
||||
echo "usage: fundle (init | plugin | list | install | update | clean | self-update | version | help)"
|
||||
end
|
||||
|
||||
function __fundle_list -d "list registered plugins"
|
||||
if begin; contains -- -s $argv; or contains -- --short $argv; end
|
||||
for name in $__fundle_plugin_names
|
||||
echo $name
|
||||
end
|
||||
else
|
||||
for i in (__fundle_seq (count $__fundle_plugin_names))
|
||||
echo {$__fundle_plugin_names[$i]}\n\t{$__fundle_plugin_urls[$i]}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function fundle -d "run fundle"
|
||||
if __fundle_no_git
|
||||
return 1
|
||||
end
|
||||
|
||||
set -l sub_args ""
|
||||
|
||||
switch (count $argv)
|
||||
case 0
|
||||
__fundle_print_help
|
||||
return 1
|
||||
case 1
|
||||
case '*'
|
||||
set sub_args $argv[2..-1]
|
||||
end
|
||||
|
||||
switch $argv[1]
|
||||
case "init"
|
||||
__fundle_init $sub_args
|
||||
case "plugin"
|
||||
__fundle_plugin $sub_args
|
||||
case "list"
|
||||
__fundle_list $sub_args
|
||||
case "plugins"
|
||||
echo "'fundle plugins' has been replaced by 'fundle list'"
|
||||
case "install"
|
||||
__fundle_install $sub_args
|
||||
case "update"
|
||||
__fundle_install __update $sub_args
|
||||
case "clean"
|
||||
__fundle_clean
|
||||
case "self-update"
|
||||
__fundle_self_update
|
||||
case "version" -v --version
|
||||
__fundle_version
|
||||
case "help" -h --help
|
||||
__fundle_print_help
|
||||
return 0
|
||||
case "*"
|
||||
__fundle_print_help
|
||||
return 1
|
||||
end
|
||||
end
|
||||
1
fish/.config/fish/fundle/decors/fish-colored-man
Submodule
1
fish/.config/fish/fundle/decors/fish-colored-man
Submodule
Submodule fish/.config/fish/fundle/decors/fish-colored-man added at c1e9db7765
1
fish/.config/fish/fundle/oh-my-fish/theme-nai
Submodule
1
fish/.config/fish/fundle/oh-my-fish/theme-nai
Submodule
Submodule fish/.config/fish/fundle/oh-my-fish/theme-nai added at 9616e644e9
Reference in New Issue
Block a user