Found a couple neat ideas that I'm going to steal--thx for sharing; but I must mention: Should probably be pgrep and pkill Should probably be setsid -f or at least use the double subshell trick...
Found a couple neat ideas that I'm going to steal--thx for sharing; but I must mention:
running foo is like ps aux | grep foo
Should probably be pgrep and pkill
bb my_command is like my_command & but it really really runs it in the background
Should probably be setsid -f or at least use the double subshell trick (ie. ((command &) &) which immediately backgrounds the process and orphans it, effectively daemonizing it)
A lot of cool ideas here, I especially like nato bar - I feel there's been a handful of occasions lately where I'm trying to read a string of letters and numbers verbally and it's been difficult....
A lot of cool ideas here, I especially like nato bar - I feel there's been a handful of occasions lately where I'm trying to read a string of letters and numbers verbally and it's been difficult. It may just be a better web app for my use case though - since it's often a phone call issue, having it on my phone would be the most beneficial.
I tend to string commands together that I use all the time into aliases in zsh. Some of my favorites: # common ways I style ls commands alias lsc="ls --color" alias lsa="ls -lha --color" alias...
I tend to string commands together that I use all the time into aliases in zsh. Some of my favorites:
# common ways I style ls commands aliaslsc="ls --color"aliaslsa="ls -lha --color"aliaslsd="ls -d --color */"aliaslsall="ls -latrh --color */"# I need cls like I need cd and lsaliascls="clear"# If you connect via SSH it'll ask for a fingerprint of your machine on each new client.# I got tired of looking up and copying this commandaliasfingerprint="ssh-keygen -E md5 -lf <(ssh-keyscan localhost 2>/dev/null)"# Technically only . ~/zshrc is doing anything useful.#The rest is# 1) an anonymous function that echos what I'm doing# 2) does what I said I'd do# 3) then confirms we're still in zsh.aliassrc="() { echo 'Reloading ZSH'; . ~/.zshrc; echo $0 }"# I honestly forgot that these aren't real commands I use them so dang much.aliashome="cd ~/"aliaswhichenv="echo $VIRTUAL_ENV"
What this does is it it updates homebrew, upgrades any packages that need upgrading, and then it clears the cached downloads. (Edited to take out the mkcd command as it... doesn't work.)
For things like your lsc, I prefer to just alias ls to itself along with some others where I pretty much never want the vanilla defaults. alias ls="ls --color=auto" alias grep="grep --color=auto"...
For things like your lsc, I prefer to just alias ls to itself along with some others where I pretty much never want the vanilla defaults.
For the very rare occasions where I actually do want the default behavior, prefixing the command with backslash disables alias expansion. E.g., \ls. This way, I give my common case the shorter name, and the uncommon case the longer name.
$ alias alias clip='xsel --clipboard --input < ' alias cls='clear' alias dj='cd $HOME/dev/java/keenwrite' alias gc='git commit -a -m' alias gp='git push' alias rd='rmdir' The dj alias points to...
I'm definitely going to have steal some of these. (Both from the article, from this thread, and from the HN thread.) Anyway, in the spirit of sharing here are some Zsh aliases and functions of my...
I'm definitely going to have steal some of these. (Both from the article, from this thread, and from the HN thread.)
Anyway, in the spirit of sharing here are some Zsh aliases and functions of my own:
rshare recurses through a directory tree and for each file or directory copies my user permissions, minus write access, to group and other. I usually run locked down with umask 077, so rshare makes things accessible to others. runshare revokes those perms. runexec is useful for cleaning up directory trees copied from Windows filesystems where the executable bit comes set on everything.
function go(){local i;for i ($@);do xdg-open $i;done}
I use this one constantly. It opens up a file or list of files with whatever desktop program is assigned to them. Or for directories, it shows me the contents in the desktop file browser, etc. (Regarding the name, I was using a version of this alias long before Golang existed, damnit!)
Quick edits in Emacs via the client. I have Emacs set to launch the server on startup, and ec just tells that instance to open whatever files I give it and then immediately returns. It's useful when I'm just cding around in the terminal and want to pop a file into my Emacs window. cde kind of goes the opposite direction and tries to cd me into the directory holding the active buffer's file.
Some image utilities: opng crunches down PNG files as much as possible, toimg renders stdin or a text/source file to a syntax highlighted image, pdf2png renders the pages of a PDF to images.
And finally a grab bag: pdiff uses Git's patience diff on two arbitrary files (which may be outside of repos), attach tries to attach the GDB debugger to a running process by name so I don't have to look up the PID, alarm takes a time in seconds and a command to run and kills the command after the time is up, countdn takes a time in seconds and gives me a little count down (useful when I want to delay or stagger the start times of some commands to run unattended), vbreak shows a honking big bold magenta divider bar with timestamp that I can't miss in the scrollback buffer, and echob just echoes some text in bold red.
I use this a lot to create a directory and enter it in one shot mkcd() { mkdir $1 && cd $_ } in skhd I have skip ahead and skip back in big and small for Kodi. Its on a different box with a screen...
I use this a lot to create a directory and enter it in one shot
mkcd(){
mkdir $1&&cd$_}
in skhd I have skip ahead and skip back in big and small for Kodi. Its on a different box with a screen just to my left -- so instead of moving my hands for the remote or the remapped keypad, I can use hyper + vim keys to skip ahead etc.
hyper - k : curl -s -u "username:password" -X POST http://pear:8080/jsonrpc -H "Content-Type: application/json" -d '{"jsonrpc
":"2.0","id":1,"method":"Player.Seek","params":{"playerid":1,"value":{"step":"smallbackward"}}}
I have similar key combos to control Hue lights, too -- but that calls a proper script.
Good article, and good thread to keep an eye on! I use the following oneliner to open a document of notes for the day: #!/bin/bash exec $EDITOR $HOME/docs/notes/$(date --iso-8601).txt I'll warn...
Good article, and good thread to keep an eye on!
I use the following oneliner to open a document of notes for the day:
I'll warn that it's for GNU date and I don't know that *BSD or busybox implement --iso-8601.
I use this to browse and search my music library with fzf and play back albums using audacious:
#!/bin/bash
cd $HOME/storage/musik/shared
case "$1" in
"") exec fzf --walker=dir --bind "enter:execute($0 play {})" ;;
play) audacious "$2" & disown ;;
esac
The library is organized in an <artist name>/<album name> hierarchy, and I tend to listen to music in units of albums. Consequently I don't use the library features of audacious.
I also use the following script to synchronize the music library to VLC on my phone (an Iphone) using ifuse and rsync:
I have a gitviz/gitvizl that visualizes the commit tree in the terminal with nice coloring. The regular variant just shows the head of every branch and the merges, the l suffix shows every commit....
I have a gitviz/gitvizl that visualizes the commit tree in the terminal with nice coloring. The regular variant just shows the head of every branch and the merges, the l suffix shows every commit.
For a Particular project or environment, usually make a cgrep (code grep) that aliases grep with exclusions for folders I don't want to search like .git, node_modules, build, dist, coverage, etc.
I wrote a program called ask that passes the rest of the line to an llm as a prompt and asks it to return a command and only a command, then offers to cool it to the clipboard. It has a few optimizations, like if you mention git/commit/merge it will include the output of git status, and if you mention a file in the current directory it will inckude the first 500kb of it. Though I guess it's not a script (go compiled binary).
I used to have a script called slackit that I could append to long running tasks to get a notification that they finished.
Found a couple neat ideas that I'm going to steal--thx for sharing; but I must mention:
Should probably be
pgrepandpkillShould probably be
setsid -for at least use the double subshell trick (ie.((command &) &)which immediately backgrounds the process and orphans it, effectively daemonizing it)A lot of cool ideas here, I especially like
nato bar- I feel there's been a handful of occasions lately where I'm trying to read a string of letters and numbers verbally and it's been difficult. It may just be a better web app for my use case though - since it's often a phone call issue, having it on my phone would be the most beneficial.I tend to string commands together that I use all the time into aliases in zsh. Some of my favorites:
What this does is it it updates homebrew, upgrades any packages that need upgrading, and then it clears the cached downloads. (Edited to take out the mkcd command as it... doesn't work.)
re
home, you can get the same effect by just runningcd!I knew there had to be something like that out there. Thanks!
For things like your
lsc, I prefer to just aliaslsto itself along with some others where I pretty much never want the vanilla defaults.For the very rare occasions where I actually do want the default behavior, prefixing the command with backslash disables alias expansion. E.g.,
\ls. This way, I give my common case the shorter name, and the uncommon case the longer name.Nice! I’ll probably incorporate some of that into my zshrc tonight after work! Thank you.
One alternative you could do is SSH Art 🎨😎
There’s always something new and interesting to learn about POSIX. Very cool! Thanks!
The
djalias points to whatever project has my attention. Theclipalias will copy the contents of a file to the clipboard, ready for pasting.Scripts of note:
I'm definitely going to have steal some of these. (Both from the article, from this thread, and from the HN thread.)
Anyway, in the spirit of sharing here are some Zsh aliases and functions of my own:
rsharerecurses through a directory tree and for each file or directory copies my user permissions, minus write access, to group and other. I usually run locked down withumask 077, sorsharemakes things accessible to others.runsharerevokes those perms.runexecis useful for cleaning up directory trees copied from Windows filesystems where the executable bit comes set on everything.I use this one constantly. It opens up a file or list of files with whatever desktop program is assigned to them. Or for directories, it shows me the contents in the desktop file browser, etc. (Regarding the name, I was using a version of this alias long before Golang existed, damnit!)
Quick edits in Emacs via the client. I have Emacs set to launch the server on startup, and
ecjust tells that instance to open whatever files I give it and then immediately returns. It's useful when I'm justcding around in the terminal and want to pop a file into my Emacs window.cdekind of goes the opposite direction and tries tocdme into the directory holding the active buffer's file.Some image utilities:
opngcrunches down PNG files as much as possible,toimgrenders stdin or a text/source file to a syntax highlighted image,pdf2pngrenders the pages of a PDF to images.And finally a grab bag:
pdiffuses Git's patience diff on two arbitrary files (which may be outside of repos),attachtries to attach the GDB debugger to a running process by name so I don't have to look up the PID,alarmtakes a time in seconds and a command to run and kills the command after the time is up,countdntakes a time in seconds and gives me a little count down (useful when I want to delay or stagger the start times of some commands to run unattended),vbreakshows a honking big bold magenta divider bar with timestamp that I can't miss in the scrollback buffer, andechobjust echoes some text in bold red.I use this a lot to create a directory and enter it in one shot
in skhd I have skip ahead and skip back in big and small for Kodi. Its on a different box with a screen just to my left -- so instead of moving my hands for the remote or the remapped keypad, I can use hyper + vim keys to skip ahead etc.
I have similar key combos to control Hue lights, too -- but that calls a proper script.
Good article, and good thread to keep an eye on!
I use the following oneliner to open a document of notes for the day:
I'll warn that it's for GNU date and I don't know that *BSD or busybox implement
--iso-8601.I use this to browse and search my music library with fzf and play back albums using audacious:
The library is organized in an <artist name>/<album name> hierarchy, and I tend to listen to music in units of albums. Consequently I don't use the library features of audacious.
I also use the following script to synchronize the music library to VLC on my phone (an Iphone) using ifuse and rsync:
I have a
gitviz/gitvizlthat visualizes the commit tree in the terminal with nice coloring. The regular variant just shows the head of every branch and the merges, thelsuffix shows every commit.For a Particular project or environment, usually make a
cgrep(code grep) that aliases grep with exclusions for folders I don't want to search like .git, node_modules, build, dist, coverage, etc.I wrote a program called
askthat passes the rest of the line to an llm as a prompt and asks it to return a command and only a command, then offers to cool it to the clipboard. It has a few optimizations, like if you mention git/commit/merge it will include the output ofgit status, and if you mention a file in the current directory it will inckude the first 500kb of it. Though I guess it's not a script (go compiled binary).I used to have a script called
slackitthat I could append to long running tasks to get a notification that they finished.