2021-12-19 06:31:30 +08:00
|
|
|
#!/bin/sh
|
2022-02-27 20:43:04 +08:00
|
|
|
|
|
|
|
# init for dotfiles.
|
|
|
|
initdots()
|
|
|
|
{
|
|
|
|
config='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'
|
|
|
|
config checkout HEAD
|
|
|
|
source $HOME/.bashrc
|
|
|
|
}
|
2021-05-05 15:07:25 +08:00
|
|
|
|
2021-09-14 17:22:55 +08:00
|
|
|
# nnn
|
|
|
|
# for nnn file manager
|
|
|
|
n ()
|
|
|
|
{
|
|
|
|
# Block nesting of nnn in subshells
|
|
|
|
if [ -n $NNNLVL ] && [ "${NNNLVL:-0}" -ge 1 ]; then
|
|
|
|
echo "nnn is already running"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
# The default behaviour is to cd on quit (nnn checks if NNN_TMPFILE is set)
|
|
|
|
# To cd on quit only on ^G, remove the "export" as in:
|
|
|
|
# NNN_TMPFILE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd"
|
|
|
|
# NOTE: NNN_TMPFILE is fixed, should not be modified
|
|
|
|
export NNN_TMPFILE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd"
|
|
|
|
|
|
|
|
# Unmask ^Q (, ^V etc.) (if required, see `stty -a`) to Quit nnn
|
|
|
|
# stty start undef
|
|
|
|
# stty stop undef
|
|
|
|
# stty lwrap undef
|
|
|
|
# stty lnext undef
|
|
|
|
|
|
|
|
nnn -A -x "$@"
|
|
|
|
|
|
|
|
if [ -f "$NNN_TMPFILE" ]; then
|
|
|
|
. "$NNN_TMPFILE"
|
|
|
|
rm -f "$NNN_TMPFILE" > /dev/null
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2021-03-06 22:05:59 +08:00
|
|
|
# cd into config dir
|
2020-06-29 08:38:46 +08:00
|
|
|
cfdir()
|
|
|
|
{
|
|
|
|
cd $HOME/.config/$1
|
|
|
|
}
|
2020-10-08 21:36:08 +08:00
|
|
|
|
2021-03-06 22:05:59 +08:00
|
|
|
# sshfs into newnumyspace
|
2020-10-08 21:36:08 +08:00
|
|
|
nnms_fs()
|
|
|
|
{
|
|
|
|
dir_name="newnumyspace"
|
2020-12-03 18:09:09 +08:00
|
|
|
path="${HOME}/dev"
|
|
|
|
if [ ! -d $path/$dir_name ]
|
2020-10-08 21:36:08 +08:00
|
|
|
then
|
2020-12-03 18:09:09 +08:00
|
|
|
mkdir $path/$dir_name
|
|
|
|
echo "Created new directory $dir_name at $path"
|
|
|
|
fi
|
|
|
|
sshfs unn_w19014537@newnumyspace.co.uk:/home/unn_w19014537/ $path/$dir_name/
|
|
|
|
if [ $? -eq 0 ]
|
|
|
|
then
|
|
|
|
echo "Mounted at $path/$dir_name."
|
2020-10-08 21:36:08 +08:00
|
|
|
fi
|
|
|
|
}
|
2020-11-05 01:11:52 +08:00
|
|
|
|
2021-03-06 22:05:59 +08:00
|
|
|
# pacman list sizes
|
2020-11-05 01:11:52 +08:00
|
|
|
pacsizes()
|
|
|
|
{
|
|
|
|
pacman -Qi $1 | awk '/^Name/{name=$3} /^Installed Size/{size=$4$5; print size, name;}' | sort -h
|
|
|
|
}
|
2021-03-06 22:05:59 +08:00
|
|
|
|
2021-09-17 11:31:34 +08:00
|
|
|
# view markdown files in zathura
|
|
|
|
viewmd()
|
|
|
|
{
|
|
|
|
[ -z $1 ] && return
|
|
|
|
[ ! -f $1 ] && return
|
2021-10-22 00:13:22 +08:00
|
|
|
pdfname=$(basename $1 .md).pdf
|
|
|
|
echo $pdfname
|
|
|
|
if [ -f $pdfname ]; then
|
2022-01-12 12:45:38 +08:00
|
|
|
zathura $pdfname
|
2021-10-22 00:13:22 +08:00
|
|
|
else
|
2022-01-12 12:45:38 +08:00
|
|
|
pandoc -t pdf $1 | zathura -
|
2021-10-22 00:13:22 +08:00
|
|
|
fi
|
2021-09-17 11:31:34 +08:00
|
|
|
}
|
|
|
|
|
2021-10-22 00:13:22 +08:00
|
|
|
# generate markdown files from markdown
|
|
|
|
makemd()
|
|
|
|
{
|
|
|
|
[ -z $1 ] && return
|
|
|
|
[ ! -f $1 ] && return
|
|
|
|
pandoc -t pdf $1 -o $(basename $1 .md).pdf
|
|
|
|
}
|
|
|
|
|
2021-11-10 02:38:56 +08:00
|
|
|
# view zathrua in tabbed
|
|
|
|
tzathura()
|
|
|
|
{
|
|
|
|
# rm tabbbed.xid if not running
|
|
|
|
! pgrep -f tabbed && rm /tmp/tabbed.xid
|
|
|
|
if [ ! -f /tmp/tabbed.xid ]; then
|
|
|
|
tabbed -c -d > /tmp/tabbed.xid
|
|
|
|
fi
|
|
|
|
zathura "$@" -e $(</tmp/tabbed.xid) & disown
|
|
|
|
}
|