Anyone else adding "verbose", "interactive" and "recursive" to basic file commands?

As a person raised by GUIs, an extra visual confirmation and an extra prompt is a nice touch. I also like when the system says “Oh, is that a directory? No problem, I’ll give you the usual treatment.” You know what I mean?

<pre style="background-color:#ffffff;">
<span style="color:#323232;">alias ls='ls --group-directories-first --color=auto -w 120'
</span><span style="color:#323232;">alias ll='exa --group-directories-first -l'
</span><span style="color:#323232;">alias la='ll -a'
</span><span style="color:#323232;">alias lt='ll --tree'
</span><span style="color:#323232;">
</span><span style="color:#323232;">alias cp='cp --recursive --interactive --verbose --reflink=always'
</span><span style="color:#323232;">alias mv='mv --interactive --verbose'
</span><span style="color:#323232;">
</span><span style="color:#323232;"># custom pwd
</span><span style="color:#323232;"># - replace $HOME with ~
</span><span style="color:#323232;"># - make everything before the last '/' green, and everything after white and bold
</span><span style="color:#323232;"># - alias to p
</span><span style="color:#323232;">alias pwd="pwd | sed 's:$HOME:~:' | sed -E 's:(.*/)([^/]+):x1b[32m1x1b[0mx1b[1m2x1b[0m:'"
</span><span style="color:#323232;">alias p="pwd"
</span><span style="color:#323232;">
</span><span style="color:#323232;"># custom cd.
</span><span style="color:#323232;"># - prints the new directory after cd'ing.
</span><span style="color:#323232;">cd () { 
</span><span style="color:#323232;">    command cd "$@" && p;
</span><span style="color:#323232;">}
</span><span style="color:#323232;">alias c="cd"
</span><span style="color:#323232;">alias '..'='c ..'
</span><span style="color:#323232;">alias '...'='c ../..'
</span><span style="color:#323232;">
</span><span style="color:#323232;"># For the '~' alias, we want to use the original cd because printing '~'
</span><span style="color:#323232;"># again would be redundant.
</span><span style="color:#323232;">alias '~'='command cd'
</span><span style="color:#323232;">
</span><span style="color:#323232;"># custom rm.
</span><span style="color:#323232;"># adds a '-r' flag only if there is a single argument and that argument
</span><span style="color:#323232;"># is a directory.
</span><span style="color:#323232;"># This is because I want the behavior of -I (interactive) to be the default,
</span><span style="color:#323232;"># but I also want to have the -r flag available when I need it without being
</span><span style="color:#323232;"># prompted for single files.
</span><span style="color:#323232;">function rm () { 
</span><span style="color:#323232;">  if [ $# -eq 1 ] && [ -d "$1" ]; then
</span><span style="color:#323232;">    rm --verbose --interactive=once --recursive "$1";
</span><span style="color:#323232;">  else
</span><span style="color:#323232;">    rm --verbose --interactive=once "$@";
</span><span style="color:#323232;">  fi;
</span><span style="color:#323232;">}
</span><span style="color:#323232;">
</span><span style="color:#323232;"># mkdir + cd (created as a function because they run on the current shell,
</span><span style="color:#323232;"># which is what we want for cd)
</span><span style="color:#323232;">mc () { 
</span><span style="color:#323232;">  mkdir -p -- "$1" && cd -P -- "$1";
</span><span style="color:#323232;">}
</span>
rubin,

The problem I have with this kind of thing is: I work on hundreds of different vms and containers and they can’t all be setup like this AND have root and system accounts be setup like this. So you get too used to it one place and forget its not there when trying to troubleshoot. These days i tend to try and keep my shell simple so my skills transfer easily anywhere.

poinck,

Same here, I even don't have ll in my vocabulary, although it seems to be a default on Debian based systems.

lungdart,
@lungdart@lemmy.ca avatar

If you’re allowed docker in your systems, build a sysadmin container with all your favorite tools. Then just run it locally and remotely with the root directory bound to /mnt or something

lynny,
@lynny@lemmy.world avatar

Be careful, as this can easily break many scripts.

sebastiancarlos,

shouldn’t be a problem because scripts are run non-interactively and my .bashrc wouldn’t be read, right?

monotrox,

Thats actually good to know, thanks

mo_ztt,
@mo_ztt@lemmy.world avatar

I definitely type cp -i and mv -i by habit, and I have a ~/trash directory that I often move stuff into instead of deleting it and then periodically blow away completely. I agree with some other commenters that all the stuff in .bash_profile is maybe not a good idea, but I find that just doing those three things creates a lot more safety than just the "you said to remove it so now 5ms later it's gone forever" Unix default.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • wartaberita
  • uselessserver093
  • Food
  • [email protected]
  • aaaaaaacccccccce
  • test
  • CafeMeta
  • testmag
  • MUD
  • RhythmGameZone
  • RSS
  • dabs
  • Socialism
  • TheResearchGuardian
  • SuperSentai
  • feritale
  • oklahoma
  • Testmaggi
  • KbinCafe
  • Ask_kbincafe
  • KamenRider
  • All magazines