This commit is contained in:
Marc Beninca 2023-05-09 22:02:34 +02:00
parent 3ed56f6453
commit 596e9b86c2
28 changed files with 420 additions and 0 deletions

23
bash.d/apt.sh Normal file
View file

@ -0,0 +1,23 @@
# show package information
alias ac='apt-cache show'
# search package
alias acs='apt-cache search'
# package versions policy
alias acp='apt-cache policy'
# update packages catalog
alias agud='apt-get update'
# upgrade forbidding package installation or removal
alias agug='apt-get upgrade'
# upgrade allowing package installation or removal
alias agdu='apt-get dist-upgrade'
# install packages
alias agi='apt-get install'
# clean packages cache
alias agc='apt-get clean;apt-get autoremove'

5
bash.d/bash-commands.sh Normal file
View file

@ -0,0 +1,5 @@
# change current directory to its parent
alias ..='cd ..'
# exit terminal
alias x='exit'

View file

@ -0,0 +1,5 @@
file='/usr/share/bash-completion/bash_completion'
if [ -f "${file}" ] ; then
source "${file}"
fi

5
bash.d/bash-history.sh Normal file
View file

@ -0,0 +1,5 @@
HISTCONTROL='ignorespace'
HISTSIZE=-1
HISTTIMEFORMAT='%Y%m%d %H%M%S '

15
bash.d/bash-prompt.sh Normal file
View file

