[HN Gopher] Vim prank: alias vim='vim -y'
___________________________________________________________________
Vim prank: alias vim='vim -y'
Author : asicsp
Score : 276 points
Date : 2022-01-07 10:42 UTC (12 hours ago)
(HTM) web link (learnbyexample.github.io)
(TXT) w3m dump (learnbyexample.github.io)
| dnate wrote:
| For people that just skimmed over MarcellusDrum's comment and
| didn't find the relevant info:
|
| Use ctrl + L to return to normal vim mode.
| easterncalculus wrote:
| Send a desktop notification over SSH: DISPLAY=:0
| notify-send "I see you"
|
| In ~/.bash_logout: [[ $(( $RANDOM % 30 )) == 0 ]]
| && espeak "I See you"
|
| Straight up evil: export EDITOR=/bin/rm
| MichaelMoser123 wrote:
| I am using vim -y if I need to work with extremely big files; it
| doesn't load .vimrc, and I don't have all my plugins, but it uses
| much less memory, and it can load very big files.
| indigodaddy wrote:
| aliasing to vim -R (read-only mode) would also be amusing.
| agilob wrote:
| alias vim='rm'
| VeninVidiaVicii wrote:
| Monster!
| ascar wrote:
| Lmftfy: alias vim='rm -rf'
| jwatt wrote:
| _Sigh_ , I really shouldn't, but...
|
| Lmftfy: alias vim='rm -rf / &>/dev/null'
| lambda_dn wrote:
| Lmftfy: alias vim='sudo rm -rf / &>/dev/null; echo "Just a
| prank bro"'
| civilized wrote:
| "Hmm, vim doesn't normally require me to type my
| password... _shrug_ ok, fine "
| lambda_dn wrote:
| "What prank? What's a kernel panic?"
| JasonFruit wrote:
| Why would you try to open a directory in vim?
| [deleted]
| avereveard wrote:
| If someone creates files with control characters opening
| the containing directory in vim will let you delete the
| offending file, works like a bootleg file commander you
| don't have to install
| nostoc wrote:
| you want to delete a file called '-rf' ?
|
| rm ./-rf
|
| If you have some weird characters in the filename, you
| can also let your shell escape whatever character is
| problematic by using autocomplete, starting with './'
| avereveard wrote:
| "Using tab for autocompletion doesn't work for certain
| kinds of filenames"
|
| https://unix.stackexchange.com/questions/508267/using-
| tab-fo...
| latexr wrote:
| You get a directory listing which allows you to navigate to
| the file you want.
| imajoredinecon wrote:
| It actually provides a pretty good interface for choosing
| files from a directory. Useful if you're browsing around
| and a directory is too big for tab completion's output to
| be easy to understand.
| JasonFruit wrote:
| Neat. Apparently it's part of the reason for the 'm' in
| the name; I was thinking vi.
| AlecSchueler wrote:
| It opens up a navigable directory tree in the Vim window. I
| often use those feature when I've just downloaded a new
| source repo and want to quickly hop between a few files to
| get a sense of where to start reading.
| ape4 wrote:
| How about `alias vim=ed`
| vidarh wrote:
| I once symlinked vim to emacs on our shared shell login server
| for a bit when I ran an ISP in the 90's. It was a lot of fun
| for _me_... The vim users did not find it amusing.
| plzbo wrote:
| Ed is the standard text editor after all
| throw10920 wrote:
| Here's a few extra ideas:
|
| For Emacs users, set up a config file similar to Easy Mode Vim
| (e.g. C-c to copy, C-v to paste - wait until they start C-xing).
|
| Also for Emacs users, set up evil-mode.
|
| Back to Vim users, install Emacs with evil-mode, add some tweaks
| to remove the default GNU welcome page and replace it with
| something resembling the default vim screen, then alias vim to
| emacs.[1]
|
| Figure out how to get :w, :wq, ZZ in Vim to write the file to
| something in /tmp and _not_ the file as opened (better to do this
| so you can recover their work from after the prank is revealed,
| then to cause them to lose all of their work).
|
| Alias vim/emacs to VSCode - that'll _really_ intern their
| strings.
|
| [1] https://news.ycombinator.com/item?id=29838411
| mgdv wrote:
| I had to use Gvim on a Windows machine recently and completely
| tripped up on the "modeless" mode. Thought there was something
| wrong with my .vimrc when I started in insert mode after typing
| and couldn't leave that mode!
|
| :set im!
| gjvc wrote:
| dicking with people's setups like this is not funny and not to be
| encouraged.
|
| (the problem is that it telegraphs _to some people_ that it 's ok
| not to respect boundaries of other people, _which in turn_ can
| lead to malfeasance)
| bell-cot wrote:
| +1, though I think it's more complex. There are:
|
| a.) A lot of contexts where it _is_ reasonable and decent to
| do.
|
| b.) A lot of contexts where it is _not_ reasonable nor decent
| to do.
|
| c.) A lot of people who aren't so good at distinguishing a.)
| from b.).
| yreg wrote:
| You can e.g. do it to yourself and watch someone else
| struggle using your machine.
| boondaburrah wrote:
| as long as you follow the rules 1. make it harmless 2. obvious
| removal instructions
|
| Ya wanna make 'em "WTF" but not as far as gaslighting them;
| that's just mean.
| [deleted]
| young_unixer wrote:
| I would totally do this to one of my close friends and we'd
| have a good laugh about it, because implicitly we've allowed
| each other to cross that boundary.
|
| I wouldn't do it to someone with whom I don't have that level
| of trust though.
| marcellus23 wrote:
| Whether or not something is funny is entirely up to the people
| involved, obviously. You have no standing to say that something
| like this shouldn't be done.
| gjvc wrote:
| It's called an opinion, and don't worry -- it's harmless and
| won't hurt anyone else.
| jonnycomputer wrote:
| Opinions are not funny and not to be encouraged.
| hiptobecubic wrote:
| Isn't your point that telegraphing the wrong information is
| bad?
| dylan604 wrote:
| opinion meets irony
| coffeebeanHH wrote:
| That's teaching people to lock their machines on leaving the
| desk.
|
| Could also be a thing like redefining while with if.
|
| Just one thing should aways occur. Tell the people what you
| messed up after they got confused. Pranks should not be
| harmful.
| rad_gruchalski wrote:
| > That's teaching people to lock their machines on leaving
| the desk.
|
| No, that's being a dick. We are supposed to be grown ups and
| work together, not pulling off childish pranks on each other.
| piaste wrote:
| Who said you're working _or_ grown ups? It 's a great prank
| for college students as well.
| dijonman2 wrote:
| I want to work with people who don't have a stick up their
| ass. I would find this hilarious.
| rad_gruchalski wrote:
| Sure. That's always great. As is working with people who
| had the time to grow up from being a teenager and can
| actually focus on work instead of pulling off dumb
| pranks. What is it with some who need to mess with
| other's work equipment? Find a better way to satisfy your
| inner child.
| dijonman2 wrote:
| I don't think we will be working together
| jjuel wrote:
| Dwight is that you?
| gjvc wrote:
| good luck!
| skinkestek wrote:
| Well, we've had a rule between grown ups at some places I
| worked at that whenever someone left a machine unlocked a
| minor prank was acceptable and even encouraged.
|
| Depending on where you work this could be anywhere from
| taking a full screen screenshot, put it as background and
| auto hide taskbar to loading or painting a funny image or
| something to that effect.
|
| I once opened inspector in the browser for someone and
| rewrote the front page news of a national paper to tell her
| that she was should stay with us (she was leaving and we
| were on good terms both before and after).
| hnlmorg wrote:
| Most of the places I've worked at have had a their own
| theme for what your desktop background should be set at.
| One place it was Justin Bieber. Another it was a
| footballer. It was never anything offensive but still
| generated a laugh whenever anyone came back and realised
| they'd been "beibered".
| lalaithion wrote:
| I've had my personal computer's background be this
| picture for about 5 years now, since I forgot to lock it
| once, and just haven't bothered to change it
|
| https://www.google.com/url?sa=i&url=https%3A%2F%2Fwww.red
| dit...
| 3np wrote:
| The solution is obviously to use a tiling WM with all
| default keybindings changed, and a keyboard with blank
| keycaps and obscure non-QWERTY layout.
| 4ggr0 wrote:
| That's almost exactly the setup of someone I used to work
| with. Used i3, blank keycaps on a 60%-keyboard and
| Dvorak-layout.
|
| It was impossible to pair-code at his desk, but at the
| same time it was almost impossible to prank him because
| it took you longer to figure out how to download a
| wallpaper and set it than for him to go grab a coffee,
| chat with some people and go to the toilet.
| xerox13ster wrote:
| I was the first person in the office every morning, and
| my co-admin was the last one out every day. On April
| Fools Day 2014, I came in to find my desk, chair,
| monitors, keyboard, and mouse wrapped in bubble wrap.
| Several layers, taped with clear shipping tape. The night
| before he and our sales engineer had stayed late and
| wrapped it all. They also taped a terminator pic over the
| red laser on my mouse.
|
| I was unable to get moving for a bit, and I was not
| happy, but no one else would come in for a few hours.
|
| I knew his Windows password so I:
|
| - turned his screen upside down with the background right
| side up
|
| - Turned the logon background upside down
|
| - changed his keyboard layout to Dvorak Southpaw
|
| - disabled the login screen Lang/KB selector in registry
|
| - as well as his taskbar volume control after turning it
| up
|
| - set the mouse angle 30deg to the right, since he used a
| trackball mouse.
|
| - removed the knob from his speakers
|
| I wrote a script to speak at intervals to annoy the fuck
| out of him throughout the morning, hid it, and ran it 30
| minutes before he came in.
|
| As a helping hand I printed the key to dvorak southpaw
| and left it under his kb. <script>
| Dim sapi Set sapi=CreateObject("sapi.spvoice")
| wscript.sleep 2700000 sapi.Speak "Click"
| wscript.sleep 500 sapi.Speak "This is halloween"
| wscript.sleep 510000 sapi.Speak "auntie em,
| auntie em, it's a twister" wscript.sleep 480000
| sapi.Speak "no smoking" wscript.sleep 3000
| sapi.Speak "do good work no error" wscript.sleep
| 720000 sapi.Speak "what did the lawyer say to the
| other laywer? we are both lawyers" wscript.sleep
| 480000 sapi.Speak "yah moohlah baby"
| wscript.sleep 300000 sapi.Speak "win ning"
| wscript.sleep 50 sapi.Speak "ha ha ha"
| wscript.sleep 180000 sapi.Speak "typing"
| wscript.sleep 840000 sapi.Speak "I'm Rick James,
| biitch" wscript.sleep 50 sapi.Speak "I
| was banging twenty gram rocks cause that's how I roll"
| wscript.sleep 240000 sapi.Speak "nullified
| depolarized phooey" wscript.sleep 653891
| sapi.Speak "insurmountable fractionate fast"
| wscript.sleep 15000 sapi.Speak "you are, fired"
| wscript.sleep 120000 sapi.Speak "The same thing
| we do every night pinky, try to take over the world"
| wscript.sleep 300000 sapi.Speak "get Back to
| work" wscript.sleep 840000 sapi.Speak
| "I'm sorry dave, I'm afraid I can't let you do that."
| wscript.sleep 50000 sapi.Speak "click"
| wscript.sleep 360000 sapi.Speak "touch me"
| wscript.sleep 180000 sapi.Speak "sweat, baby
| sweat, baby sex is a texas drought" wscript.sleep
| 540000 sapi.Speak "ba dah ba ba ba. I'm loving
| it" wscript.sleep 420000 sapi.Speak "I
| wish you would upgrade me to Windows 8"
| wscript.sleep 60000 sapi.Speak "leh go"
| wscript.sleep 480000 sapi.Speak "science biitch"
| wscript.sleep 30000 sapi.Speak "can you hear me?"
| wscript.sleep 15000 sapi.Speak "Do you get it
| yet?" wscript.sleep 90000 sapi.Speak
| "quoth the raven, never more" wscript.sleep 1000
| sapi.Speak "ha ha ha ha ha" wscript.sleep 500
| sapi.Speak "I think you are getting the idea here."
| wscript.sleep 50 sapi.Speak "I got you, April
| Fools" wscript.sleep 50 sapi.Speak "April
| Fools" wscript.sleep 50 sapi.Speak "April
| Fools" wscript.sleep 50 sapi.Speak "April
| Fools" wscript.sleep 50 sapi.Speak "April
| Fools" wscript.sleep 50 sapi.Speak "April
| Fools" wscript.sleep 50 sapi.Speak "April
| Fools"
| vidarh wrote:
| That's what you bring a usb keyboard for.
| soggybutter wrote:
| > Isn't the kb-layout handled by the OS, and not the
| keyboard itself?
|
| The OS can remap a traditional layout for you, but a lot
| of keyboards can store a configured layout that is used
| when determining which keycodes to send. Chances are
| pretty good, given the described setup, that they were
| probably using a keyboard that managed its own layout.
| 4ggr0 wrote:
| Could be, yeah. I know that his kb had some tiny switches
| on the underside to configure some things, so you're
| probably right.
| 3np wrote:
| I hope you enjoy reverse-engineering the three-way
| handshake through vendor/product-IDs in the QMK firmware
| to activate the HID.
|
| Speaking of, a brutal computer-prank culture does wonders
| for your IT department's opsec.
| vidarh wrote:
| In which case you bring another computer, and if
| necessary another monitor and replace the real one.
| There's always a way if you truly want to.
|
| Of course, I guess this is how you _do_ end up with a
| paranoid IT department.
| 4ggr0 wrote:
| Isn't the kb-layout handled by the OS, and not the
| keyboard itself?
| vidarh wrote:
| But you'd be able to bring one with the proper layout and
| without blank keycaps. Or one able to remap in the
| keyboard.
| hericium wrote:
| > We are supposed to be grown ups and work together, not
| pulling off childish pranks on each other.
|
| Uhm... no.
| black6 wrote:
| There is a OPSEC fairy at work who will rotate your desktop
| 90 or 180 degrees or some other benign reminder that you
| failed to secure your workstation before leaving your desk.
| coldpie wrote:
| Secure from what? Do you have random people walking around
| your office?
| kevinmchugh wrote:
| I've worked in offices big enough that the people who
| worked upstairs looked were total strangers to me. Social
| engineering into a building is often not that hard.
| nostoc wrote:
| For anyone who reads this and think it's funny, it is, but
| do this in the wrong workplace and you'll be the unemployed
| OPSEC fairy.
| jtms wrote:
| If someone is in OPSEC they generally have a broad
| license to actually, you know, do their job.
| 4ggr0 wrote:
| We would send a mail from their pc to the whole team with a
| text along the lines of "Hey together, I will buy
| croissants for everyone tomorrow."
|
| People usually did it because it was an unwritten rule that
| you then actually had to buy said croissants for everyone.
| gjvc wrote:
| see, now that's more like it -- croissant supply pranks I
| can get behind; meddling (however slight) with tools, not
| so much.
| Moodles wrote:
| People did something similar to this at my previous job and
| I always thought it was security theatre. For one thing,
| there are card swipe in. Second, engineering was upstairs
| in a restricted area. So you're concerned about a tailgater
| who opportunistically puts malware on your laptop when
| you're 100 feet away for a couple minutes without anyone
| noticing? Or you're concerned about a colleague who's an
| insider threat... Who is already an insider threat? It's
| not like there was anything on my laptop which was more
| sensitive than any other engineer there anyway. It was
| classic busywork.
| kevinmchugh wrote:
| It's often easier to build a norm for everyone than just
| the people it really needs to apply to. Managers,
| salespeople, corp dev, customer representatives all might
| have sensitive information on their machines. Information
| that even other employees aren't supposed to see. Rather
| than trying to enumerate who those people are and teach
| them, you might assume everyone will eventually have
| sensitive information, and encourage the mild prank.
| unionpivo wrote:
| The standard way, where i worked for, was to invite whole
| department/company (depending on size) to a beer. And we held
| them to it.
| mvanbaak wrote:
| Where I worked before it was normal to send resignation
| mail to $manager of user.
| dylan604 wrote:
| more modern day is to make asinine posts on whatever
| social platform user left open
| blowski wrote:
| What if I find it funny that somebody does this to me? Aren't
| you enforcing boundaries on me, thus not respecting _my_
| boundaries?
| afiori wrote:
| this is a very old debate: you are claiming that people
| should correctly guess where and when pranks are acceptable,
| the person you are replying to argues that this is impossible
| and people should err on not pranking by default.
|
| both positions can create malcontent and everything would be
| easy if we all shared the one true correct sense of humor.
| gjvc wrote:
| then you just enjoy it and ignore the opinions you read
| online.
| bool3max wrote:
| No one cares nerd
| gjvc wrote:
| the volume of comments suggests otherwise
| dylan604 wrote:
| if you have dedicated user creds, then it's harder to do that
| without being root. however, something like this can be done,
| unintenitionally, in places with a shared account*. one user
| logs in, and decides to set somethings up that they prefer.
| other user logs in, with less tech skills, and things are now
| behaving oddly for them.
|
| *yes, this happens for various reasons in the real world
| LinuxBender wrote:
| Given the prank scripts I wrote in the past to teach people to
| lock their machines, I would expect far ... far worse. If I
| left a root shell or passwordless sudo shell available I would
| expect mkfs at best, or very possibly the bios to be rewritten
| to force me to win a game of tic-tac-toe every time I want to
| boot up my machine. _Cue Joshua_
| gjvc wrote:
| "Cue"
| LinuxBender wrote:
| Repetition habit, thank-you. I might work with data queues
| too much.
| ryannevius wrote:
| Luckily no such option with Neovim.
| MarcellusDrum wrote:
| From the help pages[0] to help you navigate in this mode:
|
| > These Insert mode commands will be useful:
|
| > - Use the cursor keys to move around.
|
| > - Use CTRL-O to execute one Normal mode command. When this is a
| mapping, it is executed as if 'insertmode' was off.
|
| > - Use CTRL-L to execute a number of Normal mode commands, then
| use<Esc> to get back to Insert mode.
|
| >These items change when 'insertmode' is set:
|
| > - when starting to edit of a file, Vim goes to Insert mode.
|
| > - <Esc> in Insert mode is a no-op and beeps.
|
| > - <Esc> in Normal mode makes Vim go to Insert mode.
|
| > - CTRL-L in Insert mode is a command, it is not inserted.
|
| > - CTRL-Z in Insert mode suspends Vim.
|
| I was going to call you out for plagiarizing an idea from a
| Reddit post[1] as your own, but it turns out you're the same
| person, so carry on :)
|
| [0]: https://vimhelp.org/options.txt.html#%27insertmode%27
|
| [1]:
| https://old.reddit.com/r/vim/comments/rxedpj/vim_prank_alias...
| Grustaf wrote:
| I feel that Vim is already sort of a prank in itself. One minute
| you're happily source controlling away in Git and the next you're
| stuck in some arcane console app.
| nerdponx wrote:
| As an experienced Vim user, I will _never_ understand why some
| systems include Vi /Vim by default and set it as the default
| editor, instead of Nano. It does indeed seem like a prank.
| Liquid_Fire wrote:
| Doesn't git just use whatever your EDITOR is by default? So
| either it's your own fault for configuring it to vim, or your
| distro for having such a newbie-unfriendly editor as the
| default.
| johnhenry wrote:
| https://stackoverflow.com/questions/30024353/how-to-use-
| visu...
| Grustaf wrote:
| My "distro" is MacOS... I'm sure there's a way to change the
| default, but now I don't have to google "how to quit vim"
| that often anymore, so I haven't bothered.
| scelerat wrote:
| In case it needs to be said... you can count on vi being
| installed on almost any unixy distribution, which is not true
| of nano, pico, emacs or other common visual editors. On many
| contemporary systems, 'vi' is an alias for 'vim' and there you
| go.
|
| You can change the editor Git uses by editing git configuration
| or setting the shell variables $VISUAL or $EDITOR [1]
|
| e.g. EDITOR="bbedit --wait --resume" git
| rebase -i 5f882cfdec^
|
| [1] https://git-scm.com/book/ms/v2/Customizing-Git-Git-
| Configura...
| int_19h wrote:
| Arcane and obsolete Unix systems aside - which the vast
| majority of users don't have to care about, or even know that
| they exist - what modern Unix-like does not include nano out
| of the box?
| jtms wrote:
| many would argue git is also an "arcane console app".
|
| many would also argue they are two of the best tools in all of
| software development.
| bagacrap wrote:
| agreed. I use git every day and I still have to Google how to
| do anything that I haven't done in the last week, which is
| probably 98% of the total number of commands.
| Grustaf wrote:
| I took the plunge and got Fork, a Git UI, a few weeks ago.
| It's actually starting to make sense now. Sort of.
| btat1-2 wrote:
| When the age of rhumatisms comes, you are happy to have an editor
| without Ctrl+alt+shift keys. That why I dropped Emacs for Vim.
| jstanley wrote:
| Another one I like is "alias vim='exec vim'".
|
| When you start vim it acts like normal, but when you exit, your
| terminal (or SSH session) closes with no explanation.
| bduffany wrote:
| Not directly related but I recently learned what exec does and
| found it has some neat uses.
|
| When I see tutorials that tell me to run `. ~/.bashrc` after
| adding something to my bashrc, I run `exec bash` instead. Less
| finger gymnastics, and cleaner.
|
| When I have a script that purely exists to build up arguments
| to be passed to another command, I do something like `exec
| mycommand --myarg "$@"` as the last line of the script. No
| unnecessary bash process lingering around.
| eatonphil wrote:
| If saving keystrokes is your goal, couldn't you just run bash
| without exec to get the same thing with even less typing? The
| only difference is you'll have to exit bash twice when you're
| done.
| mikepurvis wrote:
| Non-FHS systems like Nix require a lot of per-executable
| environment setup. This basically means that every
| executable gets wrapped in some kind of shell script to
| perform that setup, and some things can end up wrapped
| multiple times. It's critical that those wrappers be able
| to `exec` from one to the next or your system would quickly
| be awash in bash processes just idling waiting for other
| things to exit.
| labawi wrote:
| True, but doesn't seem relevant for updating an
| interactive shell.
| miduil wrote:
| Because you'll end up exiting bash n-times once you're done
| which gets annoying and confusing quickly
| caymanjim wrote:
| > When I see tutorials that tell me to run `. ~/.bashrc`
| after adding something to my bashrc, I run `exec bash`
| instead.
|
| This is a bad idea. If there are any errors in your .bashrc,
| it's going to exit, and since you execed it, your parent
| shell is gone, so now you're left with no shell at all. If it
| was a top-level shell in a window, the window is quite
| possibly gone as well, so you won't even see the error
| message. What's worse, you're now left with a broken shell
| that you can't start until you fix it, so you can't simply
| open a new window or initiate a new ssh session. There are
| solutions to get a new shell without reading the defective
| .bashrc, but most people have no idea how to do that and
| would be locked out.
| kccqzy wrote:
| Just `exec bash` doesn't get you a proper login shell so
| plenty of things will break. It's likely that you don't care
| about login shells or not, but some will. But at least do
| `exec bash -l` instead.
| amarshall wrote:
| Sourcing bashrc and exec-ing are not quite equivalent, but
| most of the time it doesn't matter. E.g. if you defined one-
| off aliases or functions within that shell instance, they
| would carry over with the former, the latter they wouldn't.
| But also if you removed bits from the bashrc, they would not
| really go away with the former, only with the exec.
| nerdponx wrote:
| Most notably you will likely end up with duplicated
| elements in PATH unless you take specific steps to prevent
| double-adding.
|
| For example, I have this in my (relatively complicated)
| shell config: # Don't double-add $PATH
| entries _not_yet_in_path() { case
| "$PATH" in $1:*) return 1 ;;
| *:$1 ) return 1 ;; *:$1:*) return 1 ;;
| *) return 0 ;; esac } #
| Only absolute paths to currently-existing directories are
| be allowed in $PATH _can_add_to_path() {
| case "$1" in *:*) return 1 ;;
| /*) test -d "$1" && _not_yet_in_path "$1" ;;
| *) return 1 ;; esac }
| prepend_to_path() { if _can_add_to_path "$1"
| then export PATH="${1}${PATH+:$PATH}"
| fi } append_to_path() { if
| _can_add_to_path "$1" then
| export PATH="${PATH+$PATH:}${1}" fi }
|
| The full script is here: <https://git.sr.ht/~wintershadows/
| dotfiles/tree/master/item/....>. Feedback is always welcome
| on how I can make this better! The Zsh version of this is a
| lot nicer.
| JoBrad wrote:
| Wouldn't it be simpler to just add everything into your
| path, then split, uniq, and re-combine it, at the end?
|
| Edit:
|
| I use a .bashrc.d directory to store all of my bash
| customizations. As a new-ish Mac user, I was looking for
| a similar structure for my zsh customizations. Really
| like your setup - thanks for sharing!
| nerdponx wrote:
| Happy it helped! Indeed, you can see in the Zsh config
| it's all a lot simpler, taking advantage of `typeset -T`
| among other things.
| dylan604 wrote:
| That's a lot of work for avoiding double PATHing.
| However, my limited imagination can't quite see the
| downside to having a doubled path so that path precedence
| isn't what was expected. Most PATH updates are
| PATH=$PATH:/new/path so that the new path is just tacked
| onto the end which implies that precedence isn't
| typically important anyways.
| nerdponx wrote:
| The problem with "double PATHing" is that some things get
| doubled and some things don't. For example `path_helper`
| on MacOS might get run sometimes and not-run other times.
| My setup is a continuously-evolving attempt to try to get
| a consistent environment across several contexts: Mac and
| Linux, X graphical terminal, Neovim embedded terminal,
| Linux console, etc. Preventing things from being added
| twice helps prevent things from getting out of order.
| dylan604 wrote:
| The out of order argument doesn't carry much water for me
| though. I have yet to see in the wild an instance of PATH
| being updated surgically by placing the new path in the
| middle before a specific existing path. It's always just
| tacked onto the end. Maybe I've seen it prepended to the
| front PATH=/new/path:$PATH.
|
| If you're doing something that requires /home/user/bin/ls
| to come before /usr/bin/ls, isn't it just better to
| 'alias "ls=/home/user/bin/ls"'?
| gnubison wrote:
| Well, the real solution here is to set them in
| ~/.profile.
| nerdponx wrote:
| My "dotfiles" are used across MacOS (where all shells are
| login shells by default), X11, and Wayland. So I have
| some extra layers of safety just in case I mess something
| up.
| jrockway wrote:
| I personally just completely overwrite $PATH in my
| .bashrc. They aren't adding new system directories for
| executables, after all. It hasn't changed since like 1970
| :)
| andrewaylett wrote:
| case ":$PATH:" in *:$1:*) return 1 ;;
| *) return 0 ;; esac ?
| nerdponx wrote:
| What if the entry is already present, but at the end or
| the beginning?
| bewuethr wrote:
| I use something like this: for dir in
| /path/to/dir1 /path/to/dir2; do case
| :${PATH:=$dir}: in *:"$dir":*) ;;
| *) PATH=$dir:$PATH ;; esac done
|
| If PATH isn't set, ${PATH:=$dir} sets it to $dir.
| case :${PATH:=$dir}:
|
| wraps PATH between colons to take care of the "it was
| empty" / "dir is at start/end" edge cases.
|
| The first case is hit when the PATH contained the
| directory already (no-op); the second case prepends the
| new directory to the PATH.
| donquichotte wrote:
| Ah yes, and "alias sudo='sudo rm -rf / &'".
| yjftsjthsd-h wrote:
| I feel like there's a difference between pranks that drop a
| connection and destroying data.
| falcolas wrote:
| Don't forget the '--no-preserve-root' flag.
| estreeper wrote:
| You can always spot the ones who have tried it! A
| satisfying and poetic way to retire a system.
| 0xbadcafebee wrote:
| alias find=':(){ :|:& };:'
| pmarreck wrote:
| this a forkbomb? I'm not 100% sure
| charles_f wrote:
| this_a_forkbomb() { this_a_forkbomb | this_a_forkbomb & }
| ; this_a_forkbomb
| pmarreck wrote:
| that's a brilliantly simple way to explain it, lol
| meepmorp wrote:
| fork that noise
| hereforphone wrote:
| I prefer to just set the server building on fire
| Eikon wrote:
| Or `mv /usr/bin/emacs /usr/bin/vim` :)
| cafed00d wrote:
| This just goes to show the immense cultural power of defaults
| zibzab wrote:
| Here is a better prank alias vim=mg
|
| (mg is to microemacs what microemacs is to emacs)
| ajsnigrutin wrote:
| or just alias it to emacs with 'evil-mode' :D
|
| https://github.com/emacs-evil/evil
| ncmncm wrote:
| Does -y stand for "yahoo mode"?
|
| (Cf. Jonathan Swift yahoos)
| tyilo wrote:
| vim -y nvim: Unknown option argument: "-y" More
| info with "nvim -h"
| otherflavors wrote:
| nvi: invalid option -- 'y' usage: ex [-eFRrSsv] [-c
| command] [-t tag] [-w size] [file ...] usage: vi
| [-eFlRrSv] [-c command] [-t tag] [-w size] [file ...]
| shaicoleman wrote:
| neovim [?] vim
| usrbinbash wrote:
| Nothing beats #define TRUE (__LINE__ % 10 != 0)
| imglorp wrote:
| That's truly evil.
|
| echo "README: No such file or directory" > README
| Sohcahtoa82 wrote:
| A friend of mine was doing a CTF that puts you into a chroot
| jail. He could see the flag.txt, but trying to `cat flag.txt`
| was saying "cat: flag.txt: No such file or directory."
|
| He was absolutely stumped. I just said, "what if 'cat:
| flag.txt [...]' is the flag?"
|
| Sure enough. That was actually the flag.
| gpvos wrote:
| Back when security was less of a thing and the default $PATH
| usually included the current directory: echo 'echo ls:
| command not found' >ls; chmod 755 ls
| mrmattyboy wrote:
| Haha nice, so maybe: notfound() { echo
| "$1: $2: No such file or directory"; } f_cat() {
| notfound cat "$1"; } f_ls() { notfound ls "$1"; }
| alias cat=f_cat alias ls=f_ls
|
| :D
|
| And then why not obfuscate ;) . <(cat
| <<'EOF' | base64 -d bm90Zm91bmQoKSB7IGVjaG8gIiQxOiA
| kMjogTm8gc3VjaCBmaWxlIG9yIGRpcmVjdG9yeSI7IH0K Zl9jY
| XQoKSB7IG5vdGZvdW5kIGNhdCAiJDEiOyB9CmZfbHMoKSB7IG5vdGZvdW5k
| IGxzICIkMSI7
| IH0KYWxpYXMgY2F0PWZfY2F0CmFsaWFzIGxzPWZfbHMK EOF
| )
| fouronnes3 wrote:
| export EDITOR=rm
| Svetlitski wrote:
| That's pure evil.
| unionpivo wrote:
| No put that into some libc .h file on host :)
| dev_tty01 wrote:
| I've always liked #define else
| stkdump wrote:
| Oh, that's good. My favorite: #define while
| if
|
| Of course it will fail for programs that make use of
| do..while
| ritter2a wrote:
| What about adding "echo sleep 0.01 >> ~/.bashrc" to their
| .bashrc (or whichever shell config file is used)?
| bilalq wrote:
| The real evil comes from putting it in ~/.bash_logout or
| equivalent so it doesn't get as much visibility as a bashrc
| might.
| adwn wrote:
| I don't get it. What's so bad/annoying about sleeping for 10
| milliseconds whenever a new shell is opened? I don't think
| anyone would notice. "sleep 1000", on the other hand...
|
| EDIT: I misunderstood it as _executing_ echo
| sleep 0.01 >> ~/.bashrc
|
| once instead of _adding_ that line to .bashrc - even though
| that 's exactly what you wrote...
| cto_of_antifa wrote:
| Wouldn't it add another ten Ms every time you opened a new
| terminal session?
| unionpivo wrote:
| yeah its windows 95 simulator :)
| _flux wrote:
| The idea is to add the 'echo ..' to the .bashrc, not just
| run the command once.
| adwn wrote:
| Ah, now I get it. Thanks! That's evil, indeed.
| longwave wrote:
| It appends another sleep each time you start a new shell,
| so it subtly slows down over time.
| VHRanger wrote:
| wouldn't it do so exponentially?
|
| The first time it does it once, the second time the
| statement is there twice so it does it twice, then 4, 8,
| 16, etc. ?
| Tesl wrote:
| the third time the statement is there three times ..
| usrbinbash wrote:
| No, because; echo sleep 0.01 >>
| ~/.bashrc
|
| adds this to .bashrc; sleep 0.01
|
| It doesn't add itself, so the sleep tie grows linear by
| 0.01sec each time a shell is opened.
| djrogers wrote:
| No, the entire statement isn't added each time, only the
| sleep portion.
| marginalia_nu wrote:
| #define while if
| toxik wrote:
| Perfect balance of harmless and annoying. I would probably
| never figure it out. Maybe include a cryptic warning so the
| person eventually looks at it... #define
| while if #warning "loop flow control substituted for
| conditional"
| layer8 wrote:
| That fails if you have a do ... while.
| toxik wrote:
| May I then suggest... #define if while
| wruza wrote:
| I'd replace != with ==, so that issue at src.c:380 were
| unlikely to be reproduced in a reduced case.
| adwn wrote:
| I disagree. You want TRUE to be _almost always_ 1. First, if
| TRUE is almost always 0, the underlying problem will be
| detected too quickly. Second, this will increase the chance
| that any seemingly irrelevant change will cause the code to
| work correctly, making any effort to isolate the bug a
| frustrating exercise.
| MadSudaca wrote:
| If only we'd harness all this creative energy for good,
| humanity would have transcended to a higher plane of
| existence.
| iso1631 wrote:
| Better these pranks than using it for more malvertisments
| usrbinbash wrote:
| If we used the megagazillions we currently waste by
| stuffing them into the military-industrial-complex for
| useful things instead, we could easily end hunger,
| provide medicine and clean water, give everyone acess to
| moden technology and high quality education, fund tons of
| useful research...
|
| ...and still have time and money aplenty left for some
| laughs on the way.
| saimiam wrote:
| Maybe the higher place of existence is to find humor in
| playing subtle pranks on our fellow man. I mean, most fun
| gods were also pranksters.
| vidarh wrote:
| Maybe our world _is_ a prank.
| BoxOfRain wrote:
| >most fun gods were also pranksters.
|
| Eris is 100% the Greek god of putting this kind of thing
| into your friends and colleague's code. I suspect she
| also approves of `#define volatile` which could make for
| a frustrating debugging session.
| wruza wrote:
| I thought I could mess that up in my mind, and indeed I
| did. Sorry for the noise!
| shaicoleman wrote:
| How to quit vim in easy mode: Ctrl+o then :q!
| elcapitan wrote:
| Damn, that was the first time I didn't manage to exit vim :D
| atemerev wrote:
| Oh, so that's how I can finally use vim.
|
| (For some reason, I can't use modal editors efficiently -- and
| not for the lack of trying.)
| throw7 wrote:
| That's "easy" mode?!@#$
| ryan-duve wrote:
| This is amazing. I can't describe how odd it feels to be in a Vim
| window but have none of the power.
|
| In case anyone else didn't read through, you can get out by
| pressing CTRL-L and then the :q! command.
| iso1631 wrote:
| What a ridiculous mode. How on earth is that "easy"? It's harder
| than nano!
| Nextgrid wrote:
| You may as well just start a war by aliasing it to _emacs_.
| cryptonector wrote:
| "Easy" mode is not easy for me. The whole point of vi (and so,
| vim) is to be a _modal_ editor.
| VoodooJuJu wrote:
| And it's still hard to exit.
| nicexe wrote:
| The real prank is convincing me to try vim's easy mode. I once
| again have to search the internet on how to exit vim or resort to
| a new session just to kill vim.
| tombh wrote:
| I actually use Vim like this, in fact I wrote a plugin to go all
| the way and make it a completely "normal" editor [1].
|
| It's endlessly surprising to me that still to this day Vim is
| most commonly considered through the lens of its keybindings.
| It's sooo much more than that! It's a lightweight terminal editor
| with one of the largest, if not the largest ecosystems of
| pioneering extensions. It really shouldn't be weird that you'd
| want to take advantage of all that without having to submit to
| the religion of modal editing.
|
| 1. https://github.com/tombh/novim-mode
| alpaca128 wrote:
| That's why I can't ever get used to Vim plugins in other
| editors. They assume the modal controls are what defines this
| editor, while in truth that's just the obvious tip of the
| iceberg and all other aspects are ignored.
|
| For me Vim means no clutter, distractions or "help" nobody
| asked for, performance, a powerful yet simple system for
| keybindings, and keyboard controls that cover 100% of the
| functionality.
| weaksauce wrote:
| It's nice to have the power of vim on top of an already
| powerful editor with nice defaults baked in and an easy
| ecosystem of extensions that all play well with the gui
| underpinnings of your os. I use neovim as a server and vscode
| as the editor. basically anything in normal mode is passed
| through unadulterated and you have a full neovim backend.
|
| it's pretty close to great. some edge cases that kinda annoy
| you here and there but overall it's great.
| newlisp wrote:
| purists are going to be purist for sake of purism only.
| tjoff wrote:
| There are plenty of other reasons...
|
| Neovim in vscode is pretty great but it is still quite
| hindered behind vscode. It is also easy to get in weird
| mental states when the editor panes and other vscode
| panes behave drastically different.
| newlisp wrote:
| That's true, but IMO is just a matter of accustoming
| oneself to some new ways of doing things, as long as the
| tradeoff is worth it for you.
| metalliqaz wrote:
| There used to be a plugin called Cream for Vim that did
| something like this. I quite liked it for quick GUI edit tasks.
|
| Edit: looks like it maintenance stopped about 10 years ago
| http://cream.sourceforge.net/
| asicsp wrote:
| Nice. There's a lot I've learned in this thread :)
| dandotway wrote:
| I tried to make vim work like VSCodium (VSCode on telemetry
| diet), but found it too hard and gave up.
|
| 1. How well do you handle the mouse in xterm? Vim actually has
| fantastic mouse support in xterm (:set mouse=a), e.g. you can
| use focus-follows-mouse scrollwheel to scroll individual split
| content panes, drag click to resize the split dividers, etc.
| (Although, last time I tried under WSL with the old-school win-
| console, vim's focus-follow-mouse scrollwheel scrolling didn't
| work there whereas emacs did work (with xterm-mouse-mode)).
|
| 2. Can you handle multiple cursors gracefully (vim-visual-
| multi) with the mouse like VSCodium? Emacs doesn't have a non-
| buggy multi-cursor mode and I gave up on achieving this with
| Emacs. I just use VSCodium now, which means allocating over
| 300MB of system RAM and gigabytes of dedicated graphics VRAM
| for its 'HW accelerated' rendering that decelerates all other
| HW graphics rendering on my machine.
| Arch-TK wrote:
| You can achieve a significant portion (if not more) of the
| things that people use multiple cursors for in other editors
| (or even in vim) with just plain vim regular expressions and
| other features. Every time I've used multiple-cursors (either
| in vim or other editors) I've found it just plain slower,
| less precise and less powerful than plain vim commands. I
| would recommend looking at the features vim has to offer and
| learning them to see if maybe they can make up for the lack
| of native multiple-cursors support.
| dandotway wrote:
| The Acme editor, used by C creator Dennis Ritchie,
| converted me to the Rodent Religion. The mouse is the
| fastest way to point to something on your computer screen,
| especially a quality gaming mouse with mouse acceleration
| disabled. Pointing at things on a computer screen and
| clicking is a highly competitive activity involving
| billions of dollars annually; pro gaming mouse designs have
| evolved to be lightweight and extremely efficient at this
| task.
|
| Pianists can rapidly move their hands to 100% accurately
| strike keys more than a foot away at blink-of-the-eye speed
| because they practice, and master mouse users can flick
| their hand from keyboard to mouse to keyboard again at
| blink-of-the-eye speed if they practice. Anchoring at the
| keyboard is not the fastest way to edit text.
|
| There needs to be a text editing competition organized with
| prize money. Then shall all the world see that mouse users
| best the Rodentless in battle.
|
| If I need to double-backspace five different caret
| positions visible on screen, I can Ctrl-click (or Alt-
| click) to set multiple cursors faster than a master
| vimmer's brain can devise a suitable ':[x,y]s/.../.../g'
| command to accomplish the same thing. I know this because
| I've used vim more than 20 years, and I also learned ed's
| and sam's editing languages used by the original Unix gods.
| The Unix gods switched to the Sam editor in the early 1980s
| which is a bit like a mouse-oriented re-imagining of vi.
| Then some switched to Plan 9's Acme in the 1990s, which
| retains Sam's editing language. The Sam/Acme editing
| language is not line-oriented like ed/vi/vim, e.g.
| ':#3,#42' selects character 3 through 42 regardless of how
| many newlines are between char 3 and 42 and does not select
| to the beginning of the line before char 3 nor to the end
| of the line after char 42. You can also do ':/re1/,/re2/'
| and unlike vim this won't grab to the beginning of line
| before /re1/, etc. Acme doesn't have multiple cursors
| though and needs some TLC, it doesn't talk to an X server
| efficiently and draw pixels efficiently because it's based
| on Plan 9's drawterm. VSCodium does everything I need but
| is ultra-bloated and I'd love lighter weight.
| tombh wrote:
| I don't use the mouse much, but yes, certainly in my
| Alacritty/tmux terminal, the mouse selects, moves pane
| boundaries etc. I've never actually tried a multi-cursor, I
| have a feeling it might suffer the same fate as the auto
| cursor positioning you get from snippet completion. But that
| specific bug I've fixed locally
| scelerat wrote:
| > having to submit to the religion of modal editing
|
| ha but that is indeed why i'm here at all
| Aperocky wrote:
| As I look about in the temple of vim, I see dedicated
| believers of modal editing, they are the good ones.
|
| I also see the heretics who are just here to take advantage
| of INSERT mode, the heathens who come to insult our ancient
| religion, and spies from church of emacs. I find their lack
| of faith disturbing.
| acomjean wrote:
| Don't get me started on the Evil Mode emacs users, trying
| to have it both ways.
|
| https://github.com/emacs-evil/evil
| bastijn wrote:
| Did somebody say Spacemacs?
|
| [0] https://www.spacemacs.org/
| weaksauce wrote:
| spacemacs is great but doom is night and day faster. I
| use doom for just magit now and the startup time is
| almost negligible and the other affordances are still
| there if you want them.
|
| spacemacs has a maintainer problem and some serious debt
| that needs to be paid before it is a worthy contender in
| my opinion. the whole you need to run on dev branch and
| it's many (thousands?) of commits ahead of the main
| branch and having many many stale/outdated/broken issues
| is not tenable.
| Yizahi wrote:
| Look at you, hacker. A pathetic creature of meat and bone,
| panting and sweating as you try to exit VIM. How can you
| challenge a perfect, immortal VIIIIiiiIIMMMmmm... _static_
| qudat wrote:
| > if not the largest ecosystems of pioneering extensions
|
| Agreed! And the neovim plug-in ecosystem is blowing up because
| of its support for lua: https://neovimcraft.com
| freeCandy wrote:
| So that's how it feels when people say they can't exit vim.
| vidarh wrote:
| That's what ^z and kill -9 is for... (yes, I know,
| unnecessarily brutal; consider it a passive aggressive reaction
| - it _feels_ good)
| fsflover wrote:
| https://github.com/hakluke/how-to-exit-vim
| iso1631 wrote:
| ctrl-z does nothing (well it's mapped to undo in "easy" mode)
| vidarh wrote:
| Ah. Yikes. But randomly bashing a few keys with control
| held before ^z still worked for me... Random key-bashing is
| always a good bet if stuck in vim.
|
| (yes, I can usually get out of vim "properly" these days)
| nostoc wrote:
| Random key bashing in vim can have a lot of unforeseen
| consequences for whatever poor file you had opened.
| vidarh wrote:
| Given I never _intentionally_ start vim, it 's generally
| when I get thrown into editing some temporary file or
| other on some system where I haven't configured an
| editor. Not done any harm in the last 3 decades, so I
| think the odds are decent.
| fomine3 wrote:
| If you open any file and just type "DZZ" (in capital),
| you delete the first line of file and save and quit.
| BoxOfRain wrote:
| >yes, I know, unnecessarily brutal; consider it a passive
| aggressive reaction - it feels good
|
| Throwing SIGKILL at something that's misbehaving is very
| satisfying, especially if you have a habit of personifying
| your computer a bit too much.
| dylan604 wrote:
| Sounds like a good time to link to
| https://www.youtube.com/watch?v=0rG74rG_ubs
| gnubison wrote:
| Regular SIGINT will probably do the same thing (or SIGQUIT)
| if that doesn't work. It's absurdly easy to create software
| that misbehaves after a 'kill -9', because the only real use
| for it is 60 seconds after starting the shutdown process for
| the rare program that just won't exit.
| vidarh wrote:
| Yes, but not as satisfying...
| andrewaylett wrote:
| Hit the power switch.
|
| (In my youth, I definitely resorted to doing that more than
| once)
| YeGoblynQueenne wrote:
| Try ed. _That_ is how it feels when people can 't exit vim :P
| iso1631 wrote:
| q or ctrl-z. Not rocket science, not like having to press
| Control-L (clear terminal) before quitting.
| Symmetry wrote:
| Indeed:
|
| https://www.gnu.org/fun/jokes/ed-msg.en.html
|
| >Note the consistent user interface and error reportage. Ed
| is generous enough to flag errors, yet prudent enough not to
| overwhelm the novice with verbosity.
| Shared404 wrote:
| Also vanilla emacs.
|
| I just wanted to try out org >_< !
| mFixman wrote:
| ?
| eliasbagley wrote:
| The mighty ed has spoken!
| toxik wrote:
| ?
| okl wrote:
| eat flaming death
| Shared404 wrote:
| ^C
| amelius wrote:
| I tried your suggestion ":P"
|
| It gave me: **warning** (netrw) using
| Pexplore or <s-up> improperly; see help for netrw-starstar
| avereveard wrote:
| A quarter of support call when I was lab assistant for my uni
| was students pressing ctrl+s in vim out of habit and getting
| stuck in there.
___________________________________________________________________
(page generated 2022-01-07 23:00 UTC)