# Some Shell Tricks I use rc as my main shell. But you can interpret into any other sh ell. 1. I made a "Show the current directory" script. `````````````````````````````````````````````````````````````````` #!/usr/local/bin/rc clear;pwd;lc `````````````````````````````````````````````````````````````````` I named it 'l'. Then I combined 'cd' with 'l'. You can also combine 'l' with 'mv', 'rm', &c. I just don't use in that way. In ~/.rcrc, `````````````````````````````````````````````````````````````````` fn cd {builtin cd $*; l} `````````````````````````````````````````````````````````````````` 2. I made scripts to explore files. For that, I made two files. On e contains directory names. The other contains file names. `````````````````````````````````````````````````````````````````` #!/usr/local/bin/rc bmdir = $HOME/bmdir.txt bmfiles = $HOME/bmfiles.txt find $HOME -type d >$bmdir find $HOME -type f >$bmfiles `````````````````````````````````````````````````````````````````` I named the script 'fu'. You can use your cache directory instead of $HOME. But I use $HOME anyway. I restrict it in $HOME, but you can use it on /. I added it as a cron job. `````````````````````````````````````````````````````````````````` * * * * * $HOME/bin/fu `````````````````````````````````````````````````````````````````` Then I made two scripts. One for files, and the other for director ies. I named those 'f' and 'g'. `````````````````````````````````````````````````````````````````` #!/usr/local/bin/rc bmfiles = $HOME/bmfiles.txt sel = `{cat $bmfiles | fzy} v $sel `````````````````````````````````````````````````````````````````` If you 'fzy $bmfiles', it doesn't show files in ~/.config. If you will not edit config files, use in that way. 'v' is a general file opener. I made 'g' as a function in ~/.rcrc. If I made it as a seperate s cript, it doesn't work. I don't know why. `````````````````````````````````````````````````````````````````` fn g{ bmdir = $HOME/bmdir.txt cd `{cat $bmdir | fzy} } `````````````````````````````````````````````````````````````````` This is 'v'. `````````````````````````````````````````````````````````````````` #!/usr/local/bin/rc switch($*) { case *mp4 *mkv *webm *flv *ts *m4a *opus *mp3 *webp mpv $* case *jpg *jpeg *png *gif sxiv $* case *djvu *pdf *epub zathura $* case *txt *md *csv *html *js *json *conf *.c *.h *.mk *.info *.orig *.local [a-z]* /etc* *config* *rc vi $* case * echo 'Not yet defined.' } `````````````````````````````````````````````````````````````````` [a-z]* is because I make directory names start with a capital lett er. Also, I use mpv as an audio player. Since I often need the sup eruser to edit files, I made 'dv' in ~/.rcrc. `````````````````````````````````````````````````````````````````` fn dv {doas v $*} ``````````````````````````````````````````````````````````````````