Personal shell settings (aliases, functions, commands, shell options)
MIT License
This is a repository for my personal shell scripts.
The name mshex
comes from the abbreviation of "my shell extensions".
The license is MIT License.
make
(GNU make) and gawk
(GNU awk) is required.
mshex
can be installed by the following commands.
The scripts and settings will be copied to the install path specified by the make variable PREFIX
.
The default path for PREFIX
is ~/.mwg
.
$ git clone [email protected]:akinomyoga/mshex.git
$ cd mshex
$ make install PREFIX=~/.mwg
The common bashrc settings can be loaded by sourcing ~/.mwg/share/mshex/shrc/bashrc_common.sh
.
To use the external commands of this package, add PREFIX/bin
(where PREFIX
is the install path) to the environment variable PATH
.
# bashrc
# Initialize mshex install prefix
MWGPATH=~/.mwg
# Load common bashrc settings
source "$MWGPATH/share/mshex/shrc/bashrc_common.sh"
# Use mshex external commansds
export PATH=$MWGPATH/bin:$PATH
The scripts installed in PREFIX/bin
is listed here.
Please check the output of --help
for details of each command.
# Find source file names
findsrc [options]
src find [options]
# Grep patterns from the source files
grc [options] pattern [files...]
src grep [options]
# Count LoC
src wc [options]
# Replace tokens in the source files
refact [options] before after [files...]
# Update Makefile from Makefile.pp
makepp
# Create backup to file.20150101.ext
mwgbk [options] files...
# Rename files with regex (ERE)
ren before after [files...]
# Safe file removes backed up into ~/.recycle
remove [options] files...
# Safe file moves
move [options] file1 file2
move [options] files... dir
# Modify cygwin permissions
modmod [files...]
# Backupped synchronization
msync [options] srcdir dstdir
# Copy and run the executable.
crun executable
# Compile and run program.cxx.
crun program.cxx
# Generate random password
passgen
# Edit ~/.ssh/passwd.cz2
pass --edit
# View ~/.ssh/passwd.cz2
pass
# Encrypt the file
cz file
# Decrypt the file
cz file.cz2
# View contents of the encrypted file
czless file.cz2
# Remove duplicates in ~/.bash_history
hist-uniq [file]
# Filter for text justification (extended fold)
ifold [options]
# Create archive
tarc archive files...
# Show IO activities of the system
iostat.sh
j
: jobs
f
: fg
F
: fg %-
fg %NUM
fg
fg
fg %NUM
c
: cd -
(goto previous directory)C
: cd ..
(goto parent directory)m
: make
in the appropriate directoryg
: git manipulations
g
: git status
g d
: diff "working tree" vs "index" (git diff
)g d0
: diff "index" vs "HEAD" (git diff --cached
)g d[NUM]
: diff "NUM-th last commit" vs "its previous commit" (git diff @~((NUM-1)) @~NUM
)g d COMMIT
: diff "the specified commit" vs "its previous commit" (git diff COMMIT~1 COMMIT
)g t
: show commit graph (git log --graph ...
)g set-mtime
: set timestamp of each tracked file to that of the last commit that changed the fileg ...
: other git commands (git "$@"
)rmgomi
: rm -rf gomi
o
: open file with an appropriate program (cygstart
, xdg-open
, open
, etc.)p
: show processes (ps uaxf
)h
: show recent command historyd
: show date and calendara
: simple calculation command (using gawk)s
: stty sane
v
: view filel
: ls -lB
ll
: ls -l
la
: ls -la
ls
, diff
, grep
: color optionscp
, rm
, mv
, scp
: clobber optionsyes
: check stdoutmshex/display
: reset the environment variable DISPLAY
for the latest SSH session.mshex/set-prompt
: set promptmshex/set-window-title
: set window title in promptAlso, bash_common.sh
changes the settings for history, tty, checkwinsize
, TRAPERR
, LANG
, etc.
These functions are defined in PREFIX/share/mshex/shrc/path.sh
.
SYNOPSIS
PATH.canonicalize [-v VARNAME] [-F SEP]
PATH.prepend [-v VARNAME] [-F SEP] [-n] PATHS...
PATH.append [-v VARNAME] [-F SEP] [-n] PATHS...
PATH.remove [-v VARNAME] [-F SEP] PATHS...
PATH.show [VARNAME]
OPTIONS
-v VARNAME Change the target variable name. The default is PATH.
-F SEP Change the path separater. The default is colon (:).
-n Do not add non-existent path.