x64-syscall/x64-syscall.sh
2025-07-29 08:29:42 -03:00

89 lines
2.9 KiB
Bash
Executable file

#!/usr/bin/env bash
# -------------------------------------------
# @script: x64-syscall.sh
# @link: https://github.com/NRZCode/x64-syscall
# @description: ---
# @license: GNU/GPL v3.0
# @version: 0.0.1
# @author: NRZ Code <nrzcode@protonmail.com>
# @created: 29/07/2025 00:06
#
# @requirements: ---
# @bugs: ---
# @notes: ---
# @revision: ---
# -------------------------------------------
# Copyright (C) 2025 NRZ Code <nrzcode@protonmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# -------------------------------------------
# USAGE
# x64-syscall.sh
# -------------------------------------------
version='0.0.1'
usage=' Usage: x64-syscall.sh [OPTIONS]
DESCRIPTION
Script Description
OPTIONS
General options
-h, --help Print this help usage and exit
-v, --version Display version information and exit
'
copy='Copyright (C) 2025 NRZ Code <nrzcode@protonmail.com>.
License: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
'
# functions ---------------------------------
check_dependencies() {
local code=0
for dep; do
if ! type -p $dep &>/dev/null; then
echo "ERROR: ${BASH_SOURCE##*/}: $dep dependency is missing."
code=1
fi
done
return $code
}
x64-syscall() {
printf -v preview '%11s: {%d}\n' \
'references' 3 \
'RAX' 4 \
'ARG0(rdi)' 5 \
'ARG1(rsi)' 6 \
'ARG2(rdx)' 7 \
'ARG3(r10)' 8 \
'ARG4(r8)' 9 \
'ARG5(r9)' 10
preview="echo \"$preview\"; (:); printf -v hr \"%*s\" \$COLUMNS; echo \"\${hr// /─}\"; batcat --color=always -plman <(man 2 {2})"
fzf \
-e -i \
--tiebreak begin \
--border-label $'┤ \e[1;34mSystem Calls 64 BITS\e[0m ├' \
--bind 'enter:become(man 2 {2}),focus:transform-preview-label(echo [ {2} ])' \
--header-lines 1 \
--delimiter '|' \
--with-nth $'{1}\t{2}' \
--reverse \
--preview-window 70% \
--preview "$preview" < "$(dirname "$BASH_SOURCE")/x64-syscall.list"
}
# main --------------------------------------
check_dependencies fzf batcat || exit 1
[[ $BASH_SOURCE == $0 ]] && x64-syscall "$@"