dotfiles

My personal dotfiles

commit a36d4f85ca1331315663885eeddb1f26d94eec04
parent fe94cf7640ae4d27a96125a495be6f4517813aa4
Author: Pablo <pablo-escobar@riseup.net>
Date:   Fri,  9 Apr 2021 14:57:39 -0300

Converted the config fish function to a bash script

Diffstat:
A.config/amfora/config.toml | 164+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
A.config/dotfiles.list | 25+++++++++++++++++++++++++
D.config/fish/functions/config.fish | 97-------------------------------------------------------------------------------
A.local/bin/config | 142+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
M.local/bin/exports.sh | 3+++
D.local/share/configs.list | 23-----------------------
6 files changed, 334 insertions(+), 120 deletions(-)
diff --git a/.config/amfora/config.toml b/.config/amfora/config.toml
@@ -0,0 +1,164 @@
+#                   __                                    __ _       
+#   __ _ _ __ ___  / _| ___  _ __ __ _    ___ ___  _ __  / _(_) __ _ 
+#  / _` | '_ ` _ \| |_ / _ \| '__/ _` |  / __/ _ \| '_ \| |_| |/ _` |
+# | (_| | | | | | |  _| (_) | | | (_| | | (_| (_) | | | |  _| | (_| |
+#  \__,_|_| |_| |_|_|  \___/|_|  \__,_|  \___\___/|_| |_|_| |_|\__, |
+#                                                              |___/ 
+# 
+# Pablo (C) 2021
+
+[a-general]
+# Press Ctrl-H to access it
+home = "gemini://gemini.circumlunar.space"
+
+# Follow up to 5 Gemini redirects without prompting. A prompt is always shown
+# after the 5th redirect and for redirects to protocols other than Gemini. If
+# set to false, a prompt will be shown before following redirects
+auto_redirect = false
+
+# What command to run to open a HTTP(S) URL
+http = 'default'
+
+# Any URL that will accept a query string can be put here
+search = "gemini://geminispace.info/search"
+
+# Whether to replace list asterisks with unicode bullets
+bullets = true
+
+color = true
+ansi = true
+show_link = false
+left_margin = 0.15
+max_width = 100
+downloads = '/home/pablo/Downloads'
+
+# Max size for displayable content in bytes - after that size a download window
+# pops up
+page_max_size = 2097152  # 2 MiB
+
+# Max time it takes to load a page in seconds - after that a download window
+# pops up
+page_max_time = 10
+
+# "never", "auto" or "always"
+scrollbar = "auto"
+
+[auth]
+# Authentication settings 
+
+[auth.certs]
+# Client certificates
+# Set domain name equal to path to client cert
+# "example.com" = 'mycert.crt'
+
+[auth.keys]
+# Client certificate keys
+# Set domain name equal to path to key for the client cert above
+# "example.com" = 'mycert.key'
+
+[keybindings]
+# bind_tab1 = "!"
+# bind_tab2 = "@"
+# bind_tab3 = "#"
+# bind_tab4 = "$"
+# bind_tab5 = "%"
+# bind_tab6 = "^"
+# bind_tab7 = "&"
+# bind_tab8 = "*"
+# bind_tab9 = "("
+# bind_tab0 = ")"
+
+[url-handlers]
+other = 'off'
+
+[[mediatype-handlers]]
+cmd = ['sxiv']
+types = ["image/jpeg", "image/png", "image/bmp"]
+
+[[mediatype-handlers]]
+cmd = ['zathura']
+types = ["application/pdf"]
+
+[cache]
+max_size = 0  # Size in bytes
+max_pages = 30 # The maximum number of pages the cache will store
+
+# How long a page will stay in cache, in seconds
+timeout = 1800 # 30 mins
+
+[proxies]
+# Allows setting a Gemini proxy for different schemes.
+# The settings are similar to the url-handlers section above.
+# E.g. to open a gopher page by connecting to a Gemini proxy server:
+#   gopher = "example.com:123"
+#
+# Port 1965 is assumed if no port is specified.
+#
+# NOTE: These settings override any external handlers specified in
+# the url-handlers section.
+#
+# Note that HTTP and HTTPS are treated as separate protocols here.
+
+[subscriptions]
+# Whether a pop-up appears when viewing a potential feed
+popup = true
+
+# How often to check for updates to subscriptions in the background, in
+# seconds
+update_interval = 1800 # 30 mins
+
+# How many subscriptions can be checked at the same time when updating
+workers = 3
+
+# The number of subscription updates displayed per page
+entries_per_page = 20
+
+# Use the Snazzy theme
+[theme]
+bg = "#282a36"
+tab_num = "#9aedfe"
+tab_divider = "#f1f1f0"
+bottom_label = "#f1f1f0"
+bottom_text = "#282a36"
+scrollbar = "#f1f1f0"
+
+hdg_1 = "#5af78e"
+hdg_2 = "#5af78e"
+hdg_3 = "#5af78e"
+amfora_link = "#f3f99d"
+foreign_link = "#f3f99d"
+link_number = "#f1f1f0" 
+regular_text = "#f1f1f0" 
+quote_text = "#9aedfe"
+preformatted_text = "#9aedfe"
+list_text = "#f1f1f0" 
+
+btn_bg = "#f3f99d"
+btn_text = "#686868" 
+
+dl_choice_modal_bg = "#686868"
+dl_choice_modal_text = "#f1f1f0" 
+dl_modal_bg = "#686868"
+dl_modal_text = "#f1f1f0" 
+info_modal_bg = "#686868"
+info_modal_text = "#f1f1f0" 
+error_modal_bg = "#ff5c57"
+error_modal_text = "#f1f1f0" 
+yesno_modal_bg = "#686868"
+yesno_modal_text = "#f1f1f0" 
+tofu_modal_bg = "#686868"
+tofu_modal_text = "#f1f1f0" 
+subscription_modal_bg = "#686868"
+subscription_text = "#f1f1f0" 
+
+input_modal_bg = "#686868" 
+input_modal_text = "#f3f99d"
+input_modal_field_bg = "#f1f1f0" 
+input_modal_field_text = "#f3f99d"
+
+bkmk_modal_bg = "#686868"
+bkmk_modal_text = "#f1f1f0" 
+bkmk_modal_field_bg = "#f3f99d" 
+bkmk_modal_field_text = "#686868"
+bkmk_modal_label = "#f3f99d"
+
diff --git a/.config/dotfiles.list b/.config/dotfiles.list
@@ -0,0 +1,25 @@
+/home/pablo/.config/alacritty
+/home/pablo/.config/bat
+/home/pablo/.config/fish/config.fish
+/home/pablo/.config/fish/functions
+/home/pablo/.config/gdb
+/home/pablo/.config/git
+/home/pablo/.config/lynx
+/home/pablo/.config/mutt/muttrc
+/home/pablo/.config/mutt/accounts/1-public.muttrc
+/home/pablo/.config/mutt/asciidoc-template
+/home/pablo/.config/nvim/init.vim
+/home/pablo/.local/bin/exports.sh
+/home/pablo/.config/ranger/commands.py
+/home/pablo/.config/ranger/rc.conf
+/home/pablo/.config/ranger/rifle.conf
+/home/pablo/.config/ranger/scope.sh
+/home/pablo/.config/tmux/tmux.conf
+/home/pablo/.config/zathura
+/home/pablo/.config/aspell
+/home/pablo/.profile
+/home/pablo/.bashrc
+/home/pablo/.local/bin/aliases.sh
+/home/pablo/.config/amfora
+/home/pablo/.config/dotfiles.list
+/home/pablo/.local/bin/config
diff --git a/.config/fish/functions/config.fish b/.config/fish/functions/config.fish
@@ -1,97 +0,0 @@
-function config -d "A simple configuration manager"
-  # Calls git in the appropriate repository
-  function _call_git
-    git --git-dir="$HOME/Documents/dotfiles" --work-tree="$HOME" $argv
-  end
-
-  argparse u/update=+ a-add=+ r-rm=+ l/list g-log s/status d/diff f-edit-self e/edit -- $argv
-
-  # List the dotfiles specified in configurations list
-  if test -n "$_flag_list"
-    string replace --all "$HOME" '~' (cat ~/.local/share/configs.list)
-    return
-  end
-
-  # Call git log
-  if test -n "$_flag_log"
-    _call_git log
-    return
-  end
-
-  # Show the configuration files that have been modified
-  if test -n "$_flag_status"
-    _call_git status >> /tmp/config-git-status
-
-    echo 'modified files:'
-    cat /tmp/config-git-status \
-      | grep 'modified' \
-      | awk '{ print $2 }' \
-      | xargs -r realpath \
-      | string replace "$HOME" '~' \
-      | xargs -r -n 1 printf '    %s\n'
-
-    echo 'deleted files:'
-    cat /tmp/config-git-status \
-      | grep 'deleted' \
-      | awk '{ print $2 }' \
-      | xargs -r realpath \
-      | string replace "$HOME" '~' \
-      | xargs -r -n 1 printf '    %s\n'
-
-    rm /tmp/config-git-status
-    return
-  end
-
-  # Call git diff
-  if test -n "$_flag_diff"
-    _call_git diff
-    return
-  end
-
-  if test -n "$_flag_edit_self"
-    $EDITOR (type -p config)
-  end
-
-  # Add files to the list of dotfiles
-  for item in $_flag_add
-    echo "Adding '$item' to the list of dotfiles"
-    echo (realpath "$item") >> ~/.local/share/configs.list
-  end
-
-  # Remove files from the list of dotfiles
-  for item in $_flag_rm
-    echo "Removing '$item' from the list of dotfile"
-
-    # Set is used because 'item' may be a directory
-    set pattern (realpath "$item")
-    set pattern (string replace --all '/' '\/' "$pattern")
-    set pattern (string replace --all '.' '\.' "$pattern")
-    sed -e "/^$pattern/d" -i ~/.local/share/configs.list
-    _call_git rm "$item" --cached -r
-  end
-
-  # Update the repository and it's remotes
-  if test -n "$_flag_update"
-    # Add the relevant files to the repo
-    cat ~/.local/share/configs.list \
-      | xargs git --git-dir="$HOME/Documents/dotfiles" --work-tree="$HOME" add
-
-    for msg in $_flag_update
-      printf '%s\n\n' "$msg" >> /tmp/config-git-message
-    end
-
-    # Commit the changes
-    and _call_git commit -F /tmp/config-git-message
-
-    # Return if there's an error
-    or return $status
-
-    # Push the changes to all remotes
-    for remote in (_call_git remote -v | awk '{ print $1 }' | uniq)
-      _call_git push "$remote" master
-    end
-
-    rm /tmp/config-git-message
-  end
-end
-
diff --git a/.local/bin/config b/.local/bin/config
@@ -0,0 +1,142 @@
+#!/bin/bash
+#                   __ _       
+#   ___ ___  _ __  / _(_) __ _ 
+#  / __/ _ \| '_ \| |_| |/ _` |
+# | (_| (_) | | | |  _| | (_| |
+#  \___\___/|_| |_|_| |_|\__, |
+#                        |___/ 
+#
+# A simple configuration manager
+# Pablo (C) 2021
+
+# Get the name of the git repository that should be used
+if [ -n "$DOTFILES_REPO" ]
+then
+  dotfiles_repo="$DOTFILES_REPO"
+elif [ -n "$XDG_DATA_HOME" ]
+then
+  dotfiles_repo="$XDG_DATA_HOME/dotfiles"
+else
+  dotfiles_repo="$HOME/.local/share/dotfiles"
+fi
+
+# Get the name of the files that holds the list of all dotfiles that should be
+# tracked
+if [ -n "$DOTFILES_LIST" ]
+then
+  dotfiles_list="$DOTFILES_LIST"
+elif [ -n "$XDG_CONFIG_HOME" ]
+then
+  dotfiles_list="$XDG_CONFIG_HOME/dotfiles.list"
+else
+  dotfiles_list="$HOME/.config/dotfiles.list"
+fi
+
+# Calls git in the appropriate repository
+call_git() 
+{
+  git --git-dir="$dotfiles_repo" --work-tree="$HOME" "$@"
+}
+
+# Parse the commands
+case "$1" in
+  # Commit and push updates to all remotes
+  update)
+    commit_msg_file="$(mktemp)"
+
+    # Add the relevant files to the repo
+    xargs git --git-dir="$dotfiles_repo" --work-tree="$HOME" add \
+      < "$dotfiles_list"
+
+    shift
+
+    while [ $# -gt 0 ]
+    do
+      case "$1" in
+        # Edit the commit message directly
+        -e|--edit)
+          printf '' > "$commit_msg_file"
+          $EDITOR "$commit_msg_file" 
+          break
+          ;;
+
+        # Append messages to the temporary file
+        *)
+          printf '%s\n\n' "$1" >> "$commit_msg_file"
+          shift
+          ;;
+      esac
+    done
+
+    # Commit the changes
+    call_git commit -F "$commit_msg_file" || exit $?
+
+    # Push the changes to all remotes
+    for remote in $(call_git remote -v | awk '/(push)/ { print $1 }' | uniq)
+    do
+      call_git push "$remote" master
+    done
+
+    rm "$commit_msg_file"
+    ;;
+
+  # Add files to the list of files
+  add)
+    shift
+
+    # Add files to the list of dotfiles
+    for item in "$@"
+    do
+      echo "Adding '$item' to the list of dotfiles"
+      realpath "$item" >> "$dotfiles_list"
+    done
+    ;;
+
+  # Remove files from the list of dotfiles
+  rm)
+    shift
+
+    # Remove files from the list of dotfiles
+    for item in "$@"
+    do
+      echo "Removing '$item' from the list of dotfile"
+      pattern="$(realpath "$item")"
+      pattern="${pattern//\//\\\/}"
+
+      # Remove the files from the git repository and from the list of files
+      # Awk is used because 'item' may be a directory
+      awk -i inplace "!/^$pattern/ { print }" "$dotfiles_list"
+      call_git rm "$item" --cached -r
+    done
+    ;;
+
+  # List the dotfiles specified in configurations list
+  list)
+    cat "$dotfiles_list"
+    ;;
+
+  # Show the configuration files that have been modified or deleted
+  status)
+    config_git_status="$(mktemp)"
+    call_git status > "$config_git_status"
+
+    echo 'modified files:'
+    awk '/modified/ { print $2 }' "$config_git_status" \
+      | xargs -r realpath \
+      | xargs -r -n 1 printf '    %s\n'
+
+    echo 'deleted files:'
+    awk '/deleted/ { print $2 }' "$config_git_status" \
+      | awk '/deleted/ { print $2 }' \
+      | xargs -r realpath \
+      | xargs -r -n 1 printf '    %s\n'
+
+    rm "$config_git_status"
+    ;;
+
+  # Just pass the arguments to git
+  *)
+    call_git "$@"
+    ;;
+esac
+
diff --git a/.local/bin/exports.sh b/.local/bin/exports.sh
@@ -49,6 +49,9 @@ export MANPATH="$MANPATH:/usr/local/man"
 export MANPATH="$MANPATH:$XDG_DATA_HOME/man"
 export MANPATH="$MANPATH:$XDG_DATA_HOME/fzf/man"
 
