[+] Fish (#7)
This commit is contained in:
@@ -1,25 +1,11 @@
|
||||
if command -v pacman &> /dev/null; then
|
||||
alias upgrade='sudo pacman -Syu'
|
||||
alias upgrade="${ZSHRC_SUDO}pacman -Syu"
|
||||
alias install='pacman -Sy'
|
||||
alias uninstall='pacman -Rsn'
|
||||
alias list-unused='pacman -Qdtq'
|
||||
fi
|
||||
|
||||
if [ -f "/etc/arch-release" ]; then
|
||||
# Java paths
|
||||
export JDK8="/usr/lib/jvm/java-8-openjdk/"
|
||||
export JDK11="/usr/lib/jvm/java-11-openjdk/"
|
||||
export JDK17="/usr/lib/jvm/java-17-openjdk/"
|
||||
export JDK18="/usr/lib/jvm/java-18-j9/"
|
||||
export JDK19="/usr/lib/jvm/java-19-openjdk/"
|
||||
alias java8="${JDK8}/bin/java"
|
||||
alias java11="${JDK11}/bin/java"
|
||||
alias java17="${JDK17}/bin/java"
|
||||
alias java18="${JDK18}/bin/java"
|
||||
alias java19="${JDK19}/bin/java"
|
||||
export JAVA_HOME=${JDK17}
|
||||
export PATH="${JDK17}/bin:$PATH"
|
||||
|
||||
export PATH="$HOME/.local/share/JetBrains/Toolbox/scripts:$PATH"
|
||||
|
||||
# GPG Init
|
||||
@@ -32,8 +18,8 @@ if [ -f "/etc/arch-release" ]; then
|
||||
# Free up cache
|
||||
clean-cache() {
|
||||
has yay && yay -Sc --noconfirm
|
||||
has pacman && sudo pacman -Sc --noconfirm
|
||||
has pacman && rm -rf /var/cache/pacman
|
||||
has pacman && _zshrc_as_root pacman -Sc --noconfirm
|
||||
has pacman && _zshrc_as_root rm -rf /var/cache/pacman
|
||||
has paru && rm -rf "$HOME/.cache/paru"
|
||||
has yarn && yarn cache clean
|
||||
has conda && conda clean -a
|
||||
|
||||
@@ -4,7 +4,7 @@ else
|
||||
alias dc='docker compose'
|
||||
fi
|
||||
|
||||
if [[ $OSTYPE != 'darwin'* ]]; then
|
||||
if [[ $OSTYPE != 'darwin'* && $EUID -ne 0 ]]; then
|
||||
alias docker="sudo docker"
|
||||
alias docker-compose="sudo docker-compose"
|
||||
fi
|
||||
@@ -21,19 +21,3 @@ docker-compose-path()
|
||||
|
||||
docker inspect "$1" | grep "com.docker.compose.project.working_dir"
|
||||
}
|
||||
|
||||
# Docker linux containers
|
||||
alpine-create()
|
||||
{
|
||||
docker rmi azalea/alpine
|
||||
docker run -it --name alpine-init --hostname alpine alpine \
|
||||
/bin/sh -c 'apk add zsh bash git curl wget tar zstd python3 && bash <(curl -sL hydev.org/zsh)'
|
||||
docker commit alpine-init azalea/alpine
|
||||
docker rm alpine-init
|
||||
}
|
||||
alias alpine="docker start -ai alpine"
|
||||
alias alpine-init="docker run -it --name alpine --hostname alpine azalea/alpine zsh"
|
||||
|
||||
alias psqlt+="docker run --rm -dit --name psql-test --hostname psql -e POSTGRES_HOST_AUTH_METHOD=trust postgres && echo 'Created'"
|
||||
alias psqlt-="docker stop psql-test && echo 'Deleted'"
|
||||
alias psqlt='psql -h $(docker-ip psql-test) -p 5432 -U postgres'
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
# Git commit wrapper
|
||||
commit() {
|
||||
msg="$@"
|
||||
git commit -m "$msg"
|
||||
if [[ $# -eq 0 ]]; then
|
||||
git commit
|
||||
else
|
||||
msg="$@"
|
||||
git commit -m "$msg"
|
||||
fi
|
||||
}
|
||||
|
||||
commitall() {
|
||||
@@ -44,18 +48,105 @@ git() {
|
||||
fi
|
||||
}
|
||||
|
||||
git-require-clean() {
|
||||
command git rev-parse --is-inside-work-tree >/dev/null 2>&1 || return 1
|
||||
|
||||
if [[ -n "$(command git status --porcelain 2>/dev/null)" ]]; then
|
||||
echo 'Workspace is not clean.'
|
||||
command git status --short
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
git-main-branch() {
|
||||
local remote_head
|
||||
remote_head=$(command git symbolic-ref --quiet --short refs/remotes/origin/HEAD 2>/dev/null)
|
||||
if [[ -n "$remote_head" ]]; then
|
||||
echo "${remote_head#origin/}"
|
||||
return 0
|
||||
fi
|
||||
|
||||
local branch
|
||||
for branch in main master trunk develop; do
|
||||
if command git show-ref --verify --quiet "refs/heads/$branch"; then
|
||||
echo "$branch"
|
||||
return 0
|
||||
fi
|
||||
if command git show-ref --verify --quiet "refs/remotes/origin/$branch"; then
|
||||
echo "$branch"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
echo 'Could not determine main branch.' >&2
|
||||
return 1
|
||||
}
|
||||
|
||||
git-update-main() {
|
||||
local main_branch="$1"
|
||||
if [[ -z "$main_branch" ]]; then
|
||||
main_branch=$(git-main-branch) || return 1
|
||||
fi
|
||||
|
||||
command git checkout "$main_branch" || return 1
|
||||
command git pull --ff-only
|
||||
}
|
||||
|
||||
br() {
|
||||
if [[ $# -ne 1 ]]; then
|
||||
echo 'Usage: br <branch-name>'
|
||||
return 1
|
||||
fi
|
||||
|
||||
local branch="$1"
|
||||
git-require-clean || return 1
|
||||
|
||||
if command git show-ref --verify --quiet "refs/heads/$branch" || command git show-ref --verify --quiet "refs/remotes/origin/$branch"; then
|
||||
command git checkout "$branch"
|
||||
return $?
|
||||
fi
|
||||
|
||||
local main_branch
|
||||
main_branch=$(git-main-branch) || return 1
|
||||
git-update-main "$main_branch" || return 1
|
||||
command git checkout -b "$branch"
|
||||
}
|
||||
|
||||
bru() {
|
||||
local current_branch
|
||||
current_branch=$(command git symbolic-ref --quiet --short HEAD 2>/dev/null)
|
||||
if [[ -z "$current_branch" ]]; then
|
||||
echo 'Could not determine current branch.'
|
||||
return 1
|
||||
fi
|
||||
|
||||
git-require-clean || return 1
|
||||
|
||||
local main_branch
|
||||
main_branch=$(git-main-branch) || return 1
|
||||
if [[ "$current_branch" == "$main_branch" ]]; then
|
||||
echo "Already on $main_branch."
|
||||
return 1
|
||||
fi
|
||||
|
||||
git-update-main "$main_branch" || return 1
|
||||
command git checkout "$current_branch" || return 1
|
||||
command git rebase "$main_branch"
|
||||
}
|
||||
|
||||
# Git environment
|
||||
git-env() {
|
||||
git_commands=( add bisect branch checkout clone commit diff fetch grep init log merge pull push rebase reset restore show status tag )
|
||||
git_commands=( add bisect branch checkout clone commit diff fetch grep init log merge pull push rebase reset restore show stash tag )
|
||||
for i in "${git_commands[@]}"
|
||||
do
|
||||
alias "$i"="git $i"
|
||||
done
|
||||
alias 'grm'='git rm'
|
||||
alias 'gmv'='git mv'
|
||||
alias 'st'='git status'
|
||||
}
|
||||
git-unenv() {
|
||||
git_commands=( add bisect branch checkout clone commit diff fetch grep init log merge pull push rebase reset restore show status tag grm gmv )
|
||||
git_commands=( add bisect branch checkout clone commit diff fetch grep init log merge pull push rebase reset restore show stash tag grm gmv st )
|
||||
for i in "${git_commands[@]}"
|
||||
do
|
||||
unalias "$i"
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
# Cut videos - cut <file name> <end time> [start time (default 00:00:00)]
|
||||
cutv() {
|
||||
if [ "$#" -lt 2 ]; then
|
||||
echo "Usage: cut <file name> <end time (hh:mm:ss)> [start time (00:00:00)]"
|
||||
return 2
|
||||
fi
|
||||
|
||||
local start="${3:-00:00:00}"
|
||||
echo "$1"
|
||||
echo "$2"
|
||||
echo "$start"
|
||||
ffmpeg -i "$1" -codec copy -ss "$start" -t "$2" Cut\ "$1"
|
||||
}
|
||||
alias vcomp="$BASEDIR/scripts/bin/video.py"
|
||||
alias vcompy="ipython -i $BASEDIR/scripts/bin/video.py"
|
||||
|
||||
flac2mp3() {
|
||||
for file in *.flac; do
|
||||
ffmpeg -i "$file" -ab 320k -map_metadata 0 -id3v2_version 3 "${file%.flac}.mp3"
|
||||
done
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
# Nixos only
|
||||
if command -v nixos-rebuild &> /dev/null; then
|
||||
alias rebuild="sudo nixos-rebuild switch"
|
||||
alias gc="sudo nix-collect-garbage -d"
|
||||
alias rebuild-gc="rebuild; gc"
|
||||
|
||||
# Update git
|
||||
nix-git-update() {
|
||||
pushd /etc/nixos
|
||||
|
||||
# Make sure there aren't any other changes
|
||||
if git diff-index --quiet HEAD --; then
|
||||
# No changes
|
||||
update-nix-fetchgit *.nix
|
||||
|
||||
# If there are changes after updating
|
||||
if ! git diff-index --quiet HEAD --; then
|
||||
# Has changes
|
||||
rebuild-gc
|
||||
git add *.nix
|
||||
git commit -m "[U] Update fetchgit refs"
|
||||
git push
|
||||
echo "Successfully updated fetchgit refs"
|
||||
else
|
||||
echo "There aren't any updates"
|
||||
fi
|
||||
else
|
||||
# Changes
|
||||
echo "Error: There are uncommitted changes"
|
||||
git status
|
||||
fi
|
||||
|
||||
popd
|
||||
}
|
||||
fi
|
||||
Reference in New Issue
Block a user