-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
• Fixed nvim bootstrapping problem, added new keybinds & removed an unnecessary one • Refactor & improve scripts • A few changes in Ushiwaka theme
- Loading branch information
1 parent
79e7eac
commit 6b546b5
Showing
11 changed files
with
113 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
require('options') | ||
require('plugins') | ||
require('modules') | ||
require('keymaps') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,61 @@ | ||
#!/bin/sh | ||
|
||
GITHUB_LICENSE_API="https://api.github.com/licenses" | ||
CACHE_DIR="${XDG_CACHE_HOME:-${HOME}/.cache}/license-generator" | ||
github_license_api="https://api.github.com/licenses" | ||
cache_dir="${XDG_CACHE_HOME:-${HOME}/.cache}/license-generator" | ||
|
||
[ ! -d "${CACHE_DIR}" ] && mkdir -p "${CACHE_DIR}" | ||
downloadFile() { | ||
url="${1}" | ||
dest="${2}" | ||
|
||
if command -v curl >/dev/null 2>&1; then | ||
curl -sS -L "${GITHUB_LICENSE_API}" --compressed > "${CACHE_DIR}/licenses.json" | ||
else | ||
wget -r "${GITHUB_LICENSE_API}" --tries=5 -O "${CACHE_DIR}/licenses.json" | ||
fi | ||
if command -v curl >/dev/null 2>&1; then | ||
curl -sS -L "${url}" --compressed > "${dest}" \ | ||
|| { printf "%s" "Error: Failed to fetch data using curl."; exit 1; } | ||
elif command -v wget >/dev/null 2>&1; then | ||
wget -r "${url}" --tries=5 -O "${dest}" \ | ||
|| { printf "%s" "Error: Failed to fetch data using wget."; exit 1; } | ||
elif command -v aria2c >/dev/null 2>&1; then | ||
aria2c --allow-overwrite=true "${url}" -o "${dest}" \ | ||
|| { printf "%s" "Error: Failed to fetch data using aria2c."; exit 1; } | ||
else | ||
printf "%s" "Error: Neither curl nor wget nor aria2c is available. Install one of them." | ||
exit 1 | ||
fi | ||
} | ||
|
||
jq -r '[.[] | select(.key) | .url]' "${CACHE_DIR}/licenses.json" | sed 's/\\//g' | sed '1d' | sed '$d' | sed 's/,//g' | sed 's/"//g' | sed 's/^[ \t]*//' > "${CACHE_DIR}/LICENSE_URLS" | ||
[ "$(command -v fzf)" ] \ | ||
|| { printf "%s" "Error: fzf is required for this script. Install it first."; exit 1; } | ||
|
||
jq -r '[.[] | select(.key) | .name]' "${CACHE_DIR}/licenses.json" | sed 's/\\//g' | sed 's/^[ \t]*//' | sed '1d' | sed '$d' | sed 's/"//' | sed 's/.$//' | sed 's/"$//' > "${CACHE_DIR}/LICENSE_NAMES" | ||
mkdir -p "${cache_dir}" | ||
|
||
NAME=$(grep '' "${CACHE_DIR}/LICENSE_NAMES" | fzf --prompt "> Choose a license: " --height 40% --reverse) | ||
[ -z "${NAME}" ] && exit | ||
echo -e "Choose a license: ${NAME}" | ||
downloadFile "${github_license_api}" "${cache_dir}/licenses.json" | ||
|
||
N=$(grep -n "${NAME}" "${CACHE_DIR}/LICENSE_NAMES" | cut -d ":" -f1) | ||
jq -r '.[] | select(.key) | .url' "${cache_dir}/licenses.json" \ | ||
> "${cache_dir}/license_urls" | ||
|
||
LICENSE_URL="$(sed -n "${N}p" "${CACHE_DIR}/LICENSE_URLS")" | ||
LICENSE_NAME="$(echo -e "${LICENSE_URL}" | cut -d "/" -f5)" | ||
jq -r '.[] | select(.key) | .name' "${cache_dir}/licenses.json" \ | ||
> "${cache_dir}/license_names" | ||
|
||
if command -v curl >/dev/null 2>&1; then | ||
curl -sS -L "${LICENSE_URL}" --compressed > "${CACHE_DIR}/${LICENSE_NAME}.json" | ||
else | ||
wget -r "${LICENSE_URL}" --tries=5 -O "${CACHE_DIR}/${LICENSE_NAME}.json" | ||
fi | ||
chosen_license=$(grep '' "${cache_dir}/license_names" \ | ||
| fzf --prompt "> Choose a license: " --height 40% --reverse) | ||
|
||
echo -n "Enter your name: " | ||
read FN | ||
FULLNAME="${FN}" | ||
[ "${chosen_license}" ] || exit 1 | ||
printf "%s" "Choose a license: ${chosen_license}" | ||
|
||
echo -n "Enter year: " | ||
read FN | ||
[ -z "${FN}" ] && FN="$(date '+%Y')" | ||
YEAR="${FN}" | ||
line_number=$(grep -n "${chosen_license}" "${cache_dir}/license_names" \ | ||
| cut -d ":" -f1) | ||
|
||
jq -r '.body' "${CACHE_DIR}/${LICENSE_NAME}.json" | | ||
sed "s/\[fullname\]/${FULLNAME}/g" | | ||
sed "s/\[year\]/${YEAR}/g" > LICENSE | ||
license_url="$(sed -n "${line_number}p" "${cache_dir}/license_urls")" | ||
license_name="$(printf "%s" "${license_url}" | cut -d "/" -f5)" | ||
|
||
downloadFile "${license_url}" "${cache_dir}/${license_name}.json" | ||
|
||
printf "\n%s" "Enter your name: " | ||
read -r fullname | ||
|
||
printf "%s" "Enter year: " | ||
read -r year | ||
[ "${year}" ] || year="$(date '+%Y')" | ||
|
||
jq -r '.body' "${cache_dir}/${license_name}.json" \ | ||
| sed "s/\[fullname\]/${fullname}/g" \ | ||
| sed "s/\[year\]/${year}/g" > LICENSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,44 @@ | ||
#!/bin/sh | ||
|
||
PKG="${XDG_CONFIG_HOME:-${HOME}/.config}/update-arch/packages.txt" | ||
RETRY="${XDG_CONFIG_HOME:-${HOME}/.config}/update-arch/retry.txt" | ||
DED="${XDG_CONFIG_HOME:-${HOME}/.config}/update-arch/problem-packages.txt" | ||
pkgs="${XDG_CONFIG_HOME:-${HOME}/.config}/update-arch/packages.txt" | ||
retry_pkgs="${XDG_CONFIG_HOME:-${HOME}/.config}/update-arch/retry.txt" | ||
ded_pkgs="${XDG_CONFIG_HOME:-${HOME}/.config}/update-arch/problem-packages.txt" | ||
|
||
rm -rf "${PKG}" "${RETRY}" "${DED}" | ||
rm -rf "${pkgs}" "${retry_pkgs}" "${ded_pkgs}" | ||
space_left=$(df /home/ --output=avail | grep "[0-9]") | ||
|
||
[ ${space_left} == 0 ] && echo -e "No space available for update!" && exit | ||
|
||
[ ! -d "${XDG_CONFIG_HOME:-${HOME}/.config}/update-arch" ] && mkdir -p "${XDG_CONFIG_HOME:-${HOME}/.config}/update-arch" | ||
pacman -Qu | awk -F ' ' '{print $1}' >> "${PKG}" | ||
pacman -Qu | awk -F ' ' '{print $1}' >> "${pkgs}" | ||
|
||
# echo "Please write your password. It will be needed to run sudo to update your system" | ||
# read password | ||
echo ${password} | sudo pacman -Sy --noconfirm --needed archlinux-keyring | ||
|
||
pages=1 | ||
while [[ ${pages} != 0 && ${space_left} != 0 ]]; do | ||
echo ${password} | sudo pacman -Sy --noconfirm --needed $(cat "${PKG}" | sed -n 1p) | ||
[ $(echo $?) != 0 ] && echo -e $(cat "${PKG}" | sed -n 1p) >> "${RETRY}" | ||
sed -i '1d' "${PKG}" | ||
pages=$(cat "${PKG}" | wc -l) | ||
echo ${password} | sudo pacman -Sy --noconfirm --needed $(cat "${pkgs}" | sed -n 1p) | ||
[ $(echo $?) != 0 ] && echo -e $(cat "${pkgs}" | sed -n 1p) >> "${retry_pkgs}" | ||
sed -i '1d' "${pkgs}" | ||
pages=$(cat "${pkgs}" | wc -l) | ||
space_left=$(df /home/ --output=avail | grep "[0-9]") | ||
done | ||
|
||
[ ${space_left} == 0 ] && echo -e "No space available for update!" && exit | ||
|
||
pages=$(cat "${RETRY}" | wc -l) | ||
pages=$(cat "${retry_pkgs}" | wc -l) | ||
while [[ ${pages} != 0 && ${space_left} != 0 ]]; do | ||
echo ${password} | sudo pacman -Sy --noconfirm --needed $(cat "${RETRY}" | sed -n 1p) | ||
[ $(echo $?) != 0 ] && echo -e $(cat "${RETRY}" | sed -n 1p) >> "${DED}" | ||
sed -i '1d' "${RETRY}" | ||
pages=$(cat "${RETRY}" | wc -l) | ||
echo ${password} | sudo pacman -Sy --noconfirm --needed $(cat "${retry_pkgs}" | sed -n 1p) | ||
[ $(echo $?) != 0 ] && echo -e $(cat "${retry_pkgs}" | sed -n 1p) >> "${ded_pkgs}" | ||
sed -i '1d' "${retry_pkgs}" | ||
pages=$(cat "${retry_pkgs}" | wc -l) | ||
space_left=$(df /home/ --output=avail | grep "[0-9]") | ||
done | ||
|
||
[ ${space_left} == 0 ] && echo -e "No space available for update!" && exit | ||
|
||
pages=$(cat "${DED}" | wc -l) | ||
pages=$(cat "${ded_pkgs}" | wc -l) | ||
if [ ${pages} != 0 ]; then | ||
echo -e "Some packages were not updated due to some issues. Please check ${DED}. You may download & install them manually" | ||
echo -e "Some packages were not updated due to some issues. Please check ${ded_pkgs}. You may download & install them manually" | ||
fi |
Oops, something went wrong.