+export DOTFILES_REPO="$XDG_DATA_HOME/dotfiles-repo"
+export DOTFILES_LIST="$XDG_CONFIG_HOME/dotfiles.list"
+
 # =========================== Programming Languages ==========================
 
 # C
diff --git a/.local/share/configs.list b/.local/share/configs.list
@@ -1,23 +0,0 @@
-/home/pablo/.config/alacritty
-/home/pablo/.config/bat
-/home/pablo/.config/fish/config.fish
-/home/pablo/.config/fish/functions
-/home/pablo/.config/gdb
-/home/pablo/.config/git
-/home/pablo/.config/lynx
-/home/pablo/.config/mutt/muttrc
-/home/pablo/.config/mutt/accounts/1-public.muttrc
-/home/pablo/.config/mutt/asciidoc-template
-/home/pablo/.config/nvim/init.vim
-/home/pablo/.local/bin/exports.sh
-/home/pablo/.local/share/configs.list
-/home/pablo/.config/ranger/commands.py
-/home/pablo/.config/ranger/rc.conf
-/home/pablo/.config/ranger/rifle.conf
-/home/pablo/.config/ranger/scope.sh
-/home/pablo/.config/tmux/tmux.conf
-/home/pablo/.config/zathura
-/home/pablo/.config/aspell
-/home/pablo/.profile
-/home/pablo/.bashrc
-/home/pablo/.local/bin/aliases.sh