diff --git a/bash.d/apt.sh b/bash.d/apt.sh new file mode 100644 index 0000000..5de980c --- /dev/null +++ b/bash.d/apt.sh @@ -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' diff --git a/bash.d/bash-commands.sh b/bash.d/bash-commands.sh new file mode 100644 index 0000000..211a5cf --- /dev/null +++ b/bash.d/bash-commands.sh @@ -0,0 +1,5 @@ +# change current directory to its parent +alias ..='cd ..' + +# exit terminal +alias x='exit' diff --git a/bash.d/bash-completion.sh b/bash.d/bash-completion.sh new file mode 100644 index 0000000..748a2b9 --- /dev/null +++ b/bash.d/bash-completion.sh @@ -0,0 +1,5 @@ +file='/usr/share/bash-completion/bash_completion' + +if [ -f "${file}" ] ; then + source "${file}" +fi diff --git a/bash.d/bash-history.sh b/bash.d/bash-history.sh new file mode 100644 index 0000000..4a47ba3 --- /dev/null +++ b/bash.d/bash-history.sh @@ -0,0 +1,5 @@ +HISTCONTROL='ignorespace' + +HISTSIZE=-1 + +HISTTIMEFORMAT='%Y%m%d %H%M%S ' diff --git a/bash.d/bash-prompt.sh b/bash.d/bash-prompt.sh new file mode 100644 index 0000000..51b193c --- /dev/null +++ b/bash.d/bash-prompt.sh @@ -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="\ +└ " diff --git a/bash.d/batcat.sh b/bash.d/batcat.sh new file mode 100644 index 0000000..abe0b64 --- /dev/null +++ b/bash.d/batcat.sh @@ -0,0 +1 @@ +alias bat='batcat' diff --git a/bash.d/byobu.sh b/bash.d/byobu.sh new file mode 100644 index 0000000..1eb6d63 --- /dev/null +++ b/bash.d/byobu.sh @@ -0,0 +1 @@ +alias bb='byobu' diff --git a/bash.d/chmod.sh b/bash.d/chmod.sh new file mode 100644 index 0000000..357d4dc --- /dev/null +++ b/bash.d/chmod.sh @@ -0,0 +1,5 @@ +# change mode as directory +alias cmd='chmod 755' + +# change mode as file +alias cmf='chmod 644' diff --git a/bash.d/chown.sh b/bash.d/chown.sh new file mode 100644 index 0000000..4beb36d --- /dev/null +++ b/bash.d/chown.sh @@ -0,0 +1,5 @@ +# change owner as root +alias cor='chown 0:0' + +# change owner as user +alias cou='chown 1000:1000' diff --git a/bash.d/clear.sh b/bash.d/clear.sh new file mode 100644 index 0000000..350a925 --- /dev/null +++ b/bash.d/clear.sh @@ -0,0 +1,2 @@ +# clear terminal +alias c='clear' diff --git a/bash.d/git.sh b/bash.d/git.sh new file mode 100644 index 0000000..7417e4c --- /dev/null +++ b/bash.d/git.sh @@ -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' diff --git a/bash.d/gnupg.sh b/bash.d/gnupg.sh new file mode 100644 index 0000000..715e3ab --- /dev/null +++ b/bash.d/gnupg.sh @@ -0,0 +1,3 @@ +alias gpgoff='gpgconf --kill gpg-agent' + +alias gpgtty='gpg-connect-agent updatestartuptty /bye' diff --git a/bash.d/grep.sh b/bash.d/grep.sh new file mode 100644 index 0000000..6a9c514 --- /dev/null +++ b/bash.d/grep.sh @@ -0,0 +1,2 @@ +# grep from current directory with regex +alias g='grep --directories recurse --line-number --regexp' diff --git a/bash.d/kill.sh b/bash.d/kill.sh new file mode 100644 index 0000000..dbe03d1 --- /dev/null +++ b/bash.d/kill.sh @@ -0,0 +1,5 @@ +# kill a process by id +alias k='kill' + +# force kill a process by id +alias kf='kill -9' diff --git a/bash.d/killall.sh b/bash.d/killall.sh new file mode 100644 index 0000000..76c30a7 --- /dev/null +++ b/bash.d/killall.sh @@ -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' diff --git a/bash.d/ls.sh b/bash.d/ls.sh new file mode 100644 index 0000000..c820fb5 --- /dev/null +++ b/bash.d/ls.sh @@ -0,0 +1,2 @@ +# list current directory entries +alias l='ls --all --color -l -p --time-style="+%Y%m%d-%H%M%S%-:::z"' diff --git a/bash.d/lsblk.sh b/bash.d/lsblk.sh new file mode 100644 index 0000000..fca212a --- /dev/null +++ b/bash.d/lsblk.sh @@ -0,0 +1 @@ +alias lb='lsblk --noempty --output NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS' diff --git a/bash.d/micro.sh b/bash.d/micro.sh new file mode 100644 index 0000000..de78a1d --- /dev/null +++ b/bash.d/micro.sh @@ -0,0 +1 @@ +alias e='micro' diff --git a/bash.d/mkdir.sh b/bash.d/mkdir.sh new file mode 100644 index 0000000..ba8d113 --- /dev/null +++ b/bash.d/mkdir.sh @@ -0,0 +1,5 @@ +# make a directory +alias md='mkdir' + +# make a directory after making its parents +alias mdp='mkdir --parents' diff --git a/bash.d/mount-lxc.sh b/bash.d/mount-lxc.sh new file mode 100644 index 0000000..a0b3ace --- /dev/null +++ b/bash.d/mount-lxc.sh @@ -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" +} diff --git a/bash.d/mount.sh b/bash.d/mount.sh new file mode 100644 index 0000000..4e91b62 --- /dev/null +++ b/bash.d/mount.sh @@ -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 +} diff --git a/bash.d/newsboat.sh b/bash.d/newsboat.sh new file mode 100644 index 0000000..b90f01b --- /dev/null +++ b/bash.d/newsboat.sh @@ -0,0 +1 @@ +alias nb='newsboat' diff --git a/bash.d/otpclient-cli.sh b/bash.d/otpclient-cli.sh new file mode 100644 index 0000000..f2fa2ba --- /dev/null +++ b/bash.d/otpclient-cli.sh @@ -0,0 +1,5 @@ +# display otp code +alias pd='otpclient-cli show -a' + +# list otp accounts +alias pl='otpclient-cli list' diff --git a/bash.d/pass.sh b/bash.d/pass.sh new file mode 100644 index 0000000..f90153e --- /dev/null +++ b/bash.d/pass.sh @@ -0,0 +1,5 @@ +# display pass entry's content +alias p='pass' + +# copy passphrase into clipboard +alias pc='pass --clip' diff --git a/bash.d/proxy.sh b/bash.d/proxy.sh new file mode 100644 index 0000000..a5713ad --- /dev/null +++ b/bash.d/proxy.sh @@ -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}" +} diff --git a/bash.d/ps.sh b/bash.d/ps.sh new file mode 100644 index 0000000..791a664 --- /dev/null +++ b/bash.d/ps.sh @@ -0,0 +1,2 @@ +# look for a string in processes names +alias pg='ps -A | grep' diff --git a/bash.d/rsync.sh b/bash.d/rsync.sh new file mode 100644 index 0000000..ddd35b2 --- /dev/null +++ b/bash.d/rsync.sh @@ -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' diff --git a/bash.d/tar.sh b/bash.d/tar.sh new file mode 100644 index 0000000..2c1f18c --- /dev/null +++ b/bash.d/tar.sh @@ -0,0 +1,3 @@ +alias tc='tar --verbose --create --auto-compress --file' + +alias tx='tar --verbose --extract --file'