@ -0,0 +1,15 @@
PS1="\
\t\
\e[0;31m\${?}\e[0m\
\e[0;32m\u\e[0m\
@ \e[0;33m\h\e[0m\
"
if [ "$(type -t __git_ps1)" == 'function' ] ; then
PS1="${PS1} –\e[0;35m\$(__git_ps1)\e[0m"
fi
PS1="${PS1}
\e[0;36m\${PWD}\e[0m
"
PS2="\
"

1
bash.d/batcat.sh Normal file
View file

@ -0,0 +1 @@
alias bat='batcat'

1
bash.d/byobu.sh Normal file
View file

@ -0,0 +1 @@
alias bb='byobu'

5
bash.d/chmod.sh Normal file
View file

@ -0,0 +1,5 @@
# change mode as directory
alias cmd='chmod 755'
# change mode as file
alias cmf='chmod 644'

5
bash.d/chown.sh Normal file
View file

@ -0,0 +1,5 @@
# change owner as root
alias cor='chown 0:0'
# change owner as user
alias cou='chown 1000:1000'

2
bash.d/clear.sh Normal file
View file

@ -0,0 +1,2 @@
# clear terminal
alias c='clear'

190
bash.d/git.sh Normal file
View file

@ -0,0 +1,190 @@
# add to index
alias ga='git add'
# add all to index
alias gaa='git add --all'
# create a branch
alias gb='git branch'
# delete a branch
alias gbd='git branch --delete'
# force a branch deletion
alias gbdf='git branch --delete --force'
# list branches
alias gbl='git branch --all --list --verbose --verbose'
# set the link to a remote branch from a local branch
alias gbu='git branch -u'
# clone a remote repository
alias gc='git clone'
# clean untracked files
alias gcf='git clean -d --force'
# index all and commit
alias gacm='git add --all;git commit -m'
# commit the index
alias gcm='git commit -m'
# redo the last commit with a different message
alias gcma='git commit --amend -m'
# make a root commit
alias gcmr='git commit --allow-empty --allow-empty-message -m ""'
# commit the index and sign
alias gcms='git commit --gpg-sign -m'
# switch to a branch or checkout file(s) from a commit
alias gco='git checkout'
# checkout an orphan branch
alias gcoo='git checkout --orphan'
# checkout development branch
alias gcod='git checkout dev'
# checkout feature branch
alias gcof='git checkout f'
# pick a commit
alias gcp='git cherry-pick'
# abort the commit pick
alias gcpa='git cherry-pick --abort'
# continue the commit pick
alias gcpc='git cherry-pick --continue'
# configure the user name
alias gcun='git config user.name'
# configure the user email
alias gcue='git config user.email'
# differences from last or between commits
alias gd='git diff'
# display what is indexed in cache
alias gdc='git diff --cached'
# indexed character-level differences
alias gdcw='git diff --cached --word-diff-regex=.'
# differences via external tool
alias gdt='git difftool --dir-diff'
# character-level differences
alias gdw='git diff --word-diff-regex=.'
# fetch from the remote repository
alias gf='git fetch --tags --verbose'
# fetch from remote repository and prune local orphan branches
alias gfp='git fetch --prune --tags --verbose'
# garbage collect all orphan commits
alias ggc='git reflog expire --expire=now --all;git gc --prune=now'
# initialize a new repository
alias gi='git init'
# initialize a new bare repository
alias gib='git init --bare'
# log commits history
alias gl='git log --all --graph \
--format="%C(auto)%h%d %C(red)%ai%C(auto) %an%n%B"'
# log commits history with patches
alias glp='git log --all --graph \
--format="%C(auto)%h%d %C(red)%ai%C(auto) %an%n%B" --patch'
# log medium information
alias glm='git log --all --decorate --graph --pretty=medium'
# fast-forward to remote branch
alias gmf='git merge --ff-only'
# do a merge commit
alias gmc='git merge --no-ff -m'
# abort the current merge commit
alias gma='git merge --abort'
# squash a branch and index its modifications
alias gms='git merge --squash'
# merge via external tool
alias gmt='git mergetool'
# push to the remote repository
alias gp='git push --tags --verbose'
# delete from the remote repository
alias gpd='git push --delete --verbose'
# force the push to the remote repository
alias gpf='git push --tags --verbose --force'
# rebase current branch onto another
alias grb='git rebase'
# abort current rebase
alias grba='git rebase --abort'
# continue current rebase
alias grbc='git rebase --continue'
# force rebase without fast-forward
alias grbf='git rebase --no-ff'
# rebase interactively
alias grbi='git rebase --interactive'
# list all remote repositories
alias grm='git remote'
# add a new remote repository
alias grma='git remote add'
# list remote repositories
alias grml='git remote --verbose'
# show a connection to a repository
alias grms='git remote show'
# set the location of the remote repository
alias grmu='git remote set-url'
# remove file(s) from index or move current branch pointer
alias grs='git reset'
# move current branch pointer to the development branch
alias grsd='git reset dev'
# wipe modifications or reset current branch to another commit
alias grsh='git reset --hard'
# reset current branch to the development branch
alias grshd='git reset --hard dev'
# current state of repository
alias gs='git status --untracked-files=all'
# show a commit
alias gsh='git show'
# tag a commit
alias gt='git tag'
# delete a tag
alias gtd='git tag --delete'
# tag a commit and sign
alias gts='git tag --sign'

3
bash.d/gnupg.sh Normal file
View file

@ -0,0 +1,3 @@
alias gpgoff='gpgconf --kill gpg-agent'
alias gpgtty='gpg-connect-agent updatestartuptty /bye'

2
bash.d/grep.sh Normal file
View file

@ -0,0 +1,2 @@
# grep from current directory with regex
alias g='grep --directories recurse --line-number --regexp'

5
bash.d/kill.sh Normal file
View file

@ -0,0 +1,5 @@
# kill a process by id
alias k='kill'
# force kill a process by id
alias kf='kill -9'

5
bash.d/killall.sh Normal file
View file

@ -0,0 +1,5 @@
# kill all instances of a process by name
alias ka='killall'
# force kill all instances of a process by name
alias kaf='killall -9'

2
bash.d/ls.sh Normal file
View file

@ -0,0 +1,2 @@
# list current directory entries
alias l='ls --all --color -l -p --time-style="+%Y%m%d-%H%M%S%-:::z"'

1
bash.d/lsblk.sh Normal file
View file

@ -0,0 +1 @@
alias lb='lsblk --noempty --output NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS'

1
bash.d/micro.sh Normal file
View file

@ -0,0 +1 @@
alias e='micro'

5
bash.d/mkdir.sh Normal file
View file

@ -0,0 +1,5 @@
# make a directory
alias md='mkdir'
# make a directory after making its parents
alias mdp='mkdir --parents'

31
bash.d/mount-lxc.sh Normal file
View file

@ -0,0 +1,31 @@
function mrc {
local container="${1}"
local f
for f in 'dev' 'dev/pts' 'proc' 'sys' ; do
mount --bind "/${f}" "overlay/mount/var/lib/lxc/${container}/squashfs-root/${f}"
done
}
function crc {
local container="${1}"
shift
chroot "overlay/mount/var/lib/lxc/${container}/squashfs-root" "${@}"
}
function urc {
local container="${1}"
for f in 'sys' 'proc' 'dev/pts' 'dev' ; do
umount --lazy "overlay/mount/var/lib/lxc/${container}/squashfs-root/${f}"
done
}
function mmc {
local container="${1}"
mount --bind '/deb' "overlay/mount/var/lib/lxc/${container}/squashfs-root/deb"
}
function umc {
local container="${1}"
umount "overlay/mount/var/lib/lxc/${container}/squashfs-root/deb"
}

76
bash.d/mount.sh Normal file
View file

@ -0,0 +1,76 @@
alias m='mount'
function mo {
local directory="${1}"
local file
if [ "${directory}" ] ; then
directory="$(realpath "${directory}")"
file="${directory}/filesystem.squashfs"
if mkdir 'overlay' ; then
cd 'overlay'
mkdir {lower,upper,work,mount}
if mount "${file}" 'lower' ; then
mount -t 'overlay' 'overlay' 'mount' \
-o lowerdir='lower',upperdir='upper',workdir='work'
fi
cd ..
fi
else
echo 'KO: directory?'
fi
}
function uo {
cd 'overlay'
if umount 'mount' ; then
rmdir 'mount'
rm --recursive 'upper' 'work'
if umount 'lower' ; then
rmdir 'lower'
fi
fi
cd ..
rmdir 'overlay'
}
function mr {
for f in 'dev' 'dev/pts' 'proc' 'sys' ; do
mount --bind "/${f}" "overlay/mount/${f}"
done
}
alias cr='chroot overlay/mount'
function ur {
for f in 'dev/pts' 'dev' 'proc' 'sys' ; do
umount --lazy "overlay/mount/${f}"
done
}
function mm {
mount --bind '/deb' 'overlay/mount/deb'
}
function um {
umount 'overlay/mount/deb'
}
function ms {
local directory="${1}"
local level="${2}"
if [ "${directory}" ] ; then
if mkdir "${directory}" ; then
[ "${level}" ] || level='18'
cp overlay/mount/{vmlinuz,initrd.img} "${directory}"
mksquashfs \
'overlay/mount' "${directory}/filesystem.squashfs" \
-b '1M' \
-comp 'zstd' -Xcompression-level "${level}"
chown --recursive 1000:1000 "${directory}"
fi
fi
}

1
bash.d/newsboat.sh Normal file
View file

@ -0,0 +1 @@
alias nb='newsboat'

5
bash.d/otpclient-cli.sh Normal file
View file

@ -0,0 +1,5 @@
# display otp code
alias pd='otpclient-cli show -a'
# list otp accounts
alias pl='otpclient-cli list'

5
bash.d/pass.sh Normal file
View file

@ -0,0 +1,5 @@
# display pass entry's content
alias p='pass'
# copy passphrase into clipboard
alias pc='pass --clip'

8
bash.d/proxy.sh Normal file
View file

@ -0,0 +1,8 @@
function socks {
local value
case "${1}" in
'on') value='manual' ;;
*) value='none' ;;
esac
gsettings set 'org.gnome.system.proxy' 'mode' "${value}"
}

2
bash.d/ps.sh Normal file
View file

@ -0,0 +1,2 @@
# look for a string in processes names
alias pg='ps -A | grep'

8
bash.d/rsync.sh Normal file
View file

@ -0,0 +1,8 @@
# synchronize
alias rs='rsync --archive --partial --progress --verbose --no-inc-recursive'
# synchronize and delete after
alias rsda='rsync --archive --partial --progress --verbose --delete-after'
# synchronize and delete before
alias rsdb='rsync --archive --partial --progress --verbose --delete-before'

3
bash.d/tar.sh Normal file
View file

@ -0,0 +1,3 @@
alias tc='tar --verbose --create --auto-compress --file'
alias tx='tar --verbose --extract --